List of usage examples for junit.framework Assert assertFalse
static public void assertFalse(String message, boolean condition)
From source file:com.streamreduce.core.service.EmailServiceImplTest.java
@Test public void testSendInviteUserActivationEmail() throws Exception { ArgumentCaptor<SendEmailRequest> captor = ArgumentCaptor.forClass(SendEmailRequest.class); emailService.sendInviteUserActivationEmail(testUser); verify(mockAmazonSimpleEmailServiceClient).sendEmail(captor.capture()); Body body = captor.getValue().getMessage().getBody(); Assert.assertFalse("Encountered unexpanded template token.", body.getHtml().getData().contains("${")); Assert.assertFalse("Encountered unexpanded template token.", body.getText().getData().contains("${")); }
From source file:com.streamreduce.core.service.EmailServiceImplTest.java
@Test public void testSendNewUserActivationEmail() throws Exception { ArgumentCaptor<SendEmailRequest> captor = ArgumentCaptor.forClass(SendEmailRequest.class); emailService.sendNewUserActivationEmail(testUser); verify(mockAmazonSimpleEmailServiceClient).sendEmail(captor.capture()); Body body = captor.getValue().getMessage().getBody(); Assert.assertFalse("Encountered unexpanded template token.", body.getHtml().getData().contains("${")); Assert.assertFalse("Encountered unexpanded template token.", body.getText().getData().contains("${")); }
From source file:cz.PA165.vozovyPark.dao.VehicleDAOTest.java
/** * Test of findByUserClass method, of class VehicleDAO. *///from w ww . j a v a2 s.co m @Test public void testFindByUserClass() { try { Vehicle mercedes1 = VehicleDAOTest.getVehicle("Mercedes", 20000, "R4 Diesel", "E", UserClassEnum.PRESIDENT, "2a-447i-882a45", 2009, "UEW6828"); Vehicle mercedes2 = VehicleDAOTest.getVehicle("Mercedes", 20000, "R4 Diesel", "C", UserClassEnum.MANAGER, "98-447i-883345", 2009, "UEW6828"); this.vehicleDao.createVehicle(mercedes1); this.vehicleDao.createVehicle(mercedes2); em.getTransaction().begin(); Collection<Vehicle> required = this.vehicleDao.findByUserClass(UserClassEnum.MANAGER); em.getTransaction().commit(); Assert.assertTrue("Vehicle with right user class was not loaded.", required.contains(mercedes2)); Assert.assertFalse("Vehicle with different user class was loaded as well", required.contains(mercedes1)); } catch (Exception ex) { Assert.fail("Unexpected exception was throwed: " + ex + " " + ex.getMessage()); } }
From source file:com.espertech.esper.regression.support.ResultAssertExecution.java
private void assertStep(String timeInSec, int step, Map<Integer, StepDesc> stepAssertions, String[] fields, boolean isAssert, boolean isExpectNullRemoveStream) { if (preformatlog.isDebugEnabled()) { if (listener.isInvoked()) { UniformPair<String[]> received = renderReceived(fields); String[] newRows = received.getFirst(); String[] oldRows = received.getSecond(); int numMaxRows = (newRows.length > oldRows.length) ? newRows.length : oldRows.length; for (int i = 0; i < numMaxRows; i++) { String newRow = (newRows.length > i) ? newRows[i] : ""; String oldRow = (oldRows.length > i) ? oldRows[i] : ""; preformatlog.debug(String.format("%48s %-18s %-20s", "", newRow, oldRow)); }//from w w w . j a va 2 s . co m if (numMaxRows == 0) { preformatlog.debug(String.format("%48s %-18s %-20s", "", "(empty result)", "(empty result)")); } } } if (!isAssert) { listener.reset(); return; } StepDesc stepDesc = null; if (stepAssertions != null) { stepDesc = stepAssertions.get(step); } // If there is no assertion, there should be no event received if (stepDesc == null) { Assert.assertFalse("At time " + timeInSec + " expected no events but received one or more", listener.isInvoked()); } else { // If we do expect remove stream events, asset both if (!isExpectNullRemoveStream) { String message = "At time " + timeInSec; Assert.assertTrue(message + " expected events but received none", listener.isInvoked()); EPAssertionUtil.assertPropsPerRow(listener.getLastNewData(), expected.getProperties(), stepDesc.getNewDataPerRow(), "newData"); EPAssertionUtil.assertPropsPerRow(listener.getLastOldData(), expected.getProperties(), stepDesc.getOldDataPerRow(), "oldData"); } // If we don't expect remove stream events (istream only), then asset new data only if there else { // If we do expect new data, assert if (stepDesc.getNewDataPerRow() != null) { Assert.assertTrue("At time " + timeInSec + " expected events but received none", listener.isInvoked()); EPAssertionUtil.assertPropsPerRow(listener.getLastNewData(), expected.getProperties(), stepDesc.getNewDataPerRow(), "newData"); } else { // If we don't expect new data, make sure its null Assert.assertNull( "At time " + timeInSec + " expected no insert stream events but received some", listener.getLastNewData()); } Assert.assertNull("At time " + timeInSec + " expected no remove stream events but received some(check irstream/istream(default) test case)", listener.getLastOldData()); } } listener.reset(); }
From source file:com.streamreduce.core.service.EmailServiceImplTest.java
@Test public void testSendPasswordResetEmail() throws Exception { ArgumentCaptor<SendEmailRequest> captor = ArgumentCaptor.forClass(SendEmailRequest.class); emailService.sendPasswordResetEmail(testUser, true); verify(mockAmazonSimpleEmailServiceClient).sendEmail(captor.capture()); Body body = captor.getValue().getMessage().getBody(); Assert.assertFalse("Encountered unexpanded template token.", body.getHtml().getData().contains("${")); Assert.assertFalse("Encountered unexpanded template token.", body.getText().getData().contains("${")); }
From source file:com.sap.prd.mobile.ios.mios.FatBinaryTest.java
@Test public void testPrefereFatLibForNonExistingFatLibs() throws Exception { final File testSourceDirectoryApp = new File(getTestRootDirectory(), "straight-forward/MyApp"); final File alternateTestSourceDirectoryApp = new File(getTestRootDirectory(), "straight-forward-fat-libs/MyApp"); final String testName = getTestName(); final File fatLibReleaseRemoteRepo = new File(remoteRepoDir, "com/sap/ondevice/production/ios/tests/MyLibrary/" + dynamicVersion + "/MyLibrary-" + dynamicVersion + "-Release-fat-binary.a"); if (!fatLibReleaseRemoteRepo.delete()) throw new IOException("Cannot delete release fat lib file: " + fatLibReleaseRemoteRepo); Verifier verifier = new Verifier(getTestExecutionDirectory(testName, "MyApp").getAbsolutePath()); verifier.deleteArtifacts("com.sap.ondevice.production.ios.tests"); Map<String, String> additionalSystemProperties = new HashMap<String, String>(); additionalSystemProperties.put("xcode.preferFatLibs", Boolean.TRUE.toString()); Properties pomReplacements = new Properties(); pomReplacements.setProperty(PROP_NAME_DEPLOY_REPO_DIR, remoteRepoDir.getAbsolutePath()); pomReplacements.setProperty(PROP_NAME_DYNAMIC_VERSION, dynamicVersion); test(verifier, testName, testSourceDirectoryApp, "install", THE_EMPTY_LIST, additionalSystemProperties, pomReplacements, new FileCopyProjectModifier(alternateTestSourceDirectoryApp)); final File testRootDir = getTestExecutionDirectory(testName, "MyApp"); final File fatLibReleaseInProject = new File(testRootDir, "target/xcode-deps/libs/Release/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a"); final File thinLibReleaseInProject = new File(testRootDir, "target/libs/Release-iphoneos/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a"); Assert.assertFalse("Fat lib '" + fatLibReleaseInProject + " does exist but was not expected to be present.", fatLibReleaseInProject.exists()); Assert.assertTrue("Thin lib for release '" + thinLibReleaseInProject + "does exist but was not expected to be present.", thinLibReleaseInProject.exists()); Assert.assertTrue(new File(testRootDir, "target/libs/Release-iphonesimulator/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a") .exists());/* w w w.ja v a 2s . com*/ Assert.assertTrue(new File(testRootDir, "target/xcode-deps/libs/Debug/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a") .exists()); Assert.assertFalse(new File(testRootDir, "target/libs/Debug-iphoneos/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a") .exists()); Assert.assertFalse(new File(testRootDir, "target/libs/Debug-iphonesimulator/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a") .exists()); }
From source file:org.jboss.as.test.clustering.cluster.web.passivation.SessionPassivationAbstractCase.java
/** * Tests the ability to passivate session when maximum number of active sessions (max-active-sessions) reached. * * @throws Exception/* w w w .ja v a 2 s . co m*/ */ @Test @Ignore("https://issues.jboss.org/browse/AS7-4490") public void testSessionPassivationWithMaxActiveSessions( @ArquillianResource @OperateOnDeployment(DEPLOYMENT_1) URL baseURL1) throws Exception { // Create an instance of HttpClient HttpClient client = HttpClientUtils.relaxedCookieHttpClient(); try { // Setup the session HttpResponse response = ClusterHttpClientUtil.tryGet(client, baseURL1 + SimpleServlet.URL); response.getEntity().getContent().close(); // Get the Attribute set; confirm session wasn't deserialized response = ClusterHttpClientUtil.tryGet(client, baseURL1 + SimpleServlet.URL); Assert.assertFalse("Session should not be serialized", Boolean.valueOf(response.getFirstHeader(SimpleServlet.HEADER_SERIALIZED).getValue())); response.getEntity().getContent().close(); // passivation-min-idle-time is set to 5 seconds, so wait long enough // so that the session can be passivated Thread.sleep(PASSIVATION_MIN_IDLE_TIME + 1000); // Create enough sessions on the server to trigger passivation // knowing that max-active-sessions is set to 20 in jboss-web.xml for (int i = 0; i < MAX_ACTIVE_SESSIONS; i++) { HttpClient maxActiveClient = new DefaultHttpClient(); try { response = ClusterHttpClientUtil.tryGet(maxActiveClient, baseURL1 + SimpleServlet.URL); Assert.assertFalse("Session should not be serialized", Boolean.valueOf(response.getFirstHeader(SimpleServlet.HEADER_SERIALIZED).getValue())); Assert.assertEquals("The session should be new", 1, Integer.parseInt(response.getFirstHeader("value").getValue())); response.getEntity().getContent().close(); response = ClusterHttpClientUtil.tryGet(maxActiveClient, baseURL1 + SimpleServlet.URL); response.getEntity().getContent().close(); } finally { maxActiveClient.getConnectionManager().shutdown(); } } // Now access the session and confirm that it was deserialized (passivated then activated) // Activate the session by requesting the attribute response = ClusterHttpClientUtil.tryGet(client, baseURL1 + SimpleServlet.URL); Assert.assertTrue("Session should have activated and have been deserialized", Boolean.valueOf(response.getFirstHeader(SimpleServlet.HEADER_SERIALIZED).getValue())); Assert.assertEquals(3, Integer.parseInt(response.getFirstHeader("value").getValue())); response.getEntity().getContent().close(); } finally { client.getConnectionManager().shutdown(); } }
From source file:com.streamreduce.core.service.EmailServiceImplTest.java
@Test public void testSendUserAccountSetupCompleteEmail() throws Exception { ArgumentCaptor<SendEmailRequest> captor = ArgumentCaptor.forClass(SendEmailRequest.class); emailService.sendUserAccountSetupCompleteEmail(testUser); verify(mockAmazonSimpleEmailServiceClient).sendEmail(captor.capture()); Body body = captor.getValue().getMessage().getBody(); Assert.assertFalse("Encountered unexpanded template token.", body.getHtml().getData().contains("${")); Assert.assertFalse("Encountered unexpanded template token.", body.getText().getData().contains("${")); }
From source file:com.streamreduce.core.service.EmailServiceImplTest.java
@Test public void testSendBugReport() throws Exception { ArgumentCaptor<SendEmailRequest> captor = ArgumentCaptor.forClass(SendEmailRequest.class); emailService.sendBugReport("username", "company", "summary", "details", "debuginfo"); verify(mockAmazonSimpleEmailServiceClient).sendEmail(captor.capture()); Body body = captor.getValue().getMessage().getBody(); Assert.assertFalse("Encountered unexpanded template token.", body.getHtml().getData().contains("${")); Assert.assertFalse("Encountered unexpanded template token.", body.getText().getData().contains("${")); }
From source file:eu.stratosphere.nephele.services.iomanager.IOManagerITCase.java
/** * This test instantiates multiple channels and writes to them in parallel and re-reads the data in * parallel. It is designed to check the ability of the IO manager to correctly handle multiple threads. *//*from w w w . j a va 2s .co m*/ @Test public void parallelChannelsTest() throws Exception { LOG.info("Starting parallel channels test."); final Random rnd = new Random(SEED); final AbstractInvokable memOwner = new DefaultMemoryManagerTest.DummyInvokable(); Channel.ID[] ids = new Channel.ID[NUM_CHANNELS]; BlockChannelWriter[] writers = new BlockChannelWriter[NUM_CHANNELS]; BlockChannelReader[] readers = new BlockChannelReader[NUM_CHANNELS]; ChannelWriterOutputView[] outs = new ChannelWriterOutputView[NUM_CHANNELS]; ChannelReaderInputView[] ins = new ChannelReaderInputView[NUM_CHANNELS]; int[] writingCounters = new int[NUM_CHANNELS]; int[] readingCounters = new int[NUM_CHANNELS]; // instantiate the channels and writers for (int i = 0; i < NUM_CHANNELS; i++) { ids[i] = this.ioManager.createChannel(); writers[i] = this.ioManager.createBlockChannelWriter(ids[i]); List<MemorySegment> memSegs = this.memoryManager.allocatePages(memOwner, rnd.nextInt(NUMBER_OF_SEGMENTS - 2) + 2); outs[i] = new ChannelWriterOutputView(writers[i], memSegs, this.memoryManager.getPageSize()); } Value val = new Value(); // write a lot of values unevenly distributed over the channels int nextLogCount = 0; float nextLogFraction = 0.0f; LOG.info("Writing to channels..."); for (int i = 0; i < NUMBERS_TO_BE_WRITTEN; i++) { if (i == nextLogCount) { LOG.info("... " + (int) (nextLogFraction * 100) + "% done."); nextLogFraction += 0.05; nextLogCount = (int) (nextLogFraction * NUMBERS_TO_BE_WRITTEN); } int channel = skewedSample(rnd, NUM_CHANNELS - 1); val.value = String.valueOf(writingCounters[channel]++); val.write(outs[channel]); } LOG.info("Writing done, flushing contents..."); // close all writers for (int i = 0; i < NUM_CHANNELS; i++) { this.memoryManager.release(outs[i].close()); } outs = null; writers = null; // instantiate the readers for sequential read LOG.info("Reading channels sequentially..."); for (int i = 0; i < NUM_CHANNELS; i++) { List<MemorySegment> memSegs = this.memoryManager.allocatePages(memOwner, rnd.nextInt(NUMBER_OF_SEGMENTS - 2) + 2); LOG.info("Reading channel " + (i + 1) + "/" + NUM_CHANNELS + '.'); final BlockChannelReader reader = this.ioManager.createBlockChannelReader(ids[i]); final ChannelReaderInputView in = new ChannelReaderInputView(reader, memSegs, false); int nextVal = 0; try { while (true) { val.read(in); int intValue = 0; try { intValue = Integer.parseInt(val.value); } catch (NumberFormatException nfex) { Assert.fail("Invalid value read from reader. Valid decimal number expected."); } Assert.assertEquals("Written and read values do not match during sequential read.", nextVal, intValue); nextVal++; } } catch (EOFException eofex) { // expected } Assert.assertEquals("NUmber of written numbers differs from number of read numbers.", writingCounters[i], nextVal); this.memoryManager.release(in.close()); } LOG.info("Sequential reading done."); // instantiate the readers LOG.info("Reading channels randomly..."); for (int i = 0; i < NUM_CHANNELS; i++) { List<MemorySegment> memSegs = this.memoryManager.allocatePages(memOwner, rnd.nextInt(NUMBER_OF_SEGMENTS - 2) + 2); readers[i] = this.ioManager.createBlockChannelReader(ids[i]); ins[i] = new ChannelReaderInputView(readers[i], memSegs, false); } nextLogCount = 0; nextLogFraction = 0.0f; // read a lot of values in a mixed order from the channels for (int i = 0; i < NUMBERS_TO_BE_WRITTEN; i++) { if (i == nextLogCount) { LOG.info("... " + (int) (nextLogFraction * 100) + "% done."); nextLogFraction += 0.05; nextLogCount = (int) (nextLogFraction * NUMBERS_TO_BE_WRITTEN); } while (true) { final int channel = skewedSample(rnd, NUM_CHANNELS - 1); if (ins[channel] != null) { try { val.read(ins[channel]); int intValue; try { intValue = Integer.parseInt(val.value); } catch (NumberFormatException nfex) { Assert.fail("Invalid value read from reader. Valid decimal number expected."); return; } Assert.assertEquals("Written and read values do not match.", readingCounters[channel]++, intValue); break; } catch (EOFException eofex) { this.memoryManager.release(ins[channel].close()); ins[channel] = null; } } } } LOG.info("Random reading done."); // close all readers for (int i = 0; i < NUM_CHANNELS; i++) { if (ins[i] != null) { this.memoryManager.release(ins[i].close()); } readers[i].closeAndDelete(); } ins = null; readers = null; // check that files are deleted for (int i = 0; i < NUM_CHANNELS; i++) { File f = new File(ids[i].getPath()); Assert.assertFalse("Channel file has not been deleted.", f.exists()); } }