Example usage for junit.framework Assert assertNotNull

List of usage examples for junit.framework Assert assertNotNull

Introduction

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

Prototype

static public void assertNotNull(Object object) 

Source Link

Document

Asserts that an object isn't null.

Usage

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

@Test
public void saveUser_shouldSaveUser() throws Exception {
    final String userName = "User Name";

    List<User> users = userService.getUsers();
    Assert.assertEquals("There are 5 users", 5, users.size());
    Assert.assertNull(getUser(userName, users));

    User user = new User(userName);
    user.setCreator(users.get(0));/*w w w .j a v a 2  s  .  co m*/
    user.setDateCreated(new Date());

    userService.saveUser(user);

    users = userService.getUsers();
    Assert.assertEquals("Added 1 user so now there are 6", 6, userService.getUsers().size());
    Assert.assertNotNull(getUser(userName, users));
}

From source file:org.openmrs.module.webservices.rest19ext.web.v1_0.controller.VisitAttributeControllerTest.java

@Test
public void shouldGetAVisitAttribute() throws Exception {
    Object result = controller.retrieve(Rest19ExtTestConstants.VISIT_UUID,
            Rest19ExtTestConstants.VISIT_ATTRIBUTE_UUID, request);
    String rfc822Timezone = new SimpleDateFormat("Z").format(new Date());
    Assert.assertNotNull(result);
    Assert.assertEquals(Rest19ExtTestConstants.VISIT_ATTRIBUTE_UUID, PropertyUtils.getProperty(result, "uuid"));
    Assert.assertEquals("2011-04-25T00:00:00.000" + rfc822Timezone, PropertyUtils.getProperty(result, "value"));
    Assert.assertNull(PropertyUtils.getProperty(result, "auditInfo"));
}

From source file:net.sf.reportengine.core.steps.TestDataRowsOutputStep.java

@Test
public void testExecuteScenario1() {
    DataRowsOutputStep classUnderTest = new DataRowsOutputStep();

    AlgoContext reportContext = new DefaultAlgorithmContext();
    Map<AlgoIOKeys, Object> mockAlgoInput = new EnumMap<AlgoIOKeys, Object>(AlgoIOKeys.class);

    StringWriter testWriter = new StringWriter();
    MockReportOutput mockOutput = new MockReportOutput(testWriter);

    reportContext.set(StepIOKeys.LOCAL_REPORT_INPUT, Scenario1.INPUT);
    //reportContext.set(ContextKeys.NEW_LOCAL_REPORT_OUTPUT, mockOutput); 

    mockAlgoInput.put(AlgoIOKeys.DATA_COLS, Scenario1.DATA_COLUMNS);
    mockAlgoInput.put(AlgoIOKeys.GROUP_COLS, Scenario1.GROUPING_COLUMNS);
    mockAlgoInput.put(AlgoIOKeys.NEW_REPORT_OUTPUT, mockOutput);

    reportContext.set(StepIOKeys.DATA_ROW_COUNT, 0);
    classUnderTest.init(new StepInput(mockAlgoInput, reportContext));

    NewRowEvent dataRowEvent = new NewRowEvent(Scenario1.ROW_OF_DATA_1);
    StepResult<Integer> stepResult = classUnderTest.execute(dataRowEvent,
            new StepInput(mockAlgoInput, reportContext));

    Assert.assertNotNull(stepResult);
    Assert.assertEquals(NumberUtils.INTEGER_ONE, stepResult.getValue()); //(ContextKeys.DATA_ROW_COUNT));
    reportContext.set(StepIOKeys.DATA_ROW_COUNT, stepResult.getValue());

    dataRowEvent = new NewRowEvent(Scenario1.ROW_OF_DATA_2);
    stepResult = classUnderTest.execute(dataRowEvent, new StepInput(mockAlgoInput, reportContext));

    Assert.assertNotNull(stepResult);/*from   w  ww .  java  2s  . co  m*/
    Assert.assertEquals(Integer.valueOf(2), stepResult.getValue());
    reportContext.set(StepIOKeys.DATA_ROW_COUNT, stepResult.getValue());

    dataRowEvent = new NewRowEvent(Scenario1.ROW_OF_DATA_3);
    stepResult = classUnderTest.execute(dataRowEvent, new StepInput(mockAlgoInput, reportContext));

    Assert.assertNotNull(stepResult);
    Assert.assertEquals(Integer.valueOf(3), stepResult.getValue());
    reportContext.set(StepIOKeys.DATA_ROW_COUNT, stepResult.getValue());

    dataRowEvent = new NewRowEvent(Scenario1.ROW_OF_DATA_4);
    stepResult = classUnderTest.execute(dataRowEvent, new StepInput(mockAlgoInput, reportContext));

    Assert.assertNotNull(stepResult);
    Assert.assertEquals(Integer.valueOf(4), stepResult.getValue());
    reportContext.set(StepIOKeys.DATA_ROW_COUNT, stepResult.getValue());

    dataRowEvent = new NewRowEvent(Scenario1.ROW_OF_DATA_5);
    stepResult = classUnderTest.execute(dataRowEvent, new StepInput(mockAlgoInput, reportContext));

    Assert.assertNotNull(stepResult);
    Assert.assertEquals(Integer.valueOf(5), stepResult.getValue());
    reportContext.set(StepIOKeys.DATA_ROW_COUNT, stepResult.getValue());

    dataRowEvent = new NewRowEvent(Scenario1.ROW_OF_DATA_6);
    stepResult = classUnderTest.execute(dataRowEvent, new StepInput(mockAlgoInput, reportContext));

    Assert.assertNotNull(stepResult);
    Assert.assertEquals(Integer.valueOf(6), stepResult.getValue());
    reportContext.set(StepIOKeys.DATA_ROW_COUNT, stepResult.getValue());

    //CellProps[][] resultCellMatrix = Scenario1.OUTPUT.getDataCellMatrix();
    //Assert.assertTrue(MatrixUtils.compareMatrices(Scenario1.EXPECTED_OUTPUT_DATA, resultCellMatrix));
    System.out.println(testWriter.getBuffer());
}

From source file:it.geosolutions.geobatch.testsuite.EventGeneratorTestCase.java

@Test
public void testFileBasedEventGeneratorService() throws IOException, InterruptedException {
    // ///*from w  w  w  .  j a v  a  2s.com*/
    //
    // get the FileBasedEventGeneratorService bean service from the context
    //
    // //
    Object o = context.getBean("fsEventGeneratorService", FileBasedEventGeneratorService.class);
    Assert.assertNotNull(o);
    Assert.assertTrue(o instanceof FileBasedEventGeneratorService);

    final FileBasedEventGeneratorService service = (FileBasedEventGeneratorService) o;

    // //
    //
    // Create a fictitious configuration
    //
    // //
    //        final FileBasedEventGeneratorConfiguration configuration = new FileBasedEventGeneratorConfiguration();
    //        configuration.setId("id");
    //        configuration.setName("name");
    //        configuration.setDescription("description");
    //        configuration.setOsType(OsType.OS_UNDEFINED);
    //        configuration.setWorkingDirectory(TestData.file(this, ".").getAbsolutePath());

    // //
    //
    // Check if we can create the needed EventGenerator and if so create it
    //
    // //
    //        final boolean result = service.canCreateEventGenerator(configuration);
    //        Assert.assertTrue(result);
    //
    //        // create the event generator
    //        final FileBasedEventGenerator eg = service.createEventGenerator(configuration);
    // start to listen on it and then create it
    //        eg.addListener(this);
    //        eg.start();

    Thread.sleep(5000);

    //
    final File file = TestData.temp(this, "test");
    if (file.exists()) {
        synchronized (this) {
            this.wait(5000);
        }
        Assert.assertTrue("unable to create test", this.caughtEvent);
    } else {
        Assert.assertTrue("unable to create test", false);
    }

}

From source file:com.googlecode.t7mp.steps.CopySetenvScripStepTest.java

@Test
public void testCopySetenvScriptStep() {
    String setenvScriptPath = getClass().getResource("/com/googlecode/t7mp/bin/setenv.sh").getPath();
    File t7mpDirectory = new File(setenvScriptPath).getParentFile().getParentFile();
    File confDirectory = new File(t7mpDirectory, "/conf/");
    Assert.assertNotNull(confDirectory);
    Assert.assertTrue(confDirectory.exists());
    Mockito.when(configuration.getTomcatConfigDirectory()).thenReturn(new File(t7mpDirectory, "/conf/"));
    Context context = new DefaultContext(new ChainedArtifactResolver(), configuration);
    Step step = new CopySetenvScriptStep();
    step.execute(context);//from   ww  w .j  ava2s  .  c o  m
    File binDirectory = new File(catalinaBaseDir, "/bin/");
    Assert.assertNotNull(binDirectory);
    Assert.assertTrue(binDirectory.exists());
    File copyiedSetenvScript = new File(binDirectory, "setenv.sh");

    Assert.assertNotNull(copyiedSetenvScript);
    Assert.assertTrue(copyiedSetenvScript.exists());
}

From source file:ejportal.webapp.action.SigelActionTest.java

/**
 * Test edit./*  w  ww.j a v a  2  s . c  o  m*/
 * 
 * @throws Exception
 *             the exception
 */
public void testEdit() throws Exception {
    this.log.debug("testing edit...");
    this.action.setSigelId(1L);
    Assert.assertNull(this.action.getSigel());
    Assert.assertEquals("edit", this.action.edit());
    Assert.assertNotNull(this.action.getSigel());
    Assert.assertFalse(this.action.hasActionErrors());
}

From source file:ejportal.webapp.action.PaketActionTest.java

/**
 * Test edit.//w  w w.j  av a 2  s.  c  o  m
 * 
 * @throws Exception
 *             the exception
 */
public void testEdit() throws Exception {
    this.log.debug("testing edit...");
    this.action.setPaketId(1L);
    Assert.assertNull(this.action.getPaket());
    Assert.assertEquals("edit", this.action.edit());
    Assert.assertNotNull(this.action.getPaket());
    Assert.assertFalse(this.action.hasActionErrors());
}

From source file:com.taobao.ad.jpa.test.RepeatAlarmTest.java

@Test
public void testInsertReapeatAlerm_save() {
    RepeatAlarmDO r = new RepeatAlarmDO();
    r.setJobGroup("123");
    r.setJobName("222");
    r.setRepeatAlarmNum(1);//from  ww  w  .j a va2  s.  c  o  m
    r.setStatus(1);
    long t = System.currentTimeMillis();
    r.setSignTime(t);
    repeatAlarmBO.saveOrUpdateRepeatAlarm(r);

    r = repeatAlarmBO.getRepeatAlarmById(r.getId());

    Assert.assertNotNull(r);
    Assert.assertEquals("222", r.getJobName());
    Assert.assertEquals("123", r.getJobGroup());
    // Assert.assertEquals(t, r.getSignTime());
    Assert.assertEquals(1, r.getRepeatAlarmNum());
    Assert.assertEquals(1, r.getStatus().intValue());
    repeatAlarmBO.checkRepeatAlarm(r.getId());
}

From source file:org.jm.spring.controller.test.SpringMVCAPIReaderTest.java

@Test
public void test_process_method() {

    SpringMVCAPIReader mvcapiReader = new SpringMVCAPIReader("0.1", "1.1-SHAPSHOT.121026", "localhost:8080",
            "");/* www  .  jav  a  2 s  .  co m*/
    Documentation doc = mvcapiReader.processMethods(mapping, Handler.class.toString());

    Assert.assertNotNull(doc);
}

From source file:com.cloudant.sync.datastore.BasicDatastoreTestBase.java

void validateNewlyCreatedDocument(BasicDocumentRevision rev) {
    Assert.assertNotNull(rev);
    CouchUtils.validateDocumentId(rev.getId());
    CouchUtils.validateRevisionId(rev.getRevision());
    Assert.assertEquals(1, CouchUtils.generationFromRevId(rev.getRevision()));
    Assert.assertTrue(rev.isCurrent());/*ww w. jav  a  2  s. co  m*/
    Assert.assertTrue(rev.getParent() == -1L);
}