Project

General

Profile

« Previous | Next » 

Revision 2987

Added by sgarg over 18 years ago

fix to the generateDocid() function so that the docid generated always is bigger than the earlier one.

View differences:

test/edu/ucsb/nceas/metacattest/client/MetacatClientTest.java
115 115
    {
116 116
      TestSuite suite = new TestSuite();
117 117
      suite.addTest(new MetacatClientTest("initialize"));
118
      //suite.addTest(new MetacatClientTest("invalidLogin"));
119
      //suite.addTest(new MetacatClientTest("logoutAndInvalidInsert"));
118
      suite.addTest(new MetacatClientTest("invalidLogin"));
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
      suite.addTest(new MetacatClientTest("getNewestDocRevision"));
123 123
      suite.addTest(new MetacatClientTest("getLastDocid"));
124
      //suite.addTest(new MetacatClientTest("upload"));
125
      //suite.addTest(new MetacatClientTest("upload_stream"));
126
      //suite.addTest(new MetacatClientTest("invalidRead"));
127
      //suite.addTest(new MetacatClientTest("read"));
128
      //suite.addTest(new MetacatClientTest("query"));
129
      //suite.addTest(new MetacatClientTest("invalidUpdate"));
130
      //suite.addTest(new MetacatClientTest("update"));
131
      //suite.addTest(new MetacatClientTest("invalidDelete"));
132
      //suite.addTest(new MetacatClientTest("delete"));
133
      //suite.addTest(new MetacatClientTest("inaccessibleMetacat"));
134
      //suite.addTest(new MetacatClientTest("reuseSession"));
135
      //suite.addTest(new MetacatClientTest("reuseInvalidSession"));
124
      suite.addTest(new MetacatClientTest("upload"));
125
      suite.addTest(new MetacatClientTest("upload_stream"));
126
      suite.addTest(new MetacatClientTest("invalidRead"));
127
      suite.addTest(new MetacatClientTest("read"));
128
      suite.addTest(new MetacatClientTest("query"));
129
      suite.addTest(new MetacatClientTest("invalidUpdate"));
130
      suite.addTest(new MetacatClientTest("update"));
131
      suite.addTest(new MetacatClientTest("invalidDelete"));
132
      suite.addTest(new MetacatClientTest("delete"));
133
      suite.addTest(new MetacatClientTest("inaccessibleMetacat"));
134
      suite.addTest(new MetacatClientTest("reuseSession"));
135
      suite.addTest(new MetacatClientTest("reuseInvalidSession"));
136 136
      return suite;
137 137
  }
138 138

  
......
650 650
     */
651 651
    private String generateDocid()
652 652
    {
653
        StringBuffer docid = new StringBuffer(prefix);
654
        docid.append(".");
655

  
656 653
        // Create a calendar to get the date formatted properly
657 654
        String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
658 655
        SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
......
661 658
        Calendar calendar = new GregorianCalendar(pdt);
662 659
        Date trialTime = new Date();
663 660
        calendar.setTime(trialTime);
664
        docid.append(calendar.get(Calendar.YEAR));
665
        docid.append(calendar.get(Calendar.DAY_OF_YEAR));
666
        docid.append(calendar.get(Calendar.HOUR_OF_DAY));
667
        docid.append(calendar.get(Calendar.MINUTE));
668
        docid.append(calendar.get(Calendar.SECOND));
669

  
670
        return docid.toString();
661
	String docid = String.format(prefix +".%1$tY%1$tj%1$tH%1$tM%1$tS", calendar);
662
        return docid;
671 663
    }
672 664
}

Also available in: Unified diff