Example usage for junit.framework Assert assertTrue

List of usage examples for junit.framework Assert assertTrue

Introduction

In this page you can find the example usage for junit.framework Assert assertTrue.

Prototype

static public void assertTrue(boolean condition) 

Source Link

Document

Asserts that a condition is true.

Usage

From source file:com.nomsic.randb.persistence.xml.JaxbIndexTest.java

@Test
public void testRead() throws RandbException {
    File file = new File(TARGET_TEST_DATA_INDEX_XML);
    Index index = new Index();
    String key = "name";
    String value = "filename";
    index.addBlockGroup(key, value);/* w w w.j  av a2s  .  c o  m*/
    jaxbUtil.write(index, file);

    index = (Index) jaxbUtil.read(file);
    Assert.assertTrue(index.getIndexMap().containsKey(key));
    Assert.assertEquals(value, index.getIndexMap().get(key));
}

From source file:com.sap.prd.mobile.ios.mios.FileUtilsTest.java

@Test
public void testCreateSymbolicLink() throws Exception {
    File source = prepareFile();//from ww  w .  ja  v  a2s .  c  o m
    File target = tmpFolder.newFile("target");

    FileUtils.createSymbolicLink(source, target);

    Assert.assertTrue(checkForSymbolicLink(target));
}

From source file:com.rackspacecloud.blueflood.io.serializers.CounterRollupSerializationTest.java

@Test
public void testCounterV1RoundTrip() throws IOException {
    CounterRollup c0 = new CounterRollup().withCount(7442245).withSampleCount(1);
    CounterRollup c1 = new CounterRollup().withCount(34454722343L).withSampleCount(10);

    if (System.getProperty("GENERATE_COUNTER_SERIALIZATION") != null) {
        OutputStream os = new FileOutputStream("src/test/resources/serializations/counter_version_"
                + Constants.VERSION_1_COUNTER_ROLLUP + ".bin", false);
        os.write(Base64.encodeBase64(new NumericSerializer.CounterRollupSerializer().toByteBuffer(c0).array()));
        os.write("\n".getBytes());
        os.write(Base64.encodeBase64(new NumericSerializer.CounterRollupSerializer().toByteBuffer(c1).array()));
        os.write("\n".getBytes());
        os.close();//from  w  ww  . java2s  .c  o m
    }

    Assert.assertTrue(new File("src/test/resources/serializations").exists());

    int count = 0;
    int version = 0;
    final int maxVersion = Constants.VERSION_1_COUNTER_ROLLUP;
    while (version <= maxVersion) {
        BufferedReader reader = new BufferedReader(
                new FileReader("src/test/resources/serializations/counter_version_" + version + ".bin"));

        ByteBuffer bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
        CounterRollup cc0 = NumericSerializer.serializerFor(CounterRollup.class).fromByteBuffer(bb);
        Assert.assertEquals(c0, cc0);

        bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
        CounterRollup cc1 = NumericSerializer.serializerFor(CounterRollup.class).fromByteBuffer(bb);
        Assert.assertEquals(c1, cc1);

        Assert.assertFalse(cc0.equals(cc1));
        version++;
        count++;
    }

    Assert.assertTrue(count > 0);
}

From source file:com.cloud.agent.dao.impl.PropertiesStorageTest.java

@Test
public void configureWithExistingFile() throws IOException {
    String fileName = "target/existingfile" + System.currentTimeMillis();
    File file = new File(fileName);

    FileUtils.writeStringToFile(file, "a=b\n\n");

    PropertiesStorage storage = new PropertiesStorage();
    HashMap<String, Object> params = new HashMap<String, Object>();
    params.put("path", fileName);
    Assert.assertTrue(storage.configure("test", params));
    Assert.assertEquals("b", storage.get("a"));
    Assert.assertTrue(file.exists());/*from   w w w. ja v a 2 s  .  co m*/
    storage.persist("foo", "bar");
    Assert.assertEquals("bar", storage.get("foo"));

    storage.stop();
    file.delete();
}

From source file:org.openmrs.web.controller.maintenance.SystemInformationControllerTest.java

/**
 * @see SystemInformationController#showPage(ModelMap)
 *///w  w w  .  j  av a 2  s.c o m
@Test
@Verifies(value = "should add java runtime information attribute to the model map", method = "showPage()")
public void showPage_shouldReturnUserInformation() {
    Assert.assertTrue(((Map<String, Map<String, String>>) model.get("systemInfo"))
            .containsKey("SystemInfo.title.javaRuntimeEnvironmentInformation"));
}

From source file:org.wso2.carbon.ganalytics.publisher.GoogleAnalyticsDataPublisherTest.java

@Test
public void testPublishGETHTTP() throws Exception {
    GoogleAnalyticsData data = new GoogleAnalyticsData.DataBuilder("UA-50303033-1", "1",
            "35009a79-1a05-49d7-b876-2b884d0fsadfa", GoogleAnalyticsConstants.HIT_TYPE_PAGEVIEW)
                    .setDocumentPath("/testpageGET").setDocumentHostName("localhost.com")
                    .setDocumentTitle("HTTP GET").build();

    String payload = GoogleAnalyticsDataPublisher.buildPayloadString(data);
    Assert.assertTrue(GoogleAnalyticsDataPublisher.publishGET(payload,
            "Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0", false));
}

From source file:de.burlov.bouncycastle.io.test.EncryptOutputStreamTest.java

@Test
public void testEncryptDecrypt() throws IOException {
    BlockCipher cipher = new SerpentEngine();
    Random rnd = new Random();
    byte[] key = new byte[256 / 8];
    rnd.nextBytes(key);//from  w w  w .java  2  s.c  o m
    byte[] iv = new byte[cipher.getBlockSize()];
    rnd.nextBytes(iv);
    byte[] data = new byte[1230000];
    new Random().nextBytes(data);

    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    CryptOutputStream eout = new CryptOutputStream(bout, cipher, key);
    eout.write(data);
    eout.close();
    byte[] eData = bout.toByteArray();
    // eData[1000] = (byte) (eData[1000] & 0x88);
    ByteArrayInputStream bin = new ByteArrayInputStream(eData);
    CryptInputStream din = new CryptInputStream(bin, cipher, key);
    bout = new ByteArrayOutputStream();
    IOUtils.copy(din, bout);
    eData = bout.toByteArray();
    Assert.assertTrue(Arrays.areEqual(data, eData));

}

From source file:org.obiba.onyx.core.service.impl.ConfigurablePasswordValidationStrategyImplTest.java

@Test
public void testValidatePasswordReturnsList() {
    ((ConfigurablePasswordValidationStrategyImpl) passwordStrategy).setMinimumCharacterGroupsUsage(1);
    List<MessageSourceResolvable> messageList = passwordStrategy.validatePassword(user, "password");
    Assert.assertNotNull(messageList);// w w w . j  a v a 2 s.  c om
    Assert.assertTrue(messageList.size() == 0); // No error messages. Passed.
}

From source file:org.atemsource.atem.impl.pojo.CollectionAssociationAttributeTest.java

@Test
public void isEqual() {
    EntityA a1 = new EntityA();
    a1.setList(new ArrayList<EntityB>());
    final EntityB b1 = new EntityB();
    a1.getList().add(b1);/* w  w  w  . j a  v  a  2s . c  o m*/
    b1.setInteger(1);

    EntityA a2 = new EntityA();
    a2.setList(new ArrayList<EntityB>());
    final EntityB b2 = new EntityB();
    a2.getList().add(b2);
    b2.setInteger(3);

    EntityType entityType = entityTypeRepository.getEntityType(EntityA.class);
    ListAssociationAttribute attribute = (ListAssociationAttribute) entityType.getAttribute("list");
    Assert.assertFalse(attribute.isEqual(a1, a2));
    b2.setInteger(1);
    Assert.assertTrue(attribute.isEqual(a1, a2));
}

From source file:org.apache.olingo.odata2.annotation.processor.ref.ServiceJsonTest.java

@Test
public void serviceDocumentDollarFormatJson() throws Exception {
    final HttpResponse response = callUri("?$format=json");
    // checkMediaType(response, HttpContentType.APPLICATION_JSON);
    String body = getBody(response);

    Assert.assertTrue(jsonDataResponseContains(body, "Buildings"));
    Assert.assertTrue(jsonDataResponseContains(body, "Employees"));
    Assert.assertTrue(jsonDataResponseContains(body, "Managers"));
    Assert.assertTrue(jsonDataResponseContains(body, "Photos"));
    Assert.assertTrue(jsonDataResponseContains(body, "Rooms"));
    Assert.assertTrue(jsonDataResponseContains(body, "Teams"));
}