fail( e.getMessage() );
}
}
public void testGetCollection() {
Collection childcol = null;
try {
// Try getting a Collection instance for TEST_COLLECTION_CHILD1_NAME
childcol = col.getCollection(TEST_COLLECTION_CHILD1_NAME);
assertNotNull(childcol);
// Verify that we retrived the correct collection
assertTrue( childcol.getName().equals(TEST_COLLECTION_CHILD1_NAME) );
// Try getting a Collection instance for TEST_COLLECTION_CHILD1_NAME
childcol = col.getCollection(TEST_COLLECTION_CHILD2_NAME);
assertNotNull(childcol);
// Verify that we retrived the correct collection
assertTrue( childcol.getName().equals(TEST_COLLECTION_CHILD2_NAME) );
// Try retrieving a bogus collection, should get an COL_COLLECTION_NOT_FOUND faultCode
try {
exceptioncaught = false;
childcol = col.getCollection("lkasdfljkasdf");
} catch( APIException e ) {
exceptioncaught = true;
assertTrue( e.faultCode == FaultCodes.COL_COLLECTION_NOT_FOUND );
} finally {
assertTrue( exceptioncaught );
}
// Try retrieving an empty string
try {
exceptioncaught = false;
childcol = col.getCollection("");
} catch( APIException e ) {
exceptioncaught = true;
assertTrue( e.faultCode == FaultCodes.COL_COLLECTION_NOT_FOUND );
} finally {
assertTrue( exceptioncaught );
}
} catch ( APIException e) {
fail( e.getMessage() );
} finally {
childcol.remove();
}
}