List of usage examples for junit.framework Assert assertNull
static public void assertNull(Object object)
From source file:org.osaf.cosmo.eim.schema.message.MessageApplicatorTest.java
public void testApplyMissingFields() throws Exception { NoteItem masterNote = new MockNoteItem(); NoteItem modItem = new MockNoteItem(); MessageStamp messageStamp = new MockMessageStamp(masterNote); messageStamp.setMessageId("test"); messageStamp.setHeaders("test"); messageStamp.setFrom("test"); messageStamp.setCc("test"); messageStamp.setBcc("test"); messageStamp.setOriginators("test"); messageStamp.setDateSent("test"); messageStamp.setInReplyTo("test"); messageStamp.setReferences("test"); masterNote.addStamp(messageStamp);/* w w w . j av a 2 s.c o m*/ modItem.setModifies(masterNote); EimRecord record = makeTestMissingRecord(); MessageApplicator applicator = new MessageApplicator(modItem); applicator.applyRecord(record); MessageStamp modStamp = StampUtils.getMessageStamp(modItem); Assert.assertNull(modStamp.getMessageId()); Assert.assertNull(modStamp.getHeaders()); Assert.assertNull(modStamp.getFrom()); Assert.assertNull(modStamp.getCc()); Assert.assertNull(modStamp.getBcc()); Assert.assertNull(modStamp.getOriginators()); Assert.assertNull(modStamp.getDateSent()); Assert.assertNull(modStamp.getInReplyTo()); Assert.assertNull(modStamp.getReferences()); }
From source file:org.osaf.cosmo.scheduler.UserPreferencesScheduleHelperTest.java
public void testCreateUpdateSchedule() throws Exception { // create test data User user = testHelper.makeDummyUser("user1", "user1"); userService.createUser(user);/*from w w w .j a va 2 s.c om*/ Assert.assertEquals(0, user.getPreferences().size()); HashMap<String, String> scheduleProps = new HashMap<String, String>(); scheduleProps.put("enabled", "true"); scheduleProps.put("foo", "bar"); Schedule schedule = new Schedule("1", scheduleProps); helper.addScheduleToUser(user, schedule); Assert.assertEquals(2, user.getPreferences().size()); Assert.assertEquals("true", user.getPreference("cosmo.scheduler.job.1.enabled").getValue()); Assert.assertEquals("bar", user.getPreference("cosmo.scheduler.job.1.foo").getValue()); try { //shouldn't be able to create now helper.addScheduleToUser(user, schedule); Assert.fail("able to create same schdule twice!"); } catch (IllegalArgumentException e) { } schedule.getProperties().put("foo2", "bar2"); schedule.getProperties().put("enabled", "false"); schedule.getProperties().remove("foo"); helper.updateScheduleForUser(user, schedule); Assert.assertEquals(2, user.getPreferences().size()); Assert.assertEquals("false", user.getPreference("cosmo.scheduler.job.1.enabled").getValue()); Assert.assertEquals("bar2", user.getPreference("cosmo.scheduler.job.1.foo2").getValue()); Assert.assertNull(user.getPreference("cosmo.scheduler.job.1.foo")); try { //shouldn't be able to update non-existent schedule.setName("2"); helper.updateScheduleForUser(user, schedule); Assert.fail("able to update non existent schedule!"); } catch (IllegalArgumentException e) { } }
From source file:org.osaf.cosmo.service.impl.StandardContentServiceTest.java
/** */ public void testUpdateEvent() throws Exception { User user = testHelper.makeDummyUser(); CollectionItem rootCollection = contentDao.createRootItem(user); NoteItem masterNote = new MockNoteItem(); masterNote.setName("foo"); masterNote.setOwner(user);//from www . j a va 2 s . c o m Calendar calendar = getCalendar("event_with_exceptions1.ics"); EventStamp eventStamp = new MockEventStamp(masterNote); masterNote.addStamp(eventStamp); contentDao.createContent(rootCollection, masterNote); EntityConverter converter = new EntityConverter(testHelper.getEntityFactory()); Set<ContentItem> toUpdate = new HashSet<ContentItem>(); toUpdate.addAll(converter.convertEventCalendar(masterNote, calendar)); service.updateContentItems(masterNote.getParents(), toUpdate); Calendar masterCal = eventStamp.getEventCalendar(); VEvent masterEvent = eventStamp.getMasterEvent(); Assert.assertEquals(1, masterCal.getComponents().getComponents(Component.VEVENT).size()); Assert.assertNull(eventStamp.getMasterEvent().getRecurrenceId()); Assert.assertEquals(masterNote.getModifications().size(), 4); for (NoteItem mod : masterNote.getModifications()) { EventExceptionStamp eventException = StampUtils.getEventExceptionStamp(mod); VEvent exceptionEvent = eventException.getExceptionEvent(); Assert.assertEquals(mod.getModifies(), masterNote); Assert.assertEquals(masterEvent.getUid().getValue(), exceptionEvent.getUid().getValue()); } Calendar fullCal = converter.convertNote(masterNote); Assert.assertNotNull(getEvent("20060104T140000", fullCal)); Assert.assertNotNull(getEvent("20060105T140000", fullCal)); Assert.assertNotNull(getEvent("20060106T140000", fullCal)); Assert.assertNotNull(getEvent("20060107T140000", fullCal)); Assert.assertNotNull(getEventException("20060104T140000", masterNote.getModifications())); Assert.assertNotNull(getEventException("20060105T140000", masterNote.getModifications())); Assert.assertNotNull(getEventException("20060106T140000", masterNote.getModifications())); Assert.assertNotNull(getEventException("20060107T140000", masterNote.getModifications())); Assert.assertEquals(fullCal.getComponents().getComponents(Component.VEVENT).size(), 5); // now update calendar = getCalendar("event_with_exceptions2.ics"); toUpdate.addAll(converter.convertEventCalendar(masterNote, calendar)); service.updateContentItems(masterNote.getParents(), toUpdate); fullCal = converter.convertNote(masterNote); // should have removed 1, added 2 so that makes 4-1+2=5 Assert.assertEquals(masterNote.getModifications().size(), 5); Assert.assertNotNull(getEventException("20060104T140000", masterNote.getModifications())); Assert.assertNotNull(getEventException("20060105T140000", masterNote.getModifications())); Assert.assertNotNull(getEventException("20060106T140000", masterNote.getModifications())); Assert.assertNull(getEventException("20060107T140000", masterNote.getModifications())); Assert.assertNotNull(getEventException("20060108T140000", masterNote.getModifications())); Assert.assertNotNull(getEventException("20060109T140000", masterNote.getModifications())); Assert.assertNotNull(getEvent("20060104T140000", fullCal)); Assert.assertNotNull(getEvent("20060105T140000", fullCal)); Assert.assertNotNull(getEvent("20060106T140000", fullCal)); Assert.assertNull(getEvent("20060107T140000", fullCal)); Assert.assertNotNull(getEvent("20060108T140000", fullCal)); Assert.assertNotNull(getEvent("20060109T140000", fullCal)); }
From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.base.layout.model.ResultTable.java
private void assertEmptyBackground(final CellBackground background) { if (background == null) { return;//from w w w .j a v a2 s . com } Assert.assertEquals(background.getAnchors().length, 0); Assert.assertEquals(BorderEdge.EMPTY, background.getBottom()); Assert.assertEquals(BorderEdge.EMPTY, background.getTop()); Assert.assertEquals(BorderEdge.EMPTY, background.getLeft()); Assert.assertEquals(BorderEdge.EMPTY, background.getRight()); Assert.assertNull(background.getBackgroundColor()); }
From source file:org.red5.server.service.test.ConversionUtilsTest.java
public void testNullConvert() { Object result = ConversionUtils.convert(null, TestJavaBean.class); Assert.assertNull(result); result = ConversionUtils.convert(new TestJavaBean(), null); Assert.assertNull(result);/*from w ww. j av a 2 s . c o m*/ }
From source file:org.sakaiproject.coursemanagement.test.EnrollmentOnlyConfigurationTest.java
public void testSiteRoles() throws Exception { actAsUserEid(officialInstructorOfA); Site site = siteService.getSite(courseOfferingA); // Check for the officially enrolled (but waitlisted) student. Member member = site.getMember(waitListedStudentALec1); Assert.assertNotNull(member);//from w w w.j a v a2 s . c om Assert.assertEquals("Student", member.getRole().getId()); // Check for the student who was added directly to the site. member = site.getMember(unofficialStudentALec1); Assert.assertNotNull(member); Assert.assertEquals("Student", member.getRole().getId()); // Check for the expelled student. member = site.getMember(expelledStudentALec1); Assert.assertNull(member); // Check for the dropped student. member = site.getMember(droppedStudentALec1); Assert.assertNull(member); // Check for the enrollment record mapped to another role. member = site.getMember(taAsEnrollmentALec1); Assert.assertNotNull(member); Assert.assertEquals("Teaching Assistant", member.getRole().getId()); // Check for the student in a discussion section. member = site.getMember(studentADis1); Assert.assertNotNull(member); Assert.assertEquals("Student", member.getRole().getId()); // Check for a student in another course site. member = site.getMember(enrolledStudentBLec1); Assert.assertNull(member); // Check for non-integration of the TA. member = site.getMember(gsiALec1); Assert.assertNull(member); // Check for non-integration of the TA who also happens to be a DeptAdmin. member = site.getMember(deptAdminAndGsi); Assert.assertNull(member); // Check for the official instructor of the enrollment set. member = site.getMember(officialInstructorOfA); Assert.assertNotNull(member); Assert.assertEquals("Instructor", member.getRole().getId()); // Check for non-integration of the course offering member in the instructor role. member = site.getMember(unofficialInstructorOfA); Assert.assertNull(member); // Check for non-integration of the department administrator. member = site.getMember(deptAdminOfADept); Assert.assertNull(member); // Check for non-integration of the course admin. member = site.getMember(adminOfOfferingA); Assert.assertNull(member); // Check for an instructor in another course site. member = site.getMember(instructorOfB); Assert.assertNull(member); // Check for another department's administrator. member = site.getMember(deptAdminOfBDept); Assert.assertNull(member); }
From source file:org.sakaiproject.test.section.SectionManagerTest.java
public void testChangeMembershipOnDeletedSection() throws Exception { // These methods should gracefully handle operations on missing (possibly deleted) sections // Test joining a non-existent section Assert.assertNull(secMgr.joinSection("foo")); // Test switching into a non-existent section secMgr.switchSection("foo"); // Test setSectionMemberships on a non-existent section\ Set userSet = new HashSet(); userSet.add("user1"); secMgr.setSectionMemberships(userSet, Role.STUDENT, "foo"); }
From source file:org.sakaiproject.tool.gradebook.test.GradebookServiceNewTest.java
public void testGetGradeDefinitionForStudentForItem() throws Exception { setAuthnId(INSTRUCTOR_UID);// w w w . jav a 2 s . c om // start with a points-based gb GradeDefinition gradeDef = gradebookService.getGradeDefinitionForStudentForItem(GRADEBOOK_UID_NO_CAT, asn1IdNoCat, STUDENT_IN_SECTION_UID1); Assert.assertTrue(gradeDef != null); Assert.assertEquals(GradebookService.GRADE_TYPE_POINTS, gradeDef.getGradeEntryType()); Assert.assertEquals(STUDENT_IN_SECTION_UID1, gradeDef.getStudentUid()); Assert.assertTrue(gradeDef.isGradeReleased() == false); Assert.assertNull(gradeDef.getGrade()); Assert.assertNull(gradeDef.getGraderUid()); Assert.assertNull(gradeDef.getDateRecorded()); String graderComment = "grader comment"; gradebookService.setAssignmentScoreString(GRADEBOOK_UID_NO_CAT, ASN_TITLE1, STUDENT_IN_SECTION_UID1, new String("35"), "Service Test"); gradebookService.setAssignmentScoreComment(GRADEBOOK_UID_NO_CAT, ASN_TITLE1, STUDENT_IN_SECTION_UID1, graderComment); gradeDef = gradebookService.getGradeDefinitionForStudentForItem(GRADEBOOK_UID_NO_CAT, asn1IdNoCat, STUDENT_IN_SECTION_UID1); Assert.assertTrue(gradeDef != null); Assert.assertEquals(GradebookService.GRADE_TYPE_POINTS, gradeDef.getGradeEntryType()); Assert.assertEquals(STUDENT_IN_SECTION_UID1, gradeDef.getStudentUid()); Assert.assertTrue(gradeDef.isGradeReleased() == false); Assert.assertEquals("35.0", gradeDef.getGrade()); Assert.assertEquals(INSTRUCTOR_UID, gradeDef.getGraderUid()); Assert.assertEquals(graderComment, gradeDef.getGradeComment()); Assert.assertNotNull(gradeDef.getDateRecorded()); setAuthnId(STUDENT_IN_SECTION_UID1); gradeDef = gradebookService.getGradeDefinitionForStudentForItem(GRADEBOOK_UID_NO_CAT, asn1IdNoCat, STUDENT_IN_SECTION_UID1); // the grade is not released, so grade info should be null Assert.assertEquals(GradebookService.GRADE_TYPE_POINTS, gradeDef.getGradeEntryType()); Assert.assertEquals(STUDENT_IN_SECTION_UID1, gradeDef.getStudentUid()); Assert.assertTrue(gradeDef.isGradeReleased() == false); Assert.assertNull(gradeDef.getGrade()); // should be null if grade not released Assert.assertNull(gradeDef.getGradeComment()); // should be null if grade not released Assert.assertNull(gradeDef.getGraderUid()); // should be null if grade not released Assert.assertNull(gradeDef.getDateRecorded()); // should be null if grade not released // switch back to instructor and double check other grade entry types setAuthnId(INSTRUCTOR_UID); // %-based gradebook Gradebook gradebookNoCat = gradebookManager.getGradebook(GRADEBOOK_UID_NO_CAT); gradebookNoCat.setGrade_type(GradebookService.GRADE_TYPE_PERCENTAGE); gradebookManager.updateGradebook(gradebookNoCat); gradeDef = gradebookService.getGradeDefinitionForStudentForItem(GRADEBOOK_UID_NO_CAT, asn1IdNoCat, STUDENT_IN_SECTION_UID1); Assert.assertEquals("87.5", gradeDef.getGrade()); Assert.assertEquals(graderComment, gradeDef.getGradeComment()); Assert.assertEquals(GradebookService.GRADE_TYPE_PERCENTAGE, gradeDef.getGradeEntryType()); // letter-based gradebook gradebookNoCat.setGrade_type(GradebookService.GRADE_TYPE_LETTER); gradebookManager.updateGradebook(gradebookNoCat); gradeDef = gradebookService.getGradeDefinitionForStudentForItem(GRADEBOOK_UID_NO_CAT, asn1IdNoCat, STUDENT_IN_SECTION_UID1); Assert.assertEquals("B+", gradeDef.getGrade()); Assert.assertEquals(graderComment, gradeDef.getGradeComment()); Assert.assertEquals(GradebookService.GRADE_TYPE_LETTER, gradeDef.getGradeEntryType()); // the TA with standard grader perms should trigger exception for student // not in section setAuthnId(TA_UID); try { gradeDef = gradebookService.getGradeDefinitionForStudentForItem(GRADEBOOK_UID_NO_CAT, asn1IdNoCat, STUDENT_NOT_IN_SECTION_UID1); Assert.fail(); } catch (SecurityException se) { } // let's release the grade and make sure the student can access it setAuthnId(INSTRUCTOR_UID); org.sakaiproject.tool.gradebook.Assignment assignment = gradebookManager.getAssignment(asn1IdNoCat); assignment.setReleased(true); gradebookManager.updateAssignment(assignment); setAuthnId(STUDENT_IN_SECTION_UID1); gradeDef = gradebookService.getGradeDefinitionForStudentForItem(GRADEBOOK_UID_NO_CAT, asn1IdNoCat, STUDENT_IN_SECTION_UID1); Assert.assertEquals(GradebookService.GRADE_TYPE_LETTER, gradeDef.getGradeEntryType()); Assert.assertEquals(STUDENT_IN_SECTION_UID1, gradeDef.getStudentUid()); Assert.assertTrue(gradeDef.isGradeReleased()); Assert.assertEquals("B+", gradeDef.getGrade()); Assert.assertEquals(graderComment, gradeDef.getGradeComment()); Assert.assertEquals(INSTRUCTOR_UID, gradeDef.getGraderUid()); Assert.assertNotNull(gradeDef.getDateRecorded()); // try to retrieve another student's score try { gradeDef = gradebookService.getGradeDefinitionForStudentForItem(GRADEBOOK_UID_NO_CAT, asn1IdNoCat, STUDENT_IN_SECTION_UID2); fail("Did not catch a student trying to retrieve another student's grade info!"); } catch (SecurityException se) { } }
From source file:org.slc.sli.api.service.BasicServiceTest.java
@Test public void testPatchBasedOnContextualRolesWithEmptyPatchBody() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { securityContextInjector.setStaffContext(); service = (BasicService) context.getBean("basicService", "student", new ArrayList<Treatment>(), securityRepo);/* w w w. ja v a2 s . co m*/ EntityDefinition studentDef = factory.makeEntity("student").exposeAs("students").build(); service.setDefn(studentDef); EntityBody studentBody = new EntityBody(); studentBody.put("studentUniqueStateId", "123"); Entity student = securityRepo.create(EntityNames.STUDENT, studentBody); EntityBody ssaBody = new EntityBody(); ssaBody.put(ParameterConstants.STUDENT_ID, student.getEntityId()); ssaBody.put(ParameterConstants.SCHOOL_ID, SecurityContextInjector.ED_ORG_ID); securityRepo.create(EntityNames.STUDENT_SCHOOL_ASSOCIATION, ssaBody); securityRepo.createWithRetries(EntityNames.EDUCATION_ORGANIZATION, SecurityContextInjector.ED_ORG_ID, new HashMap<String, Object>(), new HashMap<String, Object>(), EntityNames.EDUCATION_ORGANIZATION, 1); EntityBody putEntity = new EntityBody(); boolean result = service.patch(student.getEntityId(), putEntity, true); Assert.assertFalse(result); Entity studentResult = securityRepo.findById(EntityNames.STUDENT, student.getEntityId()); Assert.assertNotNull(studentResult.getBody()); Assert.assertNotNull(studentResult.getBody().get("studentUniqueStateId")); Assert.assertEquals("123", studentResult.getBody().get("studentUniqueStateId")); Assert.assertNull(studentResult.getBody().get("schoolFoodServicesEligibility")); }
From source file:org.soybeanMilk.test.unit.core.TestDefaultExecutor.java
@Test public void execute_executionIsCreated() throws Exception { HashMapObjectSource os = new HashMapObjectSource(); executor.execute(KEY_EXE_HELLO, os); Execution re = os.get(KEY_EXECUTION); Assert.assertEquals(os, re.getObjectSource()); Assert.assertEquals(KEY_EXE_HELLO, re.getExecutable().getName()); Assert.assertNull(re.getExecuteException()); }