Project

General

Profile

« Previous | Next » 

Revision 9264

Added by Jing Tao over 9 years ago

Add the test to test new rules: cn and other client calling the method on the authoritative node can call the mn.update.

View differences:

test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java
506 506
      } catch (Exception ee) {
507 507
          assertTrue( ee instanceof InvalidRequest);
508 508
      }
509
      
510
      //update the authoritative node on the existing pid (newPid)
511
      NodeReference newMN = new NodeReference();
512
      newMN.setValue("urn:node:river1");
513
      newSysMeta.setAuthoritativeMemberNode(newMN);
514
      newSysMeta.setArchived(false);
515
      MNodeService.getInstance(request).updateSystemMetadata(session, newPid, newSysMeta);
516
      try {
517
          updatedPid = 
518
                 MNodeService.getInstance(request).update(session, newPid, object, newPid2, newSysMeta2);
519
          fail("update an object on non-authoritatvie node should get anexception");
520
     } catch (Exception ee) {
521
         assertTrue( ee instanceof NotAuthorized);
522
     }
523
     //cn can succeed even though it updates an object on the non-authoritative node.
524
     Session cnSession = getCNSession();
525
     updatedPid = 
526
             MNodeService.getInstance(request).update(cnSession, newPid, object, newPid2, newSysMeta2);
527
     assertEquals(updatedPid.getValue(), newPid2.getValue());
509 528
    } catch (UnsupportedEncodingException e) {
510 529
      e.printStackTrace();
511 530
      fail("Unexpected error: " + e.getMessage());

Also available in: Unified diff