/** * Test notifications on 1) addDatastream 2) modifyDatastreamByReference 3) * modifyDatastreamByValue 4) setDatastreamState 5) setDatastreamVersionable 6) purgeDatastream * * @throws Exception */ public void testDatastreamMethodNotifications() throws Exception { // (1) test addDatastream System.out.println("Running TestManagementNotifications.testAddDatastream..."); String[] altIds = new String[1]; altIds[0] = "Datastream Alternate ID"; String pid = "demo:14"; String datastreamId = apim.addDatastream( pid, "NEWDS1", altIds, "A New M-type Datastream", true, "text/xml", "info:myFormatURI/Mtype/stuff#junk", getBaseURL() + "/get/fedora-system:ContentModel-3.0/DC", "M", "A", null, null, "adding new datastream"); // test that datastream was added assertEquals(datastreamId, "NEWDS1"); // Check on the notification produced by addDatastream checkNotification(pid, "addDatastream"); datastreamId = apim.addDatastream( pid, "NEWDS2", altIds, "A New X-type Datastream", true, "text/xml", "info:myFormatURI/Mtype/stuff#junk", getBaseURL() + "/get/fedora-system:ContentModel-3.0/DC", "X", "A", null, null, "adding new datastream"); // test that datastream was added assertEquals(datastreamId, "NEWDS2"); // Check on the notification produced by addDatastream checkNotification(pid, "addDatastream"); // (2) test modifyDatastreamByReference System.out.println("Running TestManagementNotifications.testModifyDatastreamByReference..."); String updateTimestamp = apim.modifyDatastreamByReference( pid, "NEWDS1", altIds, "Modified Datastream by Reference", "text/xml", "info:newMyFormatURI/Mtype/stuff#junk", getBaseURL() + "/get/fedora-system:ContentModel-3.0/DC", null, null, "modified datastream", false); // test that method returned properly assertNotNull(updateTimestamp); // Check on the notification produced by modifyDatastreamByReference checkNotification(pid, "modifyDatastreamByReference"); // (3) test modifyDatastreamByValue System.out.println("Running TestManagementNotifications.testModifyDatastreamByValue..."); updateTimestamp = apim.modifyDatastreamByValue( pid, "NEWDS2", altIds, "Modified Datastream by Value", "text/xml", "info:newMyFormatURI/Xtype/stuff#junk", dsXML, null, null, "modified datastream", false); // test that method returned properly assertNotNull(updateTimestamp); // Check on the notification produced by modifyDatastreamByValue checkNotification(pid, "modifyDatastreamByValue"); // (4) test setDatastreamState System.out.println("Running TestManagementNotifications.testSetDatastreamState..."); String setStateresult = apim.setDatastreamState(pid, "NEWDS1", "I", "Changed state of datstream DC to Inactive"); assertNotNull(setStateresult); // Check on the notification produced by setDatastreamState checkNotification(pid, "setDatastreamState"); // (5) test setDatastreamVersionable System.out.println("Running TestManagementNotifications.testSetDatastreamVersionable..."); String setVersionableResult = apim.setDatastreamVersionable( pid, "NEWDS2", false, "Changed versionable on datastream NEWDS1 to false"); assertNotNull(setVersionableResult); // Check on the notification produced by setDatastreamVersionable checkNotification(pid, "setDatastreamVersionable"); // (5) test purgeDatastream System.out.println("Running TestManagementNotifications.testPurgeDatastream..."); String[] results = apim.purgeDatastream(pid, "NEWDS1", null, null, "purging datastream NEWDS1", false); assertTrue(results.length > 0); // Check on the notification produced by purgeDatastream checkNotification(pid, "purgeDatastream"); results = apim.purgeDatastream(pid, "NEWDS2", null, null, "purging datastream NEWDS2", false); assertTrue(results.length > 0); // Check on the notification produced by purgeDatastream checkNotification(pid, "purgeDatastream"); }