prj03-group06/src/tests/TimeTest.java
@Test
	public void testTime() {
		String time = gui.getTime().substring(6);
		Date currentTime = new Date();
		
		SimpleDateFormat format = new SimpleDateFormat("h:mm a");		
		try {
			Date testTime = format.parse(time);
			currentTime = format.parse(format.format(currentTime));
			System.out.println(Math.abs(currentTime.getTime() - testTime.getTime()));
			assertTrue(Math.abs(currentTime.getTime() - testTime.getTime()) <= 60000L,
					"Failed: "+currentTime+" vs. "+testTime);
		} catch (ParseException e) {
			fail("failed to parse time");
		}
	}
/**
	 * Test to check the time values are valid.
	 */
Test to check the time values are valid.
Test to check the time values are valid .
@Test
	public void testTime() {
		String time = gui.getTime().substring(6);
		Date currentTime = new Date();
		SimpleDateFormat format = new SimpleDateFormat("h:mm a");		
		try {
			Date testTime = format.parse(time);
			currentTime = format.parse(format.format(currentTime));
			System.out.println(Math.abs(currentTime.getTime() - testTime.getTime()));
			assertTrue(Math.abs(currentTime.getTime() - testTime.getTime()) <= 60000L,
					"Failed: "+currentTime+" vs. "+testTime);
		} catch (ParseException e) {
			fail("failed to parse time");
		}
	}
@ Test public void testTime ( ) { String time = gui . getTime ( ) . substring ( 6 ) ; Date currentTime = new Date ( ) ; SimpleDateFormat format = new SimpleDateFormat ( "h:mm a" ) ; try { Date testTime = format . parse ( time ) ; currentTime = format . parse ( format . format ( currentTime ) ) ; System . out . println ( Math . abs ( currentTime . getTime ( ) - testTime . getTime ( ) ) ) ; assertTrue ( Math . abs ( currentTime . getTime ( ) - testTime . getTime ( ) ) <= 60000L , "Failed: " + currentTime + " vs. " + testTime ) ; } catch ( ParseException e ) { fail ( "failed to parse time" ) ; } }
Test to check the time values are valid.
Test to check the time values are valid .