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:org.apache.wink.test.mock.MockHttpServletRequestWrapperTestCase.java

@Test
public void testParameter() throws Exception {
    HttpServletRequest req = MockRequestConstructor.constructMockRequest("POST", "/test", "application/json",
            "application/x-www-form-urlencoded", "x=1&y=2&z=%20".getBytes("UTF-8"));
    String x = req.getParameter("x");
    String y = req.getParameter("y");
    String z = req.getParameter("z");
    String a = req.getParameter("a");

    Assert.assertEquals("1", x);
    Assert.assertEquals("2", y);
    Assert.assertEquals(" ", z);
    Assert.assertNull(a);

    Assert.assertEquals(3, req.getParameterMap().size());
}

From source file:org.openmrs.module.formfilter.web.controller.AddFormFilterPropertyControllerTest.java

/**
 * @see {@link AddFormFilterPropertyController#addFormFilter(ModelMap, Integer, int)}
 *//*w w  w.  j a  v a  2 s.c om*/
@Test
@Verifies(value = "should support add new filter functionality", method = "addFormFilter(ModelMap,Integer,int)")
public void addFormFilter_shouldSupportAddNewFilterFunctionality() {

    AddFormFilterPropertyController controller = new AddFormFilterPropertyController();
    ModelMap model = new ModelMap();
    controller.addFormFilter(model, 1, null);
    Assert.assertNotNull(((FormFilter) model.get("formFilter")));
    Assert.assertNull(((FormFilterProperty) model.get("formFilterProperty")).getFilterName());
}

From source file:org.openxdata.server.service.impl.LocaleServiceTest.java

@Test
public void saveLocale_shouldSaveLocaleList() throws Exception {
    final String localeName = "LocaleName";
    final String localeKey = "LocaleKey";

    List<Locale> locales = localeService.getLocales();
    Assert.assertEquals(1, locales.size());
    Assert.assertNull(getLocale(localeName, locales));

    Locale locale = new Locale();
    locale.setName(localeName);//from  w  w  w.  j av  a  2s  .c o  m
    locale.setKey(localeKey);
    locale.setCreator(userService.getUsers().get(0));
    locale.setDateCreated(new Date());

    locales = new ArrayList<Locale>();
    locales.add(locale);

    localeService.saveLocale(locales);

    locales = localeService.getLocales();
    Assert.assertEquals(2, locales.size());
    Assert.assertNotNull(getLocale(localeName, locales));
}

From source file:org.openxdata.server.service.impl.StudyManagerServiceTest.java

@Test
public void saveStudy_shouldSaveStudy() throws Exception {
    final String studyName = "StudyName";

    List<StudyDef> studies = studyManagerService.getStudies();
    Assert.assertEquals("There are 4 studies", 4, studies.size());
    Assert.assertNull(getStudy(studyName, studies));

    StudyDef study = new StudyDef();
    study.setName(studyName);//  w w w . ja v  a2  s  .c om
    study.setCreator(userService.getUsers().get(0));
    study.setDateCreated(new Date());

    studyManagerService.saveStudy(study);

    studies = studyManagerService.getStudies();
    Assert.assertEquals("Added 1 study, now there are 5", 5, studies.size());
    Assert.assertNotNull(getStudy(studyName, studies));
}

From source file:com.netflix.curator.TestSessionFailRetryLoop.java

@Test
public void testRetry() throws Exception {
    Timing timing = new Timing();
    final CuratorZookeeperClient client = new CuratorZookeeperClient(server.getConnectString(),
            timing.session(), timing.connection(), null, new RetryOneTime(1));
    SessionFailRetryLoop retryLoop = client.newSessionFailRetryLoop(SessionFailRetryLoop.Mode.RETRY);
    retryLoop.start();//  w  w w  . j a v a  2s  . com
    try {
        client.start();
        final AtomicBoolean secondWasDone = new AtomicBoolean(false);
        final AtomicBoolean firstTime = new AtomicBoolean(true);
        while (retryLoop.shouldContinue()) {
            try {
                RetryLoop.callWithRetry(client, new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        if (firstTime.compareAndSet(true, false)) {
                            Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
                            KillSession.kill(client.getZooKeeper(), server.getConnectString());
                            client.getZooKeeper();
                            client.blockUntilConnectedOrTimedOut();
                        }

                        Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
                        return null;
                    }
                });

                RetryLoop.callWithRetry(client, new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        Assert.assertFalse(firstTime.get());
                        Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
                        secondWasDone.set(true);
                        return null;
                    }
                });
            } catch (Exception e) {
                retryLoop.takeException(e);
            }
        }

        Assert.assertTrue(secondWasDone.get());
    } finally {
        retryLoop.close();
        IOUtils.closeQuietly(client);
    }
}

From source file:org.openxdata.server.service.impl.MobileMenuTextServiceTest.java

@Test
public void saveMobileMenuText_shouldSaveMobileMenuTextList() throws Exception {
    final String textName = "Exit";

    List<MobileMenuText> textList = utilityService.getMobileMenuText("en");
    Assert.assertEquals(1, textList.size());
    Assert.assertNull(getMobileMenuText(textName, textList));

    MobileMenuText mobileMenuText = new MobileMenuText();
    mobileMenuText.setMenuText(textName);
    mobileMenuText.setLocaleKey("en");
    mobileMenuText.setMenuId((short) 2);
    mobileMenuText.setCreator(userService.getUsers().get(0));
    mobileMenuText.setDateCreated(new Date());

    textList = new ArrayList<MobileMenuText>();
    textList.add(mobileMenuText);/*from   ww w .  ja v a  2s. c  om*/

    utilityService.saveMobileMenuText(textList);

    textList = utilityService.getMobileMenuText("en");
    Assert.assertEquals(2, textList.size());
    Assert.assertNotNull(getMobileMenuText(textName, textList));
}

From source file:com.gisgraphy.helper.StringHelperTest.java

@Test
public void TransformStringForIlikeIndexationForNullString() {
    Assert.assertNull(StringHelper.transformStringForPartialWordIndexation(null, '_'));
}

From source file:com.logsniffer.model.support.LineInputStreamTest.java

@Test
public void testDefaultNL() throws IOException {
    FileLog flog = new FileLog(writeString2Tmp("line1\nline2", "UTF-8"));
    DirectFileLogAccess logAccess = new DirectFileLogAccess(flog);
    LineInputStream log = new LineInputStream(logAccess, logAccess.getInputStream(null), "UTF-8");
    LogPointer start = log.getPointer();
    Assert.assertEquals("line1", log.readNextLine());
    Assert.assertEquals("line1\n".length(), logAccess.getDifference(start, log.getPointer()));
    Assert.assertEquals(false, log.getPointer().isEOF());
    Assert.assertEquals("line2", log.readNextLine());
    log.close();/*from  w  w  w.  ja  va  2 s  .  c o m*/

    log = new LineInputStream(logAccess,
            logAccess.getInputStream(logAccess.createRelative(null, "line1\n".length())), "UTF-8");
    Assert.assertEquals("line2", log.readNextLine());
    Assert.assertNull(log.readNextLine());
    Assert.assertEquals(true, log.getPointer().isEOF());
    log.close();
}

From source file:org.openscore.lang.runtime.navigations.NavigationsTest.java

@Test
public void errorNavigationTest() throws Exception {

    RunEnvironment runEnv = new RunEnvironment();
    Long nextStepId = 2L;//w w w. j ava 2s  .  co m
    runEnv.putNextStepPosition(nextStepId);
    ExecutionRuntimeServices runtimeServices = new ExecutionRuntimeServices();
    runtimeServices.setStepErrorKey("Error");
    Long nextPosition = navigations.navigate(runEnv, runtimeServices);

    Collection<ScoreEvent> events = runtimeServices.getEvents();

    Assert.assertNull(nextPosition);

    Assert.assertFalse(events.isEmpty());
    ScoreEvent stepErrorEvent = null;
    for (ScoreEvent event : events) {
        if (event.getEventType().equals(SLANG_EXECUTION_EXCEPTION)) {
            stepErrorEvent = event;
        }
    }
    Assert.assertNotNull(stepErrorEvent);
}

From source file:org.openxdata.server.service.impl.SettingServiceTest.java

@Test
public void saveSetting_shouldSaveSetting() throws Exception {
    Assert.assertNull(settingService.getSetting("Name"));

    settingService.saveSetting(new Setting("Name", "Description", "Value"));

    String setting = settingService.getSetting("Name");
    Assert.assertNotNull(setting);//from  ww  w  .  jav  a2s  .c  om
}