import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.client.ClientResponse;
-//import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
-//import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
-//import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.testng.Assert;
-//import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+// FIXME: http://issues.collectionspace.org/browse/CSPACE-1685
/**
- * FIXME: http://issues.collectionspace.org/browse/CSPACE-1685
* IntakeServiceTest, carries out tests against a
* deployed and running Intake Service.
*
* $LastChangedDate$
*/
public class IntakeServiceTest extends AbstractServiceTestImpl {
- /** The logger. */
+
+ /** The logger. */
private final String CLASS_NAME = IntakeServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(IntakeServiceTest.class);
-
/** The known resource id. */
private String knownResourceId = null;
-
+
@Override
protected CollectionSpaceClient getClientInstance() {
- return new IntakeClient();
+ return new IntakeClient();
}
-
- @Override
- protected String getServiceName() {
- return IntakeClient.SERVICE_NAME;
- }
-
+
+ @Override
+ protected String getServiceName() {
+ return IntakeClient.SERVICE_NAME;
+ }
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
+ protected AbstractCommonList getAbstractCommonList(
+ ClientResponse<AbstractCommonList> response) {
+ return response.getEntity(AbstractCommonList.class);
}
-
+
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
+
// Success outcomes
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void create(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Specifically:
// Does it fall within the set of valid status codes?
// Does it exactly match the expected status code?
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
// Store the ID returned from the first resource created
// for additional tests below.
- if (knownResourceId == null){
+ if (knownResourceId == null) {
knownResourceId = extractId(res);
if (logger.isDebugEnabled()) {
logger.debug(testName + ": knownResourceId=" + knownResourceId);
}
}
-
+
// Store the IDs from every resource created by tests,
// so they can be deleted after tests have been run.
allResourceIdsCreated.add(extractId(res));
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"create"})
public void createList(String testName) throws Exception {
- for(int i = 0; i < 3; i++){
+ for (int i = 0; i < 3; i++) {
create(testName);
}
}
// Failure outcomes
// Placeholders until the three tests below can be uncommented.
+
// See Issue CSPACE-401.
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
*/
@Override
public void createWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
/* (non-Javadoc)
*/
@Override
public void createWithMalformedXml(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
/* (non-Javadoc)
*/
@Override
public void createWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
/*
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
+ dependsOnMethods = {"create", "testSubmitRequest"})
public void createWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithEmptyEntityBody();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("createWithEmptyEntityBody url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-
+ // Perform setup.
+ setupCreateWithEmptyEntityBody();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getServiceRootURL();
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = "";
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug("createWithEmptyEntityBody url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
+ dependsOnMethods = {"create", "testSubmitRequest"})
public void createWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA; // Constant from base class.
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-
+ // Perform setup.
+ setupCreateWithMalformedXml();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getServiceRootURL();
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = MALFORMED_XML_DATA; // Constant from base class.
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
+ dependsOnMethods = {"create", "testSubmitRequest"})
public void createWithWrongXmlSchema(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithWrongXmlSchema(testName, logger);
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupCreateWithWrongXmlSchema(testName, logger);
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getServiceRootURL();
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = WRONG_XML_SCHEMA_DATA;
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
}
*/
-
+
// ---------------------------------------------------------------
// CRUD tests : READ tests
// ---------------------------------------------------------------
+
// Success outcomes
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"create"})
public void read(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
IntakesCommon intakeCommons = null;
if (payloadInputPart != null) {
- intakeCommons = (IntakesCommon) payloadInputPart.getBody();
+ intakeCommons = (IntakesCommon) payloadInputPart.getBody();
}
// IntakesCommon intake = (IntakesCommon) extractPart(input,
// client.getCommonPartName(), IntakesCommon.class);
// Verify the number and contents of values in repeatable fields,
// as created in the instance record used for testing.
List<String> entryMethods =
- intakeCommons.getEntryMethods().getEntryMethod();
+ intakeCommons.getEntryMethods().getEntryMethod();
Assert.assertTrue(entryMethods.size() > 0);
Assert.assertNotNull(entryMethods.get(0));
List<String> fieldCollectionEventNames =
- intakeCommons.getFieldCollectionEventNames().getFieldCollectionEventName();
+ intakeCommons.getFieldCollectionEventNames().getFieldCollectionEventName();
Assert.assertTrue(fieldCollectionEventNames.size() > 0);
Assert.assertNotNull(fieldCollectionEventNames.get(0));
Assert.assertNotNull(currentLocationGroup.getCurrentLocationNote());
// Check the values of fields containing Unicode UTF-8 (non-Latin-1) characters.
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug("UTF-8 data sent=" + getUTF8DataFragment() + "\n"
+ "UTF-8 data received=" + intakeCommons.getEntryNote());
- }
+ }
Assert.assertEquals(intakeCommons.getEntryNote(), getUTF8DataFragment(),
"UTF-8 data retrieved '" + intakeCommons.getEntryNote()
+ "' does not match expected data '" + getUTF8DataFragment());
}
// Failure outcomes
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"read"})
public void readNonExistent(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
// ---------------------------------------------------------------
// CRUD tests : READ_LIST tests
// ---------------------------------------------------------------
+
// Success outcomes
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"createList", "read"})
public void readList(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Optionally output additional data about list members for debugging.
- boolean iterateThroughList = false;
- if(iterateThroughList && logger.isDebugEnabled()){
- List<AbstractCommonList.ListItem> items =
- list.getListItem();
- int i = 0;
- for(AbstractCommonList.ListItem item : items){
- logger.debug(testName + ": list-item[" + i + "] " +
- item.toString());
- i++;
- }
+ boolean iterateThroughList = true;
+ if (iterateThroughList && logger.isDebugEnabled()) {
+ ListItemsInAbstractCommonList(list, logger, testName);
}
}
// Failure outcomes
// None at present.
+
// ---------------------------------------------------------------
// CRUD tests : UPDATE tests
// ---------------------------------------------------------------
+
// Success outcomes
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"read"})
public void update(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Retrieve the contents of a resource to update.
IntakeClient client = new IntakeClient();
ClientResponse<String> res = client.read(knownResourceId);
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": read status = " + res.getStatus());
}
Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug("got object to update with ID: " + knownResourceId);
}
PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
IntakesCommon intakeCommons = null;
if (payloadInputPart != null) {
- intakeCommons = (IntakesCommon) payloadInputPart.getBody();
- }
+ intakeCommons = (IntakesCommon) payloadInputPart.getBody();
+ }
// IntakesCommon intake = (IntakesCommon) extractPart(input,
// client.getCommonPartName(), IntakesCommon.class);
Assert.assertNotNull(intakeCommons);
// Update the content of this resource.
intakeCommons.setEntryNumber("updated-" + intakeCommons.getEntryNumber());
intakeCommons.setEntryDate("updated-" + intakeCommons.getEntryDate());
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug("to be updated object");
logger.debug(objectAsXmlString(intakeCommons, IntakesCommon.class));
}
res = client.update(knownResourceId, output);
int statusCode = res.getStatus();
// Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn(res.getEntity());
IntakesCommon updatedIntake =
(IntakesCommon) extractPart(input,
- client.getCommonPartName(), IntakesCommon.class);
+ client.getCommonPartName(), IntakesCommon.class);
Assert.assertNotNull(updatedIntake);
Assert.assertEquals(updatedIntake.getEntryDate(),
- intakeCommons.getEntryDate(),
+ intakeCommons.getEntryDate(),
"Data in updated object did not match submitted data.");
currentLocationGroupList = updatedIntake.getCurrentLocationGroupList();
currentLocationGroups.get(0).getCurrentLocationNote(),
"Data in updated object did not match submitted data.");
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug("UTF-8 data sent=" + intakeCommons.getEntryNote() + "\n"
+ "UTF-8 data received=" + updatedIntake.getEntryNote());
- }
+ }
Assert.assertTrue(updatedIntake.getEntryNote().contains(getUTF8DataFragment()),
"UTF-8 data retrieved '" + updatedIntake.getEntryNote()
+ "' does not contain expected data '" + getUTF8DataFragment());
// Failure outcomes
// Placeholders until the three tests below can be uncommented.
+
// See Issue CSPACE-401.
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
*/
@Override
public void updateWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
-
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
*/
@Override
public void updateWithMalformedXml(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
-
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
*/
@Override
public void updateWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty?
+ //Should this really be empty?
}
/*
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
+ dependsOnMethods = {"create", "update", "testSubmitRequest"})
public void updateWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithEmptyEntityBody();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-
+ // Perform setup.
+ setupUpdateWithEmptyEntityBody();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getResourceURL(knownResourceId);
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = "";
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
+ dependsOnMethods = {"create", "update", "testSubmitRequest"})
public void updateWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
}
-
+ // Perform setup.
+ setupUpdateWithMalformedXml();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getResourceURL(knownResourceId);
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = MALFORMED_XML_DATA;
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
+ dependsOnMethods = {"create", "update", "testSubmitRequest"})
public void updateWithWrongXmlSchema(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithWrongXmlSchema();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupUpdateWithWrongXmlSchema();
+
+ // Submit the request to the service and store the response.
+ String method = REQUEST_TYPE.httpMethodName();
+ String url = getResourceURL(knownResourceId);
+ String mediaType = MediaType.APPLICATION_XML;
+ final String entity = WRONG_XML_SCHEMA_DATA;
+ int statusCode = submitRequest(method, url, mediaType, entity);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
}
*/
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"update", "testSubmitRequest"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"update", "testSubmitRequest"})
public void updateNonExistent(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
// ---------------------------------------------------------------
// CRUD tests : DELETE tests
// ---------------------------------------------------------------
+
// Success outcomes
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
public void delete(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
}
-
+
// Failure outcomes
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"delete"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"delete"})
public void deleteNonExistent(String testName) throws Exception {
if (logger.isDebugEnabled()) {
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
// ---------------------------------------------------------------
// Utility tests : tests of code used in tests above
// ---------------------------------------------------------------
+
/**
* Tests the code for manually submitting data that is used by several
* of the methods above.
// Check the status code of the response: does it match
// the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("testSubmitRequest: url=" + url +
- " status=" + statusCode);
+ if (logger.isDebugEnabled()) {
+ logger.debug("testSubmitRequest: url=" + url
+ + " status=" + statusCode);
}
Assert.assertEquals(statusCode, EXPECTED_STATUS);
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
*/
* @return the multipart output
*/
private PoxPayloadOut createIntakeInstance(String entryNumber,
- String entryDate,
- String depositor) {
+ String entryDate,
+ String depositor) {
IntakesCommon intake = new IntakesCommon();
intake.setEntryNumber(entryNumber);
intake.setEntryDate(entryDate);
PoxPayloadOut multipart = new PoxPayloadOut(IntakeClient.SERVICE_PAYLOAD_NAME);
PayloadOutputPart commonPart =
- multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
+ multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
commonPart.setLabel(new IntakeClient().getCommonPartName());
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug("to be created, intake common");
logger.debug(objectAsXmlString(intake, IntakesCommon.class));
}
return multipart;
}
-
}