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(String message, boolean condition) 

Source Link

Document

Asserts that a condition is true.

Usage

From source file:com.workday.autoparse.json.demo.JsonTestUtils.java

static void assertJSONObjectsEqual(String message, JSONObject expected, Object actual) {
    if (expected == null) {
        Assert.assertNull(message + " is null", actual);
        return;/*  w  ww  .  ja v a 2  s .c om*/
    }

    Assert.assertNotNull(message + " not null", actual);
    Assert.assertTrue(message + " expected JSONObject but found " + actual.getClass().getCanonicalName(),
            actual instanceof JSONObject);

    JSONObject actualJsonObject = (JSONObject) actual;
    Assert.assertEquals(message + ": size", expected.length(), actualJsonObject.length());

    @SuppressWarnings("unchecked")
    Iterator<String> keys = expected.keys();
    while (keys.hasNext()) {
        String key = keys.next();
        Assert.assertEquals(message + ": " + key, expected.opt(key), actualJsonObject.opt(key));
    }
}

From source file:at.tfr.securefs.util.TestMain.java

@Test
public void testMainEncryptWithSalt() throws Exception {

    Main main = new Main();
    main.parseOpts(new String[] { "-t", "-s", "test_main", "-o", "test_main.enc", "test_main.txt" });
    main.execute();/*from  ww w.  ja  va2  s .  c om*/

    main = new Main();
    main.parseOpts(new String[] { "-t", "-s", "test_main", "-d", "-o", "test_main.out.txt", "test_main.enc" });
    main.execute();

    Assert.assertTrue("encryption/decryption failed",
            IOUtils.contentEquals(this.getClass().getResourceAsStream("/" + "test_main.txt"),
                    this.getClass().getResourceAsStream("/" + "test_main.out.txt")));

}

From source file:com.vaadin.tests.server.LicenseInJavaFiles.java

private void checkForLicense(File srcDir, HashSet<String> missing) throws IOException {
    Assert.assertTrue("Source directory " + srcDir + " does not exist", srcDir.exists());

    for (File f : srcDir.listFiles()) {
        if (f.isDirectory()) {
            if (f.getPath().endsWith("com/vaadin/external")) {
                continue;
            }/*  www.  jav  a 2  s .  c om*/
            checkForLicense(f, missing);
        } else if (f.getName().endsWith(".java")) {
            checkForLicenseInFile(f, missing);
        }
    }
}

From source file:Project3Test.java

@Test
public void TruthTest() {
    Assert.assertTrue("Condition is false", service.getCondition());
}

From source file:com.healthcit.cacure.test.RecreateDBUnitDTDTestCase.java

@Test
public void doRecreate() throws DatabaseUnitException, SQLException, FileNotFoundException {
    IDatabaseConnection dconnection = new DatabaseConnection(dataSource.getConnection());
    IDataSet dataSet = dconnection.createDataSet();
    File file = new File("formbuilder-dataset.dtd");

    Assert.assertTrue("DTD file can not be deleted.", !file.exists() || file.delete());

    Writer out = new OutputStreamWriter(new FileOutputStream(file));
    FlatDtdWriter datasetWriter = new FlatDtdWriter(out);
    datasetWriter.setContentModel(FlatDtdWriter.CHOICE);
    // You could also use the sequence model which is the default
    // datasetWriter.setContentModel(FlatDtdWriter.SEQUENCE);
    datasetWriter.write(dataSet);//from   w w  w  . j  av a2s .  c  o  m

    Assert.assertTrue("DTD file did not created.", file.exists());
}

From source file:de.akquinet.gomobile.androlog.test.MailReporterTest.java

public void setUp() {
    try {//w w  w.j a v  a2 s.c om
        Assert.assertTrue("No SDCard or not the permission to write",
                Environment.getExternalStorageDirectory().canWrite());
        // Create files
        Properties propsDefault = new Properties();
        propsDefault.setProperty(Constants.ANDROLOG_ACTIVE, "true");
        propsDefault.setProperty(Constants.ANDROLOG_REPORT_ACTIVE, "true");
        propsDefault.setProperty(Constants.ANDROLOG_REPORT_REPORTERS,
                "de.akquinet.android.androlog.reporter.NoopReporter");

        Properties propsActive = new Properties();
        propsActive.setProperty(Constants.ANDROLOG_ACTIVE, "true");
        propsActive.setProperty(Constants.ANDROLOG_REPORT_ACTIVE, "true");
        propsActive.setProperty(Constants.ANDROLOG_REPORT_REPORTERS,
                "de.akquinet.android.androlog.reporter.MailReporter");
        propsActive.setProperty(MailReporter.ANDROLOG_REPORTER_MAIL_ADDRESS, "clement.escoffier@gmail.com");

        testContext = new File(Environment.getExternalStorageDirectory(),
                getContext().getPackageName() + ".properties");
        testContext.createNewFile();
        (new File(Environment.getExternalStorageDirectory(), "tmp")).mkdir();

        FileOutputStream out = new FileOutputStream(testContext);
        propsActive.store(out, "Enable Androlog file");
        out.close();
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail(e.getMessage());
    }
}

From source file:com.hybris.dataonboarding.rest.client.DataonboardingIntegrationTest.java

@Test
public void testGetImportRun() {
    Assert.assertTrue("no import runs", importRunFacade.getImportRuns().isEmpty());
}

From source file:at.tfr.securefs.util.TestMain.java

@Test
public void testMainDecrypt() throws Exception {

    Main main = new Main();
    main.parseOpts(new String[] { "-t", "-o", "test_main.enc", "test_main.txt" });
    main.execute();/*from  w w w .  j a  va2  s  .  c  o  m*/

    main = new Main();
    main.parseOpts(new String[] { "-t", "-d", "-o", "test_main.out.txt", "test_main.enc" });
    main.execute();

    Assert.assertTrue("encryption/decryption failed",
            IOUtils.contentEquals(this.getClass().getResourceAsStream("/" + "test_main.txt"),
                    this.getClass().getResourceAsStream("/" + "test_main.out.txt")));

}

From source file:de.akquinet.gomobile.androlog.test.PostReporterTest.java

public void setUp() {
    try {/*www . jav a 2  s.c om*/
        Assert.assertTrue("No SDCard or not the permission to write",
                Environment.getExternalStorageDirectory().canWrite());
        // Create files
        Properties propsDefault = new Properties();
        propsDefault.setProperty(Constants.ANDROLOG_ACTIVE, "true");
        propsDefault.setProperty(Constants.ANDROLOG_REPORT_ACTIVE, "true");
        propsDefault.setProperty(Constants.ANDROLOG_REPORT_REPORTERS,
                "de.akquinet.android.androlog.reporter.NoopReporter");

        Properties propsActive = new Properties();
        propsActive.setProperty(Constants.ANDROLOG_ACTIVE, "true");
        propsActive.setProperty(Constants.ANDROLOG_REPORT_ACTIVE, "true");
        propsActive.setProperty(Constants.ANDROLOG_REPORT_REPORTERS,
                "de.akquinet.android.androlog.reporter.PostReporter");
        propsActive.setProperty(Constants.ANDROLOG_REPORT_EXCEPTION_HANDLER_PROPAGATION, "false");

        propsActive.setProperty(PostReporter.ANDROLOG_REPORTER_POST_URL, URL);

        testContext = new File(Environment.getExternalStorageDirectory(),
                getContext().getPackageName() + ".properties");
        testContext.createNewFile();
        (new File(Environment.getExternalStorageDirectory(), "tmp")).mkdir();

        FileOutputStream out = new FileOutputStream(testContext);
        propsActive.store(out, "Enable Androlog file");
        out.close();
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail(e.getMessage());
    }
}

From source file:com.btobits.automator.fix.ant.task.SMTPStartTask.java

@Override
protected void validate() throws Exception {
    Assert.assertTrue("Reference to SMTP acceptor is not specified", StringUtils.isNotBlank(refId));
}