Index: lams_tool_nb/test/java/org/lamsfoundation/lams/tool/noticeboard/service/TestNoticeboardServicePOJO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/test/java/org/lamsfoundation/lams/tool/noticeboard/service/Attic/TestNoticeboardServicePOJO.java,v diff -u -r1.6 -r1.7 --- lams_tool_nb/test/java/org/lamsfoundation/lams/tool/noticeboard/service/TestNoticeboardServicePOJO.java 21 Jul 2005 04:39:05 -0000 1.6 +++ lams_tool_nb/test/java/org/lamsfoundation/lams/tool/noticeboard/service/TestNoticeboardServicePOJO.java 29 Jul 2005 04:33:07 -0000 1.7 @@ -34,6 +34,7 @@ import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment; import org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService; @@ -48,6 +49,7 @@ private NoticeboardContent nbContent; private NoticeboardSession nbSession; private NoticeboardUser nbUser; + private NoticeboardAttachment attachment; private boolean cleanContentData = true; @@ -60,9 +62,10 @@ protected void setUp() throws Exception { super.setUp(); - //setup some data + nbService = (INoticeboardService)this.context.getBean("nbService"); super.initAllData(); + } protected void tearDown() throws Exception @@ -415,6 +418,54 @@ } + + /* ============================================================================== + * Methods for access to NoticeboardAttachment objects + * ============================================================================== + */ + + public void testRetrieveAttachment() + { + initNbAttachmentData(); + //test retrieveAttachmentByUuid + attachment = nbService.retrieveAttachmentByUuid(TEST_UUID); + + assertAttachmentData(attachment); + /* test getAttachmentsFromContent which will return a list of attachment ids, which we can use in the next method call to + retrieveAttachment which takes in the attachmentId as the parameter. */ + List idList = nbService.getAttachmentIdsFromContent(nbService.retrieveNoticeboard(TEST_NB_ID)); + + //test retrieveAttachment (by attachmentId, which was retrieved from the previous method) + attachment = nbService.retrieveAttachment((Long)idList.get(0)); + assertAttachmentData(attachment); + } + + public void testSaveAttachment() + { + String newFilename = "NoticeboardInstructions.txt"; + initNbAttachmentData(); + + attachment = nbService.retrieveAttachmentByUuid(TEST_UUID); + attachment.setFilename(newFilename); + + nbService.saveAttachment(attachment); + + attachment = nbService.retrieveAttachmentByUuid(TEST_UUID); + assertEquals(attachment.getFilename(), newFilename); + } + + public void testRemoveAttachment() + { + initNbAttachmentData(); + attachment = nbService.retrieveAttachmentByUuid(TEST_UUID); + + nbService.removeAttachment(attachment); + + attachment = nbService.retrieveAttachmentByUuid(TEST_UUID); + + assertNull(attachment); + + } } \ No newline at end of file