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.motechproject.mobile.core.dao.hibernate.GatewayRequestDAOImplTest.java

/**
 * Test of save method with update purpose, of class GatewayRequestDAOImpl.
 *///www  . j  av a  2s .  co  m
@Test
public void testUpdate() {
    System.out.println("Update");

    md1.setMessage("First altered");
    md1.setDateFrom(new Date());
    md1.setDateTo(new Date());
    mDDAO.save(md1);
    GatewayRequest fromdb = (GatewayRequestImpl) mDDAO.getSessionFactory().getCurrentSession()
            .get(GatewayRequestImpl.class, md1.getId());
    Assert.assertFalse(text.equals(fromdb.getMessage()));
}

From source file:es.tekniker.framework.ktek.questionnaire.mng.server.test.TestQuestionnaireMngServer.java

public void testSaveKtekQuestionnaireAssesment2() {
    log.info("*************************************************************");
    log.info("testSaveKtekQuestionnaireAssesment2: START ");
    String result = TestDefines.RESULT_OK;

    String token = null;//from   w  ww  . j  a  v  a  2s  .c  o  m
    KtekQuestionnaireResultEntity resultData = null;
    QuestionnaireMngServer manager = new QuestionnaireMngServer();
    int boolOK = 0;

    try {

        token = TestData.getLoginToken();
        resultData = es.tekniker.framework.ktek.questionnaire.mng.db.TestData
                .getKtekQuestionnaireAssessmentResultEntity2();

        boolOK = manager.saveQuestionnaireModel(token, resultData);

        if (boolOK == 1) {
            log.info("testSaveKtekQuestionnaireAssesment2: SAVE OK ");
            Assert.assertTrue(true);
        } else {
            log.error("testSaveKtekQuestionnaireAssesment2: SAVE ERROR ");
            result = TestDefines.RESULT_ERROR;
            Assert.assertTrue(false);
        }

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

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

}

From source file:de.clusteval.data.dataset.TestDataSet.java

/**
 * Test method for {@link data.dataset.DataSet#register()}.
 * //from w  w w  . java 2 s  .c  o  m
 * @throws NoRepositoryFoundException
 * @throws UnknownDataSetFormatException
 * @throws DataSetNotFoundException
 * @throws DataSetConfigurationException
 * @throws RegisterException
 * @throws UnknownDataSetTypeException
 * @throws UnknownRunDataStatisticException
 * @throws UnknownRunStatisticException
 * @throws UnknownDataStatisticException
 * @throws NoOptimizableProgramParameterException
 * @throws UnknownParameterOptimizationMethodException
 * @throws IncompatibleParameterOptimizationMethodException
 * @throws IncompatibleDataSetConfigPreprocessorException
 * @throws UnknownDataPreprocessorException
 * @throws UnknownDistanceMeasureException
 * @throws UnknownRProgramException
 * @throws UnknownProgramTypeException
 * @throws UnknownProgramParameterException
 * @throws InvalidOptimizationParameterException
 * @throws UnknownRunResultFormatException
 * @throws IncompatibleContextException
 * @throws RunException
 * @throws UnknownClusteringQualityMeasureException
 * @throws UnknownParameterType
 * @throws FileNotFoundException
 * @throws UnknownContextException
 * @throws ConfigurationException
 * @throws NumberFormatException
 * @throws DataConfigNotFoundException
 * @throws DataConfigurationException
 * @throws GoldStandardConfigNotFoundException
 * @throws DataSetConfigNotFoundException
 * @throws GoldStandardConfigurationException
 * @throws GoldStandardNotFoundException
 */
public void testRegister() throws UnknownDataSetFormatException, NoRepositoryFoundException,
        DataSetNotFoundException, DataSetConfigurationException, RegisterException, UnknownDataSetTypeException,
        NoDataSetException, GoldStandardNotFoundException, GoldStandardConfigurationException,
        DataSetConfigNotFoundException, GoldStandardConfigNotFoundException, DataConfigurationException,
        DataConfigNotFoundException, NumberFormatException, ConfigurationException, UnknownContextException,
        FileNotFoundException, UnknownParameterType, UnknownClusteringQualityMeasureException, RunException,
        IncompatibleContextException, UnknownRunResultFormatException, InvalidOptimizationParameterException,
        UnknownProgramParameterException, UnknownProgramTypeException, UnknownRProgramException,
        UnknownDistanceMeasureException, UnknownDataPreprocessorException,
        IncompatibleDataSetConfigPreprocessorException, IncompatibleParameterOptimizationMethodException,
        UnknownParameterOptimizationMethodException, NoOptimizableProgramParameterException,
        UnknownDataStatisticException, UnknownRunStatisticException, UnknownRunDataStatisticException {
    this.repositoryObject = Parser.parseFromFile(DataSet.class,
            new File("testCaseRepository/data/datasets/DS1/Zachary_karate_club_similarities.txt")
                    .getAbsoluteFile());

    Assert.assertEquals(this.repositoryObject,
            this.getRepository().getRegisteredObject((DataSet) this.repositoryObject));

    // adding a data set equal to another one already registered does
    // not register the second object.
    this.repositoryObject = new RelativeDataSet((RelativeDataSet) this.repositoryObject);
    Assert.assertEquals(this.getRepository().getRegisteredObject((DataSet) this.repositoryObject),
            this.repositoryObject);
    Assert.assertFalse(
            this.getRepository().getRegisteredObject((DataSet) this.repositoryObject) == this.repositoryObject);
}

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

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

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

@Test
@Repeat(times = 3, warmUp = 1)/* w  w  w .  j  a va2s .com*/
public void test_user_read() throws Exception {

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

From source file:org.apache.gobblin.writer.AsyncHttpWriterTest.java

/**
 * Test server error. Attempt 3 times//from w ww .j  ava  2  s.  co m
 */
public void testServerError() {
    MockHttpClient client = new MockHttpClient();
    MockRequestBuilder requestBuilder = new MockRequestBuilder();
    MockResponseHandler responseHandler = new MockResponseHandler();
    MockAsyncHttpWriterBuilder builder = new MockAsyncHttpWriterBuilder(client, requestBuilder,
            responseHandler);
    TestAsyncHttpWriter asyncHttpWriter = new TestAsyncHttpWriter(builder);

    responseHandler.type = StatusType.SERVER_ERROR;
    MockWriteCallback callback = new MockWriteCallback();
    asyncHttpWriter.write(new Object(), callback);

    boolean hasAnException = false;
    try {
        asyncHttpWriter.close();
    } catch (Exception e) {
        hasAnException = true;
    }
    Assert.assertTrue(hasAnException);
    Assert.assertFalse(callback.isSuccess);
    Assert.assertTrue(client.isCloseCalled);
    Assert.assertTrue(client.attempts == AsyncHttpWriter.DEFAULT_MAX_ATTEMPTS);
    Assert.assertTrue(responseHandler.attempts == AsyncHttpWriter.DEFAULT_MAX_ATTEMPTS);
}

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

@Test
public void testPoll() {
    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.java  2  s.  c o  m
    executionQueueRepository.insertExecutionQueue(msg, 1L);
    executionQueueRepository.insertExecutionStates(msg);
    List<ExecutionMessage> result = executionQueueRepository.poll("worker1", 10, ExecStatus.IN_PROGRESS);

    Assert.assertNotNull(result);
    Assert.assertFalse(result.isEmpty());
}

From source file:de.clusteval.utils.TestRepositoryObject.java

/**
 * Test method for/*ww w. j a  v  a  2s  .com*/
 * {@link framework.repository.RepositoryObject#removeListener(utils.RepositoryListener)}
 * .
 * 
 * @throws RegisterException
 * 
 */
@Test
public void testRemoveListener() throws RegisterException {

    RepositoryObject other = new StubRepositoryObject(this.getRepository(), false, System.currentTimeMillis(),
            new File("test2"));

    /*
     * Nothing in there
     */

    Assert.assertFalse(this.repositoryObject.removeListener(other));

    /*
     * Add it
     */
    Assert.assertTrue(this.repositoryObject.addListener(other));

    /*
     * Remove it
     */
    Assert.assertTrue(this.repositoryObject.removeListener(other));
    /*
     * Not in there anymore
     */
    Assert.assertFalse(this.repositoryObject.removeListener(other));

}

From source file:org.sakaiproject.crudplus.logic.test.CrudPlusLogicImplTest.java

/**
 * Test method for {@link org.sakaiproject.crudplus.logic.impl.CrudPlusLogicImpl#canWriteItem(org.sakaiproject.crudplus.model.CrudPlusItem, java.lang.String, java.lang.String)}.
 *//*from   ww  w .  j  av a  2s. c om*/
public void testCanWriteItemCrudPlusItemStringString() {
    // set up mock objects with return values
    securityService.unlock(USER_ID, CrudPlusLogicImpl.ITEM_WRITE_ANY, SITE_REF);
    securityServiceControl.setReturnValue(false, MockControl.ZERO_OR_MORE);
    securityService.unlock(MAINT_USER_ID, CrudPlusLogicImpl.ITEM_WRITE_ANY, SITE_REF);
    securityServiceControl.setReturnValue(true, MockControl.ZERO_OR_MORE);

    // activate the mock objects
    securityServiceControl.replay();
    siteServiceControl.replay();

    // mock objects needed here
    // testing perms as a normal user
    Assert.assertFalse(logicImpl.canWriteItem(adminitem, SITE_ID, USER_ID));
    Assert.assertFalse(logicImpl.canWriteItem(maintitem, SITE_ID, USER_ID));
    Assert.assertTrue(logicImpl.canWriteItem(item1, SITE_ID, USER_ID));

    // testing perms as user with special perms
    Assert.assertFalse(logicImpl.canWriteItem(adminitem, SITE_ID, MAINT_USER_ID));
    Assert.assertTrue(logicImpl.canWriteItem(maintitem, SITE_ID, MAINT_USER_ID));
    Assert.assertTrue(logicImpl.canWriteItem(item1, SITE_ID, MAINT_USER_ID));

    // testing perms as admin user
    Assert.assertTrue(logicImpl.canWriteItem(adminitem, SITE_ID, ADMIN_USER_ID));
    Assert.assertTrue(logicImpl.canWriteItem(maintitem, SITE_ID, ADMIN_USER_ID));
    Assert.assertTrue(logicImpl.canWriteItem(item1, SITE_ID, ADMIN_USER_ID));

    // verify the mock objects were used
    securityServiceControl.verify();
    siteServiceControl.verify();
}

From source file:net.chrisrichardson.foodToGo.domain.hibernate.HibernateOrderRepositoryImpl.java

List findOrdersUsingScroll() {
    List orders = (List) getHibernateTemplate().execute(new HibernateCallback() {

        public Object doInHibernate(Session session) throws HibernateException, SQLException {
            Criteria x = session.createCriteria(Order.class);
            x.setProjection(Projections.projectionList().add(Property.forName("id"))
                    .add(Property.forName("deliveryAddress.street1")));
            List result = x.list();
            Assert.assertFalse(result.isEmpty());
            Object[] first = (Object[]) result.get(0);
            Assert.assertEquals(2, first.length);
            return result;
        }//ww w  . j a  v a  2s  . c o m
    });
    return orders;
}