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.opencastproject.episode.filesystem.FileSystemElementStoreTest.java

@Test
public void testDeleteWithVersion() throws Exception {
    DeletionSelector versionSelector = new DeletionSelector(ORG_ID, MP_ID, Option.some(VERSION_2));
    Assert.assertTrue(repo.delete(versionSelector));
    Assert.assertFalse(sampleElemDir.exists());

    File file = new File(
            PathSupport.concat(new String[] { tmpRoot.toString(), ORG_ID, MP_ID, VERSION_2.toString() }));
    Assert.assertFalse(file.exists());/*from  w ww. ja v  a2s  .  c o  m*/

    file = new File(PathSupport.concat(new String[] { tmpRoot.toString(), ORG_ID, MP_ID }));
    Assert.assertTrue(file.exists());
}

From source file:es.tekniker.framework.ktek.commons.mng.server.test.TestCommonsMngServer.java

@org.junit.Test
public void testLoginNotExists() {

    log.info("*************************************************************");
    log.info("testLoginNotExists: START ");
    String result = TestDefines.RESULT_OK;

    KtekUserEntity instance = null;/*from   www  .j ava 2  s  . com*/

    CommonsMngServer manager = new CommonsMngServer();

    KtekLoginEntity login = new KtekLoginEntity();

    login.setReference("LoginDoesNotExist");
    login.setPassword("pwd");

    KtekLoginCoordinatesEntity[] array = new KtekLoginCoordinatesEntity[3];

    KtekLoginCoordinatesEntity coord1 = new KtekLoginCoordinatesEntity();
    coord1.setLetter("A");
    coord1.setValue("vvvv");

    KtekLoginCoordinatesEntity coord2 = new KtekLoginCoordinatesEntity();
    coord2.setLetter("B");
    coord2.setValue("FDFSDFSDFSD");

    KtekLoginCoordinatesEntity coord3 = new KtekLoginCoordinatesEntity();
    coord3.setLetter("C");
    coord3.setValue("HJJGHJG");

    array[0] = coord1;
    array[1] = coord2;
    array[2] = coord3;

    login.setCoordinates(array);

    try {
        instance = manager.login(login);

        if (instance != null) {
            System.out.println("testLoginNotExists Login.token " + instance.getToken());
            result = TestDefines.RESULT_ERROR;
            Assert.assertFalse(true);
        } else {
            log.error("testLoginNotExists: instance is NULL ");
            result = TestDefines.RESULT_ERROR;
            Assert.assertNull(instance);
        }

    } catch (KtekExceptionEntity e) {
        System.out.println("TestUsersMngServer.loginExists:  exception " + e.getMessage());
        e.printStackTrace();
        Assert.assertFalse(false);
    }

    log.info("testLoginNotExists: RESULT " + result);
    log.info("testLoginNotExists: END ");
    log.info("*************************************************************");
    log.info("");

}

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

@Test
public void testPaperMedicalRecordExistsForPatientShouldReturnFalseIfPaperRecordIdentifierVoided() {

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

    // the patient (8) with this primary identifierhas a paper record identifier, but it is voided
    Assert.assertFalse(paperRecordService.paperRecordExistsForPatientWithPrimaryIdentifier("ABC123",
            medicalRecordLocation));/*  w  w  w  . j av  a 2s .  com*/
}

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

/**
 * @see ObsController#voidObs(String,String,WebRequest,HttpServletResponse)
 * @verifies void a obs/* w w  w.  j  a v  a 2 s . c  o m*/
 */
@Test
public void voidObs_shouldVoidAObs() throws Exception {
    Obs obs = Context.getObsService().getObs(9);
    Assert.assertFalse(obs.isVoided());
    new ObsController().delete("be48cdcb-6a76-47e3-9f2e-2635032f3a9a", "unit test", emptyRequest(),
            new MockHttpServletResponse());
    obs = Context.getObsService().getObs(9);
    Assert.assertTrue(obs.isVoided());
    Assert.assertEquals("unit test", obs.getVoidReason());
}

From source file:org.openmrs.module.appointmentscheduling.api.AppointmentBlockServiceTest.java

@Test
@Verifies(value = "should void given appointment block", method = "voidAppointmentBlock(AppointmentBlock, String)")
public void voidAppointmentBlock_shouldVoidGivenAppointmentBlock() throws Exception {
    AppointmentBlock appointmentBlock = service.getAppointmentBlock(1);
    assertNotNull(appointmentBlock);//from   w  w  w  .  j av  a 2s. c  om
    Assert.assertFalse(appointmentBlock.isVoided());
    assertNull(appointmentBlock.getVoidReason());

    service.voidAppointmentBlock(appointmentBlock, "void reason");

    appointmentBlock = service.getAppointmentBlock(1);
    assertNotNull(appointmentBlock);
    assertTrue(appointmentBlock.isVoided());
    assertEquals("void reason", appointmentBlock.getVoidReason());

    // make sure all the underlying appointment blocks have been voided
    assertEquals(0, service.getTimeSlotsInAppointmentBlock(appointmentBlock).size());

    //Should not change the number of appointment blocks.
    assertEquals(TOTAL_APPOINTMENT_BLOCKS, service.getAllAppointmentBlocks().size());
}

From source file:de.itsvs.cwtrpc.controller.config.RemoteServiceGroupConfigBeanDefinitionParserTest.java

@Test
public void testService1() {
    final RemoteServiceGroupConfig config;
    RemoteServiceConfig serviceConfig;// ww w  .  ja  va2 s.c om
    Iterator<RemoteServiceConfig> serviceConfigIter;

    config = appContext2.getBean("serviceGroup1", RemoteServiceGroupConfig.class);
    Assert.assertEquals(7, config.getServiceConfigs().size());
    serviceConfigIter = config.getServiceConfigs().iterator();

    serviceConfig = serviceConfigIter.next(); /* 0 */
    Assert.assertEquals("testService10", serviceConfig.getServiceName());
    Assert.assertEquals(TestService11.class, serviceConfig.getServiceInterface());
    Assert.assertNull(serviceConfig.getRelativePath());
    Assert.assertNull(serviceConfig.getResponseCompressionEnabled());
    Assert.assertNull(serviceConfig.getRpcTokenProtectionEnabled());
    Assert.assertNull(serviceConfig.getRpcTokenValidatorName());

    serviceConfig = serviceConfigIter.next(); /* 1 */
    Assert.assertEquals("testService1", serviceConfig.getServiceName());
    Assert.assertNull(serviceConfig.getServiceInterface());
    Assert.assertNull(serviceConfig.getRelativePath());

    serviceConfig = serviceConfigIter.next(); /* 2 */
    Assert.assertEquals("testService2", serviceConfig.getServiceName());
    Assert.assertNull(serviceConfig.getServiceInterface());
    Assert.assertTrue(serviceConfig.getResponseCompressionEnabled());
    Assert.assertTrue(serviceConfig.getRpcTokenProtectionEnabled());
    Assert.assertNull(serviceConfig.getRpcTokenValidatorName());

    serviceConfig = serviceConfigIter.next(); /* 3 */
    Assert.assertEquals("testService3", serviceConfig.getServiceName());
    Assert.assertFalse(serviceConfig.getResponseCompressionEnabled());
    Assert.assertNull(serviceConfig.getRpcTokenProtectionEnabled());
    Assert.assertNull(serviceConfig.getRpcTokenValidatorName());

    serviceConfig = serviceConfigIter.next(); /* 4 */
    Assert.assertEquals("testService4", serviceConfig.getServiceName());
    Assert.assertNull(serviceConfig.getResponseCompressionEnabled());
    Assert.assertFalse(serviceConfig.getRpcTokenProtectionEnabled());
    Assert.assertNull(serviceConfig.getRpcTokenValidatorName());

    serviceConfig = serviceConfigIter.next(); /* 5 */
    Assert.assertEquals("testService5", serviceConfig.getServiceName());
    Assert.assertNull(serviceConfig.getResponseCompressionEnabled());
    Assert.assertNull(serviceConfig.getRpcTokenProtectionEnabled());
    Assert.assertEquals("myRpcTokenValidator", serviceConfig.getRpcTokenValidatorName());

    serviceConfig = serviceConfigIter.next(); /* 6 */
    Assert.assertEquals("testService20", serviceConfig.getServiceName());
    Assert.assertEquals("other/20special.service", serviceConfig.getRelativePath());
}

From source file:io.cloudslang.engine.queue.repositories.ExecutionQueueRepositoryTest.java

@Test
public void testPollForRecoveryDuplicateMsg2() {

    //insert to states table
    List<ExecutionMessage> msg = new ArrayList<>();
    ExecutionMessage execMsg = generateMessage("group1", "msg1", 1);
    execMsg.setWorkerId("worker1");
    execMsg.setStatus(ExecStatus.IN_PROGRESS);
    msg.add(execMsg);//  w w w .  j  a  va  2 s.c o m
    executionQueueRepository.insertExecutionStates(msg);
    executionQueueRepository.insertExecutionQueue(msg, 1L);

    List<ExecutionMessage> result = executionQueueRepository.pollRecovery("worker1", 10,
            ExecStatus.IN_PROGRESS);

    Assert.assertNotNull(result);
    Assert.assertFalse(result.isEmpty());
    Assert.assertEquals("should find only 1 msg result!, since the second msg has higher msg seq id", 1,
            result.size());
}

From source file:com.netflix.curator.framework.recipes.queue.TestBoundedDistributedQueue.java

@Test
public void testSimple() throws Exception {
    Timing timing = new Timing();
    DistributedQueue<String> queue = null;
    CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(),
            timing.connection(), new RetryOneTime(1));
    try {/*  w  w w .j a v  a 2s.  co  m*/
        client.start();

        final List<String> messages = new CopyOnWriteArrayList<String>();
        final CountDownLatch latch = new CountDownLatch(2);
        final Semaphore semaphore = new Semaphore(0);
        QueueConsumer<String> consumer = new QueueConsumer<String>() {
            @Override
            public void consumeMessage(String message) throws Exception {
                messages.add(message);
                semaphore.acquire();
            }

            @Override
            public void stateChanged(CuratorFramework client, ConnectionState newState) {
            }
        };
        queue = QueueBuilder.builder(client, consumer, serializer, "/queue")
                .executor(Executors.newSingleThreadExecutor()).maxItems(1).buildQueue();
        queue.start();

        QueuePutListener<String> listener = new QueuePutListener<String>() {
            @Override
            public void putCompleted(String item) {
                latch.countDown();
            }

            @Override
            public void putMultiCompleted(MultiItem<String> items) {
            }
        };
        queue.getPutListenerContainer().addListener(listener);

        Assert.assertTrue(queue.put("1", timing.milliseconds(), TimeUnit.MILLISECONDS)); // should end up in consumer
        Assert.assertTrue(queue.put("2", timing.milliseconds(), TimeUnit.MILLISECONDS)); // should sit blocking in DistributedQueue
        Assert.assertTrue(timing.awaitLatch(latch));
        timing.sleepABit();
        Assert.assertFalse(queue.put("3", timing.multiple(.5).milliseconds(), TimeUnit.MILLISECONDS));

        semaphore.release(100);
        Assert.assertTrue(queue.put("3", timing.milliseconds(), TimeUnit.MILLISECONDS));
        Assert.assertTrue(queue.put("4", timing.milliseconds(), TimeUnit.MILLISECONDS));
        Assert.assertTrue(queue.put("5", timing.milliseconds(), TimeUnit.MILLISECONDS));

        for (int i = 0; i < 5; ++i) {
            if (messages.size() == 3) {
                break;
            }
            timing.sleepABit();
        }
        timing.sleepABit();

        Assert.assertEquals(messages, Arrays.asList("1", "2", "3", "4", "5"));
    } finally {
        IOUtils.closeQuietly(queue);
        IOUtils.closeQuietly(client);
    }
}

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

@Test
@Repeat(times = 3, warmUp = 1)/*from   w  w w . j ava  2  s  . c  o m*/
public void test_user_create() throws Exception {

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

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

    method.setHeaders(headers);

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

    printResponse(execute);
    printHeader(execute);

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