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:org.ocpsoft.rewrite.faces.DeferredOperationTest.java

@Test
public void testDeferOperationRedirectView() throws Exception {
    HttpAction<HttpGet> action = get("/redirect");
    String content = action.getResponseContent();
    Assert.assertTrue(content == null || content.isEmpty());
    Assert.assertEquals(201, action.getResponse().getStatusLine().getStatusCode());
    Assert.assertEquals("/redirect_result", action.getCurrentContextRelativeURL());
}

From source file:org.ocpsoft.rewrite.faces.PhaseOperationTest.java

@Test
public void testDeferOperationRestoreView() throws Exception {
    HttpAction<HttpGet> action = get("/empty.xhtml?adf=blah");
    String content = action.getResponseContent();
    Assert.assertTrue(content == null || content.isEmpty());
    Assert.assertEquals(203, action.getResponse().getStatusLine().getStatusCode());
}

From source file:com.cloud.utils.ProcessUtilTest.java

@Test
public void pidCheck() throws ConfigurationException, IOException {
    Assume.assumeTrue(SystemUtils.IS_OS_LINUX);
    FileUtils.writeStringToFile(pidFile, "123456\n");
    ProcessUtil.pidCheck(pidFile.getParent(), pidFile.getName());
    String pidStr = FileUtils.readFileToString(pidFile);
    Assert.assertFalse("pid can not be blank", pidStr.isEmpty());
    int pid = Integer.parseInt(pidStr.trim());
    int maxPid = Integer.parseInt(FileUtils.readFileToString(new File("/proc/sys/kernel/pid_max")).trim());
    Assert.assertTrue(pid <= maxPid);
}

From source file:org.xdi.oxd.license.client.LicenseClientTest.java

@Parameters({ "licenseServerEndpoint" })
@Test(enabled = false)//from w w  w .jav  a  2 s  . c  o  m
public void generateLicense(String licenseServerEndpoint) {
    final GenerateWS generateWS = LicenseClient.generateWs(licenseServerEndpoint);

    final List<LicenseResponse> generatedLicense = generateWS.generatePost("id", "mac_address");

    Assert.assertTrue(generatedLicense != null && !generatedLicense.isEmpty()
            && !Strings.isNullOrEmpty(generatedLicense.get(0).getEncodedLicense()));
    System.out.println(generatedLicense.get(0).getEncodedLicense());
}

From source file:com.feedzai.fos.server.remote.impl.RemoteClassifierFactoryTest.java

@Test
public void testCreation() throws Exception {
    BaseConfiguration configuration = new BaseConfiguration();
    configuration.setProperty(FosConfig.FACTORY_NAME, DummyManagerFactory.class.getName());
    configuration.setProperty(FosConfig.EMBEDDED_REGISTRY, true);
    configuration.setProperty(FosConfig.REGISTRY_PORT, 5959);
    final FosConfig fosConfig = new FosConfig(configuration);
    RemoteManagerFactory remoteClassifierFactory = new RemoteManagerFactory();

    Assert.assertTrue(Whitebox.getInternalState(remoteClassifierFactory.createManager(fosConfig),
            "manager") instanceof DummyManager);
    Assert.assertTrue(Whitebox.getInternalState(remoteClassifierFactory.createManager(fosConfig).getScorer(),
            "scorer") instanceof DummyScorer);
}

From source file:com.lemi.mario.download.utils.Proxy.java

/**
 * Return the proxy port set by the user.
 * //from  w  ww  .j  a v a  2  s  .  c  om
 * @param ctx A Context used to get the settings for the proxy port.
 * @return The port number to use or -1 if no proxy is to be used.
 */
static final public int getPort(Context ctx) {
    ContentResolver contentResolver = ctx.getContentResolver();
    Assert.assertNotNull(contentResolver);
    String host = Settings.Secure.getString(contentResolver, Settings.Secure.HTTP_PROXY);
    if (host != null) {
        int i = host.indexOf(':');
        if (i == -1) {
            if (DEBUG) {
                Assert.assertTrue(host.length() == 0);
            }
            return -1;
        }
        if (DEBUG) {
            Assert.assertTrue(i < host.length());
        }
        return Integer.parseInt(host.substring(i + 1));
    }
    return getDefaultPort();
}

From source file:com.couchbase.capi.TestCouchbase.java

public void testPools() throws Exception {
    HttpClient client = getClient();//from w  w  w.  j a  va2 s  . c o  m

    HttpUriRequest request = new HttpGet(String.format("http://localhost:%d/pools", port));

    HttpResponse response = client.execute(request);

    Assert.assertEquals(200, response.getStatusLine().getStatusCode());

    HttpEntity entity = response.getEntity();

    Map<String, List<Map<String, Object>>> details = null;
    if (entity != null) {
        InputStream input = entity.getContent();
        try {
            details = mapper.readValue(input, Map.class);
        } finally {
            input.close();
        }
    }

    Assert.assertTrue(details.containsKey("pools"));
    Assert.assertEquals(1, details.get("pools").size());
    Assert.assertEquals("default", details.get("pools").get(0).get("name"));
    Assert.assertEquals("/pools/default?uuid=00000000000000000000000000000000",
            details.get("pools").get(0).get("uri"));

    client.getConnectionManager().shutdown();
}

From source file:azkaban.crypto.EncryptionTest.java

@Test
public void testInvalidParams() {
    ICrypto crypto = new Crypto();
    String[] args = { "", null, "test" };
    for (Version ver : Version.values()) {
        for (String plaintext : args) {
            for (String passphrase : args) {
                try {
                    if (!StringUtils.isEmpty(plaintext) && !StringUtils.isEmpty(passphrase)) {
                        String cipheredText = crypto.encrypt(plaintext, passphrase, ver);
                        Assert.assertEquals(plaintext, crypto.decrypt(cipheredText, passphrase));
                    } else {
                        crypto.encrypt(plaintext, passphrase, ver);
                        Assert.fail("Encyption should have failed with invalid parameters. plaintext: "
                                + plaintext + " , passphrase: " + passphrase);
                    }// w ww. ja v a2  s.  c o  m
                } catch (Exception e) {
                    Assert.assertTrue(e instanceof IllegalArgumentException);
                }

            }
        }
    }
}

From source file:com.comcast.cats.jenkins.service.BuildServiceIT.java

public void startNewBuild() throws HttpException, IOException {

    boolean bool = buildService.startBuild(jobName, "", "");
    LOGGER.info(" status is " + bool);
    Assert.assertTrue(bool);
}

From source file:com.cloudant.sync.datastore.BasicDBBodyTest.java

@Test
public void constructor_byteArray_correctObjectShouldBeCreated() throws Exception {
    DocumentBody body = new BasicDocumentBody(jsonData);
    Assert.assertTrue(Arrays.equals(jsonData, body.asBytes()));
    Assert.assertNotNull(body.asMap());/*from   w ww.j  av  a2s.c o  m*/

    Map<String, Object> actualMap = body.asMap();
    assertMapIsCorrect(actualMap);
}