import org.testng.Assert;
import org.testng.annotations.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* AcquisitionServiceTest, carries out tests against a
* deployed and running Acquisition Service.
*/
public class AcquisitionServiceTest extends AbstractServiceTest {
+ private final Logger logger =
+ LoggerFactory.getLogger(AcquisitionServiceTest.class);
+
// Instance variables specific to this test.
private AcquisitionClient client = new AcquisitionClient();
private String knownResourceId = null;
// Success outcomes
@Override
@Test
- public void create() {
+ public void create() throws Exception {
// Perform setup, such as initializing the type of service request
// (e.g. CREATE, DELETE), its valid and expected status codes, and
// Specifically:
// Does it fall within the set of valid status codes?
// Does it exactly match the expected status code?
- verbose("create: status = " + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("create: status = " + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Store the ID returned from this create operation for
// additional tests below.
knownResourceId = extractId(res);
- verbose("create: knownResourceId=" + knownResourceId);
+ if(logger.isDebugEnabled()){
+ logger.debug("create: knownResourceId=" + knownResourceId);
+ }
}
@Override
@Test(dependsOnMethods = {"create"})
- public void createList() {
+ public void createList() throws Exception {
for(int i = 0; i < 3; i++){
create();
}
// Failure outcomes
// Placeholders until the three tests below can be uncommented.
// See Issue CSPACE-401.
- public void createWithEmptyEntityBody() {
+ @Override
+ public void createWithEmptyEntityBody() throws Exception {
}
- public void createWithMalformedXml() {
+ @Override
+ public void createWithMalformedXml() throws Exception {
}
- public void createWithWrongXmlSchema() {
+ @Override
+ public void createWithWrongXmlSchema() throws Exception {
}
/*
@Override
@Test(dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithMalformedXml() {
+ public void createWithMalformedXml() throws Exception {
// Perform setup.
setupCreateWithMalformedXml();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("createWithMalformedXml url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("createWithMalformedXml url=" + url +
+ " status=" + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
@Override
@Test(dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithWrongXmlSchema() {
+ public void createWithWrongXmlSchema() throws Exception {
// Perform setup.
setupCreateWithWrongXmlSchema();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("createWithWrongSchema url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("createWithWrongXmlSchema 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
@Override
@Test(dependsOnMethods = {"create"})
- public void read() {
+ public void read() throws Exception {
// Perform setup.
setupRead();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("read: status = " + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("read: status = " + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- //FIXME: remove the following try catch once Aron fixes signatures
- try{
- MultipartInput input = (MultipartInput) res.getEntity();
- AcquisitionsCommon acquistionObject = (AcquisitionsCommon) extractPart(input,
- client.getCommonPartName(), AcquisitionsCommon.class);
- Assert.assertNotNull(acquistionObject);
- }catch(Exception e){
- throw new RuntimeException(e);
- }
+
+ MultipartInput input = (MultipartInput) res.getEntity();
+ AcquisitionsCommon acquistionObject = (AcquisitionsCommon) extractPart(input,
+ client.getCommonPartName(), AcquisitionsCommon.class);
+ Assert.assertNotNull(acquistionObject);
+
}
// Failure outcomes
@Override
@Test(dependsOnMethods = {"read"})
- public void readNonExistent() {
+ public void readNonExistent() throws Exception {
// Perform setup.
setupReadNonExistent();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("readNonExistent: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("readNonExistent: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Success outcomes
@Override
@Test(dependsOnMethods = {"createList", "read"})
- public void readList() {
+ public void readList() throws Exception {
// Perform setup.
setupReadList();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("readList: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("readList: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
list.getAcquisitionListItem();
int i = 0;
for(AcquisitionsCommonList.AcquisitionListItem item : items){
- verbose("readList: list-item[" + i + "] csid=" +
+ logger.debug("readList: list-item[" + i + "] csid=" +
item.getCsid());
- verbose("readList: list-item[" + i + "] objectNumber=" +
+ logger.debug("readList: list-item[" + i + "] objectNumber=" +
item.getAccessionDate());
- verbose("readList: list-item[" + i + "] URI=" +
+ logger.debug("readList: list-item[" + i + "] URI=" +
item.getUri());
i++;
}
// Failure outcomes
// None at present.
+
// ---------------------------------------------------------------
// CRUD tests : UPDATE tests
// ---------------------------------------------------------------
+
// Success outcomes
@Override
@Test(dependsOnMethods = {"read"})
- public void update() {
+ public void update() throws Exception {
// Perform setup.
setupUpdate();
- try{ //ideally, just remove try-catch and let the exception bubble up
- // Retrieve an existing resource that we can update.
- ClientResponse<MultipartInput> res =
- client.read(knownResourceId);
- verbose("update: read status = " + res.getStatus());
- Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
- verbose("got object to update with ID: " + knownResourceId);
- MultipartInput input = (MultipartInput) res.getEntity();
- AcquisitionsCommon acquisition = (AcquisitionsCommon) extractPart(input,
- client.getCommonPartName(), AcquisitionsCommon.class);
- Assert.assertNotNull(acquisition);
-
- // Update the content of this resource.
- acquisition.setAccessionDate("updated-" + acquisition.getAccessionDate());
+
+ ClientResponse<MultipartInput> res =
+ client.read(knownResourceId);
+ if(logger.isDebugEnabled()){
+ logger.debug("update: read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("got object to update with ID: " + knownResourceId);
+ }
+ MultipartInput input = (MultipartInput) res.getEntity();
+ AcquisitionsCommon acquisition = (AcquisitionsCommon) extractPart(input,
+ client.getCommonPartName(), AcquisitionsCommon.class);
+ Assert.assertNotNull(acquisition);
+
+ // Update the content of this resource.
+ acquisition.setAccessionDate("updated-" + acquisition.getAccessionDate());
+ if(logger.isDebugEnabled()){
verbose("updated object", acquisition, AcquisitionsCommon.class);
- // Submit the request to the service and store the response.
- MultipartOutput output = new MultipartOutput();
- OutputPart commonPart = output.addPart(acquisition, MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getCommonPartName());
-
- res = client.update(knownResourceId, output);
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
- verbose("update: status = " + res.getStatus());
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-
- input = (MultipartInput) res.getEntity();
- AcquisitionsCommon updatedAcquisition =
- (AcquisitionsCommon) extractPart(input,
- client.getCommonPartName(), AcquisitionsCommon.class);
- Assert.assertNotNull(updatedAcquisition);
-
- Assert.assertEquals(updatedAcquisition.getAccessionDate(),
- acquisition.getAccessionDate(),
- "Data in updated object did not match submitted data.");
- }catch(Exception e){
- e.printStackTrace();
}
+ // Submit the request to the service and store the response.
+ MultipartOutput output = new MultipartOutput();
+ OutputPart commonPart = output.addPart(acquisition, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", client.getCommonPartName());
+
+ 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()){
+ logger.debug("update: status = " + res.getStatus());
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+
+ input = (MultipartInput) res.getEntity();
+ AcquisitionsCommon updatedAcquisition =
+ (AcquisitionsCommon) extractPart(input,
+ client.getCommonPartName(), AcquisitionsCommon.class);
+ Assert.assertNotNull(updatedAcquisition);
+
+ Assert.assertEquals(updatedAcquisition.getAccessionDate(),
+ acquisition.getAccessionDate(),
+ "Data in updated object did not match submitted data.");
+
}
// Failure outcomes
// Placeholders until the three tests below can be uncommented.
// See Issue CSPACE-401.
- public void updateWithEmptyEntityBody() {
+ public void updateWithEmptyEntityBody() throws Exception {
}
- public void updateWithMalformedXml() {
+ public void updateWithMalformedXml() throws Exception {
}
- public void updateWithWrongXmlSchema() {
+ public void updateWithWrongXmlSchema() throws Exception {
}
/*
@Override
@Test(dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithEmptyEntityBody() {
+ public void updateWithEmptyEntityBody() throws Exception {
// Perform setup.
setupUpdateWithEmptyEntityBody();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("updateWithEmptyEntityBody url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ ("updateWithEmptyEntityBody url=" + url + " status=" + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
@Override
@Test(dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithEmptyEntityBody() {
+ public void createWithEmptyEntityBody() throws Exception {
// Perform setup.
setupCreateWithEmptyEntityBody();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("createWithEmptyEntityBody url=" + url + " status=" + statusCode);
+ 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(dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithMalformedXml() {
+ public void updateWithMalformedXml() throws Exception {
// Perform setup.
setupUpdateWithMalformedXml();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("updateWithMalformedXml: url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("updateWithMalformedXml: url=" + url +
+ " status=" + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("updateWithWrongSchema: url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("updateWithWrongXmlSchema: url=" + url +
+ " status=" + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
}
*/
+
@Override
@Test(dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent() {
+ public void updateNonExistent() throws Exception {
// Perform setup.
setupUpdateNonExistent();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("updateNonExistent: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("updateNonExistent: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Success outcomes
@Override
@Test(dependsOnMethods = {"create", "read", "update"})
- public void delete() {
+ public void delete() throws Exception {
// Perform setup.
setupDelete();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("delete: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("delete: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Failure outcomes
@Override
@Test(dependsOnMethods = {"delete"})
- public void deleteNonExistent() {
+ public void deleteNonExistent() throws Exception {
// Perform setup.
setupDeleteNonExistent();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("deleteNonExistent: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("deleteNonExistent: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
* of the methods above.
*/
@Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() {
+ public void testSubmitRequest() throws Exception {
// Expected status code: 200 OK
- final int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
+ final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
// Submit the request to the service and store the response.
String method = ServiceRequestType.READ.httpMethodName();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("testSubmitRequest: url=" + url + " status=" + statusCode);
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ if(logger.isDebugEnabled()){
+ logger.debug("testSubmitRequest: url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertEquals(statusCode, EXPECTED_STATUS);
}
AcquisitionsCommon acquisition = new AcquisitionsCommon();
acquisition.setAccessionDate("accessionDate-" + identifier);
MultipartOutput multipart = new MultipartOutput();
- OutputPart commonPart = multipart.addPart(acquisition, MediaType.APPLICATION_XML_TYPE);
+ OutputPart commonPart = multipart.addPart(acquisition,
+ MediaType.APPLICATION_XML_TYPE);
commonPart.getHeaders().add("label", client.getCommonPartName());
- verbose("to be created, acquisition common ", acquisition, AcquisitionsCommon.class);
+ if(logger.isDebugEnabled()){
+ verbose("to be created, acquisition common ",
+ acquisition, AcquisitionsCommon.class);
+ }
return multipart;
}
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTest#getServicePathComponent()
*/
+ @Override
protected String getServicePathComponent() {
// no need to return anything but null since no auth resources are
// accessed
collectionObjectClient.getCommonPartName(), identifier);
if (!collectionObjectClient.isServerSecure()) {
- logger
- .warn("set -Dcspace.server.secure=true to run security tests");
+ logger.warn("set -Dcspace.server.secure=true to run security tests");
return;
}
collectionObjectClient.setProperty(CollectionSpaceClient.AUTH_PROPERTY,
return;
}
ClientResponse<Response> res = collectionObjectClient.create(multipart);
- verbose("create: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("create: status = " + res.getStatus());
+ }
Assert.assertEquals(res.getStatus(), Response.Status.CREATED
.getStatusCode(), "expected "
+ Response.Status.CREATED.getStatusCode());
}
/**
- * Creates the without user.
+ * Creates the collection object instance without user.
*/
@Test(dependsOnMethods = { "create" })
public void createWithoutUser() {
return;
}
ClientResponse<Response> res = collectionObjectClient.create(multipart);
- verbose("createWithoutUser: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("createWithoutUser: status = " + res.getStatus());
+ }
Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED
.getStatusCode(), "expected "
+ Response.Status.UNAUTHORIZED.getStatusCode());
}
/**
- * Creates the without password.
+ * Creates the collection object instance without password.
*/
@Test(dependsOnMethods = { "createWithoutUser" })
public void createWithoutPassword() {
return;
}
ClientResponse<Response> res = collectionObjectClient.create(multipart);
- verbose("createWithoutPassword: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("createWithoutPassword: status = " + res.getStatus());
+ }
Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED
.getStatusCode(), "expected "
+ Response.Status.UNAUTHORIZED.getStatusCode());
}
/**
- * Creates the with incorrect password.
+ * Creates the collection object instance with incorrect password.
*/
@Test(dependsOnMethods = { "createWithoutPassword" })
public void createWithIncorrectPassword() {
return;
}
ClientResponse<Response> res = collectionObjectClient.create(multipart);
- verbose("createWithIncorrectPassword: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("createWithIncorrectPassword: status = " + res.getStatus());
+ }
Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED
.getStatusCode(), "expected "
+ Response.Status.UNAUTHORIZED.getStatusCode());
}
/**
- * Creates the without user password.
+ * Creates the collection object instance without user password.
*/
@Test(dependsOnMethods = { "createWithoutPassword" })
public void createWithoutUserPassword() {
return;
}
ClientResponse<Response> res = collectionObjectClient.create(multipart);
- verbose("createWithoutUserPassword: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("createWithoutUserPassword: status = " + res.getStatus());
+ }
Assert.assertEquals(res.getStatus(), Response.Status.FORBIDDEN
.getStatusCode(), "expected "
+ Response.Status.FORBIDDEN.getStatusCode());
}
/**
- * Creates the with incorrect user password.
+ * Creates the collection object instance with incorrect user password.
*/
@Test(dependsOnMethods = { "createWithoutPassword" })
public void createWithIncorrectUserPassword() {
return;
}
ClientResponse<Response> res = collectionObjectClient.create(multipart);
- verbose("createWithIncorrectUserPassword: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("createWithIncorrectUserPassword: status = " +
+ res.getStatus());
+ }
Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED
.getStatusCode(), "expected "
+ Response.Status.UNAUTHORIZED.getStatusCode());
logger.error("deleteCollectionObject: caught " + e.getMessage());
return;
}
- verbose("Calling deleteCollectionObject:" + knownResourceId);
+ if(logger.isDebugEnabled()){
+ logger.debug("Calling deleteCollectionObject:" + knownResourceId);
+ }
ClientResponse<Response> res = collectionObjectClient
.delete(knownResourceId);
- verbose("deleteCollectionObject: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("deleteCollectionObject: status = " + res.getStatus());
+ }
Assert.assertEquals(res.getStatus(),
Response.Status.OK.getStatusCode(), "expected "
+ Response.Status.OK.getStatusCode());
MediaType.APPLICATION_XML_TYPE);
commonPart.getHeaders().add("label", commonPartName);
- verbose("to be created, collectionobject common ", collectionObject,
- CollectionobjectsCommon.class);
+ if(logger.isDebugEnabled()){
+ logger.debug("to be created, collectionobject common ",
+ collectionObject, CollectionobjectsCommon.class);
+ }
return multipart;
}
* @see org.collectionspace.services.client.test.AbstractServiceTest#createList()
*/
@Override
- public void createList() {
+ public void createList() throws Exception {
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTest#createWithEmptyEntityBody()
*/
@Override
- public void createWithEmptyEntityBody() {
+ public void createWithEmptyEntityBody() throws Exception {
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTest#createWithMalformedXml()
*/
@Override
- public void createWithMalformedXml() {
+ public void createWithMalformedXml() throws Exception {
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTest#createWithWrongXmlSchema()
*/
@Override
- public void createWithWrongXmlSchema() {
+ public void createWithWrongXmlSchema() throws Exception {
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTest#read()
*/
@Override
- public void read() {
+ public void read() throws Exception {
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTest#readNonExistent()
*/
@Override
- public void readNonExistent() {
+ public void readNonExistent() throws Exception {
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTest#readList()
*/
@Override
- public void readList() {
+ public void readList() throws Exception {
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTest#update()
*/
@Override
- public void update() {
+ public void update() throws Exception {
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTest#updateWithEmptyEntityBody()
*/
@Override
- public void updateWithEmptyEntityBody() {
+ public void updateWithEmptyEntityBody() throws Exception {
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTest#updateWithMalformedXml()
*/
@Override
- public void updateWithMalformedXml() {
+ public void updateWithMalformedXml() throws Exception {
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTest#updateWithWrongXmlSchema()
*/
@Override
- public void updateWithWrongXmlSchema() {
+ public void updateWithWrongXmlSchema() throws Exception {
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTest#updateNonExistent()
*/
@Override
- public void updateNonExistent() {
+ public void updateNonExistent() throws Exception {
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTest#deleteNonExistent()
*/
@Override
- public void deleteNonExistent() {
+ public void deleteNonExistent() throws Exception {
}
}
import javax.xml.bind.Unmarshaller;
import org.collectionspace.services.client.TestServiceClient;
-import org.collectionspace.services.common.context.ServiceContext;
import org.jboss.resteasy.client.ClientRequest;
import org.jboss.resteasy.client.ClientResponse;
*/
public abstract class AbstractServiceTest implements ServiceTest {
- final Logger logger = LoggerFactory.getLogger(AbstractServiceTest.class);
+ private final Logger logger =
+ LoggerFactory.getLogger(AbstractServiceTest.class);
// A base-level client, used (only) to obtain the base service URL.
- protected static final TestServiceClient serviceClient = new TestServiceClient();
+ protected static final TestServiceClient serviceClient =
+ new TestServiceClient();
// A resource identifier believed to be non-existent in actual use,
// used when testing service calls that reference non-existent resources.
protected final String NON_EXISTENT_ID = createNonExistentIdentifier();
// The HTTP status code expected to be returned in the response,
// from a request made to a service (where relevant).
int EXPECTED_STATUS_CODE = 0;
- // The generic type of service request being tested (e.g. CREATE, UPDATE, DELETE).
+ // The generic type of service request being tested
+ // (e.g. CREATE, UPDATE, DELETE).
//
// This makes it possible to check behavior specific to that type of request,
// such as the set of valid status codes that may be returned.
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
+
// Success outcomes
@Override
- public void create() {
-
+ public void create() throws Exception {
}
protected void setupCreate() {
}
protected void setupCreate(String label) {
- clearSetup(label);
+ clearSetup();
// Expected status code: 201 Created
EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
// Type of service request being tested
REQUEST_TYPE = ServiceRequestType.CREATE;
+ // Print a banner identifying the test that will be run.
+ if (logger.isDebugEnabled()) {
+ printBanner(label);
+ }
}
@Override
- public abstract void createList();
+ public abstract void createList() throws Exception;
// No setup required for createList()
+
// Failure outcomes
+
@Override
- public abstract void createWithEmptyEntityBody();
+ public abstract void createWithEmptyEntityBody()
+ throws Exception;
protected void setupCreateWithEmptyEntityBody() {
setupCreateWithEmptyEntityBody("CreateWithEmptyEntityBody");
}
protected void setupCreateWithEmptyEntityBody(String label) {
- clearSetup(label);
+ clearSetup();
EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode();
REQUEST_TYPE = ServiceRequestType.CREATE;
- }
+ if (logger.isDebugEnabled()) {
+ printBanner(label);
+ }
+ }
@Override
- public abstract void createWithMalformedXml();
+ public abstract void createWithMalformedXml() throws Exception;
protected void setupCreateWithMalformedXml() {
setupCreateWithMalformedXml("CreateWithMalformedXml");
}
protected void setupCreateWithMalformedXml(String label) {
- clearSetup(label);
+ clearSetup();
// Expected status code: 400 Bad Request
EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode();
REQUEST_TYPE = ServiceRequestType.CREATE;
+ if (logger.isDebugEnabled()) {
+ printBanner(label);
+ }
}
@Override
- public abstract void createWithWrongXmlSchema();
+ public abstract void createWithWrongXmlSchema() throws Exception;
protected void setupCreateWithWrongXmlSchema() {
setupCreateWithWrongXmlSchema("CreateWithWrongXmlSchema");
}
protected void setupCreateWithWrongXmlSchema(String label) {
- clearSetup(label);
+ clearSetup();
// Expected status code: 400 Bad Request
EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode();
REQUEST_TYPE = ServiceRequestType.CREATE;
+ if (logger.isDebugEnabled()) {
+ printBanner(label);
+ }
}
// ---------------------------------------------------------------
// CRUD tests : READ tests
// ---------------------------------------------------------------
+
// Success outcomes
@Override
- public abstract void read();
+ public abstract void read() throws Exception;
protected void setupRead() {
setupRead("Read");
}
protected void setupRead(String label) {
- clearSetup(label);
+ clearSetup();
// Expected status code: 200 OK
EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
REQUEST_TYPE = ServiceRequestType.READ;
+ if (logger.isDebugEnabled()) {
+ printBanner(label);
+ }
}
// Failure outcomes
@Override
- public abstract void readNonExistent();
+ public abstract void readNonExistent() throws Exception;
protected void setupReadNonExistent() {
setupReadNonExistent("ReadNonExistent");
}
+
protected void setupReadNonExistent(String label) {
- clearSetup(label);
+ clearSetup();
// Expected status code: 404 Not Found
EXPECTED_STATUS_CODE = Response.Status.NOT_FOUND.getStatusCode();
REQUEST_TYPE = ServiceRequestType.READ;
+ if (logger.isDebugEnabled()) {
+ printBanner(label);
+ }
}
// ---------------------------------------------------------------
// CRUD tests : READ (list, or multiple) tests
// ---------------------------------------------------------------
+
// Success outcomes
@Override
- public abstract void readList();
+ public abstract void readList() throws Exception;
protected void setupReadList() {
setupReadList("ReadList");
}
protected void setupReadList(String label) {
- clearSetup(label);
+ clearSetup();
// Expected status code: 200 OK
EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
REQUEST_TYPE = ServiceRequestType.READ_LIST;
+ if (logger.isDebugEnabled()) {
+ printBanner(label);
+ }
}
// Failure outcomes
// None tested at present.
+
// ---------------------------------------------------------------
// CRUD tests : UPDATE tests
// ---------------------------------------------------------------
+
// Success outcomes
- // ----------------
@Override
- public abstract void update();
+ public abstract void update() throws Exception;
protected void setupUpdate() {
setupUpdate("Update");
}
protected void setupUpdate(String label) {
- clearSetup(label);
+ clearSetup();
// Expected status code: 200 OK
EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
REQUEST_TYPE = ServiceRequestType.UPDATE;
+ if (logger.isDebugEnabled()) {
+ printBanner(label);
+ }
}
// Failure outcomes
@Override
- public abstract void updateWithEmptyEntityBody();
+ public abstract void updateWithEmptyEntityBody() throws Exception;
protected void setupUpdateWithEmptyEntityBody() {
setupUpdateWithEmptyEntityBody("UpdateWithEmptyEntityBody");
}
protected void setupUpdateWithEmptyEntityBody(String label) {
- clearSetup(label);
+ clearSetup();
+ // Expected status code: 400 Bad Request
EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode();
REQUEST_TYPE = ServiceRequestType.UPDATE;
+ if (logger.isDebugEnabled()) {
+ printBanner(label);
+ }
}
@Override
- public abstract void updateWithMalformedXml();
+ public abstract void updateWithMalformedXml() throws Exception;
protected void setupUpdateWithMalformedXml() {
setupUpdateWithMalformedXml("UpdateWithMalformedXml");
}
protected void setupUpdateWithMalformedXml(String label) {
- clearSetup(label);
+ clearSetup();
// Expected status code: 400 Bad Request
EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode();
REQUEST_TYPE = ServiceRequestType.UPDATE;
+ if (logger.isDebugEnabled()) {
+ printBanner(label);
+ }
}
@Override
- public abstract void updateWithWrongXmlSchema();
+ public abstract void updateWithWrongXmlSchema() throws Exception;
protected void setupUpdateWithWrongXmlSchema() {
setupUpdateWithWrongXmlSchema("UpdateWithWrongXmlSchema");
}
protected void setupUpdateWithWrongXmlSchema(String label) {
- clearSetup(label);
+ clearSetup();
// Expected status code: 400 Bad Request
EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode();
REQUEST_TYPE = ServiceRequestType.UPDATE;
+ if (logger.isDebugEnabled()) {
+ printBanner(label);
+ }
}
@Override
- public abstract void updateNonExistent();
+ public abstract void updateNonExistent() throws Exception;
protected void setupUpdateNonExistent() {
setupUpdateNonExistent("UpdateNonExistent");
}
protected void setupUpdateNonExistent(String label) {
- clearSetup(label);
+ clearSetup();
// Expected status code: 404 Not Found
EXPECTED_STATUS_CODE = Response.Status.NOT_FOUND.getStatusCode();
REQUEST_TYPE = ServiceRequestType.UPDATE;
+ if (logger.isDebugEnabled()) {
+ printBanner(label);
+ }
}
// ---------------------------------------------------------------
// CRUD tests : DELETE tests
// ---------------------------------------------------------------
+
// Success outcomes
@Override
- public abstract void delete();
+ public abstract void delete() throws Exception;
protected void setupDelete() {
setupDelete("Delete");
}
protected void setupDelete(String label) {
- clearSetup(label);
+ clearSetup();
// Expected status code: 200 OK
EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
REQUEST_TYPE = ServiceRequestType.DELETE;
+ if (logger.isDebugEnabled()) {
+ printBanner(label);
+ }
}
// Failure outcomes
@Override
- public abstract void deleteNonExistent();
+ public abstract void deleteNonExistent() throws Exception;
protected void setupDeleteNonExistent() {
setupDeleteNonExistent("DeleteNonExistent");
}
protected void setupDeleteNonExistent(String label) {
- clearSetup(label);
+ clearSetup();
// Expected status code: 404 Not Found
EXPECTED_STATUS_CODE = Response.Status.NOT_FOUND.getStatusCode();
REQUEST_TYPE = ServiceRequestType.DELETE;
+ if (logger.isDebugEnabled()) {
+ printBanner(label);
+ }
}
// ---------------------------------------------------------------
* Reinitializes setup values, to help expose any unintended reuse
* of those values between tests.
*/
- protected void clearSetup(String testName) {
+ protected void clearSetup() {
EXPECTED_STATUS_CODE = 0;
REQUEST_TYPE = ServiceRequestType.NON_EXISTENT;
- logger.debug("========================================================");
- logger.debug(" Test = " + testName);
- logger.debug("========================================================");
}
/**
}
}catch(Exception e){
logger.error(
- "Exception during HTTP " + method + " request to " + url + ":",
- e);
+ "Exception during HTTP " + method + " request to " +
+ url + ":", e);
}
return statusCode;
}
}
}catch(Exception e){
logger.error(
- "Exception during HTTP " + method + " request to " + url + ":",
- e);
+ "Exception during HTTP " + method + " request to " +
+ url + ":", e);
}
return statusCode;
}
return id;
}
- protected void verbose(String msg) {
- if(logger.isDebugEnabled()){
- logger.debug(msg);
- }
- }
-
- protected void verbose(String msg, Object o, Class clazz) {
- try{
- verbose(msg);
- JAXBContext jc = JAXBContext.newInstance(clazz);
- Marshaller m = jc.createMarshaller();
- m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
- Boolean.TRUE);
- m.marshal(o, System.out);
- }catch(Exception e){
- e.printStackTrace();
- }
- }
-
- protected void verboseMap(MultivaluedMap map) {
- for(Object entry : map.entrySet()){
- MultivaluedMap.Entry mentry = (MultivaluedMap.Entry) entry;
- verbose(" name=" + mentry.getKey() + " value=" + mentry.getValue());
- }
- }
-
- protected String createIdentifier() {
+ protected String createIdentifier() {
long identifier = System.currentTimeMillis();
return Long.toString(identifier);
}
return Long.toString(Long.MAX_VALUE);
}
- protected Object extractPart(MultipartInput input, String label, Class clazz) throws Exception {
+ protected Object extractPart(MultipartInput input, String label,
+ Class clazz) throws Exception {
Object obj = null;
for(InputPart part : input.getParts()){
String partLabel = part.getHeaders().getFirst("label");
return obj;
}
- protected Object getPartObject(String partStr, Class clazz) throws JAXBException {
+ protected Object getPartObject(String partStr, Class clazz)
+ throws JAXBException {
JAXBContext jc = JAXBContext.newInstance(clazz);
ByteArrayInputStream bais = null;
Object obj = null;
}
return obj;
}
+
+ // @TODO Some of the methods below may be candidates
+ // to be moved to a utilities module, suitable for use
+ // by both client-side and server-side code.
+
+ protected void verbose(String msg) {
+ if(logger.isDebugEnabled()){
+ logger.debug(msg);
+ }
+ }
+
+ protected void verbose(String msg, Object o, Class clazz) {
+ try{
+ verbose(msg);
+ JAXBContext jc = JAXBContext.newInstance(clazz);
+ Marshaller m = jc.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
+ Boolean.TRUE);
+ m.marshal(o, System.out);
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+ }
+
+ protected void verboseMap(MultivaluedMap map) {
+ for(Object entry : map.entrySet()){
+ MultivaluedMap.Entry mentry = (MultivaluedMap.Entry) entry;
+ verbose(" name=" + mentry.getKey() + " value=" + mentry.getValue());
+ }
+ }
+
+ private void printBanner(String label) {
+ if(logger.isDebugEnabled()){
+ logger.debug("===================================================");
+ logger.debug(" Test = " + label);
+ logger.debug("===================================================");
+ }
+ }
}
*
* Relied upon by 'read', 'update' and 'delete' tests, below.
*/
- public void create();
+ public void create() throws Exception;
/**
* Tests creation of a list of two or more new resources by repeatedly
*
* Relied upon by 'read list' tests, below.
*/
- public void createList();
+ public void createList() throws Exception;
// Failure outcomes
* Tests creation of a resource by submitting
* an empty entity body (aka empty payload).
*/
- public void createWithEmptyEntityBody();
+ public void createWithEmptyEntityBody() throws Exception;
/**
* Tests creation of a resource by submitting
* a representation with malformed XML data.
*/
- public void createWithMalformedXml();
+ public void createWithMalformedXml() throws Exception;
/**
* Tests creation of a resource by submitting
* a representation in the wrong XML schema
* (e.g. not matching the object's schema).
*/
- public void createWithWrongXmlSchema();
+ public void createWithWrongXmlSchema() throws Exception;
// @TODO If feasible, implement a negative (failure)
// test for creation of duplicate resources.
/**
* Tests reading (i.e. retrieval) of a resource.
*/
- public void read();
+ public void read() throws Exception;
// Failure outcomes
* resource, whose resource identifier does not exist
* at the specified URL.
*/
- public void readNonExistent();
+ public void readNonExistent() throws Exception;
// ---------------------------------------------------------------
* Tests reading (i.e. retrieval) of a list of
* multiple resources.
*/
- public void readList();
+ public void readList() throws Exception;
// If feasible, implement a test for reading
// an empty list returned by the service.
/**
* Tests updating the content of a resource.
*/
- public void update();
+ public void update() throws Exception;
// Failure outcomes
* Tests updating the content of a resource
* by submitting an empty entity body (aka empty payload).
*/
- public void updateWithEmptyEntityBody();
+ public void updateWithEmptyEntityBody() throws Exception;
/**
* Tests updating the content of a resource
* by submitting a representation with malformed
* XML data.
*/
- public void updateWithMalformedXml();
+ public void updateWithMalformedXml() throws Exception;
/**
* Tests updating the content of a resource
* by submitting a representation in the wrong
* XML schema (e.g. not matching the object's schema).
*/
- public void updateWithWrongXmlSchema();
+ public void updateWithWrongXmlSchema() throws Exception;
/**
* Tests updating the content of a non-existent
* resource, whose resource identifier does not exist.
*/
- public void updateNonExistent();
+ public void updateNonExistent() throws Exception;
// ---------------------------------------------------------------
/**
* Tests deleting a resource.
*/
- public void delete();
+ public void delete() throws Exception;
// Failure outcomes
* Tests deleting a non-existent resource, whose resource
* identifier does not exist at the specified URL.
*/
- public void deleteNonExistent();
+ public void deleteNonExistent() throws Exception;
}
import org.testng.Assert;
import org.testng.annotations.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* CollectionObjectServiceTest, carries out tests against a
* deployed and running CollectionObject Service.
*/
public class CollectionObjectServiceTest extends AbstractServiceTest {
+ private final Logger logger =
+ LoggerFactory.getLogger(CollectionObjectServiceTest.class);
+
// Instance variables specific to this test.
private CollectionObjectClient client = new CollectionObjectClient();
private String knownResourceId = null;
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
+
// Success outcomes
@Override
@Test
- public void create() {
+ public void create() throws Exception {
// Perform setup, such as initializing the type of service request
// (e.g. CREATE, DELETE), its valid and expected status codes, and
// Specifically:
// Does it fall within the set of valid status codes?
// Does it exactly match the expected status code?
- verbose("create: status = " + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("create: status = " + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Store the ID returned from this create operation
// for additional tests below.
knownResourceId = extractId(res);
- verbose("create: knownResourceId=" + knownResourceId);
+ if(logger.isDebugEnabled()){
+ logger.debug("create: knownResourceId=" + knownResourceId);
+ }
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTest#createList()
+ */
@Override
@Test(dependsOnMethods = {"create"})
- public void createList() {
+ public void createList() throws Exception {
for(int i = 0; i < 3; i++){
create();
}
}
// Failure outcomes
+
// Placeholders until the three tests below can be uncommented.
// See Issue CSPACE-401.
- public void createWithEmptyEntityBody() {}
- public void createWithMalformedXml() {}
- public void createWithWrongXmlSchema() {}
+ @Override
+ public void createWithEmptyEntityBody() throws Exception {}
+ @Override
+ public void createWithMalformedXml() throws Exception {}
+ @Override
+ public void createWithWrongXmlSchema() throws Exception {}
+
/*
@Override
@Test(dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithEmptyEntityBody() {
+ public void createWithEmptyEntityBody() throwsException {
// Perform setup.
setupCreateWithEmptyEntityBody();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("createWithEmptyEntityBody url=" + url + " status=" + statusCode);
+ 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(dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithMalformedXml() {
+ public void createWithMalformedXml() throws Exception {
// Perform setup.
setupCreateWithMalformedXml();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("createWithMalformedXml url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("createWithMalformedXml url=" + url +
+ " status=" + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
@Override
@Test(dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithWrongXmlSchema() {
+ public void createWithWrongXmlSchema() throws Exception {
// Perform setup.
setupCreateWithWrongXmlSchema();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("createWithWrongSchema url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("createWithWrongXmlSchema 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
@Override
@Test(dependsOnMethods = {"create"})
- public void read() {
+ public void read() throws Exception {
// Perform setup.
setupRead();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("read: status = " + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("read: status = " + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- //FIXME: remove the following try catch once Aron fixes signatures
- try{
- MultipartInput input = (MultipartInput) res.getEntity();
- CollectionobjectsCommon collectionObject = (CollectionobjectsCommon) extractPart(input,
- client.getCommonPartName(), CollectionobjectsCommon.class);
- Assert.assertNotNull(collectionObject);
- }catch(Exception e){
- throw new RuntimeException(e);
- }
+
+ MultipartInput input = (MultipartInput) res.getEntity();
+ CollectionobjectsCommon collectionObject =
+ (CollectionobjectsCommon) extractPart(input,
+ client.getCommonPartName(), CollectionobjectsCommon.class);
+ Assert.assertNotNull(collectionObject);
}
// Failure outcomes
@Override
@Test(dependsOnMethods = {"read"})
- public void readNonExistent() {
+ public void readNonExistent() throws Exception {
// Perform setup.
setupReadNonExistent();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("readNonExistent: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("readNonExistent: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Success outcomes
@Override
@Test(dependsOnMethods = {"createList", "read"})
- public void readList() {
+ public void readList() throws Exception {
// Perform setup.
setupReadList();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("readList: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("readList: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
int i = 0;
for(CollectionobjectsCommonList.CollectionObjectListItem item : items){
- verbose("readList: list-item[" + i + "] csid=" +
+ logger.debug("readList: list-item[" + i + "] csid=" +
item.getCsid());
- verbose("readList: list-item[" + i + "] objectNumber=" +
+ logger.debug("readList: list-item[" + i + "] objectNumber=" +
item.getObjectNumber());
- verbose("readList: list-item[" + i + "] URI=" +
+ logger.debug("readList: list-item[" + i + "] URI=" +
item.getUri());
i++;
+
}
}
}
// Success outcomes
@Override
@Test(dependsOnMethods = {"read"})
- public void update() {
+ public void update() throws Exception {
// Perform setup.
setupUpdate();
- try{ //ideally, just remove try-catch and let the exception bubble up
- // Retrieve an existing resource that we can update.
- ClientResponse<MultipartInput> res =
- client.read(knownResourceId);
- verbose("update: read status = " + res.getStatus());
- Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
- verbose("got object to update with ID: " + knownResourceId);
- MultipartInput input = (MultipartInput) res.getEntity();
- CollectionobjectsCommon collectionObject = (CollectionobjectsCommon) extractPart(input,
- client.getCommonPartName(), CollectionobjectsCommon.class);
- Assert.assertNotNull(collectionObject);
-
- // Update the content of this resource.
- collectionObject.setObjectNumber("updated-" + collectionObject.getObjectNumber());
- collectionObject.setObjectName("updated-" + collectionObject.getObjectName());
- verbose("updated object", collectionObject, CollectionobjectsCommon.class);
- // Submit the request to the service and store the response.
- MultipartOutput output = new MultipartOutput();
- OutputPart commonPart = output.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getCommonPartName());
-
- res = client.update(knownResourceId, output);
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
- verbose("update: status = " + res.getStatus());
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-
- input = (MultipartInput) res.getEntity();
- CollectionobjectsCommon updatedCollectionObject =
- (CollectionobjectsCommon) extractPart(input,
- client.getCommonPartName(), CollectionobjectsCommon.class);
- Assert.assertNotNull(updatedCollectionObject);
-
- Assert.assertEquals(updatedCollectionObject.getObjectName(),
- collectionObject.getObjectName(),
- "Data in updated object did not match submitted data.");
- }catch(Exception e){
- e.printStackTrace();
+
+ ClientResponse<MultipartInput> res =
+ client.read(knownResourceId);
+ if(logger.isDebugEnabled()){
+ logger.debug("update: read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("got object to update with ID: " + knownResourceId);
+ }
+ MultipartInput input = (MultipartInput) res.getEntity();
+ CollectionobjectsCommon collectionObject =
+ (CollectionobjectsCommon) extractPart(input,
+ client.getCommonPartName(), CollectionobjectsCommon.class);
+ Assert.assertNotNull(collectionObject);
+
+ // Update the content of this resource.
+ collectionObject.setObjectNumber("updated-" + collectionObject.getObjectNumber());
+ collectionObject.setObjectName("updated-" + collectionObject.getObjectName());
+ if(logger.isDebugEnabled()){
+ verbose("updated object", collectionObject,
+ CollectionobjectsCommon.class);
}
+ // Submit the request to the service and store the response.
+ MultipartOutput output = new MultipartOutput();
+ OutputPart commonPart = output.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", client.getCommonPartName());
+
+ 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()){
+ logger.debug("update: status = " + res.getStatus());
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+
+ input = (MultipartInput) res.getEntity();
+ CollectionobjectsCommon updatedCollectionObject =
+ (CollectionobjectsCommon) extractPart(input,
+ client.getCommonPartName(), CollectionobjectsCommon.class);
+ Assert.assertNotNull(updatedCollectionObject);
+
+ Assert.assertEquals(updatedCollectionObject.getObjectName(),
+ collectionObject.getObjectName(),
+ "Data in updated object did not match submitted data.");
+
}
// Failure outcomes
// Placeholders until the three tests below can be uncommented.
// See Issue CSPACE-401.
- public void updateWithEmptyEntityBody() {}
- public void updateWithMalformedXml() {}
- public void updateWithWrongXmlSchema() {}
+ @Override
+ public void updateWithEmptyEntityBody() throws Exception {}
+ @Override
+ public void updateWithMalformedXml() throws Exception {}
+ @Override
+ public void updateWithWrongXmlSchema() throws Exception {}
/*
@Override
@Test(dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithEmptyEntityBody() {
+ public void updateWithEmptyEntityBody() throws Exception {
// Perform setup.
setupUpdateWithEmptyEntityBody();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("updateWithEmptyEntityBody url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("updateWithEmptyEntityBody url=" + url +
+ " status=" + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
@Override
@Test(dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithMalformedXml() {
+ public void updateWithMalformedXml() throws Exception {
// Perform setup.
setupUpdateWithMalformedXml();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("updateWithMalformedXml: url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("updateWithMalformedXml: url=" + url +
+ " status=" + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
@Override
@Test(dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithWrongXmlSchema() {
+ public void updateWithWrongXmlSchema() throws Exception {
// Perform setup.
setupUpdateWithWrongXmlSchema();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("updateWithWrongSchema: url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("updateWithWrongXmlSchema: url=" + url +
+ " status=" + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
@Override
@Test(dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent() {
+ public void updateNonExistent() throws Exception {
// Perform setup.
setupUpdateNonExistent();
// Note: The ID used in this 'create' call may be arbitrary.
// The only relevant ID may be the one used in updateCollectionObject(), below.
- MultipartOutput multipart = createCollectionObjectInstance(client.getCommonPartName(), NON_EXISTENT_ID);
+ MultipartOutput multipart =
+ createCollectionObjectInstance(client.getCommonPartName(),
+ NON_EXISTENT_ID);
ClientResponse<MultipartInput> res =
- client.update(NON_EXISTENT_ID, multipart);
+ client.update(NON_EXISTENT_ID, multipart);
int statusCode = res.getStatus();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("updateNonExistent: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("updateNonExistent: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Success outcomes
@Override
@Test(dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
- public void delete() {
+ public void delete() throws Exception {
// Perform setup.
setupDelete();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("delete: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("delete: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Failure outcomes
@Override
@Test(dependsOnMethods = {"delete"})
- public void deleteNonExistent() {
+ public void deleteNonExistent() throws Exception {
// Perform setup.
setupDeleteNonExistent();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("deleteNonExistent: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("deleteNonExistent: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
* of the methods above.
*/
@Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() {
+ public void testSubmitRequest() throws Exception {
// Expected status code: 200 OK
- final int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
+ final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
// Submit the request to the service and store the response.
String method = ServiceRequestType.READ.httpMethodName();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("testSubmitRequest: url=" + url + " status=" + statusCode);
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ if(logger.isDebugEnabled()){
+ logger.debug("testSubmitRequest: url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertEquals(statusCode, EXPECTED_STATUS);
}
// Utility methods used by tests above
// ---------------------------------------------------------------
- private MultipartOutput createCollectionObjectInstance(String commonPartName, String identifier) {
- return createCollectionObjectInstance(commonPartName, "objectNumber-" + identifier,
- "objectName-" + identifier);
+ private MultipartOutput createCollectionObjectInstance(String commonPartName,
+ String identifier) {
+ return createCollectionObjectInstance(commonPartName,
+ "objectNumber-" + identifier,
+ "objectName-" + identifier);
}
- private MultipartOutput createCollectionObjectInstance(String commonPartName, String objectNumber, String objectName) {
+ private MultipartOutput createCollectionObjectInstance(String commonPartName,
+ String objectNumber, String objectName) {
CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
collectionObject.setObjectNumber(objectNumber);
collectionObject.setObjectName(objectName);
MultipartOutput multipart = new MultipartOutput();
- OutputPart commonPart = multipart.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE);
+ OutputPart commonPart = multipart.addPart(collectionObject,
+ MediaType.APPLICATION_XML_TYPE);
commonPart.getHeaders().add("label", commonPartName);
- verbose("to be created, collectionobject common ", collectionObject, CollectionobjectsCommon.class);
+ if(logger.isDebugEnabled()){
+ verbose("to be created, collectionobject common ",
+ collectionObject, CollectionobjectsCommon.class);
+ }
CollectionObjectNaturalhistory conh = new CollectionObjectNaturalhistory();
conh.setNhString("test-string");
OutputPart nhPart = multipart.addPart(conh, MediaType.APPLICATION_XML_TYPE);
nhPart.getHeaders().add("label", getNHPartName());
- verbose("to be created, collectionobject nhistory", conh, CollectionObjectNaturalhistory.class);
+ if(logger.isDebugEnabled()){
+ verbose("to be created, collectionobject nhistory",
+ conh, CollectionObjectNaturalhistory.class);
+ }
return multipart;
}
import org.testng.Assert;
import org.testng.annotations.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* IntakeServiceTest, carries out tests against a
* deployed and running Intake Service.
*/
public class IntakeServiceTest extends AbstractServiceTest {
+ private final Logger logger =
+ LoggerFactory.getLogger(IntakeServiceTest.class);
+
// Instance variables specific to this test.
private IntakeClient client = new IntakeClient();
final String SERVICE_PATH_COMPONENT = "intakes";
// Success outcomes
@Override
@Test
- public void create() {
+ public void create() throws Exception {
// Perform setup, such as initializing the type of service request
// (e.g. CREATE, DELETE), its valid and expected status codes, and
// Specifically:
// Does it fall within the set of valid status codes?
// Does it exactly match the expected status code?
- verbose("create: status = " + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("create: status = " + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Store the ID returned from this create operation
// for additional tests below.
knownResourceId = extractId(res);
- verbose("create: knownResourceId=" + knownResourceId);
+ if(logger.isDebugEnabled()){
+ logger.debug("create: knownResourceId=" + knownResourceId);
+ }
}
@Override
@Test(dependsOnMethods = {"create"})
- public void createList() {
+ public void createList() throws Exception {
for(int i = 0; i < 3; i++){
create();
}
// Failure outcomes
// Placeholders until the three tests below can be uncommented.
// See Issue CSPACE-401.
- public void createWithEmptyEntityBody() {
+ @Override
+ public void createWithEmptyEntityBody() throws Exception {
}
- public void createWithMalformedXml() {
+ @Override
+ public void createWithMalformedXml() throws Exception {
}
- public void createWithWrongXmlSchema() {
+ @Override
+ public void createWithWrongXmlSchema() throws Exception {
}
/*
@Override
@Test(dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithEmptyEntityBody() {
+ public void createWithEmptyEntityBody() throws Exception {
// Perform setup.
setupCreateWithEmptyEntityBody();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("createWithEmptyEntityBody url=" + url + " status=" + statusCode);
+ 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(dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithMalformedXml() {
+ public void createWithMalformedXml() throws Exception {
// Perform setup.
setupCreateWithMalformedXml();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("createWithMalformedXml url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("createWithMalformedXml url=" + url +
+ " status=" + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
@Override
@Test(dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithWrongXmlSchema() {
+ public void createWithWrongXmlSchema() throws Exception {
// Perform setup.
setupCreateWithWrongXmlSchema();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("createWithWrongSchema url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("createWithWrongSchema 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
@Override
@Test(dependsOnMethods = {"create"})
- public void read() {
+ public void read() throws Exception {
// Perform setup.
setupRead();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("read: status = " + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("read: status = " + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- //FIXME: remove the following try catch once Aron fixes signatures
- try{
- MultipartInput input = (MultipartInput) res.getEntity();
- IntakesCommon intake = (IntakesCommon) extractPart(input,
- client.getCommonPartName(), IntakesCommon.class);
- Assert.assertNotNull(intake);
- }catch(Exception e){
- throw new RuntimeException(e);
- }
+
+ MultipartInput input = (MultipartInput) res.getEntity();
+ IntakesCommon intake = (IntakesCommon) extractPart(input,
+ client.getCommonPartName(), IntakesCommon.class);
+ Assert.assertNotNull(intake);
}
// Failure outcomes
@Override
@Test(dependsOnMethods = {"read"})
- public void readNonExistent() {
+ public void readNonExistent() throws Exception {
// Perform setup.
setupReadNonExistent();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("readNonExistent: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("readNonExistent: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Success outcomes
@Override
@Test(dependsOnMethods = {"read"})
- public void readList() {
+ public void readList() throws Exception {
// Perform setup.
setupReadList();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("readList: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("readList: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
list.getIntakeListItem();
int i = 0;
for(IntakesCommonList.IntakeListItem item : items){
- verbose("readList: list-item[" + i + "] csid=" +
+ logger.debug("readList: list-item[" + i + "] csid=" +
item.getCsid());
- verbose("readList: list-item[" + i + "] objectNumber=" +
+ logger.debug("readList: list-item[" + i + "] objectNumber=" +
item.getEntryNumber());
- verbose("readList: list-item[" + i + "] URI=" +
+ logger.debug("readList: list-item[" + i + "] URI=" +
item.getUri());
i++;
}
// Success outcomes
@Override
@Test(dependsOnMethods = {"read"})
- public void update() {
+ public void update() throws Exception {
// Perform setup.
setupUpdate();
- try{ //ideally, just remove try-catch and let the exception bubble up
- // Retrieve an existing resource that we can update.
- ClientResponse<MultipartInput> res =
- client.read(knownResourceId);
- verbose("update: read status = " + res.getStatus());
- Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
- verbose("got object to update with ID: " + knownResourceId);
- MultipartInput input = (MultipartInput) res.getEntity();
- IntakesCommon intake = (IntakesCommon) extractPart(input,
- client.getCommonPartName(), IntakesCommon.class);
- Assert.assertNotNull(intake);
-
- // Update the content of this resource.
- // Update the content of this resource.
- intake.setEntryNumber("updated-" + intake.getEntryNumber());
- intake.setEntryDate("updated-" + intake.getEntryDate());
+ ClientResponse<MultipartInput> res =
+ client.read(knownResourceId);
+ if(logger.isDebugEnabled()){
+ logger.debug("update: read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("got object to update with ID: " + knownResourceId);
+ }
+ MultipartInput input = (MultipartInput) res.getEntity();
+ IntakesCommon intake = (IntakesCommon) extractPart(input,
+ client.getCommonPartName(), IntakesCommon.class);
+ Assert.assertNotNull(intake);
+
+ // Update the content of this resource.
+ // Update the content of this resource.
+ intake.setEntryNumber("updated-" + intake.getEntryNumber());
+ intake.setEntryDate("updated-" + intake.getEntryDate());
+ if(logger.isDebugEnabled()){
verbose("to be updated object", intake, IntakesCommon.class);
- // Submit the request to the service and store the response.
- MultipartOutput output = new MultipartOutput();
- OutputPart commonPart = output.addPart(intake, MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getCommonPartName());
-
- res = client.update(knownResourceId, output);
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
- verbose("update: status = " + res.getStatus());
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-
- input = (MultipartInput) res.getEntity();
- IntakesCommon updatedIntake =
- (IntakesCommon) extractPart(input,
- client.getCommonPartName(), IntakesCommon.class);
- Assert.assertNotNull(updatedIntake);
-
- Assert.assertEquals(updatedIntake.getEntryDate(),
- intake.getEntryDate(),
- "Data in updated object did not match submitted data.");
- }catch(Exception e){
- e.printStackTrace();
}
+ // Submit the request to the service and store the response.
+ MultipartOutput output = new MultipartOutput();
+ OutputPart commonPart = output.addPart(intake, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", client.getCommonPartName());
+
+ 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()){
+ logger.debug("update: status = " + res.getStatus());
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+
+ input = (MultipartInput) res.getEntity();
+ IntakesCommon updatedIntake =
+ (IntakesCommon) extractPart(input,
+ client.getCommonPartName(), IntakesCommon.class);
+ Assert.assertNotNull(updatedIntake);
+
+ Assert.assertEquals(updatedIntake.getEntryDate(),
+ intake.getEntryDate(),
+ "Data in updated object did not match submitted data.");
+
}
// Failure outcomes
// Placeholders until the three tests below can be uncommented.
// See Issue CSPACE-401.
- public void updateWithEmptyEntityBody() {
+ @Override
+ public void updateWithEmptyEntityBody() throws Exception{
}
-
- public void updateWithMalformedXml() {
+ @Override
+ public void updateWithMalformedXml() throws Exception {
}
-
- public void updateWithWrongXmlSchema() {
+ @Override
+ public void updateWithWrongXmlSchema() throws Exception {
}
/*
@Override
@Test(dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithEmptyEntityBody() {
+ public void updateWithEmptyEntityBody() throws Exception {
// Perform setup.
setupUpdateWithEmptyEntityBody();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("updateWithEmptyEntityBody url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("updateWithEmptyEntityBody url=" + url +
+ " status=" + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
@Override
@Test(dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithMalformedXml() {
+ public void updateWithMalformedXml() throws Exception {
// Perform setup.
setupUpdateWithMalformedXml();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("updateWithMalformedXml: url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("updateWithMalformedXml: url=" + url +
+ " status=" + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
@Override
@Test(dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithWrongXmlSchema() {
+ public void updateWithWrongXmlSchema() throws Exception {
// Perform setup.
setupUpdateWithWrongXmlSchema();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("updateWithWrongSchema: url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("updateWithWrongXmlSchema: url=" + url +
+ " status=" + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
}
*/
+
@Override
@Test(dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent() {
+ public void updateNonExistent() throws Exception {
// Perform setup.
setupUpdateNonExistent();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("updateNonExistent: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("updateNonExistent: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Success outcomes
@Override
@Test(dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
- public void delete() {
+ public void delete() throws Exception {
// Perform setup.
setupDelete();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("delete: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("delete: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Failure outcomes
@Override
@Test(dependsOnMethods = {"delete"})
- public void deleteNonExistent() {
+ public void deleteNonExistent() throws Exception {
// Perform setup.
setupDeleteNonExistent();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("deleteNonExistent: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("deleteNonExistent: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
public void testSubmitRequest() {
// Expected status code: 200 OK
- final int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
+ final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
// Submit the request to the service and store the response.
String method = ServiceRequestType.READ.httpMethodName();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("testSubmitRequest: url=" + url + " status=" + statusCode);
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ if(logger.isDebugEnabled()){
+ logger.debug("testSubmitRequest: url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertEquals(statusCode, EXPECTED_STATUS);
}
intake.setEntryNumber(entryNumber);
intake.setEntryDate(entryDate);
MultipartOutput multipart = new MultipartOutput();
- OutputPart commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
+ OutputPart commonPart =
+ multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
commonPart.getHeaders().add("label", client.getCommonPartName());
- verbose("to be created, intake common ", intake, IntakesCommon.class);
+ if(logger.isDebugEnabled()){
+ verbose("to be created, intake common ", intake, IntakesCommon.class);
+ }
return multipart;
}
import org.testng.Assert;
import org.testng.annotations.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* RelationServiceTest, carries out tests against a
* deployed and running Relation Service.
*/
public class RelationServiceTest extends AbstractServiceTest {
+ private final Logger logger =
+ LoggerFactory.getLogger(RelationServiceTest.class);
+
private RelationClient client = new RelationClient();
final String SERVICE_PATH_COMPONENT = "relations";
private String knownResourceId = null;
// Success outcomes
@Override
@Test
- public void create() {
+ public void create() throws Exception {
// Perform setup, such as initializing the type of service request
// (e.g. CREATE, DELETE), its valid and expected status codes, and
//
// Does it fall within the set of valid status codes?
// Does it exactly match the expected status code?
- verbose("create: status = " + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("create: status = " + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Store the ID returned from this create operation for
// additional tests below.
knownResourceId = extractId(res);
- verbose("create: knownResourceId=" + knownResourceId);
+ if(logger.isDebugEnabled()){
+ logger.debug("create: knownResourceId=" + knownResourceId);
+ }
}
@Override
@Test(dependsOnMethods = {"create"})
- public void createList() {
+ public void createList() throws Exception {
for(int i = 0; i < 3; i++){
create();
}
// Failure outcomes
// Placeholders until the three tests below can be uncommented.
// See Issue CSPACE-401.
- public void createWithEmptyEntityBody() {
+ public void createWithEmptyEntityBody() throws Exception {
}
- public void createWithMalformedXml() {
+ public void createWithMalformedXml() throws Exception {
}
- public void createWithWrongXmlSchema() {
+ public void createWithWrongXmlSchema() throws Exception {
}
/*
@Override
@Test(dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithEmptyEntityBody() {
+ public void createWithEmptyEntityBody() throws Exception {
// Perform setup.
setupCreateWithEmptyEntityBody();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("createWithEmptyEntityBody url=" + url + " status=" + statusCode);
+ 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(dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithMalformedXml() {
+ public void createWithMalformedXml() throws Exception {
// Perform setup.
setupCreateWithMalformedXml();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("createWithMalformedXml url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("createWithMalformedXml url=" + url +
+ " status=" + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
@Override
@Test(dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithWrongXmlSchema() {
+ public void createWithWrongXmlSchema()n throws Exception {
// Perform setup.
setupCreateWithWrongXmlSchema();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("createWithWrongSchema url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("createWithWrongSchema 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
@Override
@Test(dependsOnMethods = {"create"})
- public void read() {
+ public void read() throws Exception {
// Perform setup.
setupRead();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("read: status = " + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("read: status = " + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- // Verify that the resource identifier
- //FIXME: remove the following try catch once Aron fixes signatures
- try{
- MultipartInput input = (MultipartInput) res.getEntity();
- RelationsCommon relation = (RelationsCommon) extractPart(input,
- client.getCommonPartName(), RelationsCommon.class);
- Assert.assertNotNull(relation);
- } catch(Exception e){
- throw new RuntimeException(e);
- }
+ // Verify that the resource identifier ...
+ MultipartInput input = (MultipartInput) res.getEntity();
+ RelationsCommon relation = (RelationsCommon) extractPart(input,
+ client.getCommonPartName(), RelationsCommon.class);
+ Assert.assertNotNull(relation);
}
// Failure outcomes
@Override
@Test(dependsOnMethods = {"read"})
- public void readNonExistent() {
+ public void readNonExistent() throws Exception {
// Perform setup.
setupReadNonExistent();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("readNonExistent: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("readNonExistent: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Success outcomes
@Override
@Test(dependsOnMethods = {"createList", "read"})
- public void readList() {
+ public void readList() throws Exception {
// Perform setup.
setupReadList();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("readList: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("readList: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
list.getRelationListItem();
int i = 0;
for(RelationsCommonList.RelationListItem item : items){
- verbose("readList: list-item[" + i + "] csid=" +
+ logger.debug("readList: list-item[" + i + "] csid=" +
item.getCsid());
- verbose("readList: list-item[" + i + "] URI=" +
+ logger.debug("readList: list-item[" + i + "] URI=" +
item.getUri());
i++;
}
// Failure outcomes
// None at present.
+
// ---------------------------------------------------------------
// CRUD tests : UPDATE tests
// ---------------------------------------------------------------
+
// Success outcomes
@Override
@Test(dependsOnMethods = {"read"})
- public void update() {
+ public void update() throws Exception {
// Perform setup.
setupUpdate();
- try{
- // Retrieve an existing resource that we can update.
- ClientResponse<MultipartInput> res =
- client.read(knownResourceId);
- verbose("update: read status = " + res.getStatus());
- Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
- verbose("Got object to update with ID: " + knownResourceId);
- MultipartInput input = (MultipartInput) res.getEntity();
- RelationsCommon relation = (RelationsCommon) extractPart(input,
- client.getCommonPartName(), RelationsCommon.class);
- Assert.assertNotNull(relation);
-
- // Update the content of this resource.
- relation.setDocumentId1("updated-" + relation.getDocumentId1());
- relation.setDocumentType1("updated-" + relation.getDocumentType1());
- relation.setDocumentId2("updated-" + relation.getDocumentId2());
- relation.setDocumentType2("updated-" + relation.getDocumentType2());
+
+ // Retrieve an existing resource that we can update.
+ ClientResponse<MultipartInput> res =
+ client.read(knownResourceId);
+ if(logger.isDebugEnabled()){
+ logger.debug("update: read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+ if(logger.isDebugEnabled()){
+ logger.debug("Got object to update with ID: " + knownResourceId);
+ }
+ MultipartInput input = (MultipartInput) res.getEntity();
+ RelationsCommon relation = (RelationsCommon) extractPart(input,
+ client.getCommonPartName(), RelationsCommon.class);
+ Assert.assertNotNull(relation);
+
+ // Update the content of this resource.
+ relation.setDocumentId1("updated-" + relation.getDocumentId1());
+ relation.setDocumentType1("updated-" + relation.getDocumentType1());
+ relation.setDocumentId2("updated-" + relation.getDocumentId2());
+ relation.setDocumentType2("updated-" + relation.getDocumentType2());
+ if(logger.isDebugEnabled()){
verbose("updated object", relation, RelationsCommon.class);
+ }
- // Submit the request to the service and store the response.
- MultipartOutput output = new MultipartOutput();
- OutputPart commonPart = output.addPart(relation, MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getCommonPartName());
- res = client.update(knownResourceId, output);
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
- verbose("update: status = " + res.getStatus());
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- input = (MultipartInput) res.getEntity();
- RelationsCommon updatedObject = (RelationsCommon) extractPart(
- input, client.getCommonPartName(),
- RelationsCommon.class);
- Assert.assertNotNull(updatedObject);
-
- final String msg =
- "Data in updated object did not match submitted data.";
- Assert.assertEquals(
- updatedObject.getDocumentId1(), relation.getDocumentId1(), msg);
- Assert.assertEquals(
- updatedObject.getDocumentType1(), relation.getDocumentType1(), msg);
- Assert.assertEquals(
- updatedObject.getDocumentId2(), relation.getDocumentId2(), msg);
- Assert.assertEquals(
- updatedObject.getDocumentType2(), relation.getDocumentType2(), msg);
- }catch(Exception e){
- e.printStackTrace();
+ // Submit the request to the service and store the response.
+ MultipartOutput output = new MultipartOutput();
+ OutputPart commonPart = output.addPart(relation, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", client.getCommonPartName());
+ 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()){
+ logger.debug("update: status = " + res.getStatus());
}
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ input = (MultipartInput) res.getEntity();
+ RelationsCommon updatedObject = (RelationsCommon) extractPart(
+ input, client.getCommonPartName(),
+ RelationsCommon.class);
+ Assert.assertNotNull(updatedObject);
+
+ final String msg =
+ "Data in updated object did not match submitted data.";
+ Assert.assertEquals(
+ updatedObject.getDocumentId1(), relation.getDocumentId1(), msg);
+ Assert.assertEquals(
+ updatedObject.getDocumentType1(), relation.getDocumentType1(), msg);
+ Assert.assertEquals(
+ updatedObject.getDocumentId2(), relation.getDocumentId2(), msg);
+ Assert.assertEquals(
+ updatedObject.getDocumentType2(), relation.getDocumentType2(), msg);
}
// Failure outcomes
// Placeholders until the three tests below can be uncommented.
// See Issue CSPACE-401.
- public void updateWithEmptyEntityBody() {
+ public void updateWithEmptyEntityBody() throws Exception {
}
- public void updateWithMalformedXml() {
+ public void updateWithMalformedXml() throws Exception {
}
- public void updateWithWrongXmlSchema() {
+ public void updateWithWrongXmlSchema() throws Exception {
}
/*
@Override
@Test(dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithEmptyEntityBody() {
+ public void updateWithEmptyEntityBody() throws Exception {
// Perform setup.
setupUpdateWithEmptyEntityBody();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("updateWithEmptyEntityBody url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("updateWithEmptyEntityBody url=" + url +
+ " status=" + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
@Override
@Test(dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithMalformedXml() {
+ public void updateWithMalformedXml() throws Exception {
// Perform setup.
setupUpdateWithMalformedXml();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("updateWithMalformedXml: url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("updateWithMalformedXml: url=" + url +
+ " status=" + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
@Override
@Test(dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithWrongXmlSchema() {
+ public void updateWithWrongXmlSchema() throws Exception {
// Perform setup.
setupUpdateWithWrongXmlSchema();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("updateWithWrongSchema: url=" + url + " status=" + statusCode);
+ if(logger.isDebugEnabled()){
+ logger.debug("updateWithWrongXmlSchema: url=" + url +
+ " status=" + statusCode);
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
}
*/
+
@Override
@Test(dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent() {
+ public void updateNonExistent() throws Exception {
// Perform setup.
setupUpdateNonExistent();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("updateNonExistent: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("updateNonExistent: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Success outcomes
@Override
@Test(dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
- public void delete() {
+ public void delete() throws Exception {
// Perform setup.
setupDelete();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("delete: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("delete: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Failure outcomes
@Override
@Test(dependsOnMethods = {"delete"})
- public void deleteNonExistent() {
+ public void deleteNonExistent() throws Exception {
// Perform setup.
setupDeleteNonExistent();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("deleteNonExistent: status = " + res.getStatus());
+ if(logger.isDebugEnabled()){
+ logger.debug("deleteNonExistent: status = " + res.getStatus());
+ }
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
public void testSubmitRequest() {
// Expected status code: 200 OK
- final int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
+ final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
// Submit the request to the service and store the response.
String method = ServiceRequestType.READ.httpMethodName();
// Check the status code of the response: does it match
// the expected response(s)?
- verbose("testSubmitRequest: url=" + url + " status=" + statusCode);
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ if(logger.isDebugEnabled()){
+ logger.debug("testSubmitRequest: url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertEquals(statusCode, EXPECTED_STATUS);
}
fillRelation(relation, identifier);
MultipartOutput multipart = new MultipartOutput();
- OutputPart commonPart = multipart.addPart(relation, MediaType.APPLICATION_XML_TYPE);
+ OutputPart commonPart =
+ multipart.addPart(relation, MediaType.APPLICATION_XML_TYPE);
commonPart.getHeaders().add("label", client.getCommonPartName());
- verbose("to be created, relation common ", relation, RelationsCommon.class);
-
+ if(logger.isDebugEnabled()){
+ verbose("to be created, relation common ", relation,
+ RelationsCommon.class);
+ }
return multipart;
}