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:com.collective.celos.AbstractStateDatabaseTest.java

@Test
public void testPause() throws Exception {
    StateDatabaseConnection db = getStateDatabaseConnection();
    WorkflowID workflowID = new WorkflowID("wf1");

    Assert.assertFalse(db.isPaused(workflowID));

    db.setPaused(workflowID, true);// w w w . java  2s  .  co  m
    Assert.assertTrue(db.isPaused(workflowID));

    db.setPaused(workflowID, false);
    Assert.assertFalse(db.isPaused(workflowID));
}

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

/**
 * @see ObsController#updatePatient(String,SimpleObject,WebRequest,HttpServletResponse)
 * @verifies change a complex property on an obs
 *///from  w  w  w. j a  va  2s. com
@Test
@Ignore("RESTWS-238: Define creatable/updatable properties on Obs resource")
public void updateObs_shouldChangeAComplexPropertyOnAnObs() throws Exception {

    String json = "{\"location\":\"9356400c-a5a2-4532-8f2b-2361b3446eb8\"}";
    SimpleObject post = new ObjectMapper().readValue(json, SimpleObject.class);
    Object editedObs = new ObsController().update("39fb7f47-e80a-4056-9285-bd798be13c63", post, emptyRequest(),
            new MockHttpServletResponse());
    Obs oldObs = Context.getObsService().getObsByUuid("39fb7f47-e80a-4056-9285-bd798be13c63");
    List<Obs> obsList = Context.getObsService()
            .getObservationsByPerson(Context.getPersonService().getPerson(7));
    Obs newObs = obsList.get(obsList.size() - 1);
    Assert.assertTrue(Context.getObsService().getObsByUuid("39fb7f47-e80a-4056-9285-bd798be13c63").isVoided());
    Assert.assertFalse(new Integer(2).equals(oldObs.getLocation().getId()));
    Assert.assertTrue(new Integer(2).equals(newObs.getLocation().getId()));
}

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

/**
     * Test for {@link Span#crosses(Span)}.
     *//*from   w w  w .ja v a 2 s. c o  m*/
    public void testCrosses() {
        Span a = new Span(10, 50);
        Span b = new Span(40, 100);

        Assert.assertTrue(a.crosses(b));
        Assert.assertTrue(b.crosses(a));

        Span c = new Span(10, 20);
        Span d = new Span(40, 50);

        Assert.assertFalse(c.crosses(d));
        Assert.assertFalse(d.crosses(c));

        Assert.assertFalse(b.crosses(d));
    }

From source file:org.opencastproject.distribution.hls.HLSDistributionServiceImplTest.java

@Test
public void testRetract() throws Exception {
    int elementCount = mp.getElements().length;

    // Distribute the mediapackage and all of its elements
    Job job1 = service.distribute(mp, "track-1");
    Job job2 = service.distribute(mp, "catalog-1");
    Job job3 = service.distribute(mp, "catalog-2");
    Job job4 = service.distribute(mp, "notes");
    JobBarrier jobBarrier = new JobBarrier(serviceRegistry, 500, job1, job2, job3, job4);
    jobBarrier.waitForJobs();//  w w  w .  j a  va 2  s  . co  m

    // Add the new elements to the mediapackage
    mp.add(MediaPackageElementParser.getFromXml(job1.getPayload()));
    mp.add(MediaPackageElementParser.getFromXml(job2.getPayload()));
    mp.add(MediaPackageElementParser.getFromXml(job3.getPayload()));
    mp.add(MediaPackageElementParser.getFromXml(job4.getPayload()));

    File mpDir = new File(distributionRoot, mp.getIdentifier().compact());
    File mediaDir = new File(mpDir, "track-1");
    File metadata1Dir = new File(mpDir, "catalog-1");
    File metadata2Dir = new File(mpDir, "catalog-2");
    File attachmentsDir = new File(mpDir, "notes");
    Assert.assertTrue(mediaDir.exists());
    Assert.assertTrue(metadata1Dir.exists());
    Assert.assertTrue(metadata2Dir.exists());
    Assert.assertTrue(attachmentsDir.exists());
    Assert.assertTrue(new File(mediaDir, "media.mov").exists()); // the filenames are changed to reflect the element ID
    Assert.assertTrue(new File(metadata1Dir, "dublincore.xml").exists());
    Assert.assertTrue(new File(metadata2Dir, "mpeg7.xml").exists());
    Assert.assertTrue(new File(attachmentsDir, "attachment.txt").exists());

    // Now retract the mediapackage and ensure that the distributed files have been removed
    Job job5 = service.retract(mp, "track-1");
    Job job6 = service.retract(mp, "catalog-1");
    Job job7 = service.retract(mp, "catalog-2");
    Job job8 = service.retract(mp, "notes");
    jobBarrier = new JobBarrier(serviceRegistry, 500, job5, job6, job7, job8);
    jobBarrier.waitForJobs();

    // Remove the distributed elements from the mediapackage
    mp.remove(MediaPackageElementParser.getFromXml(job5.getPayload()));
    mp.remove(MediaPackageElementParser.getFromXml(job6.getPayload()));
    mp.remove(MediaPackageElementParser.getFromXml(job7.getPayload()));
    mp.remove(MediaPackageElementParser.getFromXml(job8.getPayload()));

    Assert.assertEquals(elementCount, mp.getElements().length);
    Assert.assertNotNull(mp.getElementById("track-1"));
    Assert.assertNotNull(mp.getElementById("catalog-1"));
    Assert.assertNotNull(mp.getElementById("catalog-2"));
    Assert.assertNotNull(mp.getElementById("notes"));

    Assert.assertFalse(service.getDistributionFile(mp, mp.getElementById("track-1")).isFile());
    Assert.assertFalse(service.getDistributionFile(mp, mp.getElementById("catalog-1")).isFile());
    Assert.assertFalse(service.getDistributionFile(mp, mp.getElementById("catalog-2")).isFile());
    Assert.assertFalse(service.getDistributionFile(mp, mp.getElementById("notes")).isFile());
}

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

@Test
public void testFinishExecutableEvents() {
    List<Output> possibleOutputs = Arrays.asList(new Output("name", "name"));
    List<Result> possibleResults = Arrays.asList(new Result(SUCCESS_RESULT, "true"));
    RunEnvironment runEnv = new RunEnvironment();
    runEnv.putReturnValues(new ReturnValues(new HashMap<String, Serializable>(), null));
    runEnv.getExecutionPath().down();//www.  j a va  2 s  .c om

    Map<String, Serializable> boundOutputs = new HashMap<>();
    boundOutputs.put("name", "John");
    String boundResult = SUCCESS_RESULT;

    when(outputsBinding.bindOutputs(isNull(Map.class), anyMapOf(String.class, Serializable.class),
            eq(possibleOutputs))).thenReturn(boundOutputs);
    when(resultsBinding.resolveResult(isNull(Map.class), anyMapOf(String.class, Serializable.class),
            eq(possibleResults), isNull(String.class))).thenReturn(boundResult);

    ExecutionRuntimeServices runtimeServices = new ExecutionRuntimeServices();
    executableSteps.finishExecutable(runEnv, possibleOutputs, possibleResults, runtimeServices, "task1");

    Collection<ScoreEvent> events = runtimeServices.getEvents();

    Assert.assertFalse(events.isEmpty());
    ScoreEvent boundOutputEvent = null;
    ScoreEvent startOutputEvent = null;
    ScoreEvent executableFinishedEvent = null;
    for (ScoreEvent event : events) {
        if (event.getEventType().equals(EVENT_OUTPUT_END)) {
            boundOutputEvent = event;
        } else if (event.getEventType().equals(EVENT_OUTPUT_START)) {
            startOutputEvent = event;
        } else if (event.getEventType().equals(EVENT_EXECUTION_FINISHED)) {
            executableFinishedEvent = event;
        }
    }
    Assert.assertNotNull(startOutputEvent);
    Map<String, Serializable> eventData = (Map<String, Serializable>) startOutputEvent.getData();
    Assert.assertTrue(eventData.containsKey(EXECUTABLE_OUTPUTS_KEY));
    Assert.assertTrue(eventData.containsKey(EXECUTABLE_RESULTS_KEY));
    List<Output> outputs = (List<Output>) eventData.get(EXECUTABLE_OUTPUTS_KEY);
    List<Result> results = (List<Result>) eventData.get(EXECUTABLE_RESULTS_KEY);
    Assert.assertEquals(possibleOutputs, outputs);
    Assert.assertEquals(possibleResults, results);

    Assert.assertNotNull(boundOutputEvent);
    eventData = (Map<String, Serializable>) boundOutputEvent.getData();
    Assert.assertTrue(eventData.containsKey(LanguageEventData.OUTPUTS));
    Map<String, String> returnOutputs = (Map<String, String>) eventData.get(LanguageEventData.OUTPUTS);
    String returnResult = (String) eventData.get(LanguageEventData.RESULT);
    Assert.assertEquals("task1", eventData.get(LanguageEventData.levelName.EXECUTABLE_NAME.name()));
    Assert.assertEquals(1, returnOutputs.size());
    Assert.assertEquals("John", returnOutputs.get("name"));
    Assert.assertTrue(returnResult.equals(SUCCESS_RESULT));

    Assert.assertNotNull(executableFinishedEvent);
    eventData = (Map<String, Serializable>) executableFinishedEvent.getData();
    String result = (String) eventData.get(LanguageEventData.RESULT);
    Map<String, String> eventOutputs = (Map<String, String>) eventData.get(LanguageEventData.OUTPUTS);
    Assert.assertEquals(SUCCESS_RESULT, result);
    Assert.assertEquals(boundOutputs, eventOutputs);

}

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

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

    URL url = new URL(baseUrl.toExternalForm() + "superviser_edit");
    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);
}

From source file:de.itsvs.cwtrpc.controller.AutowiredRemoteServiceGroupConfigTest.java

@Test
public void testIsAcceptedServiceInterface4() {
    final AutowiredRemoteServiceGroupConfig config;

    config = new AutowiredRemoteServiceGroupConfig();
    config.setBasePackages(Arrays.asList(
            new String[] { "de.itsvs.cwtrpc.controller.config2.", "de.itsvs.cwtrpc.controller.config." }));

    Assert.assertFalse(config.isAcceptedServiceInterface(Pattern.class));
    Assert.assertTrue(config.isAcceptedServiceInterface(TestService10.class));
}

From source file:eu.trentorise.smartcampus.ac.provider.repository.persistence.AcDaoPersistenceImplTest.java

@Test
public void sessionToken() throws AcServiceException, InterruptedException {
    User user = new User();
    user.setAuthToken(TOKEN_NOT_PRESENT);
    user.setExpTime(1000);//  w  w  w . j a va 2 s  .co  m
    user.setSocialId(System.currentTimeMillis());
    user.setAttributes(Collections.<Attribute>emptyList());
    dao.create(user);
    Assert.assertNotNull(dao.readUser((long) 1));

    String token = dao.createSessionToken(1L, System.currentTimeMillis() + 1000);
    Assert.assertTrue(serviceImpl.isValidUser(token));
    User u = dao.readUser(token);
    Assert.assertEquals(u.getAuthToken(), token);
    Thread.sleep(1000);
    Assert.assertFalse(serviceImpl.isValidUser(token));
}

From source file:com.smartitengineering.dao.hbase.autoincrement.AutoIncrementRowIdForLongTest.java

@Test
public void testMultithreadedKeysSelfProvided() throws Exception {
    ExecutorService service = Executors.newFixedThreadPool(THREAD_COUNT);
    final long start = 3102;
    final int bound = THREAD_COUNT;
    final int innerBound = 30;
    List<Future> futures = new ArrayList<Future>();
    final long startTime = System.currentTimeMillis();
    for (int i = 0; i < bound; ++i) {
        final int index = i;
        futures.add(service.submit(new Runnable() {

            @Override/*from w w  w .j a  v  a 2 s.co  m*/
            public void run() {
                for (int j = 0; j < innerBound; ++j) {
                    final HTableInterface table = pool.getTable(TABLE_NAME);
                    long id = index * bound + j + start;
                    final long id1 = Long.MAX_VALUE - id;
                    synchronized (ids) {
                        final long mainId = Long.MAX_VALUE - id1;
                        Assert.assertFalse(ids.contains(mainId));
                        ids.add(mainId);
                    }
                    final byte[] row = Bytes.toBytes(id1);
                    Put put = new Put(row);
                    final byte[] toBytes = Bytes.toBytes("value " + id);
                    put.add(FAMILY_BYTES, CELL_BYTES, toBytes);
                    Result get1;
                    try {
                        table.put(put);
                        Get get = new Get(row);
                        get1 = table.get(get);
                    } catch (Exception ex) {
                        LOGGER.error(ex.getMessage(), ex);
                        get1 = null;
                        Assert.fail(ex.getMessage());
                    }
                    pool.putTable(table);
                    Assert.assertNotNull(get1);
                    Assert.assertFalse(get1.isEmpty());
                    Assert.assertTrue(Arrays.equals(row, get1.getRow()));
                    Assert.assertTrue(Arrays.equals(toBytes, get1.getValue(FAMILY_BYTES, CELL_BYTES)));
                }
            }
        }));
    }
    for (Future future : futures) {
        future.get();
    }
    final long endTime = System.currentTimeMillis();
    LOGGER.info("Time for " + (bound * innerBound) + " rows ID retrieval, put and get is "
            + (endTime - startTime) + "ms");
    Assert.assertEquals(bound * innerBound + start - 1, ids.size());
}

From source file:com.smartitengineering.util.rest.client.jersey.cache.CustomResolverBasedCacheableClientTest.java

@Test
public void testPostNoProduce() {
    WebResource r = getClient().resource(getUri().path(Resources.METHOD_PATH).build());
    Assert.assertEquals(204, r.path("noproduce").post(ClientResponse.class, "POST").getStatus());

    ClientResponse cr = r.path("noproduce").post(ClientResponse.class, "POST");
    Assert.assertFalse(cr.hasEntity());
    cr.close();//  w  ww  .j a v a 2 s.  c o m
}