Revision 5027
Added by daigle over 14 years ago
MCTestCase.java | ||
---|---|---|
55 | 55 |
import edu.ucsb.nceas.metacat.client.MetacatFactory; |
56 | 56 |
import edu.ucsb.nceas.metacat.client.MetacatInaccessibleException; |
57 | 57 |
import edu.ucsb.nceas.metacat.service.PropertyService; |
58 |
import edu.ucsb.nceas.metacat.service.ServiceException;
|
|
58 |
import edu.ucsb.nceas.metacat.shared.ServiceException;
|
|
59 | 59 |
import edu.ucsb.nceas.metacat.util.RequestUtil; |
60 | 60 |
import edu.ucsb.nceas.utilities.IOUtil; |
61 | 61 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
... | ... | |
381 | 381 |
protected void setUp() throws Exception { |
382 | 382 |
try { |
383 | 383 |
if (metacatConnectionNeeded) |
384 |
debug("Test Metacat: " + metacatUrl);
|
|
384 |
debug("setUp() - Testing Metacat Url: " + metacatUrl);
|
|
385 | 385 |
m = MetacatFactory.createMetacatConnection(metacatUrl); |
386 | 386 |
} catch (MetacatInaccessibleException mie) { |
387 | 387 |
System.err.println("Metacat is: " + metacatUrl); |
... | ... | |
520 | 520 |
|
521 | 521 |
protected String insertDocumentId(String docid, String docText, boolean result, |
522 | 522 |
boolean expectKarmaException) { |
523 |
debug("insertDocid(): docid=" + docid + " expectedResult=" + result
|
|
523 |
debug("insertDocumentId() - docid=" + docid + " expectedResult=" + result
|
|
524 | 524 |
+ " expectKarmaException=" + expectKarmaException); |
525 | 525 |
String response = null; |
526 | 526 |
try { |
... | ... | |
552 | 552 |
|
553 | 553 |
protected String uploadDocumentId(String docid, String filePath, boolean result, |
554 | 554 |
boolean expectedKarmaException) { |
555 |
debug("uploadDocid(): docid=" + docid + " filePath=" + filePath
|
|
555 |
debug("uploadDocumentId() - docid=" + docid + " filePath=" + filePath
|
|
556 | 556 |
+ " expectedResult=" + result + " expectedKarmaException=" |
557 | 557 |
+ expectedKarmaException); |
558 | 558 |
String response = null; |
... | ... | |
588 | 588 |
*/ |
589 | 589 |
protected String updateDocumentId(String docid, String docText, boolean result, |
590 | 590 |
boolean expectedKarmaFailure) { |
591 |
debug("updateDocid(): docid=" + docid + " expectedResult=" + result
|
|
591 |
debug("updateDocumentId() - docid=" + docid + " expectedResult=" + result
|
|
592 | 592 |
+ " expectedKarmaFailure=" + expectedKarmaFailure); |
593 | 593 |
String response = null; |
594 | 594 |
try { |
595 | 595 |
response = m.update(docid, new StringReader(testdocument), null); |
596 |
|
|
596 |
debug("updateDocumentId() - response=" + response); |
|
597 |
|
|
597 | 598 |
if (result) { |
598 | 599 |
assertTrue(response, (response.indexOf("<success>") != -1)); |
599 | 600 |
assertTrue(response, response.indexOf(docid) != -1); |
600 | 601 |
} else { |
601 | 602 |
assertTrue(response, (response.indexOf("<success>") == -1)); |
602 |
} |
|
603 |
debug("updateDocid(): response=" + response); |
|
603 |
} |
|
604 | 604 |
} catch (MetacatInaccessibleException mie) { |
605 | 605 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
606 | 606 |
} catch (InsufficientKarmaException ike) { |
... | ... | |
624 | 624 |
* Delete a document into metacat. The expected result is passed as result |
625 | 625 |
*/ |
626 | 626 |
protected void deleteDocumentId(String docid, boolean result, boolean expectedKarmaFailure) { |
627 |
debug("deleteDocid(): docid=" + docid + " expectedResult=" + result
|
|
627 |
debug("deleteDocumentId() - docid=" + docid + " expectedResult=" + result
|
|
628 | 628 |
+ " expectedKarmaFailure=" + expectedKarmaFailure); |
629 | 629 |
try { |
630 | 630 |
Thread.sleep(5000); |
631 | 631 |
String response = m.delete(docid); |
632 |
debug("deleteDocumentId() - response=" + response); |
|
633 |
|
|
632 | 634 |
if (result) { |
633 | 635 |
assertTrue(response, response.indexOf("<success>") != -1); |
634 | 636 |
} else { |
635 | 637 |
assertTrue(response, response.indexOf("<success>") == -1); |
636 | 638 |
} |
637 |
debug("deleteDocid(): response=" + response); |
|
638 | 639 |
} catch (MetacatInaccessibleException mie) { |
639 | 640 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
640 | 641 |
} catch (InsufficientKarmaException ike) { |
... | ... | |
658 | 659 |
*/ |
659 | 660 |
protected void readDocumentIdWhichEqualsDoc(String docid, String testDoc, boolean result, |
660 | 661 |
boolean expectedKarmaFailure) { |
661 |
debug("readDocidWhichEqualsDoc(): docid=" + docid + " expectedResult=" + result
|
|
662 |
debug("readDocumentIdWhichEqualsDoc() - docid=" + docid + " expectedResult=" + result
|
|
662 | 663 |
+ " expectedKarmaFailure=" + expectedKarmaFailure); |
663 | 664 |
try { |
664 | 665 |
Reader r = m.read(docid); |
665 | 666 |
String doc = IOUtil.getAsString(r, true); |
667 |
debug("readDocumentIdWhichEqualsDoc() - doc=" + doc); |
|
668 |
|
|
666 | 669 |
if (result) { |
667 | 670 |
|
668 | 671 |
if (!testDoc.equals(doc)) { |
... | ... | |
678 | 681 |
} else { |
679 | 682 |
assertTrue(doc.indexOf("<error>") != -1); |
680 | 683 |
} |
681 |
debug("readDocidWhichEqualsDoc(): doc=" + doc); |
|
682 | 684 |
} catch (MetacatInaccessibleException mie) { |
683 | 685 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
684 | 686 |
} catch (InsufficientKarmaException ike) { |
Also available in: Unified diff
Change MetaCatVersion to MetacatVersion