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:fr.fastconnect.tibco.businessworks.fcunit.AssertXMLEqualTest.java

@Test
public void test_AssertAtLeastEqualXML() throws SAXException, IOException {

    String expectedXML = getExpected();
    String actualXML = getActual();
    String[] ignoredXPaths = new String[] { "/dimensions/pyramide[1]/timestamp[1]/text()[1]" };
    String[] ignoredBranches = new String[] { "/dimensions/square" };

    AssertXMLEqual assertAssertXMLEqual = new AssertXMLEqual(expectedXML, actualXML);

    assertAssertXMLEqual.setIgnoredXPaths(ignoredXPaths);

    assertAssertXMLEqual.setIgnoredBranches(ignoredBranches);

    boolean result = assertAssertXMLEqual.assertXMLAtLeastEqual();

    if (!result) {
        String[] additiionalFields = assertAssertXMLEqual.getAdditionalFields();
        printArray(additiionalFields);//from  w  w w. ja  v  a  2 s  . co  m
        String[] differentFieldsIgnorePaths = assertAssertXMLEqual.getDifferentFieldsIgnoredPaths(true);
        printArray(differentFieldsIgnorePaths);
        String[] differentFieldsIgnoredDescription = assertAssertXMLEqual.getDifferentFieldsDescriptions(true);
        printArray(differentFieldsIgnoredDescription);
        String[] differentFieldsPaths = assertAssertXMLEqual.getDifferentFieldsPaths(true);
        printArray(differentFieldsPaths);
        String[] differentFieldsExpectedValues = assertAssertXMLEqual.getDifferentFieldsActualValues(true);
        printArray(differentFieldsExpectedValues);
        String[] differentFieldsActualValues = assertAssertXMLEqual.getDifferentFieldsActualValues(true);
        printArray(differentFieldsActualValues);
        String[] differentFieldsDescription = assertAssertXMLEqual.getDifferentFieldsDescriptions(true);
        printArray(differentFieldsDescription);

    }

    Assert.assertTrue(result);

}

From source file:org.codehaus.grepo.query.jpa.repository.JpaRepositoryTest.java

@Test
public void testFindByCreationDate1() {
    TestEntity entity = new TestEntity("username", 1, "firstname");
    List<TestEntity> list = repo.findByCreationDate1(entity.getCreationDate());
    Assert.assertEquals(1, list.size());

    list = repo.findByCreationDate1(null);
    Assert.assertTrue(list.isEmpty());
}

From source file:org.openscore.lang.runtime.steps.ExecutableStepsTest.java

@Test
public void testStartWithInput() throws Exception {
    List<Input> inputs = Arrays.asList(new Input("input1", "input1"));
    RunEnvironment runEnv = new RunEnvironment();

    Map<String, Serializable> resultMap = new HashMap<>();
    resultMap.put("input1", 5);

    when(inputsBinding.bindInputs(eq(inputs), anyMap(), anyMap())).thenReturn(resultMap);
    executableSteps.startExecutable(inputs, runEnv, new HashMap<String, Serializable>(),
            new ExecutionRuntimeServices(), "", 2L);

    Map<String, Serializable> opVars = runEnv.getStack().popContext().getImmutableViewOfVariables();
    Assert.assertTrue(opVars.containsKey("input1"));
    Assert.assertEquals(5, opVars.get("input1"));

    Map<String, Serializable> callArg = runEnv.removeCallArguments();
    Assert.assertEquals(1, callArg.size());
    Assert.assertTrue(callArg.containsKey("input1"));
    Assert.assertEquals(5, callArg.get("input1"));
}

From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.PersonNameControllerTest.java

@Test
public void shouldVoidName() throws Exception {
    PersonName pname = service.getPersonNameByUuid(nameUuid);
    Assert.assertFalse(pname.isVoided());
    controller.delete(personUuid, nameUuid, "unit test", request, response);
    pname = service.getPersonNameByUuid(nameUuid);
    Assert.assertTrue(pname.isVoided());
    Assert.assertEquals("unit test", pname.getVoidReason());
}

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

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

    List<NameValuePair> payload = GoogleAnalyticsDataPublisher.buildPayload(data);
    Assert.assertTrue(GoogleAnalyticsDataPublisher.publishPOST(payload,
            "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.0 Safari/537.36",
            true));/*w ww .  j  a  va  2  s. c  o  m*/
}

From source file:com.streamreduce.util.JiraClientIT.java

@Test
public void testJiraGetIssuePriorities() throws Exception {
    Assert.assertTrue(jiraClient.getIssuePriorities().size() > 0);
}

From source file:org.openmrs.module.paperrecord.PaperRecordServiceComponentTest.java

@Test
public void testPaperMedicalRecordExistsWithIdentifierReturnsTrueIfPaperMedicalRecordExists() {

    // from the standard test dataset
    Location medicalRecordLocation = locationService.getLocation(1);

    // this identifier exists in the paper record test dataset
    Assert.assertTrue(paperRecordService.paperRecordExistsWithIdentifier("CATBALL", medicalRecordLocation));
}

From source file:com.qcadoo.model.integration.FieldModuleIntegrationTest.java

License:asdf

@Test
public void shouldCallAndPassAdditinanalFieldValidators() throws Exception {
    // given/*from  w w  w  . j av a  2  s  .c o  m*/
    DataDefinition productDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_PRODUCT);
    DataDefinition machineDao = dataDefinitionService.get(PLUGIN_MACHINES_NAME, ENTITY_NAME_MACHINE);
    DataDefinition componentDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_COMPONENT);

    PluginStateResolver pluginStateResolver = mock(PluginStateResolver.class);
    PluginUtilsService pluginUtil = new PluginUtilsService();
    ReflectionTestUtils.setField(pluginUtil, "pluginStateResolver", pluginStateResolver);
    pluginUtil.init();
    given(pluginStateResolver.isEnabled(PLUGIN_MACHINES_NAME)).willReturn(true);

    Entity machine = machineDao.save(createMachine("asd"));

    Entity product = createProduct("asd", "asd");
    product = productDao.save(product);

    Entity component = createComponent("name", product, machine);
    component.setField("machineDescription", "asdfghjkl");

    // when
    component = componentDao.save(component);

    // then
    Assert.assertTrue(component.isValid());
}

From source file:org.fusesource.fabric.itests.paxexam.FabricMavenProxyTest.java

@Test
public void testUpload() throws Exception {
    String featureLocation = System.getProperty("feature.location");
    System.out.println("Testing with feature from:" + featureLocation);
    System.err.println(executeCommand("fabric:create -n"));
    Set<Container> containers = ContainerBuilder.create(2).withName("maven").withProfiles("fabric")
            .assertProvisioningResult().build();

    FabricService fabricService = getFabricService();
    CuratorFramework curator = getCurator();
    List<String> children = getChildren(curator, ZkPath.MAVEN_PROXY.getPath("upload"));
    List<String> uploadUrls = new ArrayList<String>();
    for (String child : children) {
        String uploadeUrl = getSubstitutedPath(curator, ZkPath.MAVEN_PROXY.getPath("upload") + "/" + child);
        uploadUrls.add(uploadeUrl);/*from  w  w w  .  j  a  v a  2  s.c o  m*/
    }
    //Pick a random maven proxy from the list.
    Random random = new Random();
    int index = random.nextInt(uploadUrls.size());
    String targetUrl = uploadUrls.get(index);

    String uploadUrl = targetUrl + "itest/itest/1.0/itest-1.0-features.xml";
    System.out.println("Using URI: " + uploadUrl);
    DefaultHttpClient client = new DefaultHttpClient();
    HttpPut put = new HttpPut(uploadUrl);
    client.getCredentialsProvider().setCredentials(AuthScope.ANY,
            new UsernamePasswordCredentials("admin", "admin"));

    FileNIOEntity entity = new FileNIOEntity(new File(featureLocation), "text/xml");
    put.setEntity(entity);
    HttpResponse response = client.execute(put);
    System.err.println("Response:" + response.getStatusLine());
    Assert.assertTrue(
            response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 202);

    System.err.println(
            executeCommand("fabric:profile-edit --repositories mvn:itest/itest/1.0/xml/features default"));
    System.err.println(executeCommand("fabric:profile-edit --features example-cbr default"));
    Provision.waitForContainerStatus(containers, PROVISION_TIMEOUT);
}

From source file:org.fusesource.fabric.itests.smoke.FabricMavenProxyTest.java

@Test
public void testUpload() throws Exception {
    String featureLocation = System.getProperty("feature.location");
    System.out.println("Testing with feature from:" + featureLocation);
    System.err.println(executeCommand("fabric:create -n"));
    Set<Container> containers = ContainerBuilder.create(2).withName("maven").withProfiles("fabric")
            .assertProvisioningResult().build();

    FabricService fabricService = getFabricService();
    CuratorFramework curator = getCurator();
    List<String> children = getChildren(curator, ZkPath.MAVEN_PROXY.getPath("upload"));
    List<String> uploadUrls = new ArrayList<String>();
    for (String child : children) {
        String uploadeUrl = getSubstitutedPath(curator, ZkPath.MAVEN_PROXY.getPath("upload") + "/" + child);
        uploadUrls.add(uploadeUrl);//from   ww w  . jav  a2s  .c  o  m
    }
    //Pick a random maven proxy from the list.
    Random random = new Random();
    int index = random.nextInt(uploadUrls.size());
    String targetUrl = uploadUrls.get(index);

    String uploadUrl = targetUrl + "itest/itest/1.0/itest-1.0-features.xml";
    System.out.println("Using URI: " + uploadUrl);
    DefaultHttpClient client = new DefaultHttpClient();
    HttpPut put = new HttpPut(uploadUrl);
    client.getCredentialsProvider().setCredentials(AuthScope.ANY,
            new UsernamePasswordCredentials("admin", "admin"));

    FileNIOEntity entity = new FileNIOEntity(new File(featureLocation), "text/xml");
    put.setEntity(entity);
    HttpResponse response = client.execute(put);
    System.err.println("Response:" + response.getStatusLine());
    Assert.assertTrue(
            response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 202);

    System.err.println(
            executeCommand("fabric:profile-edit --repositories mvn:itest/itest/1.0/xml/features default"));
    System.err.println(executeCommand("fabric:profile-edit --features example-cbr default"));
    Provision.containerStatus(containers, PROVISION_TIMEOUT);
}