Example usage for junit.framework Assert assertNull

List of usage examples for junit.framework Assert assertNull

Introduction

In this page you can find the example usage for junit.framework Assert assertNull.

Prototype

static public void assertNull(Object object) 

Source Link

Document

Asserts that an object is null.

Usage

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

/**
 * CMS-3031/*from   w w w  .ja va2  s . c o m*/
 */
@Test
public void testQueryExplanation_notControll2() {
    String query = "ServiceInstance[@runsOn =& Compute]";
    QueryContext qc = newQueryContext(RAPTOR_REPO, IBranch.DEFAULT_BRANCH);
    qc.setAllowFullTableScan(true);
    qc.setExplain(false);
    qc.setRegistration(TestUtils.getDefaultDalImplementation(dataSource));
    IQueryResult queryResult = queryService.query(query, qc);
    Assert.assertNull(queryResult.getExplanations());
}

From source file:org.jasig.schedassist.impl.owner.SpringJDBCAvailableScheduleDaoImplTest.java

/**
 * Similar to {@link #testRetrieveTargetBlock()}, only exercises
 * {@link SpringJDBCAvailableScheduleDaoImpl#retrieveTargetDoubleLengthBlock(IScheduleOwner, Date)}.
 * /*from  ww  w . j a v  a 2s .c  o  m*/
 * @throws Exception
 */
@Test
public void testRetrieveDoubleLengthTargetBlock() throws Exception {
    // get owner with DURATIONS preference set to one that supports double length 
    IScheduleOwner owner = sampleOwners[4];

    // first week of November, all blocks have visitorLimit 1
    Set<AvailableBlock> blocks = AvailableBlockBuilder.createBlocks("9:00 AM", "5:00 PM", "MWF",
            CommonDateOperations.parseDatePhrase("20091102"), CommonDateOperations.parseDatePhrase("20091106"),
            1);
    availableScheduleDao.addToSchedule(owner, blocks);
    // second week of November, all blocks have visitorLimit 2
    blocks = AvailableBlockBuilder.createBlocks("9:00 AM", "5:00 PM", "MWF",
            CommonDateOperations.parseDatePhrase("20091109"), CommonDateOperations.parseDatePhrase("20091113"),
            2);
    availableScheduleDao.addToSchedule(owner, blocks);
    // third week of November, all blocks have visitorLimit 4
    blocks = AvailableBlockBuilder.createBlocks("9:00 AM", "5:00 PM", "MWF",
            CommonDateOperations.parseDatePhrase("20091116"), CommonDateOperations.parseDatePhrase("20091120"),
            4);
    availableScheduleDao.addToSchedule(owner, blocks);
    // fourth week of November, all blocks have visitorLimit 20
    blocks = AvailableBlockBuilder.createBlocks("9:00 AM", "5:00 PM", "MWF",
            CommonDateOperations.parseDatePhrase("20091123"), CommonDateOperations.parseDatePhrase("20091127"),
            20);
    availableScheduleDao.addToSchedule(owner, blocks);

    // wrong owner, assert returns null
    AvailableBlock result = availableScheduleDao.retrieveTargetDoubleLengthBlock(sampleOwners[1],
            CommonDateOperations.parseDateTimePhrase("20091102-0900"));
    Assert.assertNull(result);

    // right owner, but assert time outside stored schedule returns null
    result = availableScheduleDao.retrieveTargetDoubleLengthBlock(owner,
            CommonDateOperations.parseDateTimePhrase("20091101-0900"));
    Assert.assertNull(result);
    result = availableScheduleDao.retrieveTargetDoubleLengthBlock(owner,
            CommonDateOperations.parseDateTimePhrase("20091102-0830"));
    Assert.assertNull(result);
    result = availableScheduleDao.retrieveTargetDoubleLengthBlock(owner,
            CommonDateOperations.parseDateTimePhrase("20091102-1700"));
    Assert.assertNull(result);

    // assert proper block for a number of times
    Date expectedStart = CommonDateOperations.parseDateTimePhrase("20091102-0900");
    Date expectedEnd = DateUtils.addMinutes(expectedStart, owner.getPreferredMeetingDurations().getMaxLength());
    result = availableScheduleDao.retrieveTargetDoubleLengthBlock(owner, expectedStart);
    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.getVisitorLimit());
    Assert.assertEquals(expectedStart, result.getStartTime());
    Assert.assertEquals(expectedEnd, result.getEndTime());
    // assert retrieveTargetBlock with endTime argument can return the expected double length block
    result = availableScheduleDao.retrieveTargetBlock(owner, expectedStart, expectedEnd);
    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.getVisitorLimit());
    Assert.assertEquals(expectedStart, result.getStartTime());
    Assert.assertEquals(expectedEnd, result.getEndTime());

    expectedStart = CommonDateOperations.parseDateTimePhrase("20091102-0930");
    expectedEnd = DateUtils.addMinutes(expectedStart, owner.getPreferredMeetingDurations().getMaxLength());
    result = availableScheduleDao.retrieveTargetDoubleLengthBlock(owner, expectedStart);
    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.getVisitorLimit());
    Assert.assertEquals(expectedStart, result.getStartTime());
    Assert.assertEquals(expectedEnd, result.getEndTime());

    expectedStart = CommonDateOperations.parseDateTimePhrase("20091102-1200");
    expectedEnd = DateUtils.addMinutes(expectedStart, owner.getPreferredMeetingDurations().getMaxLength());
    result = availableScheduleDao.retrieveTargetDoubleLengthBlock(owner, expectedStart);
    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.getVisitorLimit());
    Assert.assertEquals(expectedStart, result.getStartTime());
    Assert.assertEquals(expectedEnd, result.getEndTime());

    // special case - this block butts up to the end
    // since we are asking for an end outside the schedule, should return null
    expectedStart = CommonDateOperations.parseDateTimePhrase("20091102-1630");
    expectedEnd = DateUtils.addMinutes(expectedStart, owner.getPreferredMeetingDurations().getMaxLength());
    result = availableScheduleDao.retrieveTargetDoubleLengthBlock(owner, expectedStart);
    Assert.assertNull(result);

    expectedStart = CommonDateOperations.parseDateTimePhrase("20091109-1200");
    expectedEnd = DateUtils.addMinutes(expectedStart, owner.getPreferredMeetingDurations().getMaxLength());
    result = availableScheduleDao.retrieveTargetDoubleLengthBlock(owner, expectedStart);
    Assert.assertNotNull(result);
    Assert.assertEquals(2, result.getVisitorLimit());
    Assert.assertEquals(expectedStart, result.getStartTime());
    Assert.assertEquals(expectedEnd, result.getEndTime());

    expectedStart = CommonDateOperations.parseDateTimePhrase("20091116-1200");
    expectedEnd = DateUtils.addMinutes(expectedStart, owner.getPreferredMeetingDurations().getMaxLength());
    result = availableScheduleDao.retrieveTargetDoubleLengthBlock(owner, expectedStart);
    Assert.assertNotNull(result);
    Assert.assertEquals(4, result.getVisitorLimit());
    Assert.assertEquals(expectedStart, result.getStartTime());
    Assert.assertEquals(expectedEnd, result.getEndTime());

    expectedStart = CommonDateOperations.parseDateTimePhrase("20091123-1200");
    expectedEnd = DateUtils.addMinutes(expectedStart, owner.getPreferredMeetingDurations().getMaxLength());
    result = availableScheduleDao.retrieveTargetDoubleLengthBlock(owner, expectedStart);
    Assert.assertNotNull(result);
    Assert.assertEquals(20, result.getVisitorLimit());
    Assert.assertEquals(expectedStart, result.getStartTime());
    Assert.assertEquals(expectedEnd, result.getEndTime());
}

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

@Test
public void shouldRestoreNotifications() throws Exception {
    NotificationRestorer.restore(blankActivity);
    NotificationRestorer.restored = false;

    NotificationBundleProcessor_ProcessFromGCMIntentService(blankActivity, getBaseNotifBundle(), null);

    NotificationRestorer.restore(blankActivity);
    NotificationRestorer.restored = false;
    Intent intent = Shadows.shadowOf(blankActivity).getNextStartedService();
    Assert.assertEquals(GcmIntentService.class.getName(), intent.getComponent().getClassName());

    // Go forward 1 week
    // Note: Does not effect the SQL function strftime
    ShadowSystemClock.setCurrentTimeMillis(System.currentTimeMillis() + 604801L * 1000L);

    // Restorer should not fire service since the notification is over 1 week old.
    NotificationRestorer.restore(blankActivity);
    NotificationRestorer.restored = false;
    Assert.assertNull(Shadows.shadowOf(blankActivity).getNextStartedService());
}

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

@Test
public void testOldIntValues() throws Exception {
    final SharedPreferences prefs = blankActivity.getSharedPreferences(OneSignal.class.getSimpleName(),
            Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putString("ONESIGNAL_USERSTATE_SYNCVALYES_CURRENT_STATE", "{\"tags\": {\"int\": 123}}");
    editor.putString("ONESIGNAL_USERSTATE_SYNCVALYES_TOSYNC_STATE", "{\"tags\": {\"int\": 123}}");
    editor.commit();/*from   ww  w.j av a  2  s .  c o  m*/

    OneSignalInit();
    threadAndTaskWait();

    OneSignal.deleteTag("int");
    threadAndTaskWait();

    GetTags();

    final SharedPreferences prefs2 = blankActivity.getSharedPreferences(OneSignal.class.getSimpleName(),
            Context.MODE_PRIVATE);
    Assert.assertNull(lastGetTags);
}

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

public void testOldLoadRules() throws Exception {
    // Create build definition with old style load rules
    // load directory missing
    // don't delete directory before loading (dir has other stuff that will not be deleted)
    // don't accept changes before loading

    // create a build engine
    // create a build request

    // verify that the buildConfiguration returns the load rules
    // as the workspace to be loaded

    // checkout based on the request
    // make sure only the contents identified by the load rule was loaded
    // verify extra stuff from sandbox directory not deleted
    // verify no changes accepted
    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("testOldLoadRules",
                new Class[] { String.class, // serverURL,
                        String.class, // userId,
                        String.class, // password,
                        int.class, // timeout,
                        String.class, // workspaceName,
                        String.class, // componentName,
                        String.class }, // hjPath,
                loginInfo.getServerUri(), loginInfo.getUserId(), loginInfo.getPassword(),
                loginInfo.getTimeout(), testName, getTestName(), sandboxDir.getPath());

        try {//from w w w.j ava2 s  . c o  m
            TaskListener listener = new StreamTaskListener(System.out, null);

            File changeLogFile = new File(sandboxDir, "RTCChangeLogFile");
            FileOutputStream changeLog = new FileOutputStream(changeLogFile);
            assertTrue(new File(sandboxDir, "abc").mkdirs());
            assertTrue(new File(sandboxDir, "def").mkdirs());
            assertTrue(new File(sandboxDir, "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 = sandboxDir.list();
            Assert.assertEquals(6, children.length); // change log + 3 dirs made + metadata + file loaded
            Assert.assertTrue(new File(sandboxDir, "a.txt").exists());
            Assert.assertFalse(new File(sandboxDir, "h.txt").exists());
            Assert.assertTrue(new File(sandboxDir, "abc").exists());
            Assert.assertTrue(new File(sandboxDir, "def").exists());
            Assert.assertTrue(new File(sandboxDir, "hij").exists());

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

            // verify the result
            int changeCount = result.getComponentChangeCount() + result.getChangeSetsAcceptedCount()
                    + result.getChangeSetsDiscardedCount();
            // no accept done
            Assert.assertEquals(0, changeCount);
            Assert.assertNull(result.getBaselineSetItemId());

            validateBuildProperties(setupArtifacts.get(ARTIFACT_WORKSPACE_ITEM_ID), null, false, false,
                    setupArtifacts.get("LoadRuleProperty"), false, "", result.getBaselineSetItemId(),
                    changeCount, false, buildProperties);

        } 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:org.openmrs.module.paperrecord.PaperRecordServiceComponentTest.java

@Test
public void testRequestPaperRecordShouldNotConsiderSentRequestAsDuplicate() {

    // create a request for the patient that has a "completed" request defined in paperRecordTestDataset.xml
    Patient patient = patientService.getPatient(7);
    Location medicalRecordLocation = locationService.getLocation(1);
    Location requestLocation = locationService.getLocation(2);

    paperRecordService.requestPaperRecord(patient, medicalRecordLocation, requestLocation);

    // make sure this request has been created (it is a pull request, since this patient already has a patient record)
    List<PaperRecordRequest> requests = paperRecordService
            .getOpenPaperRecordRequestsToPull(medicalRecordLocation);
    Assert.assertEquals(1, requests.size());
    Date dateCreated = requests.get(0).getDateCreated();

    PaperRecordRequest request = requests.get(0);
    Assert.assertEquals(new Integer(7), request.getPaperRecord().getPatientIdentifier().getPatient().getId());
    Assert.assertEquals(new Integer(1), request.getPaperRecord().getRecordLocation().getId());
    Assert.assertEquals(new Integer(2), request.getRequestLocation().getId());
    Assert.assertEquals(PaperRecordRequest.Status.OPEN, request.getStatus());
    Assert.assertEquals(dateCreated, request.getDateCreated());
    Assert.assertNull(request.getAssignee());
}

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

/**
 * limit for embed version// w  w  w .j  a  v  a2s.  c  o  m
 * 
 * hint for embed
 */
@Test
public void testQueryIterLimit02_embed() {
    String query = "Manifest.versions{*}";
    QueryContext qc = newQueryContext(DEPLOY_REPO, IBranch.DEFAULT_BRANCH);
    qc.setAllowFullTableScan(true);
    qc.setSkips(new int[] { 0, 0 });
    qc.setLimits(new int[] { 1, 0 });
    int hint = 1;
    qc.setHint(hint);
    qc.setSourceIP("127.0.0.1");
    IQueryResult result = queryService.query(query, qc);
    Assert.assertEquals(2, result.getEntities().size());
    Assert.assertFalse(result.hasMoreResults());
    Assert.assertNull(result.getNextCursor());
}

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

@Test
public void testGetAssignedRequestByIdentifierShouldNotReturnOpenRequest() {

    // all these are from the standard test dataset
    Patient patient = patientService.getPatient(2);
    Location medicalRecordLocation = locationService.getLocation(1);
    Location requestLocation = locationService.getLocation(3);

    paperRecordService.requestPaperRecord(patient, medicalRecordLocation, requestLocation);

    PaperRecordRequest request = paperRecordService.getAssignedPaperRecordRequestByIdentifier("101",
            medicalRecordLocation);//from   w w  w .  j a  v  a2s. c om
    Assert.assertNull(request);
}

From source file:com.amazonaws.services.kinesis.clientlibrary.lib.worker.ShardSyncerTest.java

/**
 * Test bootstrapShardLeases() - cleanup garbage leases.
 * //from www  . ja  v  a 2 s. c  om
 * @throws ProvisionedThroughputException
 * @throws InvalidStateException
 * @throws DependencyException
 * @throws IOException
 * @throws KinesisClientLibIOException
 */
@Test
public final void testBootstrapShardLeasesCleanupGarbage() throws DependencyException, InvalidStateException,
        ProvisionedThroughputException, IOException, KinesisClientLibIOException {
    String garbageShardId = "shardId-garbage-001";
    KinesisClientLease garbageLease = ShardSyncer.newKCLLease(ShardObjectHelper.newShard(garbageShardId, null,
            null, ShardObjectHelper.newSequenceNumberRange("101", null)));
    garbageLease.setCheckpoint(new ExtendedSequenceNumber("999"));
    leaseManager.createLeaseIfNotExists(garbageLease);
    Assert.assertEquals(garbageShardId, leaseManager.getLease(garbageShardId).getLeaseKey());
    testBootstrapShardLeasesAtStartingPosition(INITIAL_POSITION_LATEST);
    Assert.assertNull(leaseManager.getLease(garbageShardId));
}

From source file:com.microsoft.windowsazure.mobileservices.sdk.testapp.test.EnhancedPushTests.java

public void testReRegisterFailNative() throws Throwable {
    try {/*ww w  .jav  a2  s . c om*/

        Context context = getInstrumentation().getTargetContext();
        final SharedPreferences sharedPreferences = PreferenceManager
                .getDefaultSharedPreferences(context.getApplicationContext());

        final Container container = new Container();
        final String handle = "handle";

        String registrationId1 = "registrationId1";
        String registrationId2 = "registrationId2";

        MobileServiceClient client = new MobileServiceClient(appUrl, appKey, context);

        MobileServiceClient registrationclient = client.withFilter(getUpsertTestFilter(registrationId1));
        MobileServiceClient reRegistrationclient = client.withFilter(getUpsertFailTestFilter(registrationId2));

        final MobileServicePush registrationPush = registrationclient.getPush();
        final MobileServicePush reRegistrationPush = reRegistrationclient.getPush();

        forceRefreshSync(registrationPush, handle);
        forceRefreshSync(reRegistrationPush, handle);

        try {
            registrationPush.register(handle, new String[] { "tag1" }).get();
        } catch (Exception exception) {
            fail(exception.getMessage());
        }

        try {
            reRegistrationPush.register(handle, new String[] { "tag1" }).get();

        } catch (Exception exception) {
            if (exception instanceof ExecutionException) {
                container.exception = (Exception) exception.getCause();
            } else {
                container.exception = exception;
            }

            container.storedRegistrationId = sharedPreferences.getString(
                    STORAGE_PREFIX + REGISTRATION_NAME_STORAGE_KEY + DEFAULT_REGISTRATION_NAME, null);
        }

        // Asserts
        Exception exception = container.exception;

        if (!(exception instanceof RegistrationGoneException)) {
            fail("Expected Exception RegistrationGoneException");
        }

        Assert.assertNull(container.storedRegistrationId);
    } catch (Exception e) {
        e.printStackTrace();
    }
}