public void testSelectors() throws Exception {
    System.out.println("Running TestManagementNotifications.testSelectors...");
    messageConsumer.close();

    String messageSelector = "methodName LIKE 'ingest%'";
    messageConsumer = jmsSession.createConsumer(destination, messageSelector);
    messageConsumer.setMessageListener(this);

    // Ingest - message should be delivered
    String pid = apim.ingest(demo998FOXMLObjectXML, FOXML1_1.uri, "ingesting new foxml object");
    assertNotNull(pid);
    checkNotification(pid, "ingest");

    // Purge - message selector should prevent message from being delivered
    String purgeResult = apim.purgeObject(pid, "Purging object " + pid, false);
    assertNotNull(purgeResult);
    checkNoNotifications();
  }
Example #2
0
 public static void purge(FedoraAPIM skeleton, String pid, String logMessage, boolean force)
     throws RemoteException, IOException {
   skeleton.purgeObject(pid, logMessage, force);
 }
  /**
   * 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");
  }
  /**
   * Tests notifications on 1) ingest 2) modifyObject 3) addRelationship 4) purgeRelationship 5)
   * purgeObject
   *
   * @throws Exception
   */
  public void testObjectMethodNotifications() throws Exception {

    // (1) test ingest
    System.out.println("Running TestManagementNotifications.testIngest...");
    String pid = apim.ingest(demo998FOXMLObjectXML, FOXML1_1.uri, "ingesting new foxml object");
    assertNotNull(pid);

    // Check on the notification produced by ingest
    checkNotification(pid, "ingest");

    // (2) test modifyObject
    System.out.println("Running TestManagementNotifications.testModifyObject...");
    String modifyResult =
        apim.modifyObject(
            pid, "I", "Updated Object Label", null, "Changed state to inactive and updated label");
    assertNotNull(modifyResult);

    // Check on the notification produced by modifyObject
    checkNotification(pid, "modifyObject");

    // (3a) test addRelationship - pid
    System.out.println("Running TestManagementNotifications.testAddRelationship...");
    boolean addRelResult = apim.addRelationship(pid, "rel:isRelatedTo", "demo:5", false, null);
    assertTrue(addRelResult);

    // Check on the notification produced by addRelationship
    checkNotification(pid, "addRelationship");

    // (3b) test addRelationship - object uri
    System.out.println("Running TestManagementNotifications.testAddRelationship...");
    addRelResult = apim.addRelationship(PID.toURI(pid), "rel:isRelatedTo", "demo:6", false, null);
    assertTrue(addRelResult);

    // Check on the notification produced by addRelationship
    checkNotification(pid, "addRelationship");

    // (3c) test addRelationship - datastream uri
    System.out.println("Running TestManagementNotifications.testAddRelationship...");
    addRelResult =
        apim.addRelationship(PID.toURI(pid) + "/DS1", "rel:isRelatedTo", "demo:7", false, null);
    assertTrue(addRelResult);

    // Check on the notification produced by addRelationship
    checkNotification(pid, "addRelationship");

    // (4a) test purgeRelationship - pid
    System.out.println("Running TestManagementNotifications.testPurgeRelationship...");
    boolean purgeRelResult = apim.purgeRelationship(pid, "rel:isRelatedTo", "demo:5", false, null);
    assertTrue(purgeRelResult);

    // Check on the notification produced by purgeRelationship
    checkNotification(pid, "purgeRelationship");

    // (4b) test purgeRelationship - object uri
    System.out.println("Running TestManagementNotifications.testPurgeRelationship...");
    purgeRelResult =
        apim.purgeRelationship(PID.toURI(pid), "rel:isRelatedTo", "demo:6", false, null);
    assertTrue(purgeRelResult);

    // Check on the notification produced by purgeRelationship
    checkNotification(pid, "purgeRelationship");

    // (4c) test purgeRelationship - datastream uri
    System.out.println("Running TestManagementNotifications.testPurgeRelationship...");
    purgeRelResult =
        apim.purgeRelationship(PID.toURI(pid) + "/DS1", "rel:isRelatedTo", "demo:7", false, null);
    assertTrue(purgeRelResult);

    // Check on the notification produced by purgeRelationship
    checkNotification(pid, "purgeRelationship");

    // (5) test purgeObject
    System.out.println("Running TestManagementNotifications.testPurgeObject...");
    String purgeResult = apim.purgeObject(pid, "Purging object " + pid, false);
    assertNotNull(purgeResult);

    // Check on the notification produced by purgeObject
    checkNotification(pid, "purgeObject");
  }