List of usage examples for junit.framework Assert assertTrue
static public void assertTrue(boolean condition)
From source file:eu.stratosphere.pact.runtime.task.TempTaskExternalITCase.java
@Test public void testTempTask() { int keyCnt = 16384; int valCnt = 32; super.initEnvironment(1024 * 1024 * 1); super.addInput(new UniformPactRecordGenerator(keyCnt, valCnt, false), 1); super.addOutput(this.outList); TempTask<PactRecord> testTask = new TempTask<PactRecord>(); super.getTaskConfig().setMemorySize(1 * 1024 * 1024); super.registerTask(testTask, PrevStub.class); try {// w w w . j a v a 2s . co m testTask.invoke(); } catch (Exception e) { LOG.debug(e); Assert.fail("Invoke method caused exception."); } Assert.assertTrue(this.outList.size() == keyCnt * valCnt); }
From source file:de.tudarmstadt.ukp.dkpro.wsd.si.dictionary.GoogleDictionaryTest.java
@Test public void testGoogleDictionary() throws Exception { FileUtils.deleteQuietly(new File(output)); GoogleDictionary dictionary = new GoogleDictionary(path, needed_mentions); Assert.assertNotNull(dictionary);/* www .j a v a 2 s . c o m*/ ObjectOutputStream dictionaryWriter = new ObjectOutputStream( new BZip2CompressorOutputStream(new FileOutputStream(output))); dictionaryWriter.writeObject(dictionary); dictionaryWriter.close(); Assert.assertTrue(new File(output).exists()); ObjectInputStream dictionaryReader = new ObjectInputStream( new BZip2CompressorInputStream(new FileInputStream(output))); dictionary = null; dictionary = (GoogleDictionary) dictionaryReader.readObject(); Assert.assertNotNull(dictionary); System.out.println(dictionary.getNumberOfMentionEntityPairs()); System.out.println(dictionary.getTargetSize()); Assert.assertEquals(3, dictionary.getTargetValuePairs("claude_monet").size()); dictionaryReader.close(); }
From source file:de.hybris.basecommerce.SimpleSmtpServerUtilsTest.java
@Test public void testSendSuccess() throws EmailException, AddressException { final String origMailPortNumber = Config.getParameter(Config.Params.MAIL_SMTP_PORT); final String origMailHost = Config.getParameter(Config.Params.MAIL_SMTP_SERVER); SimpleSmtpServer server = null;//from ww w . j ava2s .com try { server = SimpleSmtpServerUtils.startServer(TEST_START_PORT); Assert.assertFalse(server.isStopped()); Assert.assertTrue(server.getPort() > 0); Config.setParameter(Config.Params.MAIL_SMTP_SERVER, "localhost"); Config.setParameter(Config.Params.MAIL_SMTP_PORT, String.valueOf(server.getPort())); final Email email = MailUtils.getPreConfiguredEmail(); email.setFrom("foo.bar@hybris.com"); email.setTo(Arrays.asList(InternetAddress.parse("foo.bar@hybris.com"))); email.setSubject("TEST TEST TEST"); email.setContent("FOO", Email.TEXT_PLAIN); email.send(); } finally { Config.setParameter(Config.Params.MAIL_SMTP_SERVER, origMailHost); Config.setParameter(Config.Params.MAIL_SMTP_PORT, origMailPortNumber); if (server != null) { server.stop(); } } }
From source file:com.rackspacecloud.blueflood.io.serializers.EnumRollupSerializationTest.java
@Test public void testEnumV1RoundTrip() throws IOException { BluefloodEnumRollup e0 = new BluefloodEnumRollup().withEnumValue("enumValue1", 1L) .withEnumValue("enumValue2", 5L); BluefloodEnumRollup e1 = new BluefloodEnumRollup().withEnumValue( "t4.enum.abcdefg.hijklmnop.qrstuvw.xyz.ABCDEFG.HIJKLMNOP.QRSTUVW.XYZ.abcdefg.hijklmnop.qrstuvw.xyz.met", 34454722343L)/* www. j a v a2 s.co m*/ .withEnumValue( "t5.enum.abcdefg.hijklmnop.qrstuvw.xyz.ABCDEFG.HIJKLMNOP.QRSTUVW.XYZ.abcdefg.hijklmnop.qrstuvw.xyz.met", 34454722343L) .withEnumValue("enumValue2", 10L); BluefloodEnumRollup e2 = new BluefloodEnumRollup().withEnumValue("enumValue1", 1L) .withEnumValue("enumValue1", 1L); BluefloodEnumRollup er = BluefloodEnumRollup .buildRollupFromEnumRollups(Rollups.asPoints(BluefloodEnumRollup.class, 0, 300, e0, e1, e2)); Assert.assertEquals(4, er.getCount()); Map<Long, Long> map = er.getHashedEnumValuesWithCounts(); Assert.assertTrue(map.get((long) "enumValue1".hashCode()) == 3L); Assert.assertTrue(map.get((long) "enumValue2".hashCode()) == 15L); ByteArrayOutputStream baos = new ByteArrayOutputStream(); baos.write(Base64.encodeBase64(new NumericSerializer.EnumRollupSerializer().toByteBuffer(e0).array())); baos.write("\n".getBytes()); baos.write(Base64.encodeBase64(new NumericSerializer.EnumRollupSerializer().toByteBuffer(e1).array())); baos.write("\n".getBytes()); baos.write(Base64.encodeBase64(new NumericSerializer.EnumRollupSerializer().toByteBuffer(e2).array())); baos.write("\n".getBytes()); baos.write(Base64.encodeBase64(new NumericSerializer.EnumRollupSerializer().toByteBuffer(er).array())); baos.write("\n".getBytes()); baos.close(); BufferedReader reader = new BufferedReader( new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()))); ByteBuffer bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes())); BluefloodEnumRollup ee0 = NumericSerializer.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb); Assert.assertEquals(e0, ee0); bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes())); BluefloodEnumRollup ee1 = NumericSerializer.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb); Assert.assertEquals(e1, ee1); bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes())); BluefloodEnumRollup ee2 = NumericSerializer.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb); Assert.assertEquals(e2, ee2); bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes())); BluefloodEnumRollup ee3 = NumericSerializer.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb); Assert.assertEquals(er, ee3); Assert.assertFalse(ee0.equals(ee1)); }
From source file:com.rackspacecloud.blueflood.io.serializers.astyanax.EnumRollupSerializationTest.java
@Test public void testEnumV1RoundTrip() throws IOException { BluefloodEnumRollup e0 = new BluefloodEnumRollup().withEnumValue("enumValue1", 1L) .withEnumValue("enumValue2", 5L); BluefloodEnumRollup e1 = new BluefloodEnumRollup().withEnumValue( "t4.enum.abcdefg.hijklmnop.qrstuvw.xyz.ABCDEFG.HIJKLMNOP.QRSTUVW.XYZ.abcdefg.hijklmnop.qrstuvw.xyz.met", 34454722343L)/*from w w w. j a v a2 s. c om*/ .withEnumValue( "t5.enum.abcdefg.hijklmnop.qrstuvw.xyz.ABCDEFG.HIJKLMNOP.QRSTUVW.XYZ.abcdefg.hijklmnop.qrstuvw.xyz.met", 34454722343L) .withEnumValue("enumValue2", 10L); BluefloodEnumRollup e2 = new BluefloodEnumRollup().withEnumValue("enumValue1", 1L) .withEnumValue("enumValue1", 1L); BluefloodEnumRollup er = BluefloodEnumRollup .buildRollupFromEnumRollups(Rollups.asPoints(BluefloodEnumRollup.class, 0, 300, e0, e1, e2)); Assert.assertEquals(4, er.getCount()); Map<Long, Long> map = er.getHashedEnumValuesWithCounts(); Assert.assertTrue(map.get((long) "enumValue1".hashCode()) == 3L); Assert.assertTrue(map.get((long) "enumValue2".hashCode()) == 15L); ByteArrayOutputStream baos = new ByteArrayOutputStream(); baos.write(Base64.encodeBase64(Serializers.enumRollupInstance.toByteBuffer(e0).array())); baos.write("\n".getBytes()); baos.write(Base64.encodeBase64(Serializers.enumRollupInstance.toByteBuffer(e1).array())); baos.write("\n".getBytes()); baos.write(Base64.encodeBase64(Serializers.enumRollupInstance.toByteBuffer(e2).array())); baos.write("\n".getBytes()); baos.write(Base64.encodeBase64(Serializers.enumRollupInstance.toByteBuffer(er).array())); baos.write("\n".getBytes()); baos.close(); BufferedReader reader = new BufferedReader( new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()))); ByteBuffer bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes())); BluefloodEnumRollup ee0 = Serializers.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb); Assert.assertEquals(e0, ee0); bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes())); BluefloodEnumRollup ee1 = Serializers.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb); Assert.assertEquals(e1, ee1); bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes())); BluefloodEnumRollup ee2 = Serializers.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb); Assert.assertEquals(e2, ee2); bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes())); BluefloodEnumRollup ee3 = Serializers.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb); Assert.assertEquals(er, ee3); Assert.assertFalse(ee0.equals(ee1)); }
From source file:com.googlecode.wickedcharts.highcharts.jackson.JsonIgnoreTest.java
@Test public void test() { // given//from w ww .ja v a 2s .c o m Options options = new MyOptions(); ChartOptions chartOptions = new ChartOptions(); chartOptions.setType(SeriesType.AREA); options.setChartOptions(chartOptions); JsonRenderer renderer = new JsonRenderer(); // when String json = renderer.toJson(options); // then Assert.assertFalse(json.contains("myIgnoredField")); Assert.assertTrue(json.contains("myIncludedField")); }
From source file:org.openmrs.module.kenyaemr.form.KenyaEmrVelocityFunctionsTest.java
/** * @see org.openmrs.module.kenyaemr.form.KenyaEmrVelocityFunctions#hasHivUniquePatientNumber() *//*ww w. jav a 2 s .c om*/ @Test public void hasHivUniquePatientNumber() { // Patient #6 doesn't have a UPN Assert.assertFalse(functionsForSession1.hasHivUniquePatientNumber()); // Patient #7 has a UPN Assert.assertTrue(functionsForSession2.hasHivUniquePatientNumber()); }
From source file:com.ancientprogramming.fixedformat4j.format.impl.TestNullableFixedFormatManagerImpl.java
public void testLoadNonNullRecord() { MyNullableRecord loadedRecord = manager.load(MyNullableRecord.class, MY_NONNULL_RECORD_DATA); Assert.assertNotNull(loadedRecord);/*w w w . j av a 2s. c o m*/ Assert.assertEquals("", loadedRecord.getStringData()); Assert.assertTrue(loadedRecord.isBooleanData()); }
From source file:com.ancientprogramming.fixedformat4j.format.impl.TestFixedFormatManagerImpl.java
public void testLoadRecord() { MyRecord loadedRecord = manager.load(MyRecord.class, MY_RECORD_DATA); Assert.assertNotNull(loadedRecord);/* www . j a v a 2 s .c o m*/ Assert.assertEquals(STR, loadedRecord.getStringData()); Assert.assertTrue(loadedRecord.isBooleanData()); }
From source file:com.joshlong.esb.springintegration.modules.nativefs.TestRecievingUsingNativeFsEventing.java
@SuppressWarnings("") @Test/* w w w . j a v a2 s.co m*/ public void testHavingRecievedEvents() throws Throwable { for (File f : fsfile.listFiles()) { if (!f.delete()) { throw new RuntimeException(String.format("couldn't delete file %s!", f.getAbsolutePath())); } } Assert.assertTrue(fsfile.list().length == 0); Assert.assertTrue(fsfile.exists()); for (int i = 0; i < 10; i++) { write(i + ".txt", "now is the time for " + i); } if (System.in.read() <= 0) { logger.debug("returning after test"); } }