Revision 4303
Added by daigle over 16 years ago
test/edu/ucsb/nceas/metacattest/client/MetacatClientTest.java | ||
---|---|---|
178 | 178 |
*/ |
179 | 179 |
public void login() |
180 | 180 |
{ |
181 |
debug("\nStarting login test..."); |
|
181 | 182 |
// Try a valid login |
182 | 183 |
try { |
183 | 184 |
String response = m.login(username, password); |
... | ... | |
200 | 201 |
*/ |
201 | 202 |
public void invalidLogin() |
202 | 203 |
{ |
204 |
debug("\nStarting invalidLogin test..."); |
|
203 | 205 |
// Try an invalid login |
204 | 206 |
try { |
205 | 207 |
m.login(username, failpass); |
... | ... | |
217 | 219 |
*/ |
218 | 220 |
public void logoutAndInvalidInsert() |
219 | 221 |
{ |
222 |
debug("\nStarting logoutAndInvalidInsert test..."); |
|
220 | 223 |
try { |
221 | 224 |
String identifier = newdocid + ".1"; |
222 | 225 |
m.login(username, password); |
... | ... | |
246 | 249 |
*/ |
247 | 250 |
public void read() |
248 | 251 |
{ |
252 |
debug("\nStarting read test..."); |
|
249 | 253 |
try { |
250 | 254 |
m.login(username, password); |
251 | 255 |
String docid = readIdFromFile(DOCID); |
... | ... | |
268 | 272 |
*/ |
269 | 273 |
public void invalidRead() |
270 | 274 |
{ |
275 |
debug("\nStarting invalidRead test..."); |
|
271 | 276 |
try { |
272 | 277 |
m.login(anotheruser, anotherpassword); |
273 | 278 |
String docid = readIdFromFile(DOCID); |
... | ... | |
298 | 303 |
*/ |
299 | 304 |
public void query() |
300 | 305 |
{ |
306 |
debug("\nStarting query test..."); |
|
301 | 307 |
try { |
302 | 308 |
m.login(username,password); |
303 | 309 |
FileReader fr = new FileReader(queryFile); |
304 | 310 |
Reader r = m.query(fr); |
305 |
debug("Starting query test..."); |
|
306 | 311 |
String result = IOUtil.getAsString(r, true); |
307 | 312 |
debug("query(): Query result=\n" + result); |
308 | 313 |
String docid = readIdFromFile(DOCID); |
... | ... | |
321 | 326 |
*/ |
322 | 327 |
public void queryWithQformat() |
323 | 328 |
{ |
329 |
debug("\nStarting queryWithQformat test..."); |
|
324 | 330 |
try { |
325 | 331 |
m.login(username,password); |
326 | 332 |
FileReader fr = new FileReader(queryFile); |
327 | 333 |
String qformat = "knb"; |
328 | 334 |
Reader r = m.query(fr, qformat); |
329 |
debug("Starting queryWithQformat test..."); |
|
330 | 335 |
String result = IOUtil.getAsString(r, true); |
331 | 336 |
debug("queryWithQformat(): Query result=\n" + result); |
332 | 337 |
String docid = readIdFromFile(DOCID); |
... | ... | |
346 | 351 |
*/ |
347 | 352 |
public void insert() |
348 | 353 |
{ |
354 |
debug("\nStarting insert test..."); |
|
349 | 355 |
try { |
350 | 356 |
String identifier = newdocid + ".1"; |
351 | 357 |
//write newdocid into file for persistance |
... | ... | |
379 | 385 |
*/ |
380 | 386 |
public void upload() |
381 | 387 |
{ |
388 |
debug("\nStarting upload test..."); |
|
382 | 389 |
try { |
383 | 390 |
newdocid = generateDocid(); |
384 | 391 |
String identifier = newdocid + ".1"; |
... | ... | |
428 | 435 |
*/ |
429 | 436 |
public void upload_stream() |
430 | 437 |
{ |
438 |
debug("\nStarting upload_stream test..."); |
|
431 | 439 |
try { |
432 | 440 |
newdocid = generateDocid(); |
433 | 441 |
String identifier = newdocid + ".1"; |
... | ... | |
469 | 477 |
*/ |
470 | 478 |
public void invalidUpdate() |
471 | 479 |
{ |
480 |
debug("\nStarting invalidUpdate test..."); |
|
472 | 481 |
try { |
473 | 482 |
String docid = readIdFromFile(DOCID); |
474 | 483 |
String identifier = docid + ".2"; |
... | ... | |
495 | 504 |
*/ |
496 | 505 |
public void update() |
497 | 506 |
{ |
507 |
debug("\nStarting update test..."); |
|
498 | 508 |
try { |
499 | 509 |
String docid = readIdFromFile(DOCID); |
500 | 510 |
String identifier = docid + ".2"; |
... | ... | |
523 | 533 |
*/ |
524 | 534 |
public void invalidDelete() |
525 | 535 |
{ |
536 |
debug("\nStarting invalidDelete test..."); |
|
526 | 537 |
try { |
527 | 538 |
String identifier = newdocid + ".2"; |
528 | 539 |
m.login(anotheruser, anotherpassword); |
... | ... | |
548 | 559 |
*/ |
549 | 560 |
public void delete() |
550 | 561 |
{ |
562 |
debug("\nStarting delete test..."); |
|
551 | 563 |
try { |
552 | 564 |
Thread.sleep(10000); |
553 | 565 |
String docid = readIdFromFile(DOCID); |
... | ... | |
580 | 592 |
*/ |
581 | 593 |
public void inaccessibleMetacat() |
582 | 594 |
{ |
595 |
debug("\nStarting inaccessibleMetacat test..."); |
|
583 | 596 |
Metacat mWrong = null; |
584 | 597 |
try { |
585 | 598 |
mWrong = MetacatFactory.createMetacatConnection(wrongMetacatUrl); |
... | ... | |
603 | 616 |
*/ |
604 | 617 |
public void reuseSession() |
605 | 618 |
{ |
619 |
debug("\nStarting reuseSession test..."); |
|
606 | 620 |
String oldSessionId = ""; |
607 | 621 |
try { |
622 |
debug("creating metacat connection to: " + metacatUrl); |
|
608 | 623 |
Metacat mtemp = MetacatFactory.createMetacatConnection(metacatUrl); |
624 |
debug("creating metacat connection with credentials: " + username + ":" + password); |
|
609 | 625 |
String response = mtemp.login(username, password); |
610 | 626 |
oldSessionId = mtemp.getSessionId(); |
611 |
debug("reuseSession(): SessionId(mtemp)=" + oldSessionId);
|
|
627 |
debug("preparing to reuse session with oldSessionId:" + oldSessionId);
|
|
612 | 628 |
} catch (MetacatAuthException mae) { |
613 | 629 |
fail("Authorization failed:\n" + mae.getMessage()); |
614 | 630 |
} catch (MetacatInaccessibleException mie) { |
... | ... | |
620 | 636 |
String identifier = generateDocid() + ".1"; |
621 | 637 |
Metacat m2 = null; |
622 | 638 |
try { |
639 |
debug("Creating second connection and logging out of it."); |
|
623 | 640 |
m2 = MetacatFactory.createMetacatConnection(metacatUrl); |
641 |
m2.login(username, password); |
|
624 | 642 |
m2.logout(); |
625 | 643 |
} catch (MetacatInaccessibleException mie) { |
626 |
System.err.println("Metacat is: " + metacatUrl); |
|
644 |
System.err.println("Could not connect to metacat at: " + metacatUrl |
|
645 |
+ " : " + mie.getMessage()); |
|
627 | 646 |
fail("Metacat connection failed." + mie.getMessage()); |
628 | 647 |
} |
629 |
debug("reuseSession(): SessionId(m2)=" + m2.getSessionId()); |
|
630 | 648 |
m2.setSessionId(oldSessionId); |
631 |
debug("reuseSession(): SessionId(m2 after set)=" + m2.getSessionId());
|
|
649 |
debug("Reusing second session with session id :" + m2.getSessionId());
|
|
632 | 650 |
String response = m2.insert(identifier, |
633 | 651 |
new StringReader(testdocument), null); |
634 |
debug("reuseSession(): Reuse Insert response=" + response);
|
|
652 |
debug("Reuse second session insert response: " + response);
|
|
635 | 653 |
assertTrue(response.indexOf("<success>") != -1); |
636 | 654 |
} catch (MetacatInaccessibleException mie) { |
637 | 655 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
... | ... | |
692 | 710 |
*/ |
693 | 711 |
public void getLastDocid() |
694 | 712 |
{ |
713 |
debug("\nStarting getLastDocid test..."); |
|
695 | 714 |
try { |
696 | 715 |
Metacat m3 = null; |
697 | 716 |
try { |
... | ... | |
750 | 769 |
*/ |
751 | 770 |
public void insertSpatialDocs() throws IOException |
752 | 771 |
{ |
772 |
debug("\nStarting insertSpatialDocs test..."); |
|
773 |
|
|
753 | 774 |
FileReader fr = new FileReader(spatialTestFile); |
754 | 775 |
String spatialtestdocument = IOUtil.getAsString(fr, true); |
755 | 776 |
debug("insertSpatialDocs(): the eml is "+spatialtestdocument); |
Also available in: Unified diff
Add debug statements