From fa9cd84fdfadcd6ce7948b29de2b13cf229245e2 Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Thu, 22 Oct 2009 20:29:33 +0000 Subject: [PATCH] CSPACE-471: Added TestNG annotations to client test framework and most client tests to return current test method name. Not yet implemented for Authentication or Vocabulary client tests. services/client module POM changed to broaden testng dependency scope to default (compile) from test, to facilitate imports in AbstractClientTest class." --- .../client/test/AcquisitionServiceTest.java | 152 +++++++++------- .../client/AuthenticationServiceTest.java | 35 ++-- services/client/pom.xml | 3 +- .../client/test/AbstractServiceTest.java | 118 ++++++++---- .../services/client/test/ServiceTest.java | 49 ++--- .../test/CollectionObjectServiceTest.java | 172 ++++++++++-------- .../client/test/IntakeServiceTest.java | 152 +++++++++------- .../client/test/RelationServiceTest.java | 151 ++++++++------- 8 files changed, 464 insertions(+), 368 deletions(-) diff --git a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java index 7a0d01170..9700810b2 100644 --- a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java +++ b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java @@ -62,13 +62,13 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // --------------------------------------------------------------- // Success outcomes @Override - @Test - public void create() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class) + public void create(String testName) throws Exception { // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(); + setupCreate(testName); // Submit the request to the service and store the response. String identifier = createIdentifier(); @@ -85,7 +85,7 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Does it fall within the set of valid status codes? // Does it exactly match the expected status code? if(logger.isDebugEnabled()){ - logger.debug("create: status = " + statusCode); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -100,10 +100,11 @@ public class AcquisitionServiceTest extends AbstractServiceTest { } @Override - @Test(dependsOnMethods = {"create"}) - public void createList() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create"}) + public void createList(String testName) throws Exception { for(int i = 0; i < 3; i++){ - create(); + create(testName); } } @@ -111,21 +112,22 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Placeholders until the three tests below can be uncommented. // See Issue CSPACE-401. @Override - public void createWithEmptyEntityBody() throws Exception { + public void createWithEmptyEntityBody(String testName) throws Exception { } @Override - public void createWithMalformedXml() throws Exception { + public void createWithMalformedXml(String testName) throws Exception { } @Override - public void createWithWrongXmlSchema() throws Exception { + public void createWithWrongXmlSchema(String testName) throws Exception { } /* @Override - @Test(dependsOnMethods = {"create", "testSubmitRequest"}) - public void createWithMalformedXml() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "testSubmitRequest"}) + public void createWithMalformedXml(String testName) throws Exception { // Perform setup. setupCreateWithMalformedXml(); @@ -139,7 +141,7 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("createWithMalformedXml url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -148,7 +150,8 @@ public class AcquisitionServiceTest extends AbstractServiceTest { } @Override - @Test(dependsOnMethods = {"create", "testSubmitRequest"}) + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithWrongXmlSchema() throws Exception { // Perform setup. @@ -163,7 +166,7 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("createWithWrongXmlSchema url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -177,11 +180,12 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // --------------------------------------------------------------- // Success outcomes @Override - @Test(dependsOnMethods = {"create"}) - public void read() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create"}) + public void read(String testName) throws Exception { // Perform setup. - setupRead(); + setupRead(testName); // Submit the request to the service and store the response. ClientResponse res = client.read(knownResourceId); @@ -190,26 +194,27 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("read: status = " + statusCode); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); MultipartInput input = (MultipartInput) res.getEntity(); - AcquisitionsCommon acquistionObject = (AcquisitionsCommon) extractPart(input, + AcquisitionsCommon acquisitionObject = (AcquisitionsCommon) extractPart(input, client.getCommonPartName(), AcquisitionsCommon.class); - Assert.assertNotNull(acquistionObject); + Assert.assertNotNull(acquisitionObject); } // Failure outcomes @Override - @Test(dependsOnMethods = {"read"}) - public void readNonExistent() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"read"}) + public void readNonExistent(String testName) throws Exception { // Perform setup. - setupReadNonExistent(); + setupReadNonExistent(testName); // Submit the request to the service and store the response. ClientResponse res = client.read(NON_EXISTENT_ID); @@ -218,7 +223,7 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("readNonExistent: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -230,11 +235,12 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // --------------------------------------------------------------- // Success outcomes @Override - @Test(dependsOnMethods = {"createList", "read"}) - public void readList() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"createList", "read"}) + public void readList(String testName) throws Exception { // Perform setup. - setupReadList(); + setupReadList(testName); // Submit the request to the service and store the response. ClientResponse res = client.readList(); @@ -244,7 +250,7 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("readList: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -257,11 +263,11 @@ public class AcquisitionServiceTest extends AbstractServiceTest { list.getAcquisitionListItem(); int i = 0; for(AcquisitionsCommonList.AcquisitionListItem item : items){ - logger.debug("readList: list-item[" + i + "] csid=" + + logger.debug(testName + ": list-item[" + i + "] csid=" + item.getCsid()); - logger.debug("readList: list-item[" + i + "] objectNumber=" + + logger.debug(testName + ": list-item[" + i + "] objectNumber=" + item.getAccessionDate()); - logger.debug("readList: list-item[" + i + "] URI=" + + logger.debug(testName + ": list-item[" + i + "] URI=" + item.getUri()); i++; } @@ -278,16 +284,17 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Success outcomes @Override - @Test(dependsOnMethods = {"read"}) - public void update() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"read"}) + public void update(String testName) throws Exception { // Perform setup. - setupUpdate(); + setupUpdate(testName); ClientResponse res = client.read(knownResourceId); if(logger.isDebugEnabled()){ - logger.debug("update: read status = " + res.getStatus()); + logger.debug(testName + ": read status = " + res.getStatus()); } Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE); @@ -313,7 +320,7 @@ public class AcquisitionServiceTest extends AbstractServiceTest { 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()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -335,22 +342,26 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Failure outcomes // Placeholders until the three tests below can be uncommented. // See Issue CSPACE-401. - public void updateWithEmptyEntityBody() throws Exception { + @Override + public void updateWithEmptyEntityBody(String testName) throws Exception { } - public void updateWithMalformedXml() throws Exception { + @Override + public void updateWithMalformedXml(String testName) throws Exception { } - public void updateWithWrongXmlSchema() throws Exception { + @Override + public void updateWithWrongXmlSchema(String testName) throws Exception { } /* @Override - @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"}) - public void updateWithEmptyEntityBody() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "update", "testSubmitRequest"}) + public void updateWithEmptyEntityBody(String testName) throws Exception { // Perform setup. - setupUpdateWithEmptyEntityBody(); + setupUpdateWithEmptyEntityBody(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -362,19 +373,20 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - ("updateWithEmptyEntityBody url=" + url + " status=" + statusCode); - } + (testName + ": 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"}) + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithEmptyEntityBody() throws Exception { // Perform setup. - setupCreateWithEmptyEntityBody(); + setupCreateWithEmptyEntityBody(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -386,20 +398,21 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("createWithEmptyEntityBody url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); - } + } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override - @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"}) - public void updateWithMalformedXml() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "update", "testSubmitRequest"}) + public void updateWithMalformedXml(String testName) throws Exception { // Perform setup. - setupUpdateWithMalformedXml(); + setupUpdateWithMalformedXml(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -410,7 +423,7 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("updateWithMalformedXml: url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -420,10 +433,10 @@ public class AcquisitionServiceTest extends AbstractServiceTest { @Override @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"}) - public void updateWithWrongXmlSchema() { + public void updateWithWrongXmlSchema(String testName) { // Perform setup. - setupUpdateWithWrongXmlSchema(); + setupUpdateWithWrongXmlSchema(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -434,7 +447,7 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("updateWithWrongXmlSchema: url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -444,11 +457,12 @@ public class AcquisitionServiceTest extends AbstractServiceTest { */ @Override - @Test(dependsOnMethods = {"update", "testSubmitRequest"}) - public void updateNonExistent() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"update", "testSubmitRequest"}) + public void updateNonExistent(String testName) throws Exception { // Perform setup. - setupUpdateNonExistent(); + setupUpdateNonExistent(testName); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. @@ -461,7 +475,7 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("updateNonExistent: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -473,11 +487,12 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // --------------------------------------------------------------- // Success outcomes @Override - @Test(dependsOnMethods = {"create", "read", "update"}) - public void delete() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "read", "update"}) + public void delete(String testName) throws Exception { // Perform setup. - setupDelete(); + setupDelete(testName); // Submit the request to the service and store the response. ClientResponse res = client.delete(knownResourceId); @@ -486,7 +501,7 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("delete: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -495,11 +510,12 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Failure outcomes @Override - @Test(dependsOnMethods = {"delete"}) - public void deleteNonExistent() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"delete"}) + public void deleteNonExistent(String testName) throws Exception { // Perform setup. - setupDeleteNonExistent(); + setupDeleteNonExistent(testName); // Submit the request to the service and store the response. ClientResponse res = client.delete(NON_EXISTENT_ID); @@ -508,7 +524,7 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("deleteNonExistent: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); diff --git a/services/authentication/client/src/test/java/org/collectionspace/services/authentication/client/AuthenticationServiceTest.java b/services/authentication/client/src/test/java/org/collectionspace/services/authentication/client/AuthenticationServiceTest.java index 72ebe285d..460b6af62 100644 --- a/services/authentication/client/src/test/java/org/collectionspace/services/authentication/client/AuthenticationServiceTest.java +++ b/services/authentication/client/src/test/java/org/collectionspace/services/authentication/client/AuthenticationServiceTest.java @@ -66,9 +66,9 @@ public class AuthenticationServiceTest extends AbstractServiceTest { /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTest#create() */ - @Test + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class) @Override - public void create() { + public void create(String testName) { CollectionObjectClient collectionObjectClient = new CollectionObjectClient(); String identifier = this.createIdentifier(); MultipartOutput multipart = createCollectionObjectInstance( @@ -289,8 +289,9 @@ public class AuthenticationServiceTest extends AbstractServiceTest { * @see org.collectionspace.services.client.test.AbstractServiceTest#delete() */ @Override - @Test(dependsOnMethods = { "createWithIncorrectUserPassword" }) - public void delete() { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = { "createWithIncorrectUserPassword" }) + public void delete(String testName) { CollectionObjectClient collectionObjectClient = new CollectionObjectClient(); collectionObjectClient = new CollectionObjectClient(); if (!collectionObjectClient.isServerSecure()) { @@ -371,90 +372,90 @@ public class AuthenticationServiceTest extends AbstractServiceTest { * @see org.collectionspace.services.client.test.AbstractServiceTest#createList() */ @Override - public void createList() throws Exception { + public void createList(String testName) throws Exception { } /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTest#createWithEmptyEntityBody() */ @Override - public void createWithEmptyEntityBody() throws Exception { + public void createWithEmptyEntityBody(String testName) throws Exception { } /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTest#createWithMalformedXml() */ @Override - public void createWithMalformedXml() throws Exception { + public void createWithMalformedXml(String testName) throws Exception { } /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTest#createWithWrongXmlSchema() */ @Override - public void createWithWrongXmlSchema() throws Exception { + public void createWithWrongXmlSchema(String testName) throws Exception { } /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTest#read() */ @Override - public void read() throws Exception { + public void read(String testName) throws Exception { } /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTest#readNonExistent() */ @Override - public void readNonExistent() throws Exception { + public void readNonExistent(String testName) throws Exception { } /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTest#readList() */ @Override - public void readList() throws Exception { + public void readList(String testName) throws Exception { } /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTest#update() */ @Override - public void update() throws Exception { + public void update(String testName) throws Exception { } /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTest#updateWithEmptyEntityBody() */ @Override - public void updateWithEmptyEntityBody() throws Exception { + public void updateWithEmptyEntityBody(String testName) throws Exception { } /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTest#updateWithMalformedXml() */ @Override - public void updateWithMalformedXml() throws Exception { + public void updateWithMalformedXml(String testName) throws Exception { } /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTest#updateWithWrongXmlSchema() */ @Override - public void updateWithWrongXmlSchema() throws Exception { + public void updateWithWrongXmlSchema(String testName) throws Exception { } /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTest#updateNonExistent() */ @Override - public void updateNonExistent() throws Exception { + public void updateNonExistent(String testName) throws Exception { } /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTest#deleteNonExistent() */ @Override - public void deleteNonExistent() throws Exception { + public void deleteNonExistent(String testName) throws Exception { } } diff --git a/services/client/pom.xml b/services/client/pom.xml index 5e05751fa..5bbebfc25 100644 --- a/services/client/pom.xml +++ b/services/client/pom.xml @@ -52,11 +52,12 @@ resteasy-multipart-provider 1.0.2.GA + + org.testng testng 5.6 - test diff --git a/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTest.java b/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTest.java index 4bdfe0463..04fe9926b 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTest.java +++ b/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTest.java @@ -24,6 +24,7 @@ package org.collectionspace.services.client.test; import java.io.ByteArrayInputStream; +import java.lang.reflect.Method; import java.util.ArrayList; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; @@ -39,6 +40,9 @@ import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.plugins.providers.multipart.InputPart; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; + +import org.testng.annotations.DataProvider; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -80,13 +84,14 @@ public abstract class AbstractServiceTest implements ServiceTest { XML_DECLARATION + "wrong schema contents"; + // --------------------------------------------------------------- // CRUD tests : CREATE tests // --------------------------------------------------------------- // Success outcomes @Override - public void create() throws Exception { + public void create(String testName) throws Exception { } protected void setupCreate() { @@ -101,19 +106,19 @@ public abstract class AbstractServiceTest implements ServiceTest { REQUEST_TYPE = ServiceRequestType.CREATE; // Print a banner identifying the test that will be run. if (logger.isDebugEnabled()) { - printBanner(label); + banner(label); } } @Override - public abstract void createList() throws Exception; + public abstract void createList(String testName) throws Exception; // No setup required for createList() // Failure outcomes @Override - public abstract void createWithEmptyEntityBody() + public abstract void createWithEmptyEntityBody(String testName) throws Exception; protected void setupCreateWithEmptyEntityBody() { @@ -125,12 +130,12 @@ public abstract class AbstractServiceTest implements ServiceTest { EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode(); REQUEST_TYPE = ServiceRequestType.CREATE; if (logger.isDebugEnabled()) { - printBanner(label); + banner(label); } } @Override - public abstract void createWithMalformedXml() throws Exception; + public abstract void createWithMalformedXml(String testName) throws Exception; protected void setupCreateWithMalformedXml() { setupCreateWithMalformedXml("CreateWithMalformedXml"); @@ -142,12 +147,12 @@ public abstract class AbstractServiceTest implements ServiceTest { EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode(); REQUEST_TYPE = ServiceRequestType.CREATE; if (logger.isDebugEnabled()) { - printBanner(label); + banner(label); } } @Override - public abstract void createWithWrongXmlSchema() throws Exception; + public abstract void createWithWrongXmlSchema(String testName) throws Exception; protected void setupCreateWithWrongXmlSchema() { setupCreateWithWrongXmlSchema("CreateWithWrongXmlSchema"); @@ -159,7 +164,7 @@ public abstract class AbstractServiceTest implements ServiceTest { EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode(); REQUEST_TYPE = ServiceRequestType.CREATE; if (logger.isDebugEnabled()) { - printBanner(label); + banner(label); } } @@ -169,7 +174,7 @@ public abstract class AbstractServiceTest implements ServiceTest { // Success outcomes @Override - public abstract void read() throws Exception; + public abstract void read(String testName) throws Exception; protected void setupRead() { setupRead("Read"); @@ -181,13 +186,13 @@ public abstract class AbstractServiceTest implements ServiceTest { EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode(); REQUEST_TYPE = ServiceRequestType.READ; if (logger.isDebugEnabled()) { - printBanner(label); + banner(label); } } // Failure outcomes @Override - public abstract void readNonExistent() throws Exception; + public abstract void readNonExistent(String testName) throws Exception; protected void setupReadNonExistent() { setupReadNonExistent("ReadNonExistent"); @@ -199,7 +204,7 @@ public abstract class AbstractServiceTest implements ServiceTest { EXPECTED_STATUS_CODE = Response.Status.NOT_FOUND.getStatusCode(); REQUEST_TYPE = ServiceRequestType.READ; if (logger.isDebugEnabled()) { - printBanner(label); + banner(label); } } @@ -209,7 +214,7 @@ public abstract class AbstractServiceTest implements ServiceTest { // Success outcomes @Override - public abstract void readList() throws Exception; + public abstract void readList(String testName) throws Exception; protected void setupReadList() { setupReadList("ReadList"); @@ -221,7 +226,7 @@ public abstract class AbstractServiceTest implements ServiceTest { EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode(); REQUEST_TYPE = ServiceRequestType.READ_LIST; if (logger.isDebugEnabled()) { - printBanner(label); + banner(label); } } @@ -234,7 +239,7 @@ public abstract class AbstractServiceTest implements ServiceTest { // Success outcomes @Override - public abstract void update() throws Exception; + public abstract void update(String testName) throws Exception; protected void setupUpdate() { setupUpdate("Update"); @@ -246,13 +251,13 @@ public abstract class AbstractServiceTest implements ServiceTest { EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode(); REQUEST_TYPE = ServiceRequestType.UPDATE; if (logger.isDebugEnabled()) { - printBanner(label); + banner(label); } } // Failure outcomes @Override - public abstract void updateWithEmptyEntityBody() throws Exception; + public abstract void updateWithEmptyEntityBody(String testName) throws Exception; protected void setupUpdateWithEmptyEntityBody() { setupUpdateWithEmptyEntityBody("UpdateWithEmptyEntityBody"); @@ -264,12 +269,12 @@ public abstract class AbstractServiceTest implements ServiceTest { EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode(); REQUEST_TYPE = ServiceRequestType.UPDATE; if (logger.isDebugEnabled()) { - printBanner(label); + banner(label); } } @Override - public abstract void updateWithMalformedXml() throws Exception; + public abstract void updateWithMalformedXml(String testName) throws Exception; protected void setupUpdateWithMalformedXml() { setupUpdateWithMalformedXml("UpdateWithMalformedXml"); @@ -281,12 +286,12 @@ public abstract class AbstractServiceTest implements ServiceTest { EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode(); REQUEST_TYPE = ServiceRequestType.UPDATE; if (logger.isDebugEnabled()) { - printBanner(label); + banner(label); } } @Override - public abstract void updateWithWrongXmlSchema() throws Exception; + public abstract void updateWithWrongXmlSchema(String testName) throws Exception; protected void setupUpdateWithWrongXmlSchema() { setupUpdateWithWrongXmlSchema("UpdateWithWrongXmlSchema"); @@ -298,12 +303,12 @@ public abstract class AbstractServiceTest implements ServiceTest { EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode(); REQUEST_TYPE = ServiceRequestType.UPDATE; if (logger.isDebugEnabled()) { - printBanner(label); + banner(label); } } @Override - public abstract void updateNonExistent() throws Exception; + public abstract void updateNonExistent(String testName) throws Exception; protected void setupUpdateNonExistent() { setupUpdateNonExistent("UpdateNonExistent"); @@ -315,7 +320,7 @@ public abstract class AbstractServiceTest implements ServiceTest { EXPECTED_STATUS_CODE = Response.Status.NOT_FOUND.getStatusCode(); REQUEST_TYPE = ServiceRequestType.UPDATE; if (logger.isDebugEnabled()) { - printBanner(label); + banner(label); } } @@ -325,7 +330,7 @@ public abstract class AbstractServiceTest implements ServiceTest { // Success outcomes @Override - public abstract void delete() throws Exception; + public abstract void delete(String testName) throws Exception; protected void setupDelete() { setupDelete("Delete"); @@ -337,13 +342,13 @@ public abstract class AbstractServiceTest implements ServiceTest { EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode(); REQUEST_TYPE = ServiceRequestType.DELETE; if (logger.isDebugEnabled()) { - printBanner(label); + banner(label); } } // Failure outcomes @Override - public abstract void deleteNonExistent() throws Exception; + public abstract void deleteNonExistent(String testName) throws Exception; protected void setupDeleteNonExistent() { setupDeleteNonExistent("DeleteNonExistent"); @@ -355,7 +360,7 @@ public abstract class AbstractServiceTest implements ServiceTest { EXPECTED_STATUS_CODE = Response.Status.NOT_FOUND.getStatusCode(); REQUEST_TYPE = ServiceRequestType.DELETE; if (logger.isDebugEnabled()) { - printBanner(label); + banner(label); } } @@ -370,9 +375,20 @@ public abstract class AbstractServiceTest implements ServiceTest { * * This component will follow directly after the * base path, if any. + * + * @return The URL path component of the service. */ protected abstract String getServicePathComponent(); + /** + * Returns the common part name for the service request. + * + * @return The common part name for the service request. + */ +/* + public String getCommonPartName(); +*/ + // --------------------------------------------------------------- // Utility methods // --------------------------------------------------------------- @@ -385,6 +401,23 @@ public abstract class AbstractServiceTest implements ServiceTest { REQUEST_TYPE = ServiceRequestType.NON_EXISTENT; } + /** + * Returns the name of the currently running test. + * + * Note: although the return type is listed as Object[][], + * this method instead returns a String. + * + * @param m The currently running test method. + * + * @return The name of the currently running test method. + */ + @DataProvider(name="testName") + public static Object[][] testName(Method m){ + return new Object[][]{ + new Object[] { m.getName() } + }; + } + /** * Returns an error message indicating that the status code returned by a * specific call to a service does not fall within a set of valid status @@ -500,10 +533,14 @@ public abstract class AbstractServiceTest implements ServiceTest { protected String extractId(ClientResponse res) { MultivaluedMap mvm = res.getMetadata(); String uri = (String) ((ArrayList) mvm.get("Location")).get(0); - verbose("extractId:uri=" + uri); + if(logger.isDebugEnabled()){ + logger.debug("extractId:uri=" + uri); + } String[] segments = uri.split("/"); String id = segments[segments.length - 1]; - verbose("id=" + id); + if(logger.isDebugEnabled()){ + logger.debug("id=" + id); + } return id; } @@ -523,9 +560,13 @@ public abstract class AbstractServiceTest implements ServiceTest { String partLabel = part.getHeaders().getFirst("label"); if(label.equalsIgnoreCase(partLabel)){ String partStr = part.getBodyAsString(); - verbose("extracted part str=\n" + partStr); + if(logger.isDebugEnabled()){ + logger.debug("extracted part str=\n" + partStr); + } obj = part.getBody(clazz, null); - verbose("extracted part obj=\n", obj, clazz); + if(logger.isDebugEnabled()){ + logger.debug("extracted part obj=\n", obj, clazz); + } break; } } @@ -564,7 +605,9 @@ public abstract class AbstractServiceTest implements ServiceTest { protected void verbose(String msg, Object o, Class clazz) { try{ - verbose(msg); + if(logger.isDebugEnabled()){ + logger.debug(msg); + } JAXBContext jc = JAXBContext.newInstance(clazz); Marshaller m = jc.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, @@ -578,11 +621,14 @@ public abstract class AbstractServiceTest implements ServiceTest { protected void verboseMap(MultivaluedMap map) { for(Object entry : map.entrySet()){ MultivaluedMap.Entry mentry = (MultivaluedMap.Entry) entry; - verbose(" name=" + mentry.getKey() + " value=" + mentry.getValue()); + if(logger.isDebugEnabled()){ + logger.debug(" name=" + mentry.getKey() + + " value=" + mentry.getValue()); + } } } - private void printBanner(String label) { + private void banner(String label) { if(logger.isDebugEnabled()){ logger.debug("==================================================="); logger.debug(" Test = " + label); diff --git a/services/client/src/main/java/org/collectionspace/services/client/test/ServiceTest.java b/services/client/src/main/java/org/collectionspace/services/client/test/ServiceTest.java index d878c8432..e778414a6 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/test/ServiceTest.java +++ b/services/client/src/main/java/org/collectionspace/services/client/test/ServiceTest.java @@ -26,24 +26,15 @@ package org.collectionspace.services.client.test; /** * ServiceTest, interface specifying the client tests to be performed * to test an entity or relation service. + * + * The 'testName' parameter will receive the name of the currently + * running test by means of reflection, from a TestNG DataProvider. + * + * @see org.collectionspace.services.client.test.AbstractServiceTest#testName */ public interface ServiceTest { - /** - * Returns the URL path component of the service. - * - * This component will follow directly after the - * base path, if any. - */ -// public String getServicePathComponent(); -// -// /** -// * getCommonPartName get common part name for the service request -// * @return -// */ -// public String getCommonPartName(); - // --------------------------------------------------------------- // CRUD tests : CREATE tests // --------------------------------------------------------------- @@ -55,7 +46,7 @@ public interface ServiceTest { * * Relied upon by 'read', 'update' and 'delete' tests, below. */ - public void create() throws Exception; + public void create(String testName) throws Exception; /** * Tests creation of a list of two or more new resources by repeatedly @@ -63,7 +54,7 @@ public interface ServiceTest { * * Relied upon by 'read list' tests, below. */ - public void createList() throws Exception; + public void createList(String testName) throws Exception; // Failure outcomes @@ -71,20 +62,20 @@ public interface ServiceTest { * Tests creation of a resource by submitting * an empty entity body (aka empty payload). */ - public void createWithEmptyEntityBody() throws Exception; + public void createWithEmptyEntityBody(String testName) throws Exception; /** * Tests creation of a resource by submitting * a representation with malformed XML data. */ - public void createWithMalformedXml() throws Exception; + public void createWithMalformedXml(String testName) 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() throws Exception; + public void createWithWrongXmlSchema(String testName) throws Exception; // @TODO If feasible, implement a negative (failure) // test for creation of duplicate resources. @@ -99,7 +90,7 @@ public interface ServiceTest { /** * Tests reading (i.e. retrieval) of a resource. */ - public void read() throws Exception; + public void read(String testName) throws Exception; // Failure outcomes @@ -108,7 +99,7 @@ public interface ServiceTest { * resource, whose resource identifier does not exist * at the specified URL. */ - public void readNonExistent() throws Exception; + public void readNonExistent(String testName) throws Exception; // --------------------------------------------------------------- @@ -121,7 +112,7 @@ public interface ServiceTest { * Tests reading (i.e. retrieval) of a list of * multiple resources. */ - public void readList() throws Exception; + public void readList(String testName) throws Exception; // If feasible, implement a test for reading // an empty list returned by the service. @@ -143,7 +134,7 @@ public interface ServiceTest { /** * Tests updating the content of a resource. */ - public void update() throws Exception; + public void update(String testName) throws Exception; // Failure outcomes @@ -151,27 +142,27 @@ public interface ServiceTest { * Tests updating the content of a resource * by submitting an empty entity body (aka empty payload). */ - public void updateWithEmptyEntityBody() throws Exception; + public void updateWithEmptyEntityBody(String testName) throws Exception; /** * Tests updating the content of a resource * by submitting a representation with malformed * XML data. */ - public void updateWithMalformedXml() throws Exception; + public void updateWithMalformedXml(String testName) 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() throws Exception; + public void updateWithWrongXmlSchema(String testName) throws Exception; /** * Tests updating the content of a non-existent * resource, whose resource identifier does not exist. */ - public void updateNonExistent() throws Exception; + public void updateNonExistent(String testName) throws Exception; // --------------------------------------------------------------- @@ -183,7 +174,7 @@ public interface ServiceTest { /** * Tests deleting a resource. */ - public void delete() throws Exception; + public void delete(String testName) throws Exception; // Failure outcomes @@ -191,7 +182,7 @@ public interface ServiceTest { * Tests deleting a non-existent resource, whose resource * identifier does not exist at the specified URL. */ - public void deleteNonExistent() throws Exception; + public void deleteNonExistent(String testName) throws Exception; } diff --git a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java index 19746a564..819d2be50 100644 --- a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java +++ b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java @@ -56,36 +56,35 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Instance variables specific to this test. private CollectionObjectClient client = new CollectionObjectClient(); - private String knownResourceId = null; + private String knownResourceId = null; /* * This method is called only by the parent class, AbstractServiceTest */ @Override - public String getServicePathComponent() { + protected String getServicePathComponent() { return client.getServicePathComponent(); } - // --------------------------------------------------------------- + // --------------------------------------------------------------- // CRUD tests : CREATE tests // --------------------------------------------------------------- // Success outcomes @Override - @Test - public void create() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class) + public void create(String testName) throws Exception { // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(); + setupCreate(testName); // Submit the request to the service and store the response. String identifier = createIdentifier(); - - MultipartOutput multipart = createCollectionObjectInstance(client.getCommonPartName(), identifier); + MultipartOutput multipart = + createCollectionObjectInstance(client.getCommonPartName(), identifier); ClientResponse res = client.create(multipart); - int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -95,7 +94,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Does it fall within the set of valid status codes? // Does it exactly match the expected status code? if(logger.isDebugEnabled()){ - logger.debug("create: status = " + statusCode); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -105,18 +104,19 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // for additional tests below. knownResourceId = extractId(res); if(logger.isDebugEnabled()){ - logger.debug("create: knownResourceId=" + knownResourceId); + logger.debug(testName + ": knownResourceId=" + knownResourceId); } } /* (non-Javadoc) - * @see org.collectionspace.services.client.test.AbstractServiceTest#createList() + * @see org.collectionspace.services.client.test.ServiceTest#createList() */ @Override - @Test(dependsOnMethods = {"create"}) - public void createList() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create"}) + public void createList(String testName) throws Exception { for(int i = 0; i < 3; i++){ - create(); + create(testName); } } @@ -125,20 +125,21 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Placeholders until the three tests below can be uncommented. // See Issue CSPACE-401. @Override - public void createWithEmptyEntityBody() throws Exception {} + public void createWithEmptyEntityBody(String testName) throws Exception {} @Override - public void createWithMalformedXml() throws Exception {} + public void createWithMalformedXml(String testName) throws Exception {} @Override - public void createWithWrongXmlSchema() throws Exception {} + public void createWithWrongXmlSchema(String testName) throws Exception {} /* @Override - @Test(dependsOnMethods = {"create", "testSubmitRequest"}) - public void createWithEmptyEntityBody() throwsException { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "testSubmitRequest"}) + public void createWithEmptyEntityBody(String testName) throwsException { // Perform setup. - setupCreateWithEmptyEntityBody(); + setupCreateWithEmptyEntityBody(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -150,7 +151,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("createWithEmptyEntityBody url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -159,11 +160,12 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { } @Override - @Test(dependsOnMethods = {"create", "testSubmitRequest"}) - public void createWithMalformedXml() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "testSubmitRequest"}) + public void createWithMalformedXml(String testName) throws Exception { // Perform setup. - setupCreateWithMalformedXml(); + setupCreateWithMalformedXml(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -175,7 +177,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("createWithMalformedXml url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -184,11 +186,12 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { } @Override - @Test(dependsOnMethods = {"create", "testSubmitRequest"}) - public void createWithWrongXmlSchema() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "testSubmitRequest"}) + public void createWithWrongXmlSchema(String testName) throws Exception { // Perform setup. - setupCreateWithWrongXmlSchema(); + setupCreateWithWrongXmlSchema(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -200,7 +203,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("createWithWrongXmlSchema url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -215,11 +218,12 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Success outcomes @Override - @Test(dependsOnMethods = {"create"}) - public void read() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create"}) + public void read(String testName) throws Exception { // Perform setup. - setupRead(); + setupRead(testName); // Submit the request to the service and store the response. ClientResponse res = client.read(knownResourceId); @@ -228,7 +232,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("read: status = " + statusCode); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -244,11 +248,12 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Failure outcomes @Override - @Test(dependsOnMethods = {"read"}) - public void readNonExistent() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"read"}) + public void readNonExistent(String testName) throws Exception { // Perform setup. - setupReadNonExistent(); + setupReadNonExistent(testName); // Submit the request to the service and store the response. ClientResponse res = client.read(NON_EXISTENT_ID); @@ -257,7 +262,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("readNonExistent: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -269,21 +274,22 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // --------------------------------------------------------------- // Success outcomes @Override - @Test(dependsOnMethods = {"createList", "read"}) - public void readList() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"createList", "read"}) + public void readList(String testName) throws Exception { + // Perform setup. - setupReadList(); + setupReadList(testName); // Submit the request to the service and store the response. ClientResponse res = client.readList(); CollectionobjectsCommonList list = res.getEntity(); - int statusCode = res.getStatus(); // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("readList: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -297,11 +303,11 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { int i = 0; for(CollectionobjectsCommonList.CollectionObjectListItem item : items){ - logger.debug("readList: list-item[" + i + "] csid=" + + logger.debug(testName + ": list-item[" + i + "] csid=" + item.getCsid()); - logger.debug("readList: list-item[" + i + "] objectNumber=" + + logger.debug(testName + ": list-item[" + i + "] objectNumber=" + item.getObjectNumber()); - logger.debug("readList: list-item[" + i + "] URI=" + + logger.debug(testName + ": list-item[" + i + "] URI=" + item.getUri()); i++; @@ -311,21 +317,23 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Failure outcomes // None at present. + // --------------------------------------------------------------- // CRUD tests : UPDATE tests // --------------------------------------------------------------- // Success outcomes @Override - @Test(dependsOnMethods = {"read"}) - public void update() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"read"}) + public void update(String testName) throws Exception { // Perform setup. - setupUpdate(); + setupUpdate(testName); ClientResponse res = client.read(knownResourceId); if(logger.isDebugEnabled()){ - logger.debug("update: read status = " + res.getStatus()); + logger.debug(testName + ": read status = " + res.getStatus()); } Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE); @@ -354,7 +362,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { 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()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -378,20 +386,20 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Placeholders until the three tests below can be uncommented. // See Issue CSPACE-401. @Override - public void updateWithEmptyEntityBody() throws Exception {} + public void updateWithEmptyEntityBody(String testName) throws Exception {} @Override - public void updateWithMalformedXml() throws Exception {} + public void updateWithMalformedXml(String testName) throws Exception {} @Override - public void updateWithWrongXmlSchema() throws Exception {} + public void updateWithWrongXmlSchema(String testName) throws Exception {} /* @Override - - @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"}) - public void updateWithEmptyEntityBody() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "update", "testSubmitRequest"}) + public void updateWithEmptyEntityBody(String testName) throws Exception { // Perform setup. - setupUpdateWithEmptyEntityBody(); + setupUpdateWithEmptyEntityBody(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -403,7 +411,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("updateWithEmptyEntityBody url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -412,11 +420,12 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { } @Override - @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"}) + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithMalformedXml() throws Exception { // Perform setup. - setupUpdateWithMalformedXml(); + setupUpdateWithMalformedXml(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -428,7 +437,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("updateWithMalformedXml: url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -437,11 +446,12 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { } @Override - @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"}) - public void updateWithWrongXmlSchema() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "update", "testSubmitRequest"}) + public void updateWithWrongXmlSchema(String testName) throws Exception { // Perform setup. - setupUpdateWithWrongXmlSchema(); + setupUpdateWithWrongXmlSchema(String testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -453,7 +463,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("updateWithWrongXmlSchema: url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -463,28 +473,28 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { */ @Override - @Test(dependsOnMethods = {"update", "testSubmitRequest"}) - public void updateNonExistent() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"update", "testSubmitRequest"}) + public void updateNonExistent(String testName) throws Exception { // Perform setup. - setupUpdateNonExistent(); + setupUpdateNonExistent(testName); // Submit the request to the service and store the response. + // // 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); ClientResponse res = client.update(NON_EXISTENT_ID, multipart); - int statusCode = res.getStatus(); // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("updateNonExistent: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -496,11 +506,12 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // --------------------------------------------------------------- // Success outcomes @Override - @Test(dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) - public void delete() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) + public void delete(String testName) throws Exception { // Perform setup. - setupDelete(); + setupDelete(testName); // Submit the request to the service and store the response. ClientResponse res = client.delete(knownResourceId); @@ -509,7 +520,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("delete: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -518,11 +529,12 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Failure outcomes @Override - @Test(dependsOnMethods = {"delete"}) - public void deleteNonExistent() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"delete"}) + public void deleteNonExistent(String testName) throws Exception { // Perform setup. - setupDeleteNonExistent(); + setupDeleteNonExistent(testName); // Submit the request to the service and store the response. ClientResponse res = client.delete(NON_EXISTENT_ID); @@ -531,7 +543,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("deleteNonExistent: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java index be6a4bcff..811f61c42 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java @@ -63,13 +63,13 @@ public class IntakeServiceTest extends AbstractServiceTest { // --------------------------------------------------------------- // Success outcomes @Override - @Test - public void create() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class) + public void create(String testName) throws Exception { // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(); + setupCreate(testName); // Submit the request to the service and store the response. String identifier = createIdentifier(); @@ -86,7 +86,7 @@ public class IntakeServiceTest extends AbstractServiceTest { // Does it fall within the set of valid status codes? // Does it exactly match the expected status code? if(logger.isDebugEnabled()){ - logger.debug("create: status = " + statusCode); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -96,15 +96,16 @@ public class IntakeServiceTest extends AbstractServiceTest { // for additional tests below. knownResourceId = extractId(res); if(logger.isDebugEnabled()){ - logger.debug("create: knownResourceId=" + knownResourceId); + logger.debug(testName + ": knownResourceId=" + knownResourceId); } } @Override - @Test(dependsOnMethods = {"create"}) - public void createList() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create"}) + public void createList(String testName) throws Exception { for(int i = 0; i < 3; i++){ - create(); + create(testName); } } @@ -112,24 +113,25 @@ public class IntakeServiceTest extends AbstractServiceTest { // Placeholders until the three tests below can be uncommented. // See Issue CSPACE-401. @Override - public void createWithEmptyEntityBody() throws Exception { + public void createWithEmptyEntityBody(String testName) throws Exception { } @Override - public void createWithMalformedXml() throws Exception { + public void createWithMalformedXml(String testName) throws Exception { } @Override - public void createWithWrongXmlSchema() throws Exception { + public void createWithWrongXmlSchema(String testName) throws Exception { } /* @Override - @Test(dependsOnMethods = {"create", "testSubmitRequest"}) - public void createWithEmptyEntityBody() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "testSubmitRequest"}) + public void createWithEmptyEntityBody(String testName) throws Exception { // Perform setup. - setupCreateWithEmptyEntityBody(); + setupCreateWithEmptyEntityBody(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -150,11 +152,12 @@ public class IntakeServiceTest extends AbstractServiceTest { } @Override - @Test(dependsOnMethods = {"create", "testSubmitRequest"}) - public void createWithMalformedXml() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "testSubmitRequest"}) + public void createWithMalformedXml(String testName) throws Exception { // Perform setup. - setupCreateWithMalformedXml(); + setupCreateWithMalformedXml(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -166,7 +169,7 @@ public class IntakeServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("createWithMalformedXml url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -175,11 +178,12 @@ public class IntakeServiceTest extends AbstractServiceTest { } @Override - @Test(dependsOnMethods = {"create", "testSubmitRequest"}) - public void createWithWrongXmlSchema() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "testSubmitRequest"}) + public void createWithWrongXmlSchema(String testName) throws Exception { // Perform setup. - setupCreateWithWrongXmlSchema(); + setupCreateWithWrongXmlSchema(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -191,7 +195,7 @@ public class IntakeServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("createWithWrongSchema url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -205,11 +209,12 @@ public class IntakeServiceTest extends AbstractServiceTest { // --------------------------------------------------------------- // Success outcomes @Override - @Test(dependsOnMethods = {"create"}) - public void read() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create"}) + public void read(String testName) throws Exception { // Perform setup. - setupRead(); + setupRead(testName); // Submit the request to the service and store the response. ClientResponse res = client.read(knownResourceId); @@ -218,7 +223,7 @@ public class IntakeServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("read: status = " + statusCode); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -232,11 +237,12 @@ public class IntakeServiceTest extends AbstractServiceTest { // Failure outcomes @Override - @Test(dependsOnMethods = {"read"}) - public void readNonExistent() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"read"}) + public void readNonExistent(String testName) throws Exception { // Perform setup. - setupReadNonExistent(); + setupReadNonExistent(testName); // Submit the request to the service and store the response. ClientResponse res = client.read(NON_EXISTENT_ID); @@ -245,7 +251,7 @@ public class IntakeServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("readNonExistent: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -257,11 +263,12 @@ public class IntakeServiceTest extends AbstractServiceTest { // --------------------------------------------------------------- // Success outcomes @Override - @Test(dependsOnMethods = {"read"}) - public void readList() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"read"}) + public void readList(String testName) throws Exception { // Perform setup. - setupReadList(); + setupReadList(testName); // Submit the request to the service and store the response. ClientResponse res = client.readList(); @@ -271,7 +278,7 @@ public class IntakeServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("readList: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -284,11 +291,11 @@ public class IntakeServiceTest extends AbstractServiceTest { list.getIntakeListItem(); int i = 0; for(IntakesCommonList.IntakeListItem item : items){ - logger.debug("readList: list-item[" + i + "] csid=" + + logger.debug(testName + ": list-item[" + i + "] csid=" + item.getCsid()); - logger.debug("readList: list-item[" + i + "] objectNumber=" + + logger.debug(testName + ": list-item[" + i + "] objectNumber=" + item.getEntryNumber()); - logger.debug("readList: list-item[" + i + "] URI=" + + logger.debug(testName + ": list-item[" + i + "] URI=" + item.getUri()); i++; } @@ -303,16 +310,17 @@ public class IntakeServiceTest extends AbstractServiceTest { // --------------------------------------------------------------- // Success outcomes @Override - @Test(dependsOnMethods = {"read"}) - public void update() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"read"}) + public void update(String testName) throws Exception { // Perform setup. - setupUpdate(); + setupUpdate(testName); ClientResponse res = client.read(knownResourceId); if(logger.isDebugEnabled()){ - logger.debug("update: read status = " + res.getStatus()); + logger.debug(testName + ": read status = " + res.getStatus()); } Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE); @@ -340,7 +348,7 @@ public class IntakeServiceTest extends AbstractServiceTest { 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()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -363,22 +371,23 @@ public class IntakeServiceTest extends AbstractServiceTest { // Placeholders until the three tests below can be uncommented. // See Issue CSPACE-401. @Override - public void updateWithEmptyEntityBody() throws Exception{ + public void updateWithEmptyEntityBody(String testName) throws Exception{ } @Override - public void updateWithMalformedXml() throws Exception { + public void updateWithMalformedXml(String testName) throws Exception { } @Override - public void updateWithWrongXmlSchema() throws Exception { + public void updateWithWrongXmlSchema(String testName) throws Exception { } /* @Override - @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"}) - public void updateWithEmptyEntityBody() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "update", "testSubmitRequest"}) + public void updateWithEmptyEntityBody(String testName) throws Exception { // Perform setup. - setupUpdateWithEmptyEntityBody(); + setupUpdateWithEmptyEntityBody(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -390,7 +399,7 @@ public class IntakeServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("updateWithEmptyEntityBody url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -399,11 +408,12 @@ public class IntakeServiceTest extends AbstractServiceTest { } @Override - @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"}) - public void updateWithMalformedXml() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "update", "testSubmitRequest"}) + public void updateWithMalformedXml(String testName) throws Exception { // Perform setup. - setupUpdateWithMalformedXml(); + setupUpdateWithMalformedXml(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -415,7 +425,7 @@ public class IntakeServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("updateWithMalformedXml: url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -424,11 +434,12 @@ public class IntakeServiceTest extends AbstractServiceTest { } @Override - @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"}) - public void updateWithWrongXmlSchema() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "update", "testSubmitRequest"}) + public void updateWithWrongXmlSchema(String testName) throws Exception { // Perform setup. - setupUpdateWithWrongXmlSchema(); + setupUpdateWithWrongXmlSchema(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -440,7 +451,7 @@ public class IntakeServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("updateWithWrongXmlSchema: url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -450,11 +461,12 @@ public class IntakeServiceTest extends AbstractServiceTest { */ @Override - @Test(dependsOnMethods = {"update", "testSubmitRequest"}) - public void updateNonExistent() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"update", "testSubmitRequest"}) + public void updateNonExistent(String testName) throws Exception { // Perform setup. - setupUpdateNonExistent(); + setupUpdateNonExistent(testName); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. @@ -469,7 +481,7 @@ public class IntakeServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("updateNonExistent: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -481,11 +493,12 @@ public class IntakeServiceTest extends AbstractServiceTest { // --------------------------------------------------------------- // Success outcomes @Override - @Test(dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) - public void delete() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) + public void delete(String testName) throws Exception { // Perform setup. - setupDelete(); + setupDelete(testName); // Submit the request to the service and store the response. ClientResponse res = client.delete(knownResourceId); @@ -494,7 +507,7 @@ public class IntakeServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("delete: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -503,11 +516,12 @@ public class IntakeServiceTest extends AbstractServiceTest { // Failure outcomes @Override - @Test(dependsOnMethods = {"delete"}) - public void deleteNonExistent() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"delete"}) + public void deleteNonExistent(String testName) throws Exception { // Perform setup. - setupDeleteNonExistent(); + setupDeleteNonExistent(testName); // Submit the request to the service and store the response. ClientResponse res = client.delete(NON_EXISTENT_ID); @@ -516,7 +530,7 @@ public class IntakeServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("deleteNonExistent: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); diff --git a/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java b/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java index 56bb2e5e5..d502f88a7 100644 --- a/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java +++ b/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java @@ -63,13 +63,13 @@ public class RelationServiceTest extends AbstractServiceTest { // --------------------------------------------------------------- // Success outcomes @Override - @Test - public void create() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class) + public void create(String testName) throws Exception { // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(); + setupCreate(testName); // Submit the request to the service and store the response. String identifier = createIdentifier(); @@ -83,7 +83,7 @@ public class RelationServiceTest extends AbstractServiceTest { // Does it fall within the set of valid status codes? // Does it exactly match the expected status code? if(logger.isDebugEnabled()){ - logger.debug("create: status = " + statusCode); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -98,32 +98,34 @@ public class RelationServiceTest extends AbstractServiceTest { } @Override - @Test(dependsOnMethods = {"create"}) - public void createList() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create"}) + public void createList(String testName) throws Exception { for(int i = 0; i < 3; i++){ - create(); + create(testName); } } // Failure outcomes // Placeholders until the three tests below can be uncommented. // See Issue CSPACE-401. - public void createWithEmptyEntityBody() throws Exception { + public void createWithEmptyEntityBody(String testName) throws Exception { } - public void createWithMalformedXml() throws Exception { + public void createWithMalformedXml(String testName) throws Exception { } - public void createWithWrongXmlSchema() throws Exception { + public void createWithWrongXmlSchema(String testName) throws Exception { } /* @Override - @Test(dependsOnMethods = {"create", "testSubmitRequest"}) - public void createWithEmptyEntityBody() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "testSubmitRequest"}) + public void createWithEmptyEntityBody(String testName) throws Exception { // Perform setup. - setupCreateWithEmptyEntityBody(); + setupCreateWithEmptyEntityBody(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -135,7 +137,7 @@ public class RelationServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("createWithEmptyEntityBody url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -144,11 +146,12 @@ public class RelationServiceTest extends AbstractServiceTest { } @Override - @Test(dependsOnMethods = {"create", "testSubmitRequest"}) - public void createWithMalformedXml() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "testSubmitRequest"}) + public void createWithMalformedXml(String testName) throws Exception { // Perform setup. - setupCreateWithMalformedXml(); + setupCreateWithMalformedXml(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -160,7 +163,7 @@ public class RelationServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("createWithMalformedXml url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -169,11 +172,12 @@ public class RelationServiceTest extends AbstractServiceTest { } @Override - @Test(dependsOnMethods = {"create", "testSubmitRequest"}) - public void createWithWrongXmlSchema()n throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "testSubmitRequest"}) + public void createWithWrongXmlSchema(String testName) throws Exception { // Perform setup. - setupCreateWithWrongXmlSchema(); + setupCreateWithWrongXmlSchema(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -185,7 +189,7 @@ public class RelationServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("createWithWrongSchema url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -199,11 +203,12 @@ public class RelationServiceTest extends AbstractServiceTest { // --------------------------------------------------------------- // Success outcomes @Override - @Test(dependsOnMethods = {"create"}) - public void read() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create"}) + public void read(String testName) throws Exception { // Perform setup. - setupRead(); + setupRead(testName); // Submit the request to the service and store the response. ClientResponse res = client.read(knownResourceId); @@ -212,7 +217,7 @@ public class RelationServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("read: status = " + statusCode); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -228,11 +233,12 @@ public class RelationServiceTest extends AbstractServiceTest { // Failure outcomes @Override - @Test(dependsOnMethods = {"read"}) - public void readNonExistent() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"read"}) + public void readNonExistent(String testName) throws Exception { // Perform setup. - setupReadNonExistent(); + setupReadNonExistent(testName); // Submit the request to the service and store the response. ClientResponse res = client.read(NON_EXISTENT_ID); @@ -241,7 +247,7 @@ public class RelationServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("readNonExistent: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -253,11 +259,12 @@ public class RelationServiceTest extends AbstractServiceTest { // --------------------------------------------------------------- // Success outcomes @Override - @Test(dependsOnMethods = {"createList", "read"}) - public void readList() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"createList", "read"}) + public void readList(String testName) throws Exception { // Perform setup. - setupReadList(); + setupReadList(testName); // Submit the request to the service and store the response. ClientResponse res = client.readList(); @@ -267,7 +274,7 @@ public class RelationServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("readList: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -280,9 +287,9 @@ public class RelationServiceTest extends AbstractServiceTest { list.getRelationListItem(); int i = 0; for(RelationsCommonList.RelationListItem item : items){ - logger.debug("readList: list-item[" + i + "] csid=" + + logger.debug(testName + ": list-item[" + i + "] csid=" + item.getCsid()); - logger.debug("readList: list-item[" + i + "] URI=" + + logger.debug(testName + ": list-item[" + i + "] URI=" + item.getUri()); i++; } @@ -299,17 +306,18 @@ public class RelationServiceTest extends AbstractServiceTest { // Success outcomes @Override - @Test(dependsOnMethods = {"read"}) - public void update() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"read"}) + public void update(String testName) throws Exception { // Perform setup. - setupUpdate(); + setupUpdate(testName); // Retrieve an existing resource that we can update. ClientResponse res = client.read(knownResourceId); if(logger.isDebugEnabled()){ - logger.debug("update: read status = " + res.getStatus()); + logger.debug(testName + ": read status = " + res.getStatus()); } Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE); if(logger.isDebugEnabled()){ @@ -335,9 +343,10 @@ public class RelationServiceTest extends AbstractServiceTest { 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()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -365,22 +374,23 @@ public class RelationServiceTest extends AbstractServiceTest { // Failure outcomes // Placeholders until the three tests below can be uncommented. // See Issue CSPACE-401. - public void updateWithEmptyEntityBody() throws Exception { + public void updateWithEmptyEntityBody(String testName) throws Exception { } - public void updateWithMalformedXml() throws Exception { + public void updateWithMalformedXml(String testName) throws Exception { } - public void updateWithWrongXmlSchema() throws Exception { + public void updateWithWrongXmlSchema(String testName) throws Exception { } /* @Override - @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"}) - public void updateWithEmptyEntityBody() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "update", "testSubmitRequest"}) + public void updateWithEmptyEntityBody(String testName) throws Exception { // Perform setup. - setupUpdateWithEmptyEntityBody(); + setupUpdateWithEmptyEntityBody(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -392,7 +402,7 @@ public class RelationServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("updateWithEmptyEntityBody url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -401,11 +411,12 @@ public class RelationServiceTest extends AbstractServiceTest { } @Override - @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"}) - public void updateWithMalformedXml() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "update", "testSubmitRequest"}) + public void updateWithMalformedXml(String testName) throws Exception { // Perform setup. - setupUpdateWithMalformedXml(); + setupUpdateWithMalformedXml(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -417,7 +428,7 @@ public class RelationServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("updateWithMalformedXml: url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -426,11 +437,12 @@ public class RelationServiceTest extends AbstractServiceTest { } @Override - @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"}) - public void updateWithWrongXmlSchema() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "update", "testSubmitRequest"}) + public void updateWithWrongXmlSchema(String testName) throws Exception { // Perform setup. - setupUpdateWithWrongXmlSchema(); + setupUpdateWithWrongXmlSchema(testName); // Submit the request to the service and store the response. String method = REQUEST_TYPE.httpMethodName(); @@ -442,7 +454,7 @@ public class RelationServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("updateWithWrongXmlSchema: url=" + url + + logger.debug(testName + ": url=" + url + " status=" + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -452,11 +464,12 @@ public class RelationServiceTest extends AbstractServiceTest { */ @Override - @Test(dependsOnMethods = {"update", "testSubmitRequest"}) - public void updateNonExistent() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"update", "testSubmitRequest"}) + public void updateNonExistent(String testName) throws Exception { // Perform setup. - setupUpdateNonExistent(); + setupUpdateNonExistent(testName); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. @@ -469,7 +482,7 @@ public class RelationServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("updateNonExistent: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -481,11 +494,12 @@ public class RelationServiceTest extends AbstractServiceTest { // --------------------------------------------------------------- // Success outcomes @Override - @Test(dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) - public void delete() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) + public void delete(String testName) throws Exception { // Perform setup. - setupDelete(); + setupDelete(testName); // Submit the request to the service and store the response. ClientResponse res = client.delete(knownResourceId); @@ -494,7 +508,7 @@ public class RelationServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("delete: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); @@ -503,11 +517,12 @@ public class RelationServiceTest extends AbstractServiceTest { // Failure outcomes @Override - @Test(dependsOnMethods = {"delete"}) - public void deleteNonExistent() throws Exception { + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"delete"}) + public void deleteNonExistent(String testName) throws Exception { // Perform setup. - setupDeleteNonExistent(); + setupDeleteNonExistent(testName); // Submit the request to the service and store the response. ClientResponse res = client.delete(NON_EXISTENT_ID); @@ -516,7 +531,7 @@ public class RelationServiceTest extends AbstractServiceTest { // Check the status code of the response: does it match // the expected response(s)? if(logger.isDebugEnabled()){ - logger.debug("deleteNonExistent: status = " + res.getStatus()); + logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); -- 2.47.3