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:es.tekniker.framework.ktek.questionnaire.mng.server.test.TestQuestionnaireMngServer.java

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

    String token = null;/*from   w w w. ja  v  a2 s.  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
                .getKtekQuestionnaireMonitoringResultEntityWithQuestions();

        boolOK = manager.saveQuestionnaireModel(token, resultData);

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

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

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

From source file:BQJDBC.QueryResultTest.BQScrollableResultSetFunctionTest.java

@Test
public void TestResultSetAbsolute() {
    try {//from ww  w.j a v  a 2s  . c  o  m
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(1));
        Assert.assertEquals("you", BQScrollableResultSetFunctionTest.Result.getString(1));
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(2));
        Assert.assertEquals("yet", BQScrollableResultSetFunctionTest.Result.getString(1));
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(3));
        Assert.assertEquals("would", BQScrollableResultSetFunctionTest.Result.getString(1));
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(4));
        Assert.assertEquals("world", BQScrollableResultSetFunctionTest.Result.getString(1));
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(5));
        Assert.assertEquals("without", BQScrollableResultSetFunctionTest.Result.getString(1));
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(6));
        Assert.assertEquals("with", BQScrollableResultSetFunctionTest.Result.getString(1));
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(7));
        Assert.assertEquals("your", BQScrollableResultSetFunctionTest.Result.getString(1));
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(8));
        Assert.assertEquals("young", BQScrollableResultSetFunctionTest.Result.getString(1));
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(9));
        Assert.assertEquals("words", BQScrollableResultSetFunctionTest.Result.getString(1));
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(10));
        Assert.assertEquals("word", BQScrollableResultSetFunctionTest.Result.getString(1));
    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }

    try {
        Assert.assertFalse(BQScrollableResultSetFunctionTest.Result.absolute(0));
        Assert.assertEquals("", BQScrollableResultSetFunctionTest.Result.getString(1));
    } catch (SQLException e) {
        boolean ct = e.toString().contains("Cursor is not in a valid Position");
        if (ct == true) {
            Assert.assertTrue(ct);
        } else {
            this.logger.error("SQLexception" + e.toString());
            Assert.fail("SQLException" + e.toString());
        }
    }

    try {
        Assert.assertFalse(BQScrollableResultSetFunctionTest.Result.absolute(11));
        Assert.assertEquals("", BQScrollableResultSetFunctionTest.Result.getString(1));
    } catch (SQLException e) {
        boolean ct = e.toString().contains("Cursor is not in a valid Position");
        if (ct == true) {
            Assert.assertTrue(ct);
        } else {
            this.logger.error("SQLexception" + e.toString());
            Assert.fail("SQLException" + e.toString());
        }
    }
}

From source file:com.test.onesignal.MainOneSignalClassRunner.java

@Test
public void testSetSubscriptionShouldNotOverrideSubscribeError() throws Exception {
    OneSignalInitWithBadProjectNum();/* w  ww  .j av  a  2  s . com*/
    threadAndTaskWait();

    // Should not try to update server
    ShadowOneSignalRestClient.lastPost = null;
    OneSignal.setSubscription(true);
    Assert.assertNull(ShadowOneSignalRestClient.lastPost);

    // Restart app - Should omit notification_types
    StaticResetHelper.restSetStaticFields();
    OneSignalInitWithBadProjectNum();
    threadAndTaskWait();
    Assert.assertFalse(ShadowOneSignalRestClient.lastPost.has("notification_types"));
}

From source file:com.ebay.cloud.cms.query.service.QueryPaginationTest.java

@Test
public void testQueryIterSkip05_embed() {
    String query = "Manifest{*}.versions{*}";
    QueryContext qc = newQueryContext(DEPLOY_REPO, IBranch.DEFAULT_BRANCH);
    qc.setAllowFullTableScan(true);//  w ww.  j  a  v  a2 s .com
    qc.setSkips(new int[] { 1, 0 });
    qc.setSourceIP("127.0.0.1");
    qc.setRegistration(TestUtils.getDefaultDalImplementation(dataSource));
    IQueryResult result = queryService.query(query, qc);
    Assert.assertEquals(0, result.getEntities().size());
    Assert.assertFalse(result.hasMoreResults());
}

From source file:com.test.onesignal.MainOneSignalClassRunner.java

@Test
public void shouldNotResetSubscriptionOnSession() throws Exception {
    OneSignalInit();//from  w w w  .  jav  a  2s . c om
    OneSignal.setSubscription(false);
    threadAndTaskWait();
    Assert.assertEquals(-2, ShadowOneSignalRestClient.lastPost.getInt("notification_types"));

    StaticResetHelper.restSetStaticFields();

    OneSignalInit();
    threadAndTaskWait();
    Assert.assertFalse(ShadowOneSignalRestClient.lastPost.has("notification_types"));
}

From source file:com.ebay.cloud.cms.query.service.QueryPaginationTest.java

@Test
public void testQueryIterSkip05_embed2() {
    String query = "Manifest{*}.versions{*}";
    QueryContext qc = newQueryContext(DEPLOY_REPO, IBranch.DEFAULT_BRANCH);
    qc.setAllowFullTableScan(true);/*from  w w  w . j a  v  a 2  s  .c  om*/
    qc.setSkips(new int[] { 0, 1 });
    qc.setRegistration(TestUtils.getDefaultDalImplementation(dataSource));
    qc.setSourceIP("127.0.0.1");
    IQueryResult result = queryService.query(query, qc);
    // compare to _embed1, the skip on the second array doesn't take affect as Manifest->Version is embed
    Assert.assertEquals(1, result.getEntities().size());
    Assert.assertFalse(result.hasMoreResults());
}

From source file:com.ebay.cloud.cms.query.service.QueryPaginationByIdTest.java

@Test
public void testQueryIterSkip02() {
    raptorContext.removeSortOn();/*from www  .  j a  va2  s.c o  m*/
    String oid = null;
    String oid_11 = null;
    {
        String query = "ServiceInstance[@name=~\"srp.*\"]{@_oid}";
        QueryContext context = newQueryContext(RAPTOR_REPO, RAPTOR_MAIN_BRANCH_ID);
        context.setAllowFullTableScan(true);
        IQueryResult result = queryService.query(query, context);
        oid = result.getEntities().get(6).getId();
        oid_11 = result.getEntities().get(10).getId();
    }
    raptorContext.setAllowFullTableScan(true);
    raptorContext.setSkips(null);
    raptorContext.setPaginationMode(PaginationMode.ID_BASED);
    raptorContext.getQueryCursor().setHint(-1);
    raptorContext.getQueryCursor().setJoinCursorValues(Arrays.asList(null, oid, null));
    // first round : 
    String query = "ApplicationService.services[@name=~\"srp.*\"].runsOn";
    raptorContext.getQueryCursor().setLimits(new int[] { 0, 0 });
    IQueryResult result0 = queryService.query(query, raptorContext);
    Assert.assertFalse(result0.hasMoreResults());
    Assert.assertEquals(3, result0.getEntities().size());

    // second round : add limit
    raptorContext.getQueryCursor().setJoinCursorValues(Arrays.asList(null, oid));
    raptorContext.setLimits(new int[] { 0, 2 });
    result0 = queryService.query(query, raptorContext);
    Assert.assertTrue(result0.hasMoreResults());
    Assert.assertEquals(2, result0.getEntities().size());

    // third round : increase join oid limit based on the suggestion
    int nextHint = result0.getNextCursor().getHint();
    Assert.assertEquals(1, nextHint);
    raptorContext.setCursor(result0.getNextCursor());
    result0 = queryService.query(query, raptorContext);
    Assert.assertFalse(result0.hasMoreResults());
    Assert.assertEquals(1, result0.getEntities().size());

    // fourth round : increase skip/limits to bigger than the available counts
    raptorContext.getCursor().setJoinCursorValues(Arrays.asList(null, oid_11, ""));
    raptorContext.getCursor().setLimits(new int[] { 0, 0, 0 });
    raptorContext.getCursor().setHint(1);
    IQueryResult result = queryService.query(query, raptorContext);
    Assert.assertFalse(result.hasMoreResults());
    Assert.assertNull(result.getNextCursor());
    Assert.assertEquals(0, result.getEntities().size());
}

From source file:com.test.onesignal.MainOneSignalClassRunner.java

@Test
public void shouldSetSubscriptionCorrectlyEvenAfterFirstOneSignalRestInitFail() throws Exception {
    // Failed to register with OneSignal but SetSubscription was called with false
    ShadowOneSignalRestClient.failAll = true;
    OneSignalInit();//from w w  w.ja v  a 2s  . c om
    OneSignal.setSubscription(false);
    threadAndTaskWait();
    ShadowOneSignalRestClient.failAll = false;

    // Restart app - Should send unsubscribe with create player call.
    StaticResetHelper.restSetStaticFields();
    OneSignalInit();
    threadAndTaskWait();
    Assert.assertEquals(-2, ShadowOneSignalRestClient.lastPost.getInt("notification_types"));

    // Restart app again - Value synced last time so don't send again.
    StaticResetHelper.restSetStaticFields();
    OneSignalInit();
    threadAndTaskWait();
    Assert.assertFalse(ShadowOneSignalRestClient.lastPost.has("notification_types"));
}

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

@org.junit.Test
public void testGetKtekQuestionnaireMonitoringSchedule() {
    log.info("*************************************************************");
    log.info("testGetKtekQuestionnaireMonitoringSchedule: START ");
    String result = TestDefines.RESULT_OK;

    QuestionnaireMngServer manager = new QuestionnaireMngServer();
    String token = null;/*  w w w .  j  a v a2  s  . c om*/
    KtekQuestionnaireMonitoringScheduleListEntity list = null;
    long datefrom = 0, dateto = 0;
    short typemonitoringactivity = 2;
    short status = 1;
    try {
        datefrom = (long) 1417478400129.0;
        dateto = (long) 1417564799129.0;

        token = TestData.getLoginToken();
        list = manager.getKtekQuestionnaireMonitoringScheduleEntity(token, datefrom, dateto,
                typemonitoringactivity, status);

        if (list != null) {
            log.info("testGetKtekQuestionnaireMonitoringSchedule: instance is NOT NULL ");
            Assert.assertTrue(true);
        } else {
            log.error("testGetKtekQuestionnaireMonitoringSchedule: instance is NULL ");
            result = TestDefines.RESULT_ERROR;
            Assert.assertTrue(false);
        }

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

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

}

From source file:org.apache.ambari.server.controller.metrics.timeline.cache.TimelineMetricCacheTest.java

@Test
public void testEqualsOnKeys() {
    long now = System.currentTimeMillis();
    TemporalInfo temporalInfo = new TemporalInfoImpl(now - 1000, now, 1);

    TimelineAppMetricCacheKey key1 = new TimelineAppMetricCacheKey(new HashSet<String>() {
        {/* ww  w  . j  a va  2  s. c  om*/
            add("cpu_num._avg");
            add("proc_run._avg");
        }
    }, "HOST", temporalInfo);

    TimelineAppMetricCacheKey key2 = new TimelineAppMetricCacheKey(new HashSet<String>() {
        {
            add("cpu_num._avg");
        }
    }, "HOST", temporalInfo);

    Assert.assertFalse(key1.equals(key2));
    Assert.assertFalse(key2.equals(key1));

    key2.getMetricNames().add("proc_run._avg");

    Assert.assertTrue(key1.equals(key2));
}