List of usage examples for junit.framework Assert assertFalse
static public void assertFalse(boolean condition)
From source file:com.cemeterylistingswebtest.test.services.ViewListingByDateOfBirthServiceTest.java
@Test(enabled = true) public void Test() { dateServ = ctx.getBean(ViewListingByDateOfBirthService.class); repoList = ctx.getBean(PublishedDeceasedListingRepository.class); subRepo = ctx.getBean(SubscriberRepository.class); userRepo = ctx.getBean(UserRoleRepository.class); //Initialise date Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, 2001); calendar.set(Calendar.MONTH, Calendar.MARCH); calendar.set(Calendar.DATE, 17); java.sql.Date javaSqlDate = new java.sql.Date(calendar.getTime().getTime()); //Initialise user role UserRole userRole = new UserRole.Builder().setLevel(2).build(); //userRepo.save(userRole); //userRoleID = userRole.getUserRoleID(); //Initialise subscriber Subscriber newSub = new Subscriber.Builder().setEmail("jGordan@gmail.com").setFirstName("james") .setSurname("gordan").setPwd("gotham").setUsername("commish").setSubscriptionDate(javaSqlDate) .setUserRoleID(userRole).build(); subRepo.save(newSub);/*from w w w . j a v a 2s .c om*/ subID = newSub.getSubscriberID(); PublishedDeceasedListing newListing = new PublishedDeceasedListing.Builder().setFirstName("Dean") .setSurname("Winchester") .setGender("Male").setDateOfBirth("27/07/1985").setDateOfDeath("14/10/2014") .setGraveInscription("will probably come back").setGraveNumber("2474") .setImageOfBurialSite("/images/004.jpg").setLastKnownContactName("sam") .setLastKnownContactNumber("07255718927") .setSubscriberSubmitID(subID).build(); repoList.save(newListing); listingId = newListing.getPublishedListingID(); List<PublishedDeceasedListing> pubListDob = dateServ.findListingByDOB("27/07/1985"); Assert.assertFalse(pubListDob.isEmpty()); repoList.delete(listingId); subRepo.delete(subID); }
From source file:org.geomajas.gwt2.client.map.layer.VectorLayerEventTest.java
@Test public void testShowHideEvents() { VectorServerLayerImpl layer = new VectorServerLayerImpl(mapConfig, layerInfo, viewPort, eventBus); eventBus.addLayerVisibilityHandler(new LayerVisibilityHandler() { public void onVisibilityMarked(LayerVisibilityMarkedEvent event) { }/*from w ww .ja va2s . c o m*/ public void onShow(LayerShowEvent event) { isShowing = true; } public void onHide(LayerHideEvent event) { isShowing = false; } }); // Scale between 6 and 20 is OK: viewPort.applyResolution(viewPort.getResolution(5)); // 32 -> NOK Assert.assertFalse(layer.isShowing()); Assert.assertEquals(layer.isShowing(), isShowing); viewPort.applyResolution(viewPort.getResolution(4)); // 16 -> OK Assert.assertTrue(layer.isShowing()); Assert.assertEquals(layer.isShowing(), isShowing); viewPort.applyResolution(viewPort.getResolution(3)); // 8 -> OK Assert.assertTrue(layer.isShowing()); Assert.assertEquals(layer.isShowing(), isShowing); viewPort.applyResolution(viewPort.getResolution(2)); // 4 -> NOK Assert.assertFalse(layer.isShowing()); Assert.assertEquals(layer.isShowing(), isShowing); viewPort.applyResolution(viewPort.getResolution(1)); // 2 -> NOK Assert.assertFalse(layer.isShowing()); Assert.assertEquals(layer.isShowing(), isShowing); viewPort.applyResolution(viewPort.getResolution(0)); // 1 -> NOK Assert.assertFalse(layer.isShowing()); Assert.assertEquals(layer.isShowing(), isShowing); // Mark as invisible: layer.setMarkedAsVisible(false); viewPort.applyResolution(viewPort.getResolution(5)); // 32 -> NOK Assert.assertFalse(layer.isShowing()); Assert.assertEquals(layer.isShowing(), isShowing); viewPort.applyResolution(viewPort.getResolution(4)); // 16 -> NOK Assert.assertFalse(layer.isShowing()); Assert.assertEquals(layer.isShowing(), isShowing); // Mark as visible while scale is within limits: layer.setMarkedAsVisible(true); Assert.assertTrue(layer.isShowing()); Assert.assertEquals(layer.isShowing(), isShowing); }
From source file:com.onesite.sdk.test.api.SessionApiTest.java
@Test public void testLogin() { SessionApi api = new SessionApi(); try {//from ww w .ja v a 2 s . c om User testUser = new User(); testUser.setId(userID); Session session = api.login(testUser, password, agent, ip, expiresFromNow); System.out.println("Active Session"); System.out.println("coreU: " + session.getCoreU()); System.out.println("coreX: " + session.getCoreU()); System.out.println("Data: " + session.getSessionDataSize()); System.out.println("Login Successful"); Assert.assertFalse(StringUtils.isEmpty(session.getCoreU())); System.out.println("Running session check against logged in coreU " + session.getCoreU()); session = api.check(session); System.out.println("coreU: " + session.getCoreU()); System.out.println("coreX: " + session.getCoreU()); System.out.println("Data: " + session.getSessionDataSize()); if (session.isSetSessionData()) { System.out.println("User Status: " + session.getSessionData().get("STATUS")); } Assert.assertFalse(StringUtils.isEmpty(session.getCoreU())); } catch (Exception e) { Assert.fail(); } }
From source file:com.google.api.ads.adwords.awreporting.model.definitions.ReportDisplayKeywordDefinitionTest.java
/** * @see com.google.api.ads.adwords.awreporting.model.definitions. * AbstractReportDefinitionTest#testLastEntry( * com.google.api.ads.adwords.awreporting.model.entities.Report) *///w w w .j a v a2 s .c om @Override protected void testLastEntry(ReportDisplayKeyword last) { Assert.assertEquals(1056270861L, last.getAccountId().longValue()); Assert.assertEquals("2014-06-09", last.getDay()); Assert.assertEquals(0.30, last.getCost().doubleValue()); Assert.assertEquals(2L, last.getClicks().longValue()); Assert.assertEquals(1853L, last.getImpressions().longValue()); Assert.assertEquals(0L, last.getConversions().longValue()); Assert.assertEquals(0.11, last.getCtrBigDecimal().doubleValue()); Assert.assertEquals(0.16, last.getAvgCpm().doubleValue()); Assert.assertEquals(0.15, last.getAvgCpc().doubleValue()); Assert.assertEquals(209867786L, last.getCampaignId().longValue()); Assert.assertEquals("Display", last.getCampaignName()); Assert.assertEquals(11553542546L, last.getAdGroupId().longValue()); Assert.assertEquals("Display", last.getAdGroupName()); Assert.assertEquals("", last.getDestinationUrl()); Assert.assertEquals(32912034877L, last.getKeywordId().longValue()); Assert.assertEquals("restaurant italien 34", last.getKeywordText()); Assert.assertFalse(last.isNegative()); }
From source file:org.openmrs.module.webservices.rest19ext.web.v1_0.controller.VisitAttributeControllerTest.java
@Test public void shouldEditAVisitAttribute() throws Exception { final String newValue = "2012-05-05"; VisitAttribute va = service.getVisitAttributeByUuid(Rest19ExtTestConstants.VISIT_ATTRIBUTE_UUID); Assert.assertFalse(new SimpleDateFormat(DATE_PATTERN).parse(newValue).equals(va.getValue())); String json = "{ \"value\":\"2012-05-05\" }"; SimpleObject post = new ObjectMapper().readValue(json, SimpleObject.class); VisitAttribute visitAttribute = service .getVisitAttributeByUuid(Rest19ExtTestConstants.VISIT_ATTRIBUTE_UUID); Assert.assertEquals("Audit Date", visitAttribute.getAttributeType().getName()); controller.update(Rest19ExtTestConstants.VISIT_UUID, Rest19ExtTestConstants.VISIT_ATTRIBUTE_UUID, post, request, response);/*from w w w .ja v a 2 s . c om*/ VisitAttribute updated = service.getVisitAttributeByUuid(Rest19ExtTestConstants.VISIT_ATTRIBUTE_UUID); Assert.assertTrue(new SimpleDateFormat(DATE_PATTERN).parse(newValue).equals(updated.getValue())); }
From source file:org.openmrs.module.sync.SyncDrugOrderTest.java
@Test @NotTransactional/*from w ww .ja v a 2 s .co m*/ public void shouldUpdateDrugOrder() throws Exception { if (TestUtil.isOpenmrsVersionAtLeast("1.10")) { log.warn("NOT RUNNING DRUG ORDER TESTS AGAINST 1.10. TODO."); return; } runSyncTest(new SyncTestHelper() { OrderService orderService = Context.getOrderService(); public void runOnChild() throws Exception { DrugOrder order = (DrugOrder) OrderService.class.getMethod("getOrder", Integer.class, Class.class) .invoke(orderService, 1, DrugOrder.class); Double d = (Double) DrugOrder.class.getMethod("getDose").invoke(order); Assert.assertFalse(d.doubleValue() == 10.0); DrugOrder.class.getMethod("setDose", Double.class).invoke(order, 10.0); OrderService.class.getMethod("saveOrder", Order.class).invoke(orderService, order); d = (Double) DrugOrder.class.getMethod("getDose").invoke(order); Assert.assertEquals(10.0, d.doubleValue()); } public void runOnParent() throws Exception { DrugOrder order = (DrugOrder) OrderService.class.getMethod("getOrder", Integer.class, Class.class) .invoke(orderService, 1, DrugOrder.class); Double d = (Double) DrugOrder.class.getMethod("getDose").invoke(order); Assert.assertEquals(10.0, d.doubleValue()); } }); }
From source file:com.xixicm.de.data.storage.DataBaseTest.java
@AfterClass public static void tearDownClass() { // delete test db InstrumentationRegistry.getTargetContext().deleteDatabase(TestUtil.TEST_DB); File testDb = InstrumentationRegistry.getTargetContext().getDatabasePath(TestUtil.TEST_DB); Assert.assertFalse(testDb.exists()); }
From source file:com.cemeterylistingswebtest.test.services.ViewListingsBySubscriberServiceTest.java
@Test(enabled = false) public void hello() { subserv = ctx.getBean(ViewListingBySubscriberService.class); repoList = ctx.getBean(PublishedDeceasedListingRepository.class); subRepo = ctx.getBean(SubscriberRepository.class); userRepo = ctx.getBean(UserRoleRepository.class); //Initialise date Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, 2008); calendar.set(Calendar.MONTH, Calendar.MARCH); calendar.set(Calendar.DATE, 5); java.sql.Date javaSqlDate = new java.sql.Date(calendar.getTime().getTime()); //Initialise date Calendar calendar2 = Calendar.getInstance(); calendar2.set(Calendar.YEAR, 2014); calendar2.set(Calendar.MONTH, Calendar.JUNE); calendar2.set(Calendar.DATE, 20); java.sql.Date validDate = new java.sql.Date(calendar2.getTime().getTime()); //Initialise user role UserRole userRole = new UserRole.Builder().setLevel(2).build(); //userRepo.save(userRole); //userRoleID = userRole.getUserRoleID(); //Initialise subscriber Subscriber newSub = new Subscriber.Builder().setEmail("jackieChan@yahoo.com").setFirstName("jackie") .setSurname("Chan").setPwd("whaa").setUsername("jChan").setSubscriptionDate(javaSqlDate) .setUserRoleID(userRole).setValidUntil(validDate).build(); subRepo.save(newSub);/*w w w . j a v a2 s .c o m*/ subID = newSub.getSubscriberID(); PublishedDeceasedListing newListing = new PublishedDeceasedListing.Builder().setFirstName("Julie") .setSurname("Romanov").setMaidenName("black").setGender("Female").setDateOfBirth("08/06/1974") .setDateOfDeath("14/02/2009").setGraveInscription("triple agent").setGraveNumber("2986") .setImageOfBurialSite("/images/001.jpg") .setSubscriberSubmitID(subID).build(); repoList.save(newListing); List<PublishedDeceasedListing> pubListDod = subserv.findListingBySubscriber(javaSqlDate, validDate); Assert.assertFalse(pubListDod.isEmpty()); //Assert.assertTrue(pubListDod.isEmpty()); repoList.delete(newListing); subRepo.delete(newSub); }
From source file:com.espertech.esper.multithread.StmtListenerAddRemoveCallable.java
public Object call() throws Exception { try {/*w ww.j av a 2 s.c o m*/ for (int loop = 0; loop < numRepeats; loop++) { // Add assertListener SupportMTUpdateListener assertListener = new SupportMTUpdateListener(); LogUpdateListener logListener; if (isEPL) { logListener = new LogUpdateListener(null); } else { logListener = new LogUpdateListener("a"); } ThreadLogUtil.trace("adding listeners ", assertListener, logListener); stmt.addListener(assertListener); stmt.addListener(logListener); // send event Object theEvent = makeEvent(); ThreadLogUtil.trace("sending event ", theEvent); engine.getEPRuntime().sendEvent(theEvent); // Should have received one or more events, one of them must be mine EventBean[] newEvents = assertListener.getNewDataListFlattened(); Assert.assertTrue("No event received", newEvents.length >= 1); ThreadLogUtil.trace("assert received, size is", newEvents.length); boolean found = false; for (int i = 0; i < newEvents.length; i++) { Object underlying = newEvents[i].getUnderlying(); if (!isEPL) { underlying = newEvents[i].get("a"); } if (underlying == theEvent) { found = true; } } Assert.assertTrue(found); assertListener.reset(); // Remove assertListener ThreadLogUtil.trace("removing assertListener"); stmt.removeListener(assertListener); stmt.removeListener(logListener); // Send another event theEvent = makeEvent(); ThreadLogUtil.trace("send non-matching event ", theEvent); engine.getEPRuntime().sendEvent(theEvent); // Make sure the event was not received newEvents = assertListener.getNewDataListFlattened(); found = false; for (int i = 0; i < newEvents.length; i++) { Object underlying = newEvents[i].getUnderlying(); if (!isEPL) { underlying = newEvents[i].get("a"); } if (underlying == theEvent) { found = true; } } Assert.assertFalse(found); } } catch (AssertionFailedError ex) { log.fatal("Assertion error in thread " + Thread.currentThread().getId(), ex); return false; } catch (Exception ex) { log.fatal("Error in thread " + Thread.currentThread().getId(), ex); return false; } return true; }
From source file:com.currencyfair.minfraud.MinFraudImplTest.java
@Test public void testNonCloseableHttpResponseIsSupported() throws Exception { StringEntity responseEntity = new StringEntity(VALID_RESPONSE, ContentType.TEXT_PLAIN); HttpMethodFactory methodFactory = expectCreateHttpPost(); HttpResponse httpResponse = EasyMock.createMock(HttpResponse.class); expectHttpResponse(httpResponse, 200, responseEntity); HttpClient client = expectHttpInvocation(httpResponse); EasyMock.replay(httpResponse);//from www . j a v a2 s . c o m minFraudImpl.setHttpClient(client); minFraudImpl.setMethodFactory(methodFactory); minFraudImpl.setEndpoint(ENDPOINT); RiskScoreResponse response = minFraudImpl.calculateRisk(newRiskScoreRequest()); Assert.assertNotNull(response); Assert.assertEquals(new BigDecimal("23.2"), response.getRiskScore()); Assert.assertTrue(response.getGeoIpDetails().isCountryMatch()); Assert.assertFalse(response.getGeoIpDetails().isHighRiskCountry()); Assert.assertEquals("IE", response.getGeoIpDetails().getIpCountryCode()); Assert.assertEquals(Integer.valueOf(48), response.getGeoIpDetails().getDistance()); EasyMock.verify(httpResponse); }