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.osaf.cosmo.calendar.RecurrenceExpanderTest.java

public void testRecurrenceExpanderAllDay() throws Exception {
    RecurrenceExpander expander = new RecurrenceExpander();

    Calendar calendar = getCalendar("allday_recurring1.ics");

    Date[] range = expander.calculateRecurrenceRange(calendar);

    Assert.assertEquals("20070101", range[0].toString());
    Assert.assertEquals("20070120", range[1].toString());

    calendar = getCalendar("allday_recurring2.ics");

    range = expander.calculateRecurrenceRange(calendar);

    Assert.assertEquals("20070101", range[0].toString());
    Assert.assertNull(range[1]);
}

From source file:org.osaf.cosmo.calendar.RecurrenceExpanderTest.java

public void testRecurrenceExpanderFloating() throws Exception {
    RecurrenceExpander expander = new RecurrenceExpander();
    Calendar calendar = getCalendar("floating_recurring1.ics");

    Date[] range = expander.calculateRecurrenceRange(calendar);

    Assert.assertEquals("20070101T100000", range[0].toString());
    Assert.assertEquals("20070119T120000", range[1].toString());

    calendar = getCalendar("floating_recurring2.ics");
    range = expander.calculateRecurrenceRange(calendar);

    Assert.assertEquals("20070101T100000", range[0].toString());
    Assert.assertNull(range[1]);
}

From source file:org.osaf.cosmo.calendar.RecurrenceExpanderTest.java

public void testRecurrenceExpanderTimezone() throws Exception {
    RecurrenceExpander expander = new RecurrenceExpander();
    Calendar calendar = getCalendar("tz_recurring1.ics");

    Date[] range = expander.calculateRecurrenceRange(calendar);

    Assert.assertEquals("20070101T100000", range[0].toString());
    Assert.assertEquals("20070119T120000", range[1].toString());

    Assert.assertEquals(((DateTime) range[0]).getTimeZone().getID(), "America/Chicago");
    Assert.assertEquals(((DateTime) range[1]).getTimeZone().getID(), "America/Chicago");

    calendar = getCalendar("tz_recurring2.ics");

    range = expander.calculateRecurrenceRange(calendar);

    Assert.assertEquals("20070101T100000", range[0].toString());
    Assert.assertNull(range[1]);

    Assert.assertEquals(((DateTime) range[0]).getTimeZone().getID(), "America/Chicago");
}

From source file:org.osaf.cosmo.dao.hibernate.HibernateContentDaoStampingTest.java

public void testStampHandlers() throws Exception {
    User user = getUser(userDao, "testuser");
    CollectionItem root = (CollectionItem) contentDao.getRootItem(user);

    NoteItem item = generateTestContent();

    item.setIcalUid("icaluid");
    item.setBody("this is a body");

    HibEventStamp event = new HibEventStamp();
    event.setEventCalendar(helper.getCalendar("cal1.ics"));

    item.addStamp(event);/* ww w  . jav  a2s .com*/

    Assert.assertNull(event.getTimeRangeIndex());

    ContentItem newItem = contentDao.createContent(root, item);
    clearSession();

    ContentItem queryItem = (ContentItem) contentDao.findItemByUid(newItem.getUid());

    event = (HibEventStamp) queryItem.getStamp(EventStamp.class);
    Assert.assertEquals("20050817T115000Z", event.getTimeRangeIndex().getStartDate());
    Assert.assertEquals("20050817T131500Z", event.getTimeRangeIndex().getEndDate());
    Assert.assertFalse(event.getTimeRangeIndex().getIsFloating().booleanValue());

    event.setStartDate(new Date("20070101"));
    event.setEndDate(null);

    contentDao.updateContent(queryItem);
    clearSession();

    queryItem = (ContentItem) contentDao.findItemByUid(newItem.getUid());

    event = (HibEventStamp) queryItem.getStamp(EventStamp.class);
    Assert.assertEquals("20070101", event.getTimeRangeIndex().getStartDate());
    Assert.assertEquals("20070101", event.getTimeRangeIndex().getEndDate());
    Assert.assertTrue(event.getTimeRangeIndex().getIsFloating().booleanValue());
}

From source file:org.osaf.cosmo.dao.hibernate.HibernateContentDaoStampingTest.java

public void testStampsUpdate() throws Exception {
    User user = getUser(userDao, "testuser");
    CollectionItem root = (CollectionItem) contentDao.getRootItem(user);

    ContentItem item = generateTestContent();

    ((NoteItem) item).setBody("this is a body");
    ((NoteItem) item).setIcalUid("icaluid");

    MessageStamp message = new HibMessageStamp(item);
    message.setBcc("bcc");
    message.setTo("to");
    message.setFrom("from");
    message.setCc("cc");

    EventStamp event = new HibEventStamp();
    event.setEventCalendar(helper.getCalendar("cal1.ics"));

    item.addStamp(message);// w ww . ja  v a2 s .  c om
    item.addStamp(event);

    ContentItem newItem = contentDao.createContent(root, item);
    clearSession();

    ContentItem queryItem = (ContentItem) contentDao.findItemByUid(newItem.getUid());
    Assert.assertEquals(2, queryItem.getStamps().size());

    Stamp stamp = queryItem.getStamp(MessageStamp.class);
    queryItem.removeStamp(stamp);

    stamp = queryItem.getStamp(EventStamp.class);
    EventStamp es = (EventStamp) stamp;
    queryItem.setClientModifiedDate(new Date());
    es.setEventCalendar(helper.getCalendar("cal2.ics"));
    Calendar newCal = es.getEventCalendar();
    Thread.sleep(10);

    contentDao.updateContent(queryItem);

    clearSession();
    queryItem = (ContentItem) contentDao.findItemByUid(newItem.getUid());
    Assert.assertEquals(1, queryItem.getStamps().size());
    Assert.assertNull(queryItem.getStamp(MessageStamp.class));
    stamp = queryItem.getStamp(EventStamp.class);
    es = (EventStamp) stamp;

    Assert.assertTrue(stamp.getModifiedDate().after(stamp.getCreationDate()));

    if (!es.getEventCalendar().toString().equals(newCal.toString())) {
        log.error(es.getEventCalendar().toString());
        log.error(newCal.toString());
    }
    Assert.assertEquals(es.getEventCalendar().toString(), newCal.toString());
}

From source file:org.osaf.cosmo.eim.schema.contentitem.ContentItemApplicatorTest.java

public void testApplyMissingField() throws Exception {
    NoteItem modification = new MockNoteItem();
    NoteItem parent = new MockNoteItem();
    parent.setDisplayName("test");
    modification.setModifies(parent);/*w  w  w. j  av a 2 s . co m*/

    EimRecord record = makeTestMissingRecord();

    ContentItemApplicator applicator = new ContentItemApplicator(modification);
    applicator.applyRecord(record);

    Assert.assertNull(modification.getDisplayName());
}

From source file:org.osaf.cosmo.eim.schema.event.alarm.DisplayAlarmApplicatorTest.java

public void testApplyField() throws Exception {
    NoteItem noteItem = new MockNoteItem();
    EventStamp eventStamp = new MockEventStamp(noteItem);
    eventStamp.createCalendar();/* w w  w.j a  v  a2s .com*/
    eventStamp.setStartDate(new DateTime(true));
    noteItem.addStamp(eventStamp);

    EimRecord record = makeTestRecord();

    DisplayAlarmApplicator applicator = new DisplayAlarmApplicator(noteItem);
    applicator.applyRecord(record);

    Period period = new Period((DateTime) eventStamp.getStartDate(), new Dur("PT15M"));

    Assert.assertEquals(eventStamp.getDisplayAlarmDescription(), "My alarm");
    Assert.assertEquals(eventStamp.getDisplayAlarmTrigger().getValue(), "PT15M");
    Assert.assertEquals(eventStamp.getDisplayAlarmDuration().toString(), "P1W");
    Assert.assertEquals(eventStamp.getDisplayAlarmRepeat(), new Integer(1));

    // verify that NoteItem.reminderTime was updated
    Assert.assertNotNull(noteItem.getReminderTime());
    // it should be the end date of the period of eventStart,trigger duration
    Assert.assertEquals(period.getEnd().getTime(), noteItem.getReminderTime().getTime());

    // test removing alarm from event
    record = makeTestNoneRecord();

    applicator.applyRecord(record);

    Assert.assertNull(noteItem.getReminderTime());
    Assert.assertNull(eventStamp.getDisplayAlarm());
}

From source file:org.osaf.cosmo.eim.schema.event.alarm.DisplayAlarmApplicatorTest.java

public void testApplyFieldNonEvent() throws Exception {
    NoteItem noteItem = new MockNoteItem();
    EimRecord record = makeTestRecordNonEvent();

    DisplayAlarmApplicator applicator = new DisplayAlarmApplicator(noteItem);
    applicator.applyRecord(record);//from   w ww.  jav  a 2 s  .  c  o m

    Assert.assertNotNull(noteItem.getReminderTime());
    Assert.assertEquals(noteItem.getReminderTime(), new DateTime("20080101T075900Z"));

    record = makeTestNoneRecord();

    applicator.applyRecord(record);

    Assert.assertNull(noteItem.getReminderTime());
}

From source file:org.osaf.cosmo.eim.schema.event.alarm.DisplayAlarmApplicatorTest.java

public void testApplyMissingField() throws Exception {
    NoteItem masterNote = new MockNoteItem();
    EventStamp masterEvent = new MockEventStamp(masterNote);
    masterEvent.createCalendar();/*from  w w  w.ja v  a2 s  .c om*/
    masterEvent.creatDisplayAlarm();
    masterEvent.setDisplayAlarmDescription("My alarm");
    masterEvent.setDisplayAlarmDuration(new Dur("P1W"));
    masterEvent.setDisplayAlarmTrigger(EimValueConverter.toIcalTrigger("-PT15M"));
    masterEvent.setDisplayAlarmRepeat(1);

    masterNote.addStamp(masterEvent);

    NoteItem modNote = new MockNoteItem();
    EventExceptionStamp modEvent = new MockEventExceptionStamp(modNote);
    modEvent.createCalendar();
    modNote.setModifies(masterNote);
    modNote.addStamp(modEvent);

    EimRecord record = makeTestMissingRecord();

    DisplayAlarmApplicator applicator = new DisplayAlarmApplicator(modNote);
    applicator.applyRecord(record);

    modEvent.getEventCalendar().validate(true);

    Assert.assertNull(modEvent.getDisplayAlarmDescription());
    Assert.assertNull(modEvent.getDisplayAlarmTrigger());
    Assert.assertNull(modEvent.getDisplayAlarmDuration());
    Assert.assertNull(modEvent.getDisplayAlarmRepeat());
}

From source file:org.osaf.cosmo.eim.schema.event.EventApplicatorTest.java

public void testApplyMissingField() throws Exception {
    NoteItem masterNote = new MockNoteItem();
    EventStamp masterEvent = new MockEventStamp(masterNote);
    masterEvent.createCalendar();//from www.j av  a  2 s .c  om
    masterEvent.setLocation("here");
    masterEvent.setStatus("CONFIRMED");
    masterEvent.setStartDate(EimValueConverter.toICalDate(";VALUE=DATE-TIME:20070210T074500").getDate());
    masterEvent.setEndDate(EimValueConverter.toICalDate(";VALUE=DATE-TIME:20070214T084500").getDate());

    masterNote.addStamp(masterEvent);

    NoteItem modNote = new MockNoteItem();
    EventExceptionStamp modEvent = new MockEventExceptionStamp(modNote);
    modEvent.createCalendar();
    modEvent.setRecurrenceId(EimValueConverter.toICalDate(";VALUE=DATE-TIME:20070212T074500").getDate());
    modEvent.setLocation("blah");
    modEvent.setStatus("blah");
    modNote.setModifies(masterNote);
    modNote.addStamp(modEvent);

    EimRecord record = makeTestMissingRecord();

    EventApplicator applicator = new EventApplicator(modNote);
    applicator.applyRecord(record);

    Assert.assertEquals("20070212T074500", modEvent.getStartDate().toString());
    Assert.assertNull(modEvent.getDuration());
    Assert.assertNull(modEvent.getAnyTime());
    Assert.assertNull(modEvent.getLocation());
    Assert.assertNull(modEvent.getStatus());

    record = makeTestModificationRecord();

    applicator.applyRecord(record);

    Assert.assertEquals("20070213T074500", modEvent.getStartDate().toString());
    Assert.assertFalse(modEvent.getAnyTime());
}