Project

General

Profile

« Previous | Next » 

Revision 10268

Added by Jing Tao over 7 years ago

Revised the method for testing replication. It did nothing but does test the replication between the mock mn and the local host.

View differences:

test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java
701 701
        Session session = getTestSession();
702 702
        Identifier guid = new Identifier();
703 703
        guid.setValue("testReplicate." + System.currentTimeMillis());
704
        InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
704
        System.out.println("======================the id need to be replicated is "+guid.getValue());
705
        InputStream object = new FileInputStream(new File(MockReplicationMNode.replicationSourceFile));
705 706
        SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
706
        // save locally
707
        Identifier pid = MNodeService.getInstance(request).create(session, guid, object, sysmeta);
708
        // get our node reference (attempting to replicate with self)
709
        NodeReference sourceNode = MNodeService.getInstance(request).getCapabilities().getIdentifier();
710
        // attempt to replicate with ourselves -- this should fail!
711
      boolean result = false;
712
      try {
707
        ObjectFormatIdentifier formatId = new ObjectFormatIdentifier();
708
        formatId.setValue("eml://ecoinformatics.org/eml-2.0.1");
709
        sysmeta.setFormatId(formatId);
710
        NodeReference sourceNode = new NodeReference();
711
        sourceNode.setValue(MockReplicationMNode.NODE_ID);
712
        sysmeta.setAuthoritativeMemberNode(sourceNode);
713
        sysmeta.setOriginMemberNode(sourceNode);
714
        boolean result = false;
713 715
        result = MNodeService.getInstance(request).replicate(session, sysmeta, sourceNode);
714
      } catch (Exception inu) {
715
        // we are expecting this to fail since we already have the doc
716
        result = true;
717
      }
718
      assertTrue(result);
716
        assertTrue(result);
717
        SystemMetadata sys =  MNodeService.getInstance(request).getSystemMetadata(session, guid);
718
        assertTrue(sys.getIdentifier().equals(guid));
719 719
      } catch (Exception e) {
720 720
        e.printStackTrace();
721 721
      fail("Probably not yet implemented: " + e.getMessage());

Also available in: Unified diff