Revision 4151
Added by daigle over 16 years ago
test/edu/ucsb/nceas/metacattest/client/MetacatClientTest.java | ||
---|---|---|
119 | 119 |
} |
120 | 120 |
|
121 | 121 |
try { |
122 |
System.err.println("Test Metacat: " + metacatUrl);
|
|
122 |
debug("Test Metacat: " + metacatUrl);
|
|
123 | 123 |
m = MetacatFactory.createMetacatConnection(metacatUrl); |
124 | 124 |
} catch (MetacatInaccessibleException mie) { |
125 | 125 |
System.err.println("Metacat is: " + metacatUrl); |
... | ... | |
181 | 181 |
// Try a valid login |
182 | 182 |
try { |
183 | 183 |
String response = m.login(username, password); |
184 |
//System.err.println("Login response: " + response);
|
|
184 |
debug("login(): response=" + response);
|
|
185 | 185 |
assertTrue(response != null); |
186 | 186 |
assertTrue(response.indexOf("<login>") != -1); |
187 | 187 |
String sessionId = m.getSessionId(); |
188 |
//System.err.println("Session ID: " + m.getSessionId());
|
|
188 |
debug("login(): Session ID=" + m.getSessionId());
|
|
189 | 189 |
assertTrue(sessionId != null); |
190 | 190 |
assertTrue(response.indexOf(m.getSessionId()) != -1); |
191 | 191 |
} catch (MetacatAuthException mae) { |
... | ... | |
223 | 223 |
m.logout(); |
224 | 224 |
String response = m.insert(identifier, |
225 | 225 |
new StringReader(testdocument), null); |
226 |
//System.err.println("Response in logout: "+response);
|
|
226 |
debug("logoutAndInvalidInsert(): Response in logout="+response);
|
|
227 | 227 |
assertTrue(response.indexOf("<success>") == -1); |
228 | 228 |
} catch (MetacatAuthException mae) { |
229 | 229 |
fail("Authorization failed:\n" + mae.getMessage()); |
... | ... | |
252 | 252 |
Reader r = m.read(docid+".1"); |
253 | 253 |
String doc = IOUtil.getAsString(r, true); |
254 | 254 |
doc = doc +"\n"; |
255 |
//System.err.println(doc);
|
|
255 |
debug("read(): doc=" + doc);
|
|
256 | 256 |
assertTrue(doc.equals(testdocument)); |
257 | 257 |
} catch (MetacatAuthException mae) { |
258 | 258 |
fail("Authorization failed:\n" + mae.getMessage()); |
... | ... | |
274 | 274 |
Reader r = m.read(docid+".1"); |
275 | 275 |
String doc = IOUtil.getAsString(r, true); |
276 | 276 |
assertTrue(doc.indexOf("<error>") != -1); |
277 |
//System.err.println(doc);
|
|
277 |
debug("invalidRead(): doc="+ doc);
|
|
278 | 278 |
} catch (MetacatAuthException mae) { |
279 | 279 |
fail("Authorization failed:\n" + mae.getMessage()); |
280 | 280 |
} catch (MetacatInaccessibleException mie) { |
... | ... | |
302 | 302 |
m.login(username,password); |
303 | 303 |
FileReader fr = new FileReader(queryFile); |
304 | 304 |
Reader r = m.query(fr); |
305 |
//System.err.println("Starting query...");
|
|
305 |
debug("Starting query test...");
|
|
306 | 306 |
String result = IOUtil.getAsString(r, true); |
307 |
System.err.println("Query result:\n" + result);
|
|
307 |
debug("query(): Query result=\n" + result);
|
|
308 | 308 |
String docid = readIdFromFile(DOCID); |
309 | 309 |
assertTrue(result.indexOf(docid+".1")!=-1); |
310 | 310 |
assertTrue(result.indexOf("<?xml")!=-1); |
... | ... | |
326 | 326 |
FileReader fr = new FileReader(queryFile); |
327 | 327 |
String qformat = "knb"; |
328 | 328 |
Reader r = m.query(fr, qformat); |
329 |
//System.err.println("Starting query...");
|
|
329 |
debug("Starting queryWithQformat test...");
|
|
330 | 330 |
String result = IOUtil.getAsString(r, true); |
331 |
System.err.println("Query result:\n" + result);
|
|
331 |
debug("queryWithQformat(): Query result=\n" + result);
|
|
332 | 332 |
String docid = readIdFromFile(DOCID); |
333 | 333 |
assertTrue(result.indexOf(docid+".1")!=-1); |
334 | 334 |
assertTrue(result.indexOf("<html>")!=-1); |
... | ... | |
355 | 355 |
new StringReader(testdocument), null); |
356 | 356 |
assertTrue(response.indexOf("<success>") != -1); |
357 | 357 |
assertTrue(response.indexOf(identifier) != -1); |
358 |
//System.err.println(response);
|
|
358 |
debug("insert(): response=" + response);
|
|
359 | 359 |
|
360 | 360 |
} catch (MetacatAuthException mae) { |
361 | 361 |
fail("Authorization failed:\n" + mae.getMessage()); |
... | ... | |
393 | 393 |
new File(onlinetestdatafile)); |
394 | 394 |
assertTrue(response.indexOf("<success>") != -1); |
395 | 395 |
assertTrue(response.indexOf(identifier) != -1); |
396 |
//System.err.println(response);
|
|
396 |
debug("upload(): response=" + response);
|
|
397 | 397 |
//upload the same identifier again. it should return an error |
398 | 398 |
try |
399 | 399 |
{ |
... | ... | |
446 | 446 |
|
447 | 447 |
assertTrue(response.indexOf("<success>") != -1); |
448 | 448 |
assertTrue(response.indexOf(identifier) != -1); |
449 |
//System.err.println(response);
|
|
449 |
debug("upload_stream(): response=" + response);
|
|
450 | 450 |
|
451 | 451 |
} catch (MetacatAuthException mae) { |
452 | 452 |
fail("Authorization failed:\n" + mae.getMessage()); |
... | ... | |
503 | 503 |
new StringReader(testdocument), null); |
504 | 504 |
assertTrue(response.indexOf("<success>") != -1); |
505 | 505 |
assertTrue(response.indexOf(identifier) != -1); |
506 |
//System.err.println(response);
|
|
506 |
debug("update(): response=" + response);
|
|
507 | 507 |
|
508 | 508 |
} catch (MetacatAuthException mae) { |
509 | 509 |
fail("Authorization failed:\n" + mae.getMessage()); |
... | ... | |
528 | 528 |
m.login(anotheruser, anotherpassword); |
529 | 529 |
String response = m.delete(identifier); |
530 | 530 |
assertTrue(response.indexOf("<success>") == -1); |
531 |
//System.err.println(response);
|
|
531 |
debug("invalidDelete(): response=" + response);
|
|
532 | 532 |
|
533 | 533 |
} catch (MetacatAuthException mae) { |
534 | 534 |
fail("Authorization failed:\n" + mae.getMessage()); |
... | ... | |
558 | 558 |
// delete the docid persistence file. |
559 | 559 |
deleteFile(DOCID); |
560 | 560 |
deleteFile(DATAID); |
561 |
//System.err.println(response);
|
|
561 |
debug("delete(): response=" + response);
|
|
562 | 562 |
|
563 | 563 |
} catch (MetacatAuthException mae) { |
564 | 564 |
fail("Authorization failed:\n" + mae.getMessage()); |
... | ... | |
608 | 608 |
Metacat mtemp = MetacatFactory.createMetacatConnection(metacatUrl); |
609 | 609 |
String response = mtemp.login(username, password); |
610 | 610 |
oldSessionId = mtemp.getSessionId(); |
611 |
//System.err.println("SessionId (mtemp): " + oldSessionId);
|
|
611 |
debug("reuseSession(): SessionId(mtemp)=" + oldSessionId);
|
|
612 | 612 |
} catch (MetacatAuthException mae) { |
613 | 613 |
fail("Authorization failed:\n" + mae.getMessage()); |
614 | 614 |
} catch (MetacatInaccessibleException mie) { |
... | ... | |
626 | 626 |
System.err.println("Metacat is: " + metacatUrl); |
627 | 627 |
fail("Metacat connection failed." + mie.getMessage()); |
628 | 628 |
} |
629 |
System.err.println("SessionId (m2): " + m2.getSessionId());
|
|
629 |
debug("reuseSession(): SessionId(m2)=" + m2.getSessionId());
|
|
630 | 630 |
m2.setSessionId(oldSessionId); |
631 |
System.err.println("SessionId (m2 after set): " + m2.getSessionId());
|
|
631 |
debug("reuseSession(): SessionId(m2 after set)=" + m2.getSessionId());
|
|
632 | 632 |
String response = m2.insert(identifier, |
633 | 633 |
new StringReader(testdocument), null); |
634 |
System.err.println("Reuse Insert response: " + response);
|
|
634 |
debug("reuseSession(): Reuse Insert response=" + response);
|
|
635 | 635 |
assertTrue(response.indexOf("<success>") != -1); |
636 | 636 |
} catch (MetacatInaccessibleException mie) { |
637 | 637 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
... | ... | |
651 | 651 |
*/ |
652 | 652 |
public void reuseInvalidSession() |
653 | 653 |
{ |
654 |
System.err.println("Starting resuseInvalidSession test...");
|
|
654 |
debug("\nStarting resuseInvalidSession test...");
|
|
655 | 655 |
String oldSessionId = "foobar"; |
656 | 656 |
try { |
657 | 657 |
String identifier = generateDocid() + ".1"; |
... | ... | |
663 | 663 |
System.err.println("Metacat is: " + metacatUrl); |
664 | 664 |
fail("Metacat connection failed." + mie.getMessage()); |
665 | 665 |
} |
666 |
System.err.println("SessionId (m3): " + m3.getSessionId());
|
|
666 |
debug("reuseInvalidSession(): SessionId (m3): " + m3.getSessionId());
|
|
667 | 667 |
m3.setSessionId(oldSessionId); |
668 |
System.err.println("SessionId (m3 after set): " + m3.getSessionId()); |
|
669 |
System.err.println("Performing resuseInvalidSession insert: " + |
|
670 |
identifier); |
|
668 |
debug("reuseInvalidSession(): SessionId(m3 after set)=" + m3.getSessionId()); |
|
669 |
debug("reuseInvalidSession(): identifier=" + identifier); |
|
671 | 670 |
String response = m3.insert(identifier, |
672 | 671 |
new StringReader(testdocument), null); |
673 |
System.err.println("ReuseInvalid Insert response: " + response);
|
|
672 |
debug("reuseInvalidSession(): response=" + response);
|
|
674 | 673 |
assertTrue(response.indexOf("<success>") == -1); |
675 | 674 |
} catch (MetacatInaccessibleException mie) { |
676 | 675 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
... | ... | |
702 | 701 |
fail("Metacat connection failed." + mie.getMessage()); |
703 | 702 |
} |
704 | 703 |
String lastId = m3.getLastDocid(prefix); |
705 |
System.err.println("Last Id: " + lastId);
|
|
704 |
debug("getLastDocid(): Last Id=" + lastId);
|
|
706 | 705 |
//get docid from file |
707 | 706 |
String docid = readIdFromFile(DOCID); |
708 | 707 |
assertTrue(lastId.equals(docid + ".1")); |
... | ... | |
720 | 719 |
*/ |
721 | 720 |
public void getNewestDocRevision() |
722 | 721 |
{ |
723 |
//System.err.println("Starting getNewestDocRevision test...");
|
|
722 |
debug("\nStarting getNewestDocRevision test...");
|
|
724 | 723 |
try { |
725 | 724 |
|
726 | 725 |
Metacat m3 = null; |
... | ... | |
733 | 732 |
// get docid from file |
734 | 733 |
String docid = readIdFromFile(DOCID); |
735 | 734 |
int revision = m3.getNewestDocRevision(docid); |
736 |
//System.err.println("Newest revision number is: " + revision);
|
|
735 |
debug("getNewestDocRevision(): revision=" + revision);
|
|
737 | 736 |
assertTrue(revision == 1); |
738 | 737 |
} catch (MetacatException me) { |
739 | 738 |
if(me.getMessage(). |
... | ... | |
753 | 752 |
{ |
754 | 753 |
FileReader fr = new FileReader(spatialTestFile); |
755 | 754 |
String spatialtestdocument = IOUtil.getAsString(fr, true); |
756 |
System.out.println("the eml is "+spatialtestdocument);
|
|
755 |
debug("insertSpatialDocs(): the eml is "+spatialtestdocument);
|
|
757 | 756 |
for (int i=0; i<TIME; i++) |
758 | 757 |
{ |
759 | 758 |
try { |
760 | 759 |
newdocid = generateDocid(); |
761 | 760 |
String identifier = newdocid + ".1"; |
762 |
System.out.println("the docid is "+identifier);
|
|
761 |
debug("insertSpatialDocs(): the docid is "+identifier);
|
|
763 | 762 |
m.login(username, password); |
764 | 763 |
String response = m.insert(identifier, |
765 | 764 |
new StringReader(spatialtestdocument), null); |
... | ... | |
773 | 772 |
Thread.sleep(6000); |
774 | 773 |
String response2 = m.delete(identifier); |
775 | 774 |
assertTrue(response2.indexOf("<success>") != -1); |
776 |
//System.err.println(response);
|
|
775 |
debug("insertSpatialDocs(): response=" + response);
|
|
777 | 776 |
|
778 | 777 |
} catch (MetacatAuthException mae) { |
779 | 778 |
fail("Authorization failed:\n" + mae.getMessage()); |
Also available in: Unified diff
Add debug statements