Project

General

Profile

« Previous | Next » 

Revision 2338

Added by Jing Tao almost 20 years ago

Add a new test case for testing get newest revision number.

View differences:

test/edu/ucsb/nceas/metacattest/client/MetacatClientTest.java
119 119
      suite.addTest(new MetacatClientTest("logoutAndInvalidInsert"));
120 120
      suite.addTest(new MetacatClientTest("login"));
121 121
      suite.addTest(new MetacatClientTest("insert"));
122
      suite.addTest(new MetacatClientTest("getNewestDocRevision"));
122 123
      suite.addTest(new MetacatClientTest("upload"));
123 124
      suite.addTest(new MetacatClientTest("upload_stream"));
124 125
      suite.addTest(new MetacatClientTest("invalidRead"));
......
582 583
            fail("General exception:\n" + e.getMessage());
583 584
        }
584 585
    }
586
    
585 587
    /**
588
    * Try to perform an action that requires a session to be valid without
589
    * having logged in first, but use an invalid session identifier.
590
    * Then insert a document, which should fail.
591
    */
592
   public void getNewestDocRevision()
593
   {
594
       System.err.println("Starting getNewestDocRevision test...");
595
       try {
596
           
597
           Metacat m3 = null;
598
           try {
599
               m3 = MetacatFactory.createMetacatConnection(metacatUrl);
600
           } catch (MetacatInaccessibleException mie) {
601
               System.err.println("Metacat is: " + metacatUrl);
602
               fail("Metacat connection failed." + mie.getMessage());
603
           }
604
          
605
           int revision = m3.getNewestDocRevision(newdocid);
606
           System.err.println("Newest revision number is: " + revision);
607
           assertTrue(revision == 1);
608
       } catch (MetacatException me) {
609
           if(me.getMessage().
610
              indexOf("Permission denied for user public inser") == -1){
611
               fail("Metacat Error:\n" + me.getMessage());
612
           }
613
       } catch (Exception e) {
614
           fail("General exception:\n" + e.getMessage());
615
       }
616
   }
617

  
618
    
619
    /**
586 620
     * Create a hopefully unique docid for testing insert and update. Does
587 621
     * not include the 'revision' part of the id.
588 622
     *

Also available in: Unified diff