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.linkedin.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManagerTest.java

@Test
public void testCommitAfterCatchup() throws Exception {
    FakeLLRealtimeSegmentDataManager segmentDataManager = createFakeSegmentManager();
    LLRealtimeSegmentDataManager.PartitionConsumer consumer = segmentDataManager.createPartitionConsumer();
    final long firstOffset = _startOffset + 500;
    final long catchupOffset = firstOffset + 10;
    // We should consume initially...
    segmentDataManager._consumeOffsets.add(firstOffset);
    segmentDataManager._consumeOffsets.add(catchupOffset); // Offset after catchup
    final SegmentCompletionProtocol.Response holdResponse1 = new SegmentCompletionProtocol.Response(
            new SegmentCompletionProtocol.Response.Params()
                    .withStatus(SegmentCompletionProtocol.ControllerResponseStatus.HOLD)
                    .withOffset(firstOffset));
    final SegmentCompletionProtocol.Response catchupResponse = new SegmentCompletionProtocol.Response(
            new SegmentCompletionProtocol.Response.Params()
                    .withStatus(SegmentCompletionProtocol.ControllerResponseStatus.CATCH_UP)
                    .withOffset(catchupOffset));
    final SegmentCompletionProtocol.Response holdResponse2 = new SegmentCompletionProtocol.Response(
            new SegmentCompletionProtocol.Response.Params().withOffset(catchupOffset)
                    .withStatus(SegmentCompletionProtocol.ControllerResponseStatus.HOLD));
    final SegmentCompletionProtocol.Response commitResponse = new SegmentCompletionProtocol.Response(
            new SegmentCompletionProtocol.Response.Params().withOffset(catchupOffset)
                    .withStatus(SegmentCompletionProtocol.ControllerResponseStatus.COMMIT));
    // And then never consume as long as we get a hold response, 100 times.
    segmentDataManager._responses.add(holdResponse1);
    segmentDataManager._responses.add(catchupResponse);
    segmentDataManager._responses.add(holdResponse2);
    segmentDataManager._responses.add(commitResponse);

    consumer.run();//w w  w. jav  a 2s  .  c  o  m

    Assert.assertTrue(segmentDataManager._responses.isEmpty());
    Assert.assertTrue(segmentDataManager._consumeOffsets.isEmpty());
    Assert.assertTrue(segmentDataManager._buildSegmentCalled);
    Assert.assertFalse(segmentDataManager._buildAndReplaceCalled);
    Assert.assertFalse(segmentDataManager._downloadAndReplaceCalled);
    Assert.assertTrue(segmentDataManager._commitSegmentCalled);
    Assert.assertEquals(segmentDataManager._state.get(segmentDataManager),
            LLRealtimeSegmentDataManager.State.COMMITTED);
}

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

@Test
public void testQueryIte_reverse() {
    String query = "VPool[exists @environment]{*}.parentCluster!Compute[@fqdns=~\".*.com\"]";
    QueryContext qc = newQueryContext(STRATUS_REPO, IBranch.DEFAULT_BRANCH);
    qc.setAllowFullTableScan(true);/*  w ww  . j  a  va2  s  .  c  o m*/
    qc.setLimits(new int[] { 1, 2 });
    qc.setRegistration(TestUtils.getDefaultDalImplementation(dataSource));
    qc.setSourceIP("127.0.0.1");
    IQueryResult result = queryService.query(query, qc);
    Assert.assertTrue(result.hasMoreResults());
    int[] nLimit = result.getNextCursor().getLimits();
    int[] nSkips = result.getNextCursor().getSkips();
    int hint = result.getNextCursor().getHint();
    Assert.assertEquals(0, hint);
    Assert.assertEquals(0, nSkips[0]);
    Assert.assertEquals(2, nSkips[1]);
    Assert.assertEquals(2, nLimit.length);
    Assert.assertEquals(1, nLimit[0]);
    Assert.assertEquals(2, nLimit[1]);

    int count = result.getEntities().size();
    System.out.println("fetch size:  " + count);
    int iterateCount = 1;
    while (result.hasMoreResults()) {
        iterateCount++;
        System.out.println("iterate round: " + iterateCount + ", next skips: "
                + ArrayUtils.toString(result.getNextCursor().getSkips()) + ",next limits: "
                + ArrayUtils.toString(result.getNextCursor().getLimits()));
        qc.setSkips(result.getNextCursor().getSkips());
        qc.setLimits(result.getNextCursor().getLimits());

        result = queryService.query(query, qc);
        System.out.println("fetch size:  " + result.getEntities().size());
        count += result.getEntities().size();
    }
    Assert.assertEquals(11, iterateCount);

    QueryContext qc1 = newQueryContext(STRATUS_REPO, IBranch.DEFAULT_BRANCH);
    qc1.setAllowFullTableScan(true);
    qc1.setSourceIP("127.0.0.1");
    IQueryResult result1 = queryService.query(query, qc1);
    Assert.assertFalse(result1.hasMoreResults());
    Assert.assertTrue(count >= result1.getEntities().size());
}

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

@Test
public void testQueryIterSkip03_hint() {
    raptorContext.removeSortOn();//from w  w w.j a  va  2 s .co m
    String oid = null;
    {
        String query = "ApplicationService.services[@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(9).getId();
    }
    String query = "ApplicationService.services[@name=~\"srp.*\"].runsOn";
    raptorContext.setPaginationMode(PaginationMode.ID_BASED);
    raptorContext.getCursor().setLimits(new int[] { 0, 0 });
    raptorContext.getCursor().setJoinCursorValues(Arrays.asList(null, oid));
    raptorContext.setHint(0);
    IQueryResult result = queryService.query(query, raptorContext);
    Assert.assertFalse(result.hasMoreResults());
    Assert.assertEquals(0, result.getEntities().size());
}

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

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

    QuestionnaireMngServer manager = new QuestionnaireMngServer();
    String token = null;/*from   www . jav  a  2  s  .c  o m*/
    short typemonitoringactivity = 1;
    short status = 1;
    String codtelecareprogram = "DEP1";

    try {
        token = TestData.getLoginToken();
        List<KtekQuestionnaireMonitoringScheduleEntity> list = manager
                .getKtekQuestionnaireMonitoringScheduleNow(token, codtelecareprogram, 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:com.couchbase.lite.AttachmentsTest.java

@SuppressWarnings("unchecked")
public void testPutAttachment() throws CouchbaseLiteException {

    String testAttachmentName = "test_attachment";
    BlobStore attachments = database.getAttachments();
    attachments.deleteBlobs();/*from w w w .  java2 s  .  com*/
    Assert.assertEquals(0, attachments.count());

    // Put a revision that includes an _attachments dict:
    byte[] attach1 = "This is the body of attach1".getBytes();
    String base64 = Base64.encodeBytes(attach1);

    Map<String, Object> attachment = new HashMap<String, Object>();
    attachment.put("content_type", "text/plain");
    attachment.put("data", base64);
    Map<String, Object> attachmentDict = new HashMap<String, Object>();
    attachmentDict.put(testAttachmentName, attachment);
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("foo", 1);
    properties.put("bar", false);
    properties.put("_attachments", attachmentDict);

    RevisionInternal rev1 = database.putRevision(new RevisionInternal(properties, database), null, false);

    // Examine the attachment store:
    Assert.assertEquals(1, attachments.count());

    // Get the revision:
    RevisionInternal gotRev1 = database.getDocumentWithIDAndRev(rev1.getDocId(), rev1.getRevId(),
            EnumSet.noneOf(Database.TDContentOptions.class));
    Map<String, Object> gotAttachmentDict = (Map<String, Object>) gotRev1.getProperties().get("_attachments");

    Map<String, Object> innerDict = new HashMap<String, Object>();
    innerDict.put("content_type", "text/plain");
    innerDict.put("digest", "sha1-gOHUOBmIMoDCrMuGyaLWzf1hQTE=");
    innerDict.put("length", 27);
    innerDict.put("stub", true);
    innerDict.put("revpos", 1);

    Map<String, Object> expectAttachmentDict = new HashMap<String, Object>();
    expectAttachmentDict.put(testAttachmentName, innerDict);

    Assert.assertEquals(expectAttachmentDict, gotAttachmentDict);

    // Update the attachment directly:
    byte[] attachv2 = "Replaced body of attach".getBytes();
    boolean gotExpectedErrorCode = false;

    BlobStoreWriter blobWriter = new BlobStoreWriter(database.getAttachments());
    blobWriter.appendData(attachv2);
    blobWriter.finish();

    try {
        database.updateAttachment(testAttachmentName, blobWriter, "application/foo",
                AttachmentInternal.AttachmentEncoding.AttachmentEncodingNone, rev1.getDocId(), null);
    } catch (CouchbaseLiteException e) {
        gotExpectedErrorCode = (e.getCBLStatus().getCode() == Status.CONFLICT);
    }
    Assert.assertTrue(gotExpectedErrorCode);

    gotExpectedErrorCode = false;
    try {
        database.updateAttachment(testAttachmentName, blobWriter, "application/foo",
                AttachmentInternal.AttachmentEncoding.AttachmentEncodingNone, rev1.getDocId(), "1-bogus");
    } catch (CouchbaseLiteException e) {
        gotExpectedErrorCode = (e.getCBLStatus().getCode() == Status.CONFLICT);
    }
    Assert.assertTrue(gotExpectedErrorCode);

    gotExpectedErrorCode = false;
    RevisionInternal rev2 = null;
    try {
        rev2 = database.updateAttachment(testAttachmentName, blobWriter, "application/foo",
                AttachmentInternal.AttachmentEncoding.AttachmentEncodingNone, rev1.getDocId(), rev1.getRevId());
    } catch (CouchbaseLiteException e) {
        gotExpectedErrorCode = true;
    }
    Assert.assertFalse(gotExpectedErrorCode);

    Assert.assertEquals(rev1.getDocId(), rev2.getDocId());
    Assert.assertEquals(2, rev2.getGeneration());

    // Get the updated revision:
    RevisionInternal gotRev2 = database.getDocumentWithIDAndRev(rev2.getDocId(), rev2.getRevId(),
            EnumSet.noneOf(Database.TDContentOptions.class));
    attachmentDict = (Map<String, Object>) gotRev2.getProperties().get("_attachments");

    innerDict = new HashMap<String, Object>();
    innerDict.put("content_type", "application/foo");
    innerDict.put("digest", "sha1-mbT3208HI3PZgbG4zYWbDW2HsPk=");
    innerDict.put("length", 23);
    innerDict.put("stub", true);
    innerDict.put("revpos", 2);

    expectAttachmentDict.put(testAttachmentName, innerDict);

    Assert.assertEquals(expectAttachmentDict, attachmentDict);

    // Delete the attachment:
    gotExpectedErrorCode = false;
    try {
        database.updateAttachment("nosuchattach", null, null,
                AttachmentInternal.AttachmentEncoding.AttachmentEncodingNone, rev2.getDocId(), rev2.getRevId());
    } catch (CouchbaseLiteException e) {
        gotExpectedErrorCode = (e.getCBLStatus().getCode() == Status.NOT_FOUND);
    }
    Assert.assertTrue(gotExpectedErrorCode);

    gotExpectedErrorCode = false;
    try {
        database.updateAttachment("nosuchattach", null, null,
                AttachmentInternal.AttachmentEncoding.AttachmentEncodingNone, "nosuchdoc", "nosuchrev");
    } catch (CouchbaseLiteException e) {
        gotExpectedErrorCode = (e.getCBLStatus().getCode() == Status.NOT_FOUND);
    }
    Assert.assertTrue(gotExpectedErrorCode);

    RevisionInternal rev3 = database.updateAttachment(testAttachmentName, null, null,
            AttachmentInternal.AttachmentEncoding.AttachmentEncodingNone, rev2.getDocId(), rev2.getRevId());
    Assert.assertEquals(rev2.getDocId(), rev3.getDocId());
    Assert.assertEquals(3, rev3.getGeneration());

    // Get the updated revision:
    RevisionInternal gotRev3 = database.getDocumentWithIDAndRev(rev3.getDocId(), rev3.getRevId(),
            EnumSet.noneOf(Database.TDContentOptions.class));
    attachmentDict = (Map<String, Object>) gotRev3.getProperties().get("_attachments");
    Assert.assertNull(attachmentDict);

    database.close();
}

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

@Test
public void shouldNotFireIdsAvailableWithoutUserId() throws Exception {
    ShadowOneSignalRestClient.failNext = true;
    ShadowPushRegistratorGPS.fail = true;

    OneSignal.idsAvailable(new OneSignal.IdsAvailableHandler() {
        @Override/*w  ww. j a va 2s .  com*/
        public void idsAvailable(String userId, String registrationId) {
            if (userId == null)
                userIdWasNull = true;
        }
    });

    OneSignalInit();
    Assert.assertFalse(userIdWasNull);
    threadAndTaskWait();
}

From source file:is.artefact.flume.source.kafka.TestKafkaSource.java

@Test
public void testPatternBasedSubscription() {
    Context context = new Context();

    context.put(TOPICS_REGEX, "^topic[0-9]$");
    context.put(BOOTSTRAP_SERVERS, "real-bootstrap-servers-list");
    KafkaSource source = new KafkaSource();
    source.doConfigure(context);/*w  ww.  java2  s  . c  o  m*/
    KafkaSource.Subscriber<Pattern> subscriber = source.getSubscriber();
    for (int i = 0; i < 10; i++) {
        Assert.assertTrue(subscriber.get().matcher("topic" + i).find());
    }
    Assert.assertFalse(subscriber.get().matcher("topic").find());
}

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

@Test
public void testGCMTimeOutThenSuccessesLater() throws Exception {
    // Init with a bad connection to Google.
    ShadowPushRegistratorGPS.fail = true;
    OneSignalInit();/*from ww w . j  a va 2 s  .  co m*/
    threadAndTaskWait();
    Assert.assertFalse(ShadowOneSignalRestClient.lastPost.has("identifier"));

    // Registers for GCM after a retry
    ShadowPushRegistratorGPS.fail = false;
    ShadowPushRegistratorGPS.manualFireRegisterForPush();
    threadAndTaskWait();
    Assert.assertEquals(ShadowPushRegistratorGPS.regId,
            ShadowOneSignalRestClient.lastPost.getString("identifier"));

    // Cold restart app, should not send the same identifier again.
    ShadowOneSignalRestClient.lastPost = null;
    StaticResetHelper.restSetStaticFields();
    OneSignalInit();
    threadAndTaskWait();
    Assert.assertFalse(ShadowOneSignalRestClient.lastPost.has("identifier"));
}

From source file:com.ibm.team.build.internal.hjplugin.tests.BuildConfigurationIT.java

public void testPersonalBuild() throws Exception {
    // create a build definition
    // load directory ${propertyA}/here
    // build properties
    // myPropsFile = ${team.scm.fetchDestination}/com.ibm.team.build.releng/continuous-buildsystem.properties
    // propertyA = loadDir
    // propertyB = a place (${propertyA}) to load some stuff 
    // propertyC = original
    // using a load rule

    // create a build engine
    // create a build request for this test with personal build specified
    // (build workspace overridden, build engine is a random one, override load rule, override a build property)

    // verify that the buildConfiguration returns the personal build workspace
    // as the workspace to be loaded
    // verify the load rule is changed
    // verify the build property is changed

    // checkout based on the request
    // make sure the personal build workspace was loaded and the load rule used
    if (Config.DEFAULT.isConfigured()) {
        RTCLoginInfo loginInfo = Config.DEFAULT.getLoginInfo();

        String testName = getTestName() + System.currentTimeMillis();

        @SuppressWarnings("unchecked")
        Map<String, String> setupArtifacts = (Map<String, String>) testingFacade.invoke("testPersonalBuild",
                new Class[] { String.class, // serverURL,
                        String.class, // userId,
                        String.class, // password,
                        int.class, // timeout,
                        String.class, // workspaceName,
                        String.class, // componentName,
                        String.class, // hjPath,
                        String.class }, // buildPath
                loginInfo.getServerUri(), loginInfo.getUserId(), loginInfo.getPassword(),
                loginInfo.getTimeout(), testName, getTestName(), sandboxDir.getPath(), "${propertyA}/here");

        try {/*from   w  ww.  j a  va  2 s.co m*/
            TaskListener listener = new StreamTaskListener(System.out, null);

            File changeLogFile = new File(sandboxDir, "RTCChangeLogFile");
            FileOutputStream changeLog = new FileOutputStream(changeLogFile);

            // put extraneous stuff in the load directory (which is different from sandbox cause
            // we want to get a the change log.
            File loadDir = new File(sandboxDir, "loadDir/here");
            assertTrue(loadDir.mkdirs());
            assertTrue(new File(loadDir, "abc").mkdirs());
            assertTrue(new File(loadDir, "def").mkdirs());
            assertTrue(new File(loadDir, "hij").mkdirs());

            // checkout the changes
            @SuppressWarnings("unchecked")
            Map<String, String> buildProperties = (Map<String, String>) testingFacade.invoke("checkout",
                    new Class[] { String.class, // serverURL,
                            String.class, // userId,
                            String.class, // password,
                            int.class, // timeout,
                            String.class, // buildResultUUID,
                            String.class, // workspaceName,
                            String.class, // hjWorkspacePath,
                            OutputStream.class, // changeLog,
                            String.class, // baselineSetName,
                            Object.class, // listener
                            Locale.class }, // clientLocale
                    loginInfo.getServerUri(), loginInfo.getUserId(), loginInfo.getPassword(),
                    loginInfo.getTimeout(), setupArtifacts.get("buildResultItemId"), null,
                    sandboxDir.getCanonicalPath(), changeLog, "Snapshot", listener, Locale.getDefault());

            String[] children = loadDir.list();
            Assert.assertEquals(5, children.length); // just what the load rule says to load (children of f) + metadata
            Assert.assertTrue(new File(loadDir, "b.txt").exists());
            Assert.assertFalse(new File(loadDir, "i.txt").exists());
            assertTrue(new File(loadDir, "abc").exists());
            assertTrue(new File(loadDir, "def").exists());
            assertTrue(new File(loadDir, "hij").exists());

            RTCChangeLogParser parser = new RTCChangeLogParser();
            FileReader changeLogReader = new FileReader(changeLogFile);
            RTCChangeLogSet result = (RTCChangeLogSet) parser.parse(null, null, changeLogReader);

            // verify the result
            Assert.assertTrue(result.isPersonalBuild());
            int changeCount = result.getComponentChangeCount() + result.getChangeSetsAcceptedCount()
                    + result.getChangeSetsDiscardedCount();
            Assert.assertEquals(0, changeCount);

            validateBuildProperties(setupArtifacts.get(ARTIFACT_STREAM_ITEM_ID), "loadDir/here", false, true,
                    setupArtifacts.get("LoadRuleProperty"), false, "", result.getBaselineSetItemId(),
                    changeCount, false, buildProperties);

            // propertyA = loadDir
            // propertyB = a place (${propertyA}) to load some stuff 
            // propertyC = original
            Assert.assertEquals("loadDir", buildProperties.get("propertyA"));
            Assert.assertEquals("a place (loadDir) to load some stuff", buildProperties.get("propertyB"));
            Assert.assertEquals("overwritten", buildProperties.get("propertyC"));
        } finally {
            // clean up
            testingFacade.invoke("tearDown", new Class[] { String.class, // serverURL,
                    String.class, // userId,
                    String.class, // password,
                    int.class, // timeout,
                    Map.class }, // setupArtifacts
                    loginInfo.getServerUri(), loginInfo.getUserId(), loginInfo.getPassword(),
                    loginInfo.getTimeout(), setupArtifacts);
        }
    }
}

From source file:com.linkedin.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManagerTest.java

@Test
public void testDiscarded() throws Exception {
    FakeLLRealtimeSegmentDataManager segmentDataManager = createFakeSegmentManager();
    LLRealtimeSegmentDataManager.PartitionConsumer consumer = segmentDataManager.createPartitionConsumer();
    final long endOffset = _startOffset + 500;
    segmentDataManager._consumeOffsets.add(endOffset);
    final SegmentCompletionProtocol.Response discardResponse = new SegmentCompletionProtocol.Response(
            new SegmentCompletionProtocol.Response.Params().withOffset(endOffset)
                    .withStatus(SegmentCompletionProtocol.ControllerResponseStatus.DISCARD));
    segmentDataManager._responses.add(discardResponse);

    consumer.run();//from w w  w.java 2  s  . c o  m

    Assert.assertTrue(segmentDataManager._responses.isEmpty());
    Assert.assertTrue(segmentDataManager._consumeOffsets.isEmpty());
    Assert.assertFalse(segmentDataManager._buildSegmentCalled);
    Assert.assertFalse(segmentDataManager._buildAndReplaceCalled);
    Assert.assertFalse(segmentDataManager._downloadAndReplaceCalled);
    Assert.assertFalse(segmentDataManager._commitSegmentCalled);
    Assert.assertEquals(segmentDataManager._state.get(segmentDataManager),
            LLRealtimeSegmentDataManager.State.DISCARDED);
}