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:eu.delving.sip.TestCoordinateConversion.java

@Test
public void runThrough() {
    for (String line : inputLines) {
        if (line.trim().isEmpty())
            continue;
        String latLongString = functionCall(line, false);
        System.out.println(latLongString);
        checkLatLong(line, latLongString);
        String utmString = functionCall(line, true);
        Matcher matcher = utmPattern.matcher(utmString);
        Assert.assertTrue("SRID format violation: " + utmString, matcher.matches());
        String srid = matcher.group(1);
        String east = matcher.group(2);
        String north = matcher.group(3);
        UTMRef ref = new UTMRef(Double.parseDouble(east), Double.parseDouble(north), 'V',
                Integer.parseInt(srid) % 100);
        String latLongConverted = String.format("%f, %f", ref.toLatLng().getLat(), ref.toLatLng().getLng());
        System.out.println(String.format(
                "SRID=%s;POINT(%s,%s) ==> %s  (https://maps.google.com/maps?f=q&hl=en&geocode=&q=%s&ie=UTF8&z=10)",
                srid, east, north, latLongConverted, latLongConverted));
        checkLatLong(line, latLongConverted);
    }//from  ww  w  . jav  a2  s  . c om
}

From source file:org.openspaces.eviction.test.FIFOSingleOrderTest.java

protected void assertMemoryShortageTest() {
    Assert.assertTrue("amount of objects in space is larger than cache size",
            gigaSpace.count(new Object()) <= cacheSize);
}

From source file:fi.vm.sade.organisaatio.business.impl.OrganisaatioBusinessServiceImplTest.java

@Test
public void processOrganisaatioSuhdeChangesNoNewChanges() {
    List<Organisaatio> results = service.processNewOrganisaatioSuhdeChanges();
    Assert.assertNotNull(results);//from w w w.  j  av a  2  s . c o  m
    Assert.assertTrue("Results should be empty!", results.isEmpty());
}

From source file:fll.web.WebTestUtils.java

public static WebClient getConversation() throws IOException, SAXException {
    final WebClient conversation = new WebClient();

    // always login first
    final Page loginPage = conversation.getPage(TestUtils.URL_ROOT + "login.jsp");
    Assert.assertTrue("Received non-HTML response from web server", loginPage.isHtmlPage());

    final HtmlPage loginHtml = (HtmlPage) loginPage;
    HtmlForm form = loginHtml.getFormByName("login");
    Assert.assertNotNull("Cannot find login form", form);

    final HtmlTextInput userTextField = form.getInputByName("user");
    userTextField.setValueAttribute(IntegrationTestUtils.TEST_USERNAME);

    final HtmlPasswordInput passTextField = form.getInputByName("pass");
    passTextField.setValueAttribute(IntegrationTestUtils.TEST_PASSWORD);

    final HtmlSubmitInput button = form.getInputByName("submit_login");
    final Page response = button.click();

    final URL responseURL = response.getUrl();
    final String address = responseURL.getPath();
    final boolean correctAddress;
    if (address.contains("login.jsp")) {
        correctAddress = false;/*from ww w  . j av  a 2s  .  com*/
    } else {
        correctAddress = true;
    }
    Assert.assertTrue("Unexpected URL after login: " + address, correctAddress);

    return conversation;
}

From source file:com.rmn.qa.aws.VmManagerTest.java

@Test
// Test if an AWS access key is not set, the appropriate exception if thrown
public void testAccessKeyNotSet() {
    MockAmazonEc2Client client = new MockAmazonEc2Client(null);
    Properties properties = new Properties();
    String region = "east";
    AwsVmManager AwsVmManager = new AwsVmManager(client, properties, region);
    try {/*from  w w w . ja  v  a 2 s .c o m*/
        AwsVmManager.getCredentials();
    } catch (IllegalArgumentException e) {
        Assert.assertTrue("Message should be related to access key",
                e.getMessage().contains(AutomationConstants.AWS_ACCESS_KEY));
        return;
    }
    Assert.fail("Exception should have been throw for access key");
}

From source file:org.openspaces.eviction.test.ClassSpecificOrderTest.java

@Test
public void inClassLRUReadTest() throws Exception {

    logger.info("write an object");
    gigaSpace.write(new SilverMedal(0));

    logger.info("fill the space with more than cache size object and red the original in the middle");
    for (int i = 1; i <= cacheSize + 10; i++) {
        if (i == (cacheSize / 2))
            gigaSpace.read(new SilverMedal(0));
        else//from www . j a v a  2  s  . c  o m
            gigaSpace.write(new SilverMedal(i));
    }
    Assert.assertTrue("amount of objects in space is larger than cache size",
            gigaSpace.count(new Object()) == cacheSize);
    logger.info("assert the original object is still in cache");
    Assert.assertNotNull("silver medal 0 is not in space", gigaSpace.read(new SilverMedal(0)));
    logger.info("Test Passed");
}

From source file:net.carinae.dev.async.TasksIntegrationTest.java

/**
 * Enqueues a simple task and waits for 3 minutes for it to be executed.
 *///www  .  j  a va 2s . co  m
@Test
public void testSimpleTask() throws InterruptedException {

    String data = "" + System.nanoTime();

    enqueueSimpleTask(data);

    // Now, try to read from the database
    int tries = 0;
    while (tries < 180 && pollDummyEntity(data)) {
        Thread.sleep(1000); // 1 second
        tries++;
    }

    Assert.assertTrue("Task didn't execute in 3 minutes time", tries < 180);
}

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

@Override
protected void validate() {
    Assert.assertTrue("Reference to FIX session is not specified", StringUtils.isNotBlank(refId));
    final Object obj = getProject().getReference(refId);
    Assert.assertNotNull("RefId[" + refId + "]. Failed to get FIX session.", obj);
    Assert.assertTrue("RefId[" + refId + "]. Unknown FIX session mode: " + obj.getClass().getSimpleName(),
            (obj instanceof FixSession));
    fixSession = (FixSession) obj;//from   w ww.j  av a  2s . co m
    // get FIX connectivity object
    conn = fixSession.getConnectivity();
    Assert.assertNotNull("RefId[" + refId + "]. getConnectivity() return NULL", conn);
}

From source file:com.zimbra.cs.imap.ImapProxyTest.java

@Test(timeout = 30000)
public void bye() throws Exception {
    server = MockTcpServer.scenario().sendLine("* OK server ready").recvLine() // CAPABILITY
            .sendLine("* CAPABILITY IMAP4rev1 AUTH=X-ZIMBRA")
            .reply(Pattern.compile("(.*) CAPABILITY"), "{0} OK CAPABILITY\r\n").recvLine() // ID
            .sendLine("* ID (\"NAME\" \"Zimbra\")").reply(Pattern.compile("(.*) ID"), "{0} OK ID completed\r\n")
            .recvLine() // AUTHENTICATE
            .sendLine("+ ready for literal")
            .reply(Pattern.compile("(.*) AUTHENTICATE"), "{0} OK AUTHENTICATE\r\n").recvLine() // credential
            .recvLine() // NOOP
            .reply(Pattern.compile("(.*) NOOP"), "{0} OK NOOP\r\n").sendLine("* BYE server closing connection")
            .build().start(PORT);/*from  w  w  w  . ja va 2s. c  om*/

    MockImapHandler handler = new MockImapHandler();
    ImapProxy proxy = new ImapProxy(new InetSocketAddress(PORT), "test@zimbra.com", "secret", handler);
    proxy.proxy("001", "NOOP");
    try {
        proxy.proxy("002", "NOOP");
        Assert.fail();
    } catch (ImapProxyException expected) {
    }

    // verify BYE was not proxied
    Assert.assertEquals("001 OK NOOP\r\n", handler.output.toString());

    server.shutdown(3000);
    Assert.assertEquals("C01 CAPABILITY\r\n", server.replay());
    String id = server.replay();
    Assert.assertTrue(id,
            id.matches("C02 ID \\(\"name\" \"ZCS\" \"version\" \".*\" \"X-VIA\" \"127\\.0\\.0\\.1\"\\)\r\n"));
    Assert.assertEquals("C03 AUTHENTICATE X-ZIMBRA\r\n", server.replay());
    server.replay(); // auth token
    Assert.assertEquals("001 NOOP\r\n", server.replay());
    Assert.assertEquals(null, server.replay());
}

From source file:de.extrastandard.persistence.model.InputDataIT.java

@Test
@Transactional/*from  w  w  w.ja v a 2  s . c o m*/
public void testFindInputDataForExecutionWithLimit() {
    final Integer testDataSize = 6;
    for (Integer counter = 0; counter < testDataSize; counter++) {
        persistenceTestSetup.setUpTestDatenForProcedureSendFetchPhase2();
    }
    final Integer inputDataLimit = 5;
    final List<ICommunicationProtocol> findInputDataForExecution = executionPersistence
            .findInputDataForExecution(PersistenceTestSetup.PROCEDURE_DATA_MATCH_NAME, PhaseQualifier.PHASE2,
                    inputDataLimit);
    Assert.assertTrue("Zu viele Daten ausgewhlt", findInputDataForExecution.size() <= inputDataLimit);
    for (final ICommunicationProtocol communicationProtocol : findInputDataForExecution) {

        final Long phaseConnectionStatusId = communicationProtocol.getNextPhaseConnection().getStatus().getId();

        Assert.assertEquals(PersistentStatus.INITIAL.getId(), phaseConnectionStatusId);
    }
}