Example usage for junit.framework Assert assertFalse

List of usage examples for junit.framework Assert assertFalse

Introduction

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

Prototype

static public void assertFalse(boolean condition) 

Source Link

Document

Asserts that a condition is false.

Usage

From source file:org.wso2.carbon.apimgt.handlers.AuthenticationHandlerTest.java

@Test(description = "Handle request with cert management exception ", dependsOnMethods = "testHandleSuccessRequestEncodedPem")
public void testHandleRequestWithCertMgmtException() throws Exception {
    HashMap<String, String> transportHeaders = new HashMap<>();
    transportHeaders.put(AuthConstants.ENCODED_PEM, "encoded pem");
    setMockClient();/*from w  w w . j a va2s.  c  o  m*/
    this.mockClient.setResponse(null);
    MessageContext messageContext = createSynapseMessageContext("<empty/>", this.synapseConfiguration,
            transportHeaders, "https://test.com/testservice/api/testdevice");
    boolean response = this.handler.handleRequest(messageContext);
    Assert.assertFalse(response);
    this.mockClient.reset();
}

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

@Test
public void shouldDeleteDrugOrder() throws Exception {
    Assert.assertFalse(service.getOrderByUuid(DRUG_ORDER_UUID).isVoided());
    controller.delete(DRUG_ORDER_UUID, "because", request, response);
    Assert.assertTrue(service.getOrderByUuid(DRUG_ORDER_UUID).isVoided());
}

From source file:org.openmrs.module.atomfeed.AtomFeedUtilTest.java

/**
 * @see AtomFeedUtil#getAtomFeedStream(java.io.OutputStream, java.util.Date)
 * @verifies download partial stream by given date
 *//*from  w w w .  ja v  a2s .c  o m*/
@Test
public void getAtomFeedStream_shouldDownloadPartialStreamByGivenDate() throws Exception {
    MockHttpServletResponse response = new MockHttpServletResponse();
    // if atom feed file exists, just get rid of it 
    File feedFile = AtomFeedUtil.getFeedEntriesFile();
    if (feedFile.exists()) {
        feedFile.delete();
    }
    // write couple of entries to atom feed 
    AtomFeedUtil.writeToFeed("test1", new Encounter());
    AtomFeedUtil.writeToFeed("test2", new Patient());
    // do some sleep to have asOfDate parameter for filtering entries
    Calendar asOfDate = Calendar.getInstance();
    Thread.sleep(1500);
    // add another entries (ones which will be filtered to stream)
    AtomFeedUtil.writeToFeed("test3", new Encounter());
    AtomFeedUtil.writeToFeed("test4", new Patient());

    AtomFeedUtil.getAtomFeedStream(response.getOutputStream(), asOfDate.getTime());

    // get response content to use it when asserting
    String responseContent = response.getContentAsString();

    // test if response contains header file content
    String atomHeader = FileUtils.readFileToString(AtomFeedUtil.getFeedHeaderFile());
    // truncate "</feed>" from the atom header string
    if (StringUtils.isNotBlank(atomHeader)) {
        atomHeader = StringUtils.substringBeforeLast(atomHeader, "</feed>");
    }
    Assert.assertTrue(StringUtils.contains(responseContent, atomHeader));

    // test that response content also contains both entries, added after sleep
    Assert.assertTrue(StringUtils.contains(responseContent, "<action>test3</action>"));
    Assert.assertTrue(StringUtils.contains(responseContent, "<action>test4</action>"));

    // test that response content also contains both entries, added after sleep
    Assert.assertFalse(StringUtils.contains(responseContent, "<action>test1</action>"));
    Assert.assertFalse(StringUtils.contains(responseContent, "<action>test2</action>"));

    // test that response content also contains closing tag </feed>
    Assert.assertTrue(StringUtils.endsWith(responseContent, "</feed>"));

}

From source file:at.tfr.securefs.process.ProcessFilesTest.java

@Test
public void testValidationFailsWrongSecretFromByWalkFileHierarchy() throws Exception {

    // Given: NO target directory yet!!, the source file
    generateFileHierarchy(fromRoot, 0, MAX_DIR_DEPTH, cp, secret);
    Assert.assertFalse(Files.exists(toRoot.resolve(DATA_FILES)));
    Assert.assertFalse(Files.exists(targetToFile));
    ProcessFiles pf = new ProcessFilesBean(new MockSecureFsCache());
    ProcessFilesData cfd = new ProcessFilesData();

    // Then we can generate a full hierarchy copy
    generateHierachyCopy(pf, cfd);//from   ww w. j  ava2  s .  com

    // Then both hierarchies cannot be validated with bad secret:
    pf.verify(fromRoot, cp, newSecret, cfd);
    Assert.assertFalse("verification failed", cfd.getErrors().isEmpty());

    cfd.getErrors().clear();
    cfd.setLastError((String) null);
    pf.verifyDecryption(generateSomeFile(fromRoot), cp, newSecret, cfd);
    Assert.assertTrue("no error on validation", cfd.getErrors().size() == 1);
    Assert.assertTrue("no error on validation",
            cfd.getErrors().entrySet().iterator().next().getValue().contains("IOException"));
    Assert.assertTrue("no error on validation", cfd.getLastError().contains("IOException"));

}

From source file:com.impetus.kundera.rest.resources.DataTypeTest.java

private void assertAllProfessionalsString(String queryResult) {
    Assert.assertFalse(StringUtils.isEmpty(queryResult));
    Assert.assertTrue(queryResult.indexOf("professional") > 0);
    Assert.assertTrue(queryResult.indexOf(pk1) > 0);
    Assert.assertTrue(queryResult.indexOf(pk2) > 0);
}

From source file:opennlp.tools.util.Span.java

/**
     * Test for {@link Span#contains(int)}.
     */// www . j  a v  a2 s .c  om
    public void testContainsInt() {
        Span a = new Span(10, 300);

        Assert.assertFalse(a.contains(9));
        Assert.assertTrue(a.contains(10));
        Assert.assertTrue(a.contains(200));
        Assert.assertTrue(a.contains(300));
        Assert.assertFalse(a.contains(301));
    }

From source file:org.sonatype.nexus.plugins.rrb.MavenRepositoryReaderIT.java

@Test(timeout = 5000)
public void testAmazon_20110112_slashCom() {
    // Fetched from URI http://repository.springsource.com/?prifix=maven/bundles/release&delimiter=/
    // and http://repository.springsource.com/maven/bundles/release/com
    List<RepositoryDirectory> result = reader.extract("/com/", localUrl,
            getFakeProxyRepository(getRemoteUrl() + "Amazon_20110112/maven/bundles/release"), "test");
    assertEquals("Result: " + result, 1, result.size());

    RepositoryDirectory repositoryDirectory1 = result.get(0);
    Assert.assertFalse(repositoryDirectory1.isLeaf());
    Assert.assertEquals(localUrl + "/com/springsource/", repositoryDirectory1.getResourceURI());
    Assert.assertEquals("/com/springsource/", repositoryDirectory1.getRelativePath());
}

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

/**
 * @see ObsController#updatePatient(String,SimpleObject,WebRequest,HttpServletResponse)
 * @verifies change a property on an obs
 *///from w  w  w .j  a  va  2s .c  o m
@Test
@Ignore("RESTWS-238: Define creatable/updatable properties on Obs resource")
public void updateObs_shouldChangeAPropertyOnAnObs() throws Exception {
    SimpleObject post = new ObjectMapper().readValue("{\"valueNumeric\": 35.0}", SimpleObject.class);
    Object editedObs = new ObsController().update("39fb7f47-e80a-4056-9285-bd798be13c63", post, emptyRequest(),
            new MockHttpServletResponse());
    List<Obs> obsList = Context.getObsService()
            .getObservationsByPerson(Context.getPersonService().getPerson(7));
    Obs newObs = obsList.get(obsList.size() - 1);
    Obs oldObs = Context.getObsService().getObsByUuid("39fb7f47-e80a-4056-9285-bd798be13c63");
    Assert.assertTrue(Context.getObsService().getObsByUuid("39fb7f47-e80a-4056-9285-bd798be13c63").isVoided());
    Assert.assertFalse(oldObs.getValueNumeric().equals(new Double("35.0")));
    Assert.assertTrue(newObs.getValueNumeric().equals(new Double("35.0")));
}

From source file:datafu.test.pig.sessions.SessionTests.java

@Test
public void sessionizeAccumulateTest() throws Exception {
    Sessionize sessionize = new Sessionize("30m");
    Tuple input = TupleFactory.getInstance().newTuple(1);
    DataBag inputBag = BagFactory.getInstance().newDefaultBag();
    input.set(0, inputBag);//from ww w .jav  a 2s .c  om

    Tuple item;
    List<Tuple> result;
    DateTime dt;

    // test same session id
    dt = new DateTime();
    item = TupleFactory.getInstance().newTuple(1);
    item.set(0, dt.getMillis());
    inputBag.add(item);
    sessionize.accumulate(input);
    inputBag.clear();
    item = TupleFactory.getInstance().newTuple(1);
    item.set(0, dt.plusMinutes(28).getMillis());
    inputBag.add(item);
    sessionize.accumulate(input);
    inputBag.clear();
    result = toList(sessionize.getValue());

    Assert.assertEquals(2, result.size());
    Assert.assertEquals(2, result.get(0).size());
    Assert.assertEquals(2, result.get(1).size());
    // session ids match
    Assert.assertTrue(result.get(0).get(1).equals(result.get(1).get(1)));

    // test different session id
    sessionize.cleanup();
    dt = new DateTime();
    item = TupleFactory.getInstance().newTuple(1);
    item.set(0, dt.getMillis());
    inputBag.add(item);
    sessionize.accumulate(input);
    inputBag.clear();
    item = TupleFactory.getInstance().newTuple(1);
    item.set(0, dt.plusMinutes(31).getMillis());
    inputBag.add(item);
    sessionize.accumulate(input);
    inputBag.clear();
    result = toList(sessionize.getValue());

    Assert.assertEquals(2, result.size());
    Assert.assertEquals(2, result.get(0).size());
    Assert.assertEquals(2, result.get(1).size());
    // session ids don't match
    Assert.assertFalse(result.get(0).get(1).equals(result.get(1).get(1)));

    sessionize.cleanup();
    Assert.assertEquals(0, sessionize.getValue().size());
}

From source file:me.buom.shiro.test.AppTest.java

@Test
@Repeat(times = 3, warmUp = 1)//from w  w  w .j  av a2 s.c  om
public void test_superviser_read() throws Exception {

    URL url = new URL(baseUrl.toExternalForm() + "superviser_read");
    HttpGet method = new HttpGet(url.toURI());

    String contentType = "application/json; charset=utf-8";
    Header[] headers = buildHeader(ApiKey.SUPERVISER, method, contentType, null);

    method.setHeaders(headers);

    HttpResponse execute = client.execute(method);
    StatusLine statusLine = execute.getStatusLine();

    printResponse(execute);
    printHeader(execute);

    Assert.assertFalse(statusLine.getStatusCode() != 200);
}