host=127.0.0.1\r
#cspace\r
-release.version=2.0\r
+release.version=2.1\r
cspace.release=${release.version}-SNAPSHOT\r
cspace.services.release=cspace-services-${cspace.release}\r
domain.cspace=cspace-services\r
<artifactId>slf4j-log4j12</artifactId>\r
<version>1.5.8</version>\r
</dependency>\r
+ <dependency>\r
+ <groupId>org.testng</groupId>\r
+ <artifactId>testng</artifactId>\r
+ <version>6.1.1</version>\r
+ <!-- <version>5.6</version> -->\r
+ <scope>test</scope>\r
+ </dependency> \r
<dependency>\r
<groupId>javax.ejb</groupId>\r
<artifactId>ejb</artifactId>\r
</parent>\r
\r
<modelVersion>4.0.0</modelVersion>\r
- <groupId>org.collectionspace.services</groupId>\r
<artifactId>org.collectionspace.services.IntegrationTests</artifactId>\r
<name>services.IntegrationTests</name>\r
<packaging>jar</packaging>\r
<dependency>\r
<groupId>commons-cli</groupId>\r
<artifactId>commons-cli</artifactId>\r
- <version>1.2</version>\r
</dependency>\r
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
+ <scope>compile</scope>\r
</dependency>\r
<dependency>\r
<groupId>org.jboss.resteasy</groupId>\r
<dependency>\r
<groupId>commons-httpclient</groupId>\r
<artifactId>commons-httpclient</artifactId>\r
- <version>3.1</version>\r
</dependency>\r
<dependency>\r
<groupId>javax.security</groupId>\r
import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;\r
import org.collectionspace.services.intake.IntakesCommon;\r
import org.collectionspace.services.relation.RelationsCommon;\r
-import org.collectionspace.services.relation.RelationshipType;\r
import org.jboss.resteasy.client.ClientResponse;\r
-import org.jboss.resteasy.plugins.providers.multipart.InputPart;\r
-import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;\r
\r
/**\r
* The Class CollectionSpaceIntegrationTest.\r
import org.slf4j.LoggerFactory;
import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.collectionspace.services.client.CollectionObjectClient;
import org.collectionspace.services.client.PayloadOutputPart;
List<List<ServiceResult>> list = replay.runMaster(masterFile);
logTestForGroup(list, "XmlReplayMasterTest");
} else {
- System.out.println("XmlReplayDevTest skipping local dev test "+masterFile+" because it doesn't exist in "+replay.getBaseDir()+". This is expected behavior on a production installation.");
+ System.out.println("XmlReplayDevTest skipping local dev test "
+ + masterFile+" because it doesn't exist in "
+ + replay.getBaseDir()
+ + ". This is expected behavior on a production installation.");
}
-
-
- //used for testing load.
- // bigLoop(masterFile);
}
private void bigLoop(String masterFile){
while (!quitNow) {
Thread.yield();
}
- System.out.println("DONE. workers: "+MAXWORKERS+" time: "+(System.currentTimeMillis()-start));
+ System.out.println("DONE. workers: " + MAXWORKERS+" time: " + (System.currentTimeMillis()-start));
for (Long l: stats){
System.out.println(""+l);
}
import org.collectionspace.services.IntegrationTests.xmlreplay.XmlReplayTest;\r
import org.testng.annotations.Test;\r
\r
-import java.util.ArrayList;\r
import java.util.List;\r
import java.util.Map;\r
\r
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
<!-- Possibly not needed. Please experiment and remove unnecessary artifacts -->\r
<dependency>\r
#\r
# CollectionSpace log levels\r
#\r
-log4j.logger.org.collectionspace=DEBUG\r
+log4j.logger.org.collectionspace=INFO\r
#log4j.logger.org.collectionspace.services.common.vocabulary.nuxeo=TRACE\r
log4j.logger.perf.collectionspace=ERROR\r
\r
-log4j.logger.org.nuxeo=ERROR\r
+log4j.logger.org.nuxeo=INFO\r
#log4j.logger.org.nuxeo.ecm.core.storage.sql=TRACE\r
log4j.logger.org.apache=ERROR\r
log4j.logger.httpclient=ERROR\r
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
<dependency>\r
<groupId>org.jboss.resteasy</groupId>\r
import org.jboss.resteasy.client.ClientResponse;
import org.jboss.resteasy.util.HttpResponseCodes;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.CollectionObjectClient;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
/**
package org.collectionspace.services.client;
import javax.ws.rs.core.Response;
+import org.jboss.resteasy.client.ClientResponse;
+
import org.collectionspace.services.account.AccountsCommon;
import org.collectionspace.services.account.AccountsCommonList;
-import org.jboss.resteasy.client.ClientResponse;
/**
* A AccountClient.
* @version $Revision:$
*/
-public class AccountClient extends AbstractServiceClientImpl<AccountsCommonList, AccountProxy> {
+public class AccountClient extends AbstractServiceClientImpl<AccountsCommonList, AccountsCommon,
+ AccountsCommon, AccountProxy> {
public static final String SERVICE_NAME = "accounts";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
package org.collectionspace.services.client;
import javax.ws.rs.core.Response;
+import org.jboss.resteasy.client.ClientResponse;
-//import org.collectionspace.services.authorization.AccountRolesList;
import org.collectionspace.services.authorization.AccountRole;
-import org.jboss.resteasy.client.ClientResponse;
+import org.collectionspace.services.jaxb.AbstractCommonList;
/**
* A AccountRoleClient.
* @version $Revision:$
*/
-public class AccountRoleClient extends AbstractServiceClientImpl<AccountRole, AccountRoleProxy> {
+public class AccountRoleClient extends AbstractServiceClientImpl<AbstractCommonList, AccountRole, AccountRole, AccountRoleProxy> {
public static final String SERVICE_NAME = "accountroles";
@Override
public ClientResponse<Response> create(String csid, AccountRole accRole) {
return getProxy().create(csid, accRole);
}
-
+
+ /*
+ *
+ * Updates on AccountRole entities is not supported.
+ *
+ */
+ @Override
+ public ClientResponse<AccountRole> update(String csid, AccountRole payload) {
+ throw new RuntimeException("You cannot update an AccountRole object. You must delete and recreate it instead.");
+ }
/**
* @param csid
public ClientResponse<Response> delete(String csid, AccountRole accRole) {
return getProxy().delete(csid, "delete", accRole);
}
+
+ /*
+ * Not supported.
+ */
+ @Override
+ public ClientResponse<Response> create(AccountRole payload) {
+ // Use the create(String csid, AccountRole accRole) method instead
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ClientResponse<AbstractCommonList> readList() {
+ throw new UnsupportedOperationException();
+ }
}
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
-//import org.collectionspace.services.authorization.AccountRolesList;
+import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.authorization.AccountRole;
import org.jboss.resteasy.client.ClientResponse;
@Path("/accounts")
@Produces({"application/xml"})
@Consumes({"application/xml"})
-public interface AccountRoleProxy extends CollectionSpaceProxy<AccountRole> {
+public interface AccountRoleProxy extends CollectionSpaceProxy<AbstractCommonList> {
//(C)reate
@POST
@QueryParam("_method") String method,
AccountRole accRole);
+ //(U)pdate
+ @PUT
+ @Path("/{csid}/accountroles")
+ ClientResponse<AccountRole> update(@PathParam("csid") String csid, AccountRole role);
+
//(D)elete
@Override
@DELETE
*/
package org.collectionspace.services.account.client.test;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Hashtable;
import java.util.List;
-import javax.ws.rs.core.Response;
-//import org.collectionspace.services.authorization.AccountRolesList;
import org.collectionspace.services.account.AccountsCommon;
import org.collectionspace.services.account.AccountsCommonList;
import org.collectionspace.services.account.AccountListItem;
-
import org.collectionspace.services.authorization.AccountRole;
import org.collectionspace.services.authorization.AccountValue;
import org.collectionspace.services.authorization.Role;
import org.collectionspace.services.client.RoleFactory;
import org.collectionspace.services.client.test.AbstractServiceTestImpl;
import org.collectionspace.services.client.test.ServiceRequestType;
-import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.jboss.resteasy.client.ClientResponse;
+import javax.ws.rs.core.Response;
+import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
import org.testng.annotations.Test;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
/**
* AccountServiceTest, carries out tests against a
* $LastChangedRevision: 917 $
* $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
*/
-public class AccountRoleServiceTest extends AbstractServiceTestImpl {
+public class AccountRoleServiceTest extends AbstractServiceTestImpl<AccountRole, AccountRole, AccountRole, AccountRole> {
/** The Constant logger. */
private final static String CLASS_NAME = AccountRoleServiceTest.class.getName();
private final static Logger logger = LoggerFactory.getLogger(CLASS_NAME);
// Instance variables specific to this test.
- /** The known resource id. */
- private String knownResourceId = null;
private String prebuiltAdminCSID = null;
private String prebuiltAdminUserId = "admin@core.collectionspace.org";
/** The all resource ids created. */
- private List<String> allResourceIdsCreated = new ArrayList<String>();
/** The acc values. */
private Hashtable<String, AccountValue> accValues = new Hashtable<String, AccountValue>();
/** The role values. */
return new AccountRoleClient();
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
- throw new UnsupportedOperationException();
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
- */
- @Test(dataProvider = "testName")
- @Override
- public void readPaginatedList(String testName) throws Exception {
- //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
- }
-
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
// Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- testBanner(testName, CLASS_NAME);
- }
- // 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();
-
- // Submit the request to the service and store the response.
+
+ public void createList(String testName) throws Exception {
+ // Do nothing. We do not support list creation in this test yet.
+ }
+
+ @Override
+ protected AccountRole createInstance(String commonPartName,
+ String identifier) {
+ AccountRole result = null;
+
+ // Use a known Account to associate the AccountRole instance to
+ AccountValue av = accValues.get("acc-role-user1");
+ AccountRole accRole = createAccountRoleInstance(av,
+ roleValues.values(), true, true);
+
+ result = accRole;
+ return result;
+ }
+
+ @Override
+ public void create(String testName) throws Exception {
+ setupCreate();
AccountValue av = accValues.get("acc-role-user1");
AccountRole accRole = createAccountRoleInstance(av,
roleValues.values(), true, true);
AccountRoleClient client = new AccountRoleClient();
ClientResponse<Response> res = client.create(av.getAccountId(), accRole);
try {
- int statusCode = res.getStatus();
-
+ assertStatusCode(res, testName);
+ knownResourceId = av.getAccountId();
if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Store the ID returned from this create operation
- // for additional tests below.
- //this is is not important in case of this relationship
- knownResourceId = extractId(res);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
+ logger.debug(testName + ": Created an AccountRole instance for account with knownResourceId="
+ + knownResourceId);
}
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- }
-
- //to not cause uniqueness violation for accRole, createList is removed
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- @Override
- public void createList(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
- */
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
+ }
// ---------------------------------------------------------------
// CRUD tests : READ tests
// ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- testBanner(testName, CLASS_NAME);
- }
-
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- AccountRoleClient client = new AccountRoleClient();
- ClientResponse<AccountRole> res = client.read(
- accValues.get("acc-role-user1").getAccountId());
- assertStatusCode(res, testName);
- try {
- AccountRole output = res.getEntity();
- Assert.assertNotNull(output);
- } finally {
- res.releaseConnection();
- }
- }
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void readNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- testBanner(testName, CLASS_NAME);
- }
-
- // Perform setup.
- setupReadNonExistent();
- // Submit the request to the service and store the response.
- AccountRoleClient client = new AccountRoleClient();
- ClientResponse<AccountRole> res = client.read(this.NON_EXISTENT_ID);
- int statusCode = res.getStatus();
- try {
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void readNoRelationship(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- testBanner(testName, CLASS_NAME);
- }
-
// Perform setup.
setupRead();
AccountRoleClient client = new AccountRoleClient();
ClientResponse<AccountRole> res = client.read(
accValues.get("acc-role-user2").getAccountId());
- assertStatusCode(res, testName);
try {
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ assertStatusCode(res, testName);
AccountRole output = res.getEntity();
-
if(logger.isDebugEnabled()) {
org.collectionspace.services.authorization.ObjectFactory objectFactory = new org.collectionspace.services.authorization.ObjectFactory();
String sOutput = objectAsXmlString(objectFactory.createAccountRole(output), AccountRole.class);
logger.debug(testName + " received " + sOutput);
}
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
* After we've performed this setup, our call to "/role/{csid}/accountroles" should contain an AccountRole that has
* a list of 1 account -the test user account we associated during setup.
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"delete"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void readRoleAccounts(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- testBanner(testName, CLASS_NAME);
- }
-
/*
* Setup a temp local scope for local variables that we need to create the AccountRole for
* the setup of the read tests.
*/
{
- setupCreate();
-
// Associate "acc-role-user2" with all the roles.
AccountValue av = accValues.get("acc-role-user2");
AccountRole accRole = createAccountRoleInstance(av,
roleValues.values(), true, true);
AccountRoleClient client = new AccountRoleClient();
+ setupCreate();
ClientResponse<Response> res = client.create(av.getAccountId(), accRole);
- int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
}
//
// Now read the list of accounts associated with the role "ROLE_CO1".
// There should be just the "acc-role-user2" account.
//
- setupRead();
RoleClient roleClient = new RoleClient();
// Submit the request to the service and store the response.
+ setupRead();
ClientResponse<AccountRole> res = roleClient.readRoleAccounts(
roleValues.get("ROLE_CO1").getRoleId());
- assertStatusCode(res, testName);
try {
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ assertStatusCode(res, testName);
AccountRole output = res.getEntity();
// Now verify that the role has 2 accounts associate to it.
Assert.assertEquals(output.getAccount().size(), 1);
-
String sOutput = objectAsXmlString(output, AccountRole.class);
if(logger.isDebugEnabled()) {
logger.debug(testName + " received " + sOutput);
}
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
// CRUD tests : READ_LIST tests
// ---------------------------------------------------------------
// Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
- */
+
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
public void readList(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
+ //
+ // There is no such thing as a list of AccountRole resources
+ //
}
+
+ @Override
+ public void readPaginatedList(String testName) throws Exception {
+ //
+ // There is no such thing as a list of AccountRole resources
+ //
+ }
// Failure outcomes
// None at present.
// CRUD tests : UPDATE tests
// ---------------------------------------------------------------
// Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read", "readList", "readNonExistent"})
- public void update(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
- */
@Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
- */
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
+ public void update(String testName) throws Exception {
+ //
+ // AccountRole entities cannot be updated. You must delete and recreate them
+ //
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
- */
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void updateNonExistent(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
+ //
+ // AccountRole entities cannot be updated. You must delete and recreate them
+ //
}
// ---------------------------------------------------------------
// CRUD tests : DELETE tests
// ---------------------------------------------------------------
// Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
- */
+
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- testBanner(testName, CLASS_NAME);
- }
-
- // Perform setup.
- setupDelete();
-
//
- // Lookup a know account, and delete all of its role relationships
+ // First, lookup the known account and delete all of its role relationships
//
AccountRoleClient client = new AccountRoleClient();
+ setupRead();
ClientResponse<AccountRole> readResponse = client.read(
accValues.get("acc-role-user1").getAccountId());
AccountRole toDelete = null;
try {
+ assertStatusCode(readResponse, testName);
toDelete = readResponse.getEntity();
- } catch (Throwable e) {
- e.printStackTrace();
+ Assert.assertNotNull(toDelete);
} finally {
- readResponse.releaseConnection();
+ if (readResponse != null) {
+ readResponse.releaseConnection();
+ }
}
+ setupDelete();
ClientResponse<Response> res = client.delete(
- toDelete.getAccount().get(0).getAccountId(), toDelete);
+ toDelete.getAccount().get(0).getAccountId(), toDelete); // delete form #1
try {
- int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ assertStatusCode(readResponse, testName);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
-
//
- // recreate 'acc-role-user1' account and roles
+ // Recreate 'acc-role-user1' account and roles for the next test
//
-// create(testName);
-
- /*
- setupDelete();
-
+ create(testName);
+
//
- // Lookup a know account, and delete all of its role relationships
+ // Lookup a known account and delete all of its role relationships again
//
+ setupRead();
readResponse = client.read(
- accValues.get("acc-role-user1").getAccountId());
+ accValues.get("acc-role-user1").getAccountId());
toDelete = null;
try {
toDelete = readResponse.getEntity();
- } catch (Throwable e) {
- e.printStackTrace();
} finally {
- readResponse.releaseConnection();
+ if (readResponse != null) {
+ readResponse.releaseConnection();
+ }
}
- res = client.delete(toDelete.getAccount().get(0).getAccountId());
+ setupDelete();
+ res = client.delete(toDelete.getAccount().get(0).getAccountId()); // delete form #2
try {
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
res.releaseConnection();
}
- */
-
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void deleteLockedAccount(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- testBanner(testName, CLASS_NAME);
- }
-
findPrebuiltAdminAccount();
// Perform setup.
- EXPECTED_STATUS_CODE = Response.Status.FORBIDDEN.getStatusCode();
- REQUEST_TYPE = ServiceRequestType.DELETE;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
+ testExpectedStatusCode = Response.Status.FORBIDDEN.getStatusCode();
+ testRequestType = ServiceRequestType.DELETE;
+ testSetup(testExpectedStatusCode, testRequestType);
AccountRoleClient client = new AccountRoleClient();
ClientResponse<Response> res = client.delete(prebuiltAdminCSID);
try {
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
- */
+ //
+ // Tests with expected failure outcomes
+ //
+
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void deleteNonExistent(String testName) throws Exception {
//ignoring this test as the service side returns 200 now even if it does
//not find a record in the db
+
+ //FIXME: REM - 1/9/2012, need to find out why a 200 status code is returned and fix this.
}
// ---------------------------------------------------------------
// ---------------------------------------------------------------
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void searchWorkflowDeleted(String testName) throws Exception {
// Fixme: null test for now, overriding test in base class
}
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
- /**
- * Tests the code for manually submitting data that is used by several
- * of the methods above.
- * @throws Exception
- */
- @Test(dependsOnMethods = {"create"})
- public void testSubmitRequest() throws Exception { //FIXME: REM - This is not testing a submit /accounts/*/accountroles, but instead just to /accounts
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(accValues.get("acc-role-user1").getAccountId());
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testSubmitRequest: url=" + url
- + " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
- }
-
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
+
/**
* Creates the account role instance.
*
logger.debug("Cleaning up temporary resources created for testing ...");
}
-
for (AccountValue pv : accValues.values()) {
deleteAccount(pv.getAccountId());
}
* @return the string
*/
private String createAccount(String userName, String email) {
-
- if (logger.isDebugEnabled()) {
- testBanner("createAccount");
- }
-
- setupCreate();
-
AccountClient accClient = new AccountClient();
AccountsCommon account = AccountFactory.createAccountInstance(
userName, userName, userName, email, accClient.getTenantId(),
true, false, true, true);
+ String result = null;
+
+ setupCreate();
ClientResponse<Response> res = accClient.create(account);
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug("createAccount: userName=" + userName
- + " status = " + statusCode);
+ try {
+ assertStatusCode(res, "CreateAccount");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
- return extractId(res);
+
+ return result;
}
private void findPrebuiltAdminAccount() {
// Search for the prebuilt admin user and then hold its CSID
- if(prebuiltAdminCSID == null) {
+ if (prebuiltAdminCSID == null) {
setupReadList();
AccountClient client = new AccountClient();
ClientResponse<AccountsCommonList> res =
client.readSearchList(null, this.prebuiltAdminUserId, null);
- assertStatusCode(res, "findPrebuiltAdminAccount");
- AccountsCommonList list = res.getEntity();
-
- List<AccountListItem> items = list.getAccountListItem();
- Assert.assertEquals(1, items.size(), "Found more than one Admin account!");
- AccountListItem item = items.get(0);
- prebuiltAdminCSID = item.getCsid();
- if (logger.isDebugEnabled()) {
- logger.debug("Found Admin Account with ID: " + prebuiltAdminCSID);
+ try {
+ assertStatusCode(res, "findPrebuiltAdminAccount");
+ AccountsCommonList list = res.getEntity();
+ List<AccountListItem> items = list.getAccountListItem();
+ Assert.assertEquals(1, items.size(), "Found more than one Admin account!");
+ AccountListItem item = items.get(0);
+ prebuiltAdminCSID = item.getCsid();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Found Admin Account with ID: " + prebuiltAdminCSID);
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
}
* @param accId the acc id
*/
private void deleteAccount(String accId) {
-
- if (logger.isDebugEnabled()) {
- testBanner("deleteAccount");
- }
-
- setupDelete();
-
AccountClient accClient = new AccountClient();
+ setupDelete();
ClientResponse<Response> res = accClient.delete(accId);
- int statusCode = res.getStatus();
try {
- if (logger.isDebugEnabled()) {
- logger.debug("deleteAccount: delete account id="
- + accId + " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ assertStatusCode(res, "DeleteAccount");
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
* @return the string
*/
private String createRole(String roleName) {
- if (logger.isDebugEnabled()) {
- testBanner("createRole");
- }
- setupCreate();
+ String result = null;
+
RoleClient roleClient = new RoleClient();
-
Role role = RoleFactory.createRoleInstance(roleName,
roleName, //the display name
"role for " + roleName, true);
+ setupCreate();
ClientResponse<Response> res = roleClient.create(role);
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug("createRole: name=" + roleName
- + " status = " + statusCode);
+ try {
+ assertStatusCode(res, "CreateRole");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
- return extractId(res);
+
+ return result;
}
/**
* @param roleId the role id
*/
private void deleteRole(String roleId) {
- if (logger.isDebugEnabled()) {
- testBanner("deleteRole");
- }
setupDelete();
RoleClient roleClient = new RoleClient();
ClientResponse<Response> res = roleClient.delete(roleId);
- int statusCode = res.getStatus();
try {
- if (logger.isDebugEnabled()) {
- logger.debug("deleteRole: delete role id=" + roleId
- + " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ assertStatusCode(res, "DeleteRole");
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
// AccountRoles service is a sub-service of the Account service, so we return Account's service name
return AccountClient.SERVICE_NAME;
}
+
+ /*
+ * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
+ * refer to this method in their @Test annotation declarations.
+ */
+ @Override
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {
+ "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
+ public void CRUDTests(String testName) {
+ // Do nothing. Simply here to for a TestNG execution order for our tests
+ }
+
+ @Override
+ protected AccountRole updateInstance(AccountRole commonPartObject) {
+ //
+ // AccountRole entities cannot be updated. You must delete and recreate them
+ //
+ return null;
+ }
+
+ @Override
+ protected void compareReadInstances(AccountRole original, AccountRole updated)
+ throws Exception {
+ // FIXME: Should add field checks here.
+ }
+
+ @Override
+ protected void compareUpdatedInstances(AccountRole original,
+ AccountRole updated) throws Exception {
+ //
+ // AccountRole entities cannot be updated. You must delete and recreate them
+ //
+ }
+
+ @Override
+ protected Class<AccountRole> getCommonListType() {
+ return AccountRole.class;
+ }
}
import java.util.List;
import javax.ws.rs.core.Response;
+import org.jboss.resteasy.client.ClientResponse;
import org.collectionspace.services.client.AccountClient;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.AccountFactory;
import org.collectionspace.services.client.test.AbstractServiceTestImpl;
import org.collectionspace.services.client.test.ServiceRequestType;
-import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
import org.testng.annotations.Test;
* $LastChangedRevision: 917 $
* $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
*/
-public class AccountServiceTest extends AbstractServiceTestImpl {
+public class AccountServiceTest extends AbstractServiceTestImpl<AccountsCommonList, AccountsCommon, AccountsCommon, AccountsCommon> {
/** The Constant logger. */
private final String CLASS_NAME = AccountServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
+
// Instance variables specific to this test.
- /** The known resource id. */
- private String knownResourceId = null;
private String prebuiltAdminCSID = null;
private String prebuiltAdminUserId = "admin@core.collectionspace.org";
private String knownUserId = "barney";
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
+ protected AccountsCommonList getCommonList(
+ ClientResponse<AccountsCommonList> response) {
//FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
throw new UnsupportedOperationException();
}
+
+ protected Class<AccountsCommonList> getCommonListType() {
+ return (Class<AccountsCommonList>) AccountsCommonList.class;
+ }
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"readList"})
@Override
public void readPaginatedList(String testName) throws Exception {
//FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
// Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // 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();
-
- AccountClient client = new AccountClient();
- // Submit the request to the service and store the response.
- AccountsCommon account =
- createAccountInstance(knownUserId, knownUserId, knownUserPassword,
- "barney@dinoland.com", client.getTenantId(),
- true, false, true, true);
- ClientResponse<Response> res = client.create(account);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Store the ID returned from this create operation
- // for additional tests below.
- knownResourceId = extractId(res);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
- }
-
+
/**
* Creates the for unique user.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void createForUniqueUser(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
// Submit the request to the service and store the response.
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
public void createWithInvalidTenant(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
// Submit the request to the service and store the response.
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
-
}
/**
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
public void createWithoutUser(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
// Submit the request to the service and store the response.
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
public void createWithInvalidEmail(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
// Submit the request to the service and store the response.
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
public void createWithoutScreenName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
// Submit the request to the service and store the response.
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
public void createWithInvalidPassword(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
// Submit the request to the service and store the response.
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
public void createWithMostInvalid(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
// Submit the request to the service and store the response.
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
- //to not cause uniqueness violation for account, createList is removed
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
- */
+ //
+ // To avoid uniqueness violations for accounts, createList is removed
+ //
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
public void createList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
// Submit the request to the service and store the response.
AccountClient client = new AccountClient();
client.getTenantId(), true, false, true, true);
ClientResponse<Response> res = client.create(account1);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
allResourceIdsCreated.add(extractId(res));
AccountsCommon account2 =
client.getTenantId(), true, false, true, true);
res = client.create(account2);
statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
allResourceIdsCreated.add(extractId(res));
AccountsCommon account3 =
client.getTenantId(), true, false, true, true);
res = client.create(account3);
statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
allResourceIdsCreated.add(extractId(res));
}
- // Failure outcomes
+ //
+ // Tests with expected failure outcomes
+ //
// Placeholders until the three tests below can be uncommented.
// See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
- */
@Override
public void createWithEmptyEntityBody(String testName) throws Exception {
//FIXME: Should this test really be empty? If so, please comment accordingly.
//FIXME: Should this test really be empty? If so, please comment accordingly.
}
- // ---------------------------------------------------------------
- // CRUD tests : READ tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- AccountClient client = new AccountClient();
- ClientResponse<AccountsCommon> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
-
- AccountsCommon output = (AccountsCommon) res.getEntity();
- Assert.assertNotNull(output);
- }
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void readNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- AccountClient client = new AccountClient();
- ClientResponse<AccountsCommon> res = client.read(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
// ---------------------------------------------------------------
// CRUD tests : READ_LIST tests
// ---------------------------------------------------------------
// Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
- public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadList();
-
- // Submit the request to the service and store the response.
- AccountClient client = new AccountClient();
- ClientResponse<AccountsCommonList> res = client.readList();
- assertStatusCode(res, testName);
- AccountsCommonList list = res.getEntity();
-
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = true;
- if (iterateThroughList && logger.isDebugEnabled()) {
- printList(testName, list);
- }
- }
/**
* Search screen name.
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
public void searchScreenName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupReadList();
AccountClient client = new AccountClient();
ClientResponse<AccountsCommonList> res =
client.readSearchList("tom", null, null);
- assertStatusCode(res, testName);
-
- AccountsCommonList list = res.getEntity();
- Assert.assertEquals(1, list.getAccountListItem().size());
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = true;
- if (iterateThroughList && logger.isDebugEnabled()) {
- printList(testName, list);
+ try {
+ assertStatusCode(res, testName);
+ AccountsCommonList list = res.getEntity();
+ Assert.assertEquals(1, list.getAccountListItem().size());
+ // Optionally output additional data about list members for debugging.
+ boolean iterateThroughList = true;
+ if (iterateThroughList && logger.isDebugEnabled()) {
+ printList(testName, list);
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
+ @Override
+ @Test(dataProvider = "testName")
+ public void searchWorkflowDeleted(String testName) throws Exception {
+ // Fixme: null test for now, overriding test in base class
+ }
+
/**
* Search user id.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
public void searchUserId(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupReadList();
// Submit the request to the service and store the response.
AccountClient client = new AccountClient();
- ClientResponse<AccountsCommonList> res =
- client.readSearchList(null, "tom", null);
- assertStatusCode(res, testName);
-
- AccountsCommonList list = res.getEntity();
- Assert.assertEquals(1, list.getAccountListItem().size());
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = true;
- if (iterateThroughList && logger.isDebugEnabled()) {
- printList(testName, list);
+ ClientResponse<AccountsCommonList> res = client.readSearchList(null, "tom", null);
+ try {
+ assertStatusCode(res, testName);
+ AccountsCommonList list = res.getEntity();
+ Assert.assertEquals(1, list.getAccountListItem().size());
+ // Optionally output additional data about list members for debugging.
+ boolean iterateThroughList = true;
+ if (iterateThroughList && logger.isDebugEnabled()) {
+ printList(testName, list);
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
public void searchEmail(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupReadList();
// Submit the request to the service and store the response.
AccountClient client = new AccountClient();
- ClientResponse<AccountsCommonList> res =
- client.readSearchList(null, null, "dinoland");
- assertStatusCode(res, testName);
-
- AccountsCommonList list = res.getEntity();
- Assert.assertEquals(2, list.getAccountListItem().size());
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = true;
- if (iterateThroughList && logger.isDebugEnabled()) {
- printList(testName, list);
+ ClientResponse<AccountsCommonList> res = client.readSearchList(null, null, "dinoland");
+ try {
+ assertStatusCode(res, testName);
+ AccountsCommonList list = res.getEntity();
+ Assert.assertEquals(2, list.getAccountListItem().size());
+ // Optionally output additional data about list members for debugging.
+ boolean iterateThroughList = true;
+ if (iterateThroughList && logger.isDebugEnabled()) {
+ printList(testName, list);
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
public void searchScreenNameEmail(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupReadList();
// Submit the request to the service and store the response.
AccountClient client = new AccountClient();
- ClientResponse<AccountsCommonList> res =
- client.readSearchList("tom", null, "jerry");
- assertStatusCode(res, testName);
-
- AccountsCommonList list = res.getEntity();
- Assert.assertEquals(1, list.getAccountListItem().size());
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = true;
- if (iterateThroughList && logger.isDebugEnabled()) {
- printList(testName, list);
+ ClientResponse<AccountsCommonList> res = client.readSearchList("tom", null, "jerry");
+ try {
+ assertStatusCode(res, testName);
+ AccountsCommonList list = res.getEntity();
+ Assert.assertEquals(1, list.getAccountListItem().size());
+ // Optionally output additional data about list members for debugging.
+ boolean iterateThroughList = true;
+ if (iterateThroughList && logger.isDebugEnabled()) {
+ printList(testName, list);
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
- // Failure outcomes
- // None at present.
// ---------------------------------------------------------------
// CRUD tests : UPDATE tests
// ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read", "readList", "readNonExistent"})
- public void update(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
-
- AccountClient client = new AccountClient();
- ClientResponse<AccountsCommon> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
-
- if (logger.isDebugEnabled()) {
- logger.debug("got object to update with ID: " + knownResourceId);
- }
- AccountsCommon accountFound =
- (AccountsCommon) res.getEntity();
- Assert.assertNotNull(accountFound);
-
- //create a new account object to test partial updates
- AccountsCommon accountToUpdate = new AccountsCommon();
- accountToUpdate.setCsid(knownResourceId);
- accountToUpdate.setUserId(accountFound.getUserId());
- // Update the content of this resource.
- accountToUpdate.setEmail("updated-" + accountFound.getEmail());
- if (logger.isDebugEnabled()) {
- logger.debug("updated object");
- logger.debug(objectAsXmlString(accountFound,
- AccountsCommon.class));
- }
-
- // Submit the request to the service and store the response.
- res = client.update(knownResourceId, accountToUpdate);
- assertStatusCode(res, testName);
-
- AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
- Assert.assertNotNull(accountUpdated);
-
- Assert.assertEquals(accountUpdated.getEmail(),
- accountToUpdate.getEmail(),
- "Data in updated object did not match submitted data.");
- }
/**
* Update password.
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"update"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
public void updatePassword(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupUpdate();
AccountClient client = new AccountClient();
ClientResponse<AccountsCommon> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
if (logger.isDebugEnabled()) {
logger.debug(testName + ": got object to update password with ID: " + knownResourceId);
// Submit the request to the service and store the response.
res = client.update(knownResourceId, accountToUpdate);
- assertStatusCode(res, testName);
+ int statusCode = res.getStatus();
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
Assert.assertNotNull(accountUpdated);
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"update"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
public void updatePasswordWithoutUser(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupUpdate();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"update"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
public void updateInvalidPassword(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupUpdate();
AccountClient client = new AccountClient();
ClientResponse<AccountsCommon> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
if (logger.isDebugEnabled()) {
logger.debug(testName + ": got object to update password with ID: " + knownResourceId);
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
-
}
private void findPrebuiltAdminAccount() {
// Search for the prebuilt admin user and then hold its CSID
- if(prebuiltAdminCSID == null) {
+ if (prebuiltAdminCSID == null) {
setupReadList();
AccountClient client = new AccountClient();
ClientResponse<AccountsCommonList> res =
client.readSearchList(null, this.prebuiltAdminUserId, null);
- assertStatusCode(res, "findPrebuiltAdminAccount");
- AccountsCommonList list = res.getEntity();
- List<AccountListItem> items = list.getAccountListItem();
- Assert.assertEquals(1, items.size(), "Found more than one Admin account!");
- AccountListItem item = items.get(0);
- prebuiltAdminCSID = item.getCsid();
- if (logger.isDebugEnabled()) {
- logger.debug("Found Admin Account with ID: " + prebuiltAdminCSID);
+ try {
+ assertStatusCode(res, "findPrebuiltAdminAccount");
+ AccountsCommonList list = res.getEntity();
+ List<AccountListItem> items = list.getAccountListItem();
+ Assert.assertEquals(1, items.size(), "Found more than one Admin account!");
+ AccountListItem item = items.get(0);
+ prebuiltAdminCSID = item.getCsid();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Found Admin Account with ID: " + prebuiltAdminCSID);
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read", "readList", "readNonExistent"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
public void verifyMetadataProtection(String testName) throws Exception {
findPrebuiltAdminAccount();
// Try to update the metadata - it should just get ignored
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupUpdate();
AccountClient client = new AccountClient();
ClientResponse<AccountsCommon> res = client.read(prebuiltAdminCSID);
- assertStatusCode(res, testName);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Did get on Admin Account to update with ID: " + prebuiltAdminCSID);
+ }
AccountsCommon accountFound = (AccountsCommon) res.getEntity();
Assert.assertNotNull(accountFound);
// Submit the request to the service and store the response.
res = client.update(prebuiltAdminCSID, accountToUpdate);
int statusCode = res.getStatus();
-
- // Comment below was not understood - but preserved in case it is
- // important - during work on CSPACE-4572, which replaced several
- // lines of status code checking with the call below.
- //
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
// Note that the error is not returned, it is just ignored
- assertStatusCode(res, testName);
-
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
Assert.assertNotNull(accountUpdated);
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read", "readList", "readNonExistent"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
public void verifyProtectionReadOnly(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
setupCreate();
// Submit the request to the service and store the response.
AccountClient client = new AccountClient();
- AccountsCommon account =
- createAccountInstance("mdTest", "mdTest", "mdTestPW", "md@test.com",
+ AccountsCommon account = createAccountInstance("mdTest", "mdTest", "mdTestPW", "md@test.com",
client.getTenantId(), true, false, true, true);
account.setMetadataProtection(AccountClient.IMMUTABLE);
account.setRolesProtection(AccountClient.IMMUTABLE);
ClientResponse<Response> res = client.create(account);
- int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Store the ID returned from this create operation
- // for additional tests below.
- String testResourceId = extractId(res);
- allResourceIdsCreated.add(testResourceId);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": testResourceId=" + testResourceId);
+ String testResourceId = null;
+ try {
+ assertStatusCode(res, testName);
+ // Store the ID returned from this create operation
+ // for additional tests below.
+ testResourceId = extractId(res);
+ allResourceIdsCreated.add(testResourceId);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": testResourceId=" + testResourceId);
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
+
setupRead();
// Submit the request to the service and store the response.
ClientResponse<AccountsCommon> accountRes = client.read(testResourceId);
- assertStatusCode(accountRes, testName);
-
- AccountsCommon accountRead = (AccountsCommon) accountRes.getEntity();
- Assert.assertNotNull(accountRead);
- String mdProtection = accountRead.getMetadataProtection();
- String rolesProtection = accountRead.getRolesProtection();
- if (logger.isTraceEnabled()) {
- logger.trace(testName + ": metadataProtection=" + mdProtection);
- logger.trace(testName + ": rolesProtection=" + rolesProtection);
+ try {
+ assertStatusCode(accountRes, testName);
+ AccountsCommon accountRead = (AccountsCommon) accountRes.getEntity();
+ Assert.assertNotNull(accountRead);
+ String mdProtection = accountRead.getMetadataProtection();
+ String rolesProtection = accountRead.getRolesProtection();
+ if (logger.isTraceEnabled()) {
+ logger.trace(testName + ": metadataProtection=" + mdProtection);
+ logger.trace(testName + ": rolesProtection=" + rolesProtection);
+ }
+ Assert.assertFalse(account.getMetadataProtection().equals(mdProtection),
+ "Account allowed create to set the metadata protection flag.");
+ Assert.assertFalse(account.getRolesProtection().equals(rolesProtection),
+ "Account allowed create to set the perms protection flag.");
+ } finally {
+ if (accountRes != null) {
+ accountRes.releaseConnection();
+ }
}
- Assert.assertFalse(account.getMetadataProtection().equals(mdProtection),
- "Account allowed create to set the metadata protection flag.");
- Assert.assertFalse(account.getRolesProtection().equals(rolesProtection),
- "Account allowed create to set the perms protection flag.");
setupUpdate();
- AccountsCommon accountToUpdate =
- createAccountInstance("mdTest", "mdTest", "mdTestPW", "md@test.com",
+ AccountsCommon accountToUpdate = createAccountInstance("mdTest", "mdTest", "mdTestPW", "md@test.com",
client.getTenantId(), true, false, true, true);
accountToUpdate.setMetadataProtection(AccountClient.IMMUTABLE);
accountToUpdate.setRolesProtection(AccountClient.IMMUTABLE);
// Submit the request to the service and store the response.
accountRes = client.update(testResourceId, accountToUpdate);
- assertStatusCode(accountRes, testName);
-
- AccountsCommon accountUpdated = (AccountsCommon) accountRes.getEntity();
- Assert.assertNotNull(accountUpdated);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + "Updated account: ");
- logger.debug(objectAsXmlString(accountUpdated,AccountsCommon.class));
- }
-
- Assert.assertFalse(
- AccountClient.IMMUTABLE.equalsIgnoreCase(accountUpdated.getMetadataProtection()),
- "Account allowed update of the metadata protection flag.");
- Assert.assertFalse(
- AccountClient.IMMUTABLE.equalsIgnoreCase(accountUpdated.getRolesProtection()),
- "Account allowed update of the roles protection flag.");
+ try {
+ assertStatusCode(accountRes, testName);
+ AccountsCommon accountUpdated = (AccountsCommon) accountRes.getEntity();
+ Assert.assertNotNull(accountUpdated);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + "Updated account: ");
+ logger.debug(objectAsXmlString(accountUpdated,AccountsCommon.class));
+ }
+ Assert.assertFalse(
+ AccountClient.IMMUTABLE.equalsIgnoreCase(accountUpdated.getMetadataProtection()),
+ "Account allowed update of the metadata protection flag.");
+ Assert.assertFalse(
+ AccountClient.IMMUTABLE.equalsIgnoreCase(accountUpdated.getRolesProtection()),
+ "Account allowed update of the roles protection flag.");
+ } finally {
+ if (accountRes != null) {
+ accountRes.releaseConnection();
+ }
+ }
}
-
-
/**
* Deactivate.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"updatePasswordWithoutUser"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"updatePasswordWithoutUser"})
public void deactivate(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupUpdate();
AccountClient client = new AccountClient();
ClientResponse<AccountsCommon> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
if (logger.isDebugEnabled()) {
logger.debug("got object to update with ID: " + knownResourceId);
// Submit the request to the service and store the response.
res = client.update(knownResourceId, accountToUpdate);
- assertStatusCode(res, testName);
+ int statusCode = res.getStatus();
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
Assert.assertNotNull(accountUpdated);
Assert.assertEquals(accountUpdated.getStatus(),
accountToUpdate.getStatus(),
"Data in updated object did not match submitted data.");
-
}
// Failure outcomes
//FIXME: Should this test really be empty? If so, please comment accordingly.
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
- */
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"deactivate", "readNonExistent", "testSubmitRequest"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"deactivate", "CRUDTests"})
public void updateNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupUpdateNonExistent();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
/**
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"deactivate", "readNonExistent", "testSubmitRequest"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"deactivate", "CRUDTests"})
public void updateWrongUser(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupUpdate();
// Submit the request to the service and store the response.
// The only relevant ID may be the one used in updateAccount(), below.
AccountClient client = new AccountClient();
ClientResponse<AccountsCommon> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
if (logger.isDebugEnabled()) {
logger.debug("got object to update with ID: " + knownResourceId);
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
// CRUD tests : DELETE tests
// ---------------------------------------------------------------
// Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"testSubmitRequest", "updateWrongUser"})
- public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- // Submit the request to the service and store the response.
- AccountClient client = new AccountClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDeleteNonExistent();
-
- // Submit the request to the service and store the response.
- AccountClient client = new AccountClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // Search tests
- // ---------------------------------------------------------------
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void searchWorkflowDeleted(String testName) throws Exception {
- // Fixme: null test for now, overriding test in base class
+ public void delete(String testName) throws Exception {
+ // Do nothing because this test is not ready to delete the "knownResourceId".
+ // Instead, the method localDelete() will get called later in the dependency chain. The
+ // method localDelete() has a dependency on the test "updateWrongUser". Once the "updateWrongUser"
+ // test is run, the localDelete() test/method will get run. The localDelete() test/method in turn
+ // calls the inherited delete() test/method.
}
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
- /**
- * Tests the code for manually submitting data that is used by several
- * of the methods above.
- * @throws Exception
- */
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() throws Exception {
-
- setupRead();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testSubmitRequest: url=" + url
- + " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests", "updateWrongUser"})
+ public void localDelete(String testName) throws Exception {
+ // Because of issues with TestNG not allowing @Test annotations on on override methods,
+ // and because we want the "updateWrongUser" to run before the "delete" test, we need
+ // this method. This method will call super.delete() after all the dependencies have been
+ // met.
+ super.delete(testName);
}
// ---------------------------------------------------------------
logger.debug(objectAsXmlString(account,
AccountsCommon.class));
}
+
return account;
-
}
* @param testName the test name
* @param list the list
*/
- private void printList(String testName, AccountsCommonList list) {
+ @Override
+ protected void printList(String testName, AccountsCommonList list) {
+ AccountsCommonList acl = (AccountsCommonList)list;
List<AccountListItem> items =
- list.getAccountListItem();
+ acl.getAccountListItem();
int i = 0;
-
for (AccountListItem item : items) {
logger.debug(testName + ": list-item[" + i + "] csid="
+ item.getCsid());
logger.debug(testName + ": list-item[" + i + "] URI="
+ item.getUri());
i++;
-
}
}
+
+ @Override
+ protected AccountsCommon createInstance(String commonPartName,
+ String identifier) {
+ AccountClient client = new AccountClient();
+ AccountsCommon account =
+ createAccountInstance(knownUserId, knownUserId, knownUserPassword,
+ "barney@dinoland.com", client.getTenantId(),
+ true, false, true, true);
+ return account;
+ }
+
+ /*
+ * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
+ * refer to this method in their @Test annotation declarations.
+ */
+ @Override
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {
+ "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
+ public void CRUDTests(String testName) {
+ // Do nothing. Simply here to for a TestNG execution order for our tests
+ }
+
+ @Override
+ protected AccountsCommon updateInstance(AccountsCommon accountsCommon) {
+ AccountsCommon result = new AccountsCommon();
+
+ result.setCsid(knownResourceId);
+ result.setUserId(accountsCommon.getUserId());
+ // Update the content of this resource.
+ result.setEmail("updated-" + accountsCommon.getEmail());
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(AccountsCommon original,
+ AccountsCommon updated) throws Exception {
+ Assert.assertEquals(original.getEmail(), updated.getEmail(),
+ "Data in updated object did not match submitted data.");
+ }
+
}
import java.util.UUID;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
-import javax.persistence.NoResultException;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
@BeforeMethod
public void init() {
-
emf = Persistence.createEntityManagerFactory("org.collectionspace.services.account");
-
em = emf.createEntityManager();
-// if (logger.isDebugEnabled()) {
-// logger.debug("created entity manager");
-// }
}
@AfterMethod
}
}
-
@SuppressWarnings("unchecked")
@Test(dataProvider = "testName", dataProviderClass = AccountTest.class)
public void create(String testName) throws Exception {
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.account.jaxb</artifactId>
<name>services.account.jaxb</name>
<groupId>org.jvnet.hyperjaxb3</groupId>
<artifactId>hyperjaxb3-ejb-runtime</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.hyperjaxb</artifactId>
<xs:complexType name="abstractCommonList">
<xs:annotation>
<xs:appinfo>
- <jaxb:class ref="org.collectionspace.services.hyperjaxb.AbstractCommonList"/>
+ <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
</xs:appinfo>
</xs:annotation>
</xs:complexType>
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
\r
<!-- apache -->\r
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
<dependency>\r
<groupId>org.jboss.resteasy</groupId>\r
package org.collectionspace.services.client;
import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-
-import org.collectionspace.services.client.workflow.WorkflowClient;
-import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.jboss.resteasy.client.ClientResponse;
/**
* @version $Revision:$
import java.util.List;
import java.util.Map;
-import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.collectionspace.services.PersonJAXBSchema;
import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
* $LastChangedRevision: 1327 $
* $LastChangedDate: 2010-02-12 10:35:11 -0800 (Fri, 12 Feb 2010) $
*/
-public class AcquisitionAuthRefsTest extends BaseServiceTest {
+public class AcquisitionAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
private final String CLASS_NAME = AcquisitionAuthRefsTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
+ protected AbstractCommonList getCommonList(
ClientResponse<AbstractCommonList> response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
// Success outcomes
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
public void createWithAuthRefs(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- };
-
// Perform setup.
testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
if(logger.isDebugEnabled()){
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Store the ID returned from the first resource created
// for additional tests below.
ClientResponse<Response> res = personAuthClient.create(multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
personAuthCSID = extractId(res);
ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
return extractId(res);
}
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
dependsOnMethods = {"createWithAuthRefs"})
public void readAndCheckAuthRefs(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- };
-
// Perform setup.
testSetup(STATUS_OK, ServiceRequestType.READ);
// Submit the request to the service and store the response.
AcquisitionClient acquisitionClient = new AcquisitionClient();
ClientResponse<String> res = acquisitionClient.read(knownResourceId);
- assertStatusCode(res, testName);
-
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- AcquisitionsCommon acquisition = (AcquisitionsCommon) extractPart(input,
- acquisitionClient.getCommonPartName(), AcquisitionsCommon.class);
- Assert.assertNotNull(acquisition);
+ AcquisitionsCommon acquisition = null;
+ try {
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ assertStatusCode(res, testName);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ acquisition = (AcquisitionsCommon) extractPart(input,
+ acquisitionClient.getCommonPartName(), AcquisitionsCommon.class);
+ Assert.assertNotNull(acquisition);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
// Check a couple of fields
// Scalar fields
for (String refName : sources) {
Assert.assertTrue(acquisitionSourcesRefNames.contains(refName));
}
-
+ //
// Get the auth refs and check them
- ClientResponse<AuthorityRefList> res2 =
- acquisitionClient.getAuthorityRefs(knownResourceId);
- assertStatusCode(res2, testName);
-
- AuthorityRefList list = res2.getEntity();
+ //
+ ClientResponse<AuthorityRefList> res2 = acquisitionClient.getAuthorityRefs(knownResourceId);
+ AuthorityRefList list = null;
+ try {
+ assertStatusCode(res2, testName);
+ list = res2.getEntity();
+ Assert.assertNotNull(list);
+ } finally {
+ if (res2 != null) {
+ res2.releaseConnection();
+ }
+ }
List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
int numAuthRefsFound = items.size();
- if(logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()){
logger.debug("Expected " + NUM_AUTH_REFS_EXPECTED +
" authority references, found " + numAuthRefsFound);
}
}
acquisition.setAcquisitionSources(acqSourcesList);
+ AcquisitionClient acquisitionClient = new AcquisitionClient();
PoxPayloadOut multipart = new PoxPayloadOut(AcquisitionClient.SERVICE_PAYLOAD_NAME);
PayloadOutputPart commonPart =
- multipart.addPart(acquisition, MediaType.APPLICATION_XML_TYPE);
- AcquisitionClient acquisitionClient = new AcquisitionClient();
- commonPart.setLabel(acquisitionClient.getCommonPartName());
+ multipart.addPart(acquisitionClient.getCommonPartName(), acquisition);
if(logger.isDebugEnabled()){
logger.debug("to be created, acquisition common");
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.AcquisitionClient;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
* $LastChangedRevision: 621 $
* $LastChangedDate: 2009-09-02 16:49:01 -0700 (Wed, 02 Sep 2009) $
*/
-public class AcquisitionServiceTest extends AbstractServiceTestImpl {
+public class AcquisitionServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, AcquisitionsCommon> {
/** The logger. */
private final String CLASS_NAME = AcquisitionServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
// Instance variables specific to this test.
- /** The known resource id. */
- private String knownResourceId = null;
private final static String CURRENT_DATE_UTC =
GregorianCalendarDateTimeUtils.timestampUTC();
-
@Override
public String getServicePathComponent() {
return AcquisitionClient.SERVICE_PATH_COMPONENT;
}
-
@Override
protected String getServiceName() {
return AcquisitionClient.SERVICE_NAME;
* @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
+// @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// 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).
if(logger.isDebugEnabled()){
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Store the ID returned from the first resource created
// for additional tests below.
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+// @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+// dependsOnMethods = {"create"})
public void createList(String testName) throws Exception {
for(int i = 0; i < 3; i++){
create(testName);
// Verify that record creation occurs successfully when there is NO whitespace
// between the acquisitionFunding tag and its first child element tag
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "testSubmitRequest"}, groups = {"cspace2578group"})
+ dependsOnMethods = {"CRUDTests"}, groups = {"cspace2578group"})
public void createFromXmlNoWhitespaceAfterRepeatableGroupTag(String testName) throws Exception {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
String testDataDir = System.getProperty("test-data.fileName");
String newId =
createFromXmlFile(testName, testDataDir + "/cspace-2578-no-whitespace.xml", false);
// fixes, and also after the issue is resolved, to help detect any regressions.
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "testSubmitRequest"}, groups = {"cspace2578group"})
+ dependsOnMethods = {"CRUDTests"}, groups = {"cspace2578group"})
public void createFromXmlWhitespaceAfterRepeatableGroupTag(String testName) throws Exception {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
String testDataDir = System.getProperty("test-data.fileName");
String newId =
createFromXmlFile(testName, testDataDir + "/cspace-2578-whitespace.xml", false);
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+// @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+// dependsOnMethods = {"create"})
public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Perform setup.
setupRead();
if(logger.isDebugEnabled()){
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
AcquisitionsCommon acquisitionObject = (AcquisitionsCommon) extractPart(input,
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+// @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+// dependsOnMethods = {"read"})
public void readNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Perform setup.
setupReadNonExistent();
if(logger.isDebugEnabled()){
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
+// @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+// dependsOnMethods = {"createList", "read"})
public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Perform setup.
setupReadList();
// Submit the request to the service and store the response.
AcquisitionClient client = new AcquisitionClient();
ClientResponse<AbstractCommonList> res = client.readList();
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
-
- // Optionally output additional data about list members for debugging.
- if(logger.isTraceEnabled()){
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
+ try {
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ assertStatusCode(res, testName);
+ AbstractCommonList list = res.getEntity();
+
+ // Optionally output additional data about list members for debugging.
+ if (logger.isTraceEnabled() == true){
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
-
}
// Failure outcomes
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+// @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+// dependsOnMethods = {"read"})
public void update(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Perform setup.
setupUpdate();
// Retrieve the contents of a resource to update.
AcquisitionClient client = new AcquisitionClient();
ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
res = client.update(knownResourceId, output);
int statusCode = res.getStatus();
- assertStatusCode(res, testName);
+ // Check the status code of the response: does it match the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
input = new PoxPayloadIn(res.getEntity());
AcquisitionsCommon updatedAcquisition =
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"update", "testSubmitRequest"})
+// @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+// dependsOnMethods = {"update", "testSubmitRequest"})
public void updateNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Perform setup.
setupUpdateNonExistent();
if(logger.isDebugEnabled()){
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "read", "update"})
+// @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+// dependsOnMethods = {"create", "read", "update"})
public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Perform setup.
setupDelete();
if(logger.isDebugEnabled()){
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// Failure outcomes
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"delete"})
+// @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+// dependsOnMethods = {"delete"})
public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Perform setup.
setupDeleteNonExistent();
if(logger.isDebugEnabled()){
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
// Utility tests : tests of code used in tests above
// ---------------------------------------------------------------
- /**
- * Tests the code for manually submitting data that is used by several
- * of the methods above.
- * @throws Exception
- */
-
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() throws Exception {
- testSubmitRequest(knownResourceId);
- }
-
- /**
- * Test submit request.
- *
- * @param resourceId the resource id
- * @throws Exception the exception
- */
- private void testSubmitRequest(String resourceId) throws Exception {
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(resourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testSubmitRequest: url=" + url
- + " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
- }
-
- // ---------------------------------------------------------------
- // Utility methods used by tests above
- // ---------------------------------------------------------------
@Override
protected PoxPayloadOut createInstance(String identifier) {
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
String newId = extractId(res);
allResourceIdsCreated.add(newId);
return newId;
// Submit the request to the service and store the response.
AcquisitionClient client = new AcquisitionClient();
ClientResponse<String> res = client.read(csid);
- assertStatusCode(res, testName);
-
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
-
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": Reading Common part ...");
+ AcquisitionsCommon acquisition = null;
+ try {
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ assertStatusCode(res, testName);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": Reading Common part ...");
+ }
+ acquisition = (AcquisitionsCommon) extractPart(input,
+ client.getCommonPartName(), AcquisitionsCommon.class);
+ Assert.assertNotNull(acquisition);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- AcquisitionsCommon acquisition =
- (AcquisitionsCommon) extractPart(input,
- client.getCommonPartName(), AcquisitionsCommon.class);
- Assert.assertNotNull(acquisition);
return acquisition;
}
+
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected AcquisitionsCommon updateInstance(
+ AcquisitionsCommon commonPartObject) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(AcquisitionsCommon original,
+ AcquisitionsCommon updated) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
+ * refer to this method in their @Test annotation declarations.
+ */
+ @Override
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {
+ "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
+ public void CRUDTests(String testName) {
+ // Do nothing. Simply here to for a TestNG execution order for our tests
+ }
}
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
<dependency>\r
<groupId>org.jboss.resteasy</groupId>\r
* @version $Revision:$
*/
-public class PermissionClient extends AbstractServiceClientImpl<PermissionsList, PermissionProxy> {
+public class PermissionClient extends AbstractServiceClientImpl<PermissionsList, Permission, Permission, PermissionProxy> {
public static final String SERVICE_NAME = "authorization/permissions";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
* @version $Revision:$
*/
-public class PermissionRoleClient extends AbstractServiceClientImpl<PermissionRole, PermissionRoleProxy> {
+public class PermissionRoleClient extends AbstractServiceClientImpl<PermissionRole, PermissionRole, PermissionRole, PermissionRoleProxy> {
@Override
public String getServiceName() {
throw new UnsupportedOperationException(); //FIXME: REM - http://issues.collectionspace.org/browse/CSPACE-3497
public ClientResponse<Response> delete(String csid, PermissionRole permRole) {
return getProxy().delete(csid, "delete", permRole);
}
+
+ @Override
+ public ClientResponse<Response> create(PermissionRole payload) {
+ throw new UnsupportedOperationException(); //method not supported nor needed
+ }
+
+ @Override
+ public ClientResponse<PermissionRole> update(String csid,
+ PermissionRole payload) {
+ throw new UnsupportedOperationException(); //method not supported nor needed
+ }
+
+ @Override
+ public ClientResponse<PermissionRole> readList() {
+ throw new UnsupportedOperationException(); //method not supported nor needed
+ }
}
* @version $Revision:$
*/
-public class RoleClient extends AbstractServiceClientImpl<RolesList, RoleProxy> {
+public class RoleClient extends AbstractServiceClientImpl<RolesList, Role, Role, RoleProxy> {
public static final String SERVICE_NAME = "authorization/roles";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
package org.collectionspace.services.client;
import javax.ws.rs.core.Response;
-
-
-import org.collectionspace.services.authorization.PermissionRole;
-import org.jboss.resteasy.client.ProxyFactory;
-import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor;
-import org.jboss.resteasy.spi.ResteasyProviderFactory;
+import org.collectionspace.services.authorization.PermissionRole;
// TODO: Auto-generated Javadoc
/**
* @version $Revision:$
*/
-public class RolePermissionClient extends AbstractServiceClientImpl<PermissionRole, RolePermissionProxy> {
+public class RolePermissionClient extends AbstractServiceClientImpl<PermissionRole, PermissionRole, PermissionRole, RolePermissionProxy> {
@Override
public String getServiceName() {
throw new UnsupportedOperationException(); //FIXME: REM - http://issues.collectionspace.org/browse/CSPACE-3498
public ClientResponse<Response> delete(String csid, PermissionRole permRole) {
return getProxy().delete(csid, "delete", permRole);
}
+
+ @Override
+ public ClientResponse<Response> create(PermissionRole payload) {
+ throw new UnsupportedOperationException(); //method not supported nor needed
+ }
+
+ @Override
+ public ClientResponse<PermissionRole> update(String csid,
+ PermissionRole payload) {
+ throw new UnsupportedOperationException(); //method not supported nor needed
+ }
+
+ @Override
+ public ClientResponse<PermissionRole> readList() {
+ throw new UnsupportedOperationException(); //method not supported nor needed
+ }
}
import java.util.List;
import javax.ws.rs.core.Response;
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.authorization.perms.EffectType;
import org.collectionspace.services.authorization.perms.Permission;
import org.collectionspace.services.authorization.perms.PermissionAction;
* $LastChangedRevision: 917 $
* $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
*/
-public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
+public class PermissionRoleServiceTest extends AbstractServiceTestImpl<PermissionRole, PermissionRole,
+ PermissionRole, PermissionRole> {
/** The Constant logger. */
private final static String CLASS_NAME = PermissionRoleServiceTest.class.getName();
private final static Logger logger = LoggerFactory.getLogger(CLASS_NAME);
+
// Instance variables specific to this test.
- /** The known resource id. */
- private String knownResourceId = null;
- /** The all resource ids created. */
- private List<String> allResourceIdsCreated = new ArrayList<String>();
final private static String TEST_MARKER = "_PermissionRoleServiceTest";
final private static String TEST_SERVICE_NAME = "fakeservice";
final private static String NO_REL_SUFFIX = "-no-rel";
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
+ protected PermissionRole getCommonList(
+ ClientResponse<PermissionRole> response) {
//FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
throw new UnsupportedOperationException();
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
*/
- @Test(dataProvider = "testName")
@Override
public void readPaginatedList(String testName) throws Exception {
//FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// 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).
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
- // Store the ID returned from this create operation
- // for additional tests below.
- //this is is not important in case of this relationship
- knownResourceId = extractId(res);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ knownResourceId = extractId(res); //This is meaningless in this test, see getKnowResourceId() method for details
if (logger.isDebugEnabled()) {
logger.debug(testName + ": knownResourceId=" + knownResourceId);
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"create"})
public void createList(String testName) throws Exception {
//Should this really be empty?
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"create"})
public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupRead();
try {
res = client.read(
permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId());
- assertStatusCode(res, testName);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
PermissionRole output = (PermissionRole) res.getEntity();
Assert.assertNotNull(output);
} finally {
@Override
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void readNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupReadNonExistent();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
res.releaseConnection();
}
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void readNoRelationship(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupRead();
try {
res = client.read(
permValues.get(TEST_SERVICE_NAME + TEST_MARKER + NO_REL_SUFFIX).getPermissionId());
+ // Check the status code of the response: does it match
+ // the expected response(s)?
assertStatusCode(res, testName);
-
PermissionRole output = (PermissionRole) res.getEntity();
String sOutput = objectAsXmlString(output, PermissionRole.class);
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"createList", "read"})
public void readList(String testName) throws Exception {
//Should this really be empty?
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read", "readList", "readNonExistent"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"read", "readList", "readNonExistent"})
public void update(String testName) throws Exception {
//Should this really be empty?
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
public void updateNonExistent(String testName) throws Exception {
//Should this really be empty?
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"read"})
public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupDelete();
toDelete.getPermission().get(0).getPermissionId(), toDelete);
try {
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
res.releaseConnection();
res = client.delete(toDelete.getPermission().get(0).getPermissionId());
try {
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
res.releaseConnection();
}
// Fixme: null test for now, overriding test in base class
}
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
- /**
- * Tests the code for manually submitting data that is used by several
- * of the methods above.
- * @throws Exception
- */
- @Test(dependsOnMethods = {"create"})
- public void testSubmitRequest() throws Exception { //FIXME: REM - This is testing /permissions not /permissions/permroles
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId());
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testSubmitRequest: url=" + url
- + " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
-
+ @Override
+ protected String getKnowResourceId() {
+ return permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId();
}
-
+
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
*/
private String createPermission(String resName, EffectType effect) {
if (logger.isDebugEnabled()) {
- logger.debug(testBanner("createPermission"));
+ logger.debug(getTestBanner("createPermission"));
}
setupCreate();
PermissionClient permClient = new PermissionClient();
logger.debug("createPermission: resName=" + resName
+ " status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
id = extractId(res);
} finally {
if (res != null) {
*/
private void deletePermission(String permId) {
if (logger.isDebugEnabled()) {
- logger.debug(testBanner("deletePermission"));
+ logger.debug(getTestBanner("deletePermission"));
}
setupDelete();
PermissionClient permClient = new PermissionClient();
logger.debug("deletePermission: delete permission id="
+ permId + " status=" + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
res.releaseConnection();
}
*/
private String createRole(String roleName) {
if (logger.isDebugEnabled()) {
- logger.debug(testBanner("createRole"));
+ logger.debug(getTestBanner("createRole"));
}
setupCreate();
RoleClient roleClient = new RoleClient();
logger.debug("createRole: name=" + roleName
+ " status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
id = extractId(res);
} finally {
*/
private void deleteRole(String roleId) {
if (logger.isDebugEnabled()) {
- logger.debug(testBanner("deleteRole"));
+ logger.debug(getTestBanner("deleteRole"));
}
setupDelete();
RoleClient roleClient = new RoleClient();
logger.debug("deleteRole: delete role id=" + roleId
+ " status=" + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
res.releaseConnection();
}
}
-
+
+ @Override
+ protected PermissionRole createInstance(String commonPartName,
+ String identifier) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected PermissionRole updateInstance(PermissionRole commonPartObject) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(PermissionRole original,
+ PermissionRole updated) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected Class<PermissionRole> getCommonListType() {
+ return PermissionRole.class;
+ }
+
+ /*
+ * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
+ * refer to this method in their @Test annotation declarations.
+ */
+ @Override
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {
+ "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
+ public void CRUDTests(String testName) {
+ // Do nothing. Simply here to for a TestNG execution order for our tests
+ }
}
import org.collectionspace.services.client.PermissionFactory;
import org.collectionspace.services.client.test.AbstractServiceTestImpl;
import org.collectionspace.services.client.test.ServiceRequestType;
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
* $LastChangedRevision: 917 $
* $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
*/
-public class PermissionServiceTest extends AbstractServiceTestImpl {
+public class PermissionServiceTest extends AbstractServiceTestImpl<PermissionsList, Permission,
+ Permission, Permission> {
/** The Constant logger. */
private final static String CLASS_NAME = PermissionServiceTest.class.getName();
private final static Logger logger = LoggerFactory.getLogger(CLASS_NAME);
// Instance variables specific to this test.
- /** The known resource id. */
- private String knownResourceId = null;
private String knownResource = "accounts-test";
@Override
return new PermissionClient();
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
- throw new UnsupportedOperationException();
- }
-
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
*/
- @Test(dataProvider = "testName")
+// @Test(dataProvider = "testName")
@Override
public void readPaginatedList(String testName) throws Exception {
//FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
}
- // ---------------------------------------------------------------
- // CRUD tests : CREATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
- */
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // 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();
-
- // Submit the request to the service and store the response.
- List<PermissionAction> actions = PermissionFactory.createDefaultActions();
- Permission permission = createPermissionInstance(knownResource,
- "default permissions for account",
- actions,
- EffectType.PERMIT,
- true,
- true,
- true);
- PermissionClient client = new PermissionClient();
- ClientResponse<Response> res = client.create(permission);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Store the ID returned from this create operation
- // for additional tests below.
- knownResourceId = extractId(res);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
+ protected String getKnowResourceIdentifier() {
+ return knownResource;
}
-
+
/**
* Creates the without resource name.
*
* @throws Exception the exception
*/
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ dependsOnMethods = {"CRUDTests"})
public void createWithoutResourceName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
// Submit the request to the service and store the response.
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
- //to not cause uniqueness violation for permission, createList is removed
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void createList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- setupCreate();
- // Submit the request to the service and store the response.
- List<PermissionAction> actions = PermissionFactory.createDefaultActions();
- Permission permission1 = createPermissionInstance("test-objects",
- "default permissions for test-objects",
- actions,
- EffectType.PERMIT,
- true,
- true,
- true);
- PermissionClient client = new PermissionClient();
- ClientResponse<Response> res = client.create(permission1);
- int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- allResourceIdsCreated.add(extractId(res));
-
- Permission permission2 = createPermissionInstance("test-acquisitions",
- "default permissions for test-acquisitions",
- actions,
- EffectType.PERMIT,
- true,
- true,
- true);
- res = client.create(permission2);
- statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- allResourceIdsCreated.add(extractId(res));
-
- Permission permission3 = createPermissionInstance("test-ids",
- "default permissions for id service",
- actions,
- EffectType.PERMIT,
- true,
- true,
- true);
- res = client.create(permission3);
- statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- allResourceIdsCreated.add(extractId(res));
- }
-
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
- */
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : READ tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- PermissionClient client = new PermissionClient();
- ClientResponse<Permission> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
- Permission output = (Permission) res.getEntity();
- Assert.assertNotNull(output);
- }
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void readNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- PermissionClient client = new PermissionClient();
- ClientResponse<Permission> res = client.read(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : READ_LIST tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
- public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadList();
-
- // Submit the request to the service and store the response.
- PermissionClient client = new PermissionClient();
- ClientResponse<PermissionsList> res = client.readList();
- assertStatusCode(res, testName);
- PermissionsList list = res.getEntity(PermissionsList.class);
-
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = true;
- if (iterateThroughList && logger.isDebugEnabled()) {
- printList(testName, list);
- }
- }
-
/**
* Search resource name.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void searchResourceName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupReadList();
// Submit the request to the service and store the response.
PermissionClient client = new PermissionClient();
ClientResponse<PermissionsList> res = client.readSearchList("acquisition");
- assertStatusCode(res, testName);
- PermissionsList list = res.getEntity(PermissionsList.class);
- int EXPECTED_ITEMS = 5; //seeded permissions
- int actual = list.getPermission().size();
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": received = " + actual
- + " expected=" + EXPECTED_ITEMS);
- }
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = true;
- if ((iterateThroughList || (EXPECTED_ITEMS != list.getPermission().size()))
- && logger.isDebugEnabled()) {
- printList(testName, list);
+ try {
+ assertStatusCode(res, testName);
+ PermissionsList list = res.getEntity(PermissionsList.class);
+ int EXPECTED_ITEMS = 4; //seeded permissions
+ int actual = list.getPermission().size();
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": received = " + actual
+ + " expected=" + EXPECTED_ITEMS);
+ }
+ // Optionally output additional data about list members for debugging.
+ boolean iterateThroughList = true;
+ if ((iterateThroughList || (EXPECTED_ITEMS != list.getPermission().size()))
+ && logger.isDebugEnabled()) {
+ printList(testName, list);
+ }
+ Assert.assertEquals(list.getPermission().size(), EXPECTED_ITEMS);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertEquals(list.getPermission().size(), EXPECTED_ITEMS);
-
}
-
- // Failure outcomes
- // None at present.
- // ---------------------------------------------------------------
- // CRUD tests : UPDATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
- */
+
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read", "readList", "readNonExistent"})
- public void update(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
-
- Permission permToUpdate = new Permission();
- permToUpdate.setCsid(knownResourceId);
- permToUpdate.setResourceName(knownResource);
- // Update the content of this resource.
- permToUpdate.setDescription("updated description");
- if (logger.isDebugEnabled()) {
- logger.debug("updated object");
- logger.debug(objectAsXmlString(permToUpdate,
- Permission.class));
- }
- PermissionClient client = new PermissionClient();
- // Submit the request to the service and store the response.
- ClientResponse<Permission> res = client.update(knownResourceId, permToUpdate);
- assertStatusCode(res, testName);
- Permission permUpdated = (Permission) res.getEntity();
- Assert.assertNotNull(permUpdated);
-
- Assert.assertEquals(permUpdated.getDescription(),
- permToUpdate.getDescription(),
- "Data in updated object did not match submitted data.");
+ public void delete(String testName) throws Exception {
+ //This method does nothing because we want to postpone the "delete" test until after
+ //the "updateNotAllowed" test gets run. Our "localDelete" test will call the real "delete" test later.
+ }
+
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"updateNotAllowed", "updateActions"})
+ public void localDelete(String testName) throws Exception {
+ super.delete(testName);
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read", "readList", "readNonExistent"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void updateNotAllowed(String testName) throws Exception {
// Perform setup.
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
* @throws Exception the exception
*/
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"updateNotAllowed"})
+ dependsOnMethods = {"updateNotAllowed"})
public void updateActions(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupUpdate();
PermissionClient client = new PermissionClient();
// Submit the request to the service and store the response.
ClientResponse<Permission> res = client.update(knownResourceId, permToUpdate);
- assertStatusCode(res, testName);
+ int statusCode = res.getStatus();
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
Permission permUpdated = (Permission) res.getEntity();
Assert.assertNotNull(permUpdated);
int updated_actions = permToUpdate.getAction().size();
updated_actions,
"Data in updated object did not match submitted data.");
}
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
- */
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
public void updateNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupUpdateNonExistent();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : DELETE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"update", "updateActions", "testSubmitRequest"})
- public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- // Submit the request to the service and store the response.
- PermissionClient client = new PermissionClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDeleteNonExistent();
-
- // Submit the request to the service and store the response.
- PermissionClient client = new PermissionClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
// ---------------------------------------------------------------
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void searchWorkflowDeleted(String testName) throws Exception {
// Fixme: null test for now, overriding test in base class
}
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
- /**
- * Tests the code for manually submitting data that is used by several
- * of the methods above.
- * @throws Exception
- */
- @Test(dependsOnMethods = {"create"})
- public void testSubmitRequest() throws Exception {
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testSubmitRequest: url=" + url
- + " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
- }
-
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
* @param list the list
* @return the int
*/
- private int printList(String testName, PermissionsList list) {
-
- int i = 0;
-
+ @Override
+ protected void printList(String testName, PermissionsList list) {
for (Permission permission : list.getPermission()) {
logger.debug(testName + " permission csid=" + permission.getCsid()
+ " name=" + permission.getResourceName()
+ " desc=" + permission.getDescription());
- i++;
}
- return i;
}
+
+ @Override
+ protected Permission createInstance(String commonPartName, String identifier) {
+ List<PermissionAction> actions = PermissionFactory.createDefaultActions();
+ Permission permission = createPermissionInstance(identifier,
+ "default permissions for " + identifier,
+ actions,
+ EffectType.PERMIT,
+ true,
+ true,
+ true);
+ return permission;
+ }
+
+ @Override
+ protected Permission updateInstance(Permission original) {
+ Permission result = new Permission();
+
+ result.setCsid(original.getCsid());
+ result.setResourceName(original.getResourceName());
+ // Update the content of this resource.
+ result.setDescription("updated-" + original.getDescription());
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(Permission original,
+ Permission updated) throws Exception {
+ Assert.assertEquals(updated.getCsid(),
+ original.getCsid(),
+ "CSID in updated object did not match submitted data.");
+
+ Assert.assertEquals(updated.getResourceName(),
+ original.getResourceName(),
+ "Resource name in updated object did not match submitted data.");
+
+ Assert.assertEquals(updated.getDescription(),
+ original.getDescription(),
+ "Description in updated object did not match submitted data.");
+ }
+
+ @Override
+ protected Class<PermissionsList> getCommonListType() {
+ return PermissionsList.class;
+ }
+
+ @Override
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {
+ "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
+ public void CRUDTests(String testName) {
+ // Do nothing. Simply here to for a TestNG execution order for our tests
+ }
+
+ @Override
+ public void updateWithEmptyEntityBody(String testName) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateWithMalformedXml(String testName) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateWithWrongXmlSchema(String testName) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
}
import org.collectionspace.services.client.RoleFactory;
import org.collectionspace.services.client.test.AbstractServiceTestImpl;
import org.collectionspace.services.client.test.ServiceRequestType;
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
* $LastChangedRevision: 917 $
* $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
*/
-public class RolePermissionServiceTest extends AbstractServiceTestImpl {
+public class RolePermissionServiceTest extends AbstractServiceTestImpl<PermissionRole, PermissionRole,
+ PermissionRole, PermissionRole> {
/** The Constant logger. */
private final static String CLASS_NAME = RolePermissionServiceTest.class.getName();
private final static Logger logger = LoggerFactory.getLogger(CLASS_NAME);
// Instance variables specific to this test.
- /** The known resource id. */
- private String knownResourceId = null;
- /** The all resource ids created. */
- private List<String> allResourceIdsCreated = new ArrayList<String>();
final private static String TEST_MARKER = "_RolePermissionServiceTest";
final private static String TEST_ROLE_NAME = "ROLE";
final private static String NO_REL_SUFFIX = "-no-rel";
return new RolePermissionClient();
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
- throw new UnsupportedOperationException();
- }
-
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
*/
- @Test(dataProvider = "testName")
+// @Test(dataProvider = "testName")
@Override
public void readPaginatedList(String testName) throws Exception {
//FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
}
+
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- ;
// 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).
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- // Store the ID returned from this create operation
- // for additional tests below.
- //this is is not important in case of this relationship
- knownResourceId = extractId(res);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ knownResourceId = extractId(res); //This is meaningless in this test, see getKnowResourceId() method for details
if (logger.isDebugEnabled()) {
logger.debug(testName + ": knownResourceId=" + knownResourceId);
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"create"})
public void createList(String testName) throws Exception {
//Should this really be empty?
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"create"})
public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- ;
// Perform setup.
setupRead();
ClientResponse<PermissionRole> res = null;
try {
res = client.read(roleValues.get(getRoleName()).getRoleId());
- assertStatusCode(res, testName);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
PermissionRole output = (PermissionRole) res.getEntity();
Assert.assertNotNull(output);
} finally {
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void readNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- ;
// Perform setup.
setupReadNonExistent();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
res.releaseConnection();
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void readNoRelationship(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- ;
setupRead();
// Submit the request to the service and store the response.
RolePermissionClient client = new RolePermissionClient();
try {
res = client.read(roleValues.get(getRoleName() + NO_REL_SUFFIX).getRoleId());
- assertStatusCode(res, testName);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
PermissionRole output = (PermissionRole) res.getEntity();
String sOutput = objectAsXmlString(output, PermissionRole.class);
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"createList", "read"})
public void readList(String testName) throws Exception {
//Should this really be empty?
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read", "readList", "readNonExistent"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"read", "readList", "readNonExistent"})
public void update(String testName) throws Exception {
//Should this really be empty?
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
public void updateNonExistent(String testName) throws Exception {
//Should this really be empty?
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"read"})
public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Perform setup.
setupDelete();
try {
delRes = client.delete(rv.getRoleId());
int statusCode = delRes.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (delRes != null) {
delRes.releaseConnection();
res = client.delete(
rv.getRoleId(), toDelete);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
res.releaseConnection();
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void deleteNonExistent(String testName) throws Exception {
//ignoring this test as the service side returns 200 now even if it does
//not find a record in the db
// ---------------------------------------------------------------
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void searchWorkflowDeleted(String testName) throws Exception {
// Fixme: null test for now, overriding test in base class
}
/**
* Tests the code for manually submitting data that is used by several
* of the methods above.
- * @throws Exception
*/
- @Test(dependsOnMethods = {"create"}) //FIXME: REM - This is not a test of a submit to the permroles service, but to just authorization/roles
- public void testSubmitRequest() throws Exception {
+ @Override
+// @Test(dependsOnMethods = {"create"}) //FIXME: REM - This is not a test of a submit to the permroles service, but to just authorization/roles
+ public void testSubmitRequest() {
// Expected status code: 200 OK
final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
+ " status=" + statusCode);
}
Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
-
}
// ---------------------------------------------------------------
logger.debug("createPermission: resName=" + resName
+ " status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
id = extractId(res);
} finally {
if (res != null) {
logger.debug("deletePermission: delete permission id="
+ permId + " status=" + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
logger.debug("createRole: name=" + roleName
+ " status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
id = extractId(res);
} finally {
if (res != null) {
logger.debug("deleteRole: delete role id=" + roleId
+ " status=" + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
res.releaseConnection();
}
}
+
+ @Override
+ protected PermissionRole createInstance(String commonPartName,
+ String identifier) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected PermissionRole updateInstance(PermissionRole commonPartObject) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(PermissionRole original,
+ PermissionRole updated) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected Class<PermissionRole> getCommonListType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected String getKnowResourceId() {
+ return roleValues.get(getRoleName()).getRoleId();
+ }
+
+ /*
+ * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
+ * refer to this method in their @Test annotation declarations.
+ */
+ @Override
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {
+ "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
+ public void CRUDTests(String testName) {
+ // Do nothing. Simply here to for a TestNG execution order for our tests
+ }
}
import org.collectionspace.services.authorization.RolesList;
import org.collectionspace.services.client.RoleFactory;
import org.collectionspace.services.client.test.AbstractServiceTestImpl;
-import org.collectionspace.services.client.test.ServiceRequestType;
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
* $LastChangedRevision: 917 $
* $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
*/
-public class RoleServiceTest extends AbstractServiceTestImpl {
+public class RoleServiceTest extends AbstractServiceTestImpl<RolesList, Role, Role, Role> {
/** The logger. */
private final static String CLASS_NAME = RoleServiceTest.class.getName();
// Instance variables specific to this test.
/** The known resource id. */
- private String knownResourceId = null;
- private String knownRoleName = "ROLE_USERS_MOCK";
- private String knownRoleDisplayName = "ROLE_DISPLAYNAME_USERS_MOCK";
+ private String knownRoleName = "ROLE_USERS_MOCK-1";
+ private String knownRoleDisplayName = "ROLE_DISPLAYNAME_USERS_MOCK-1";
private String verifyResourceId = null;
- private String verifyRoleName = "collections_manager_mock";
+ private String verifyRoleName = "collections_manager_mock-1";
// private List<String> allResourceIdsCreated = new ArrayList<String>();
@Override
return new RoleClient();
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
- throw new UnsupportedOperationException();
- }
-
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
*/
- @Test(dataProvider = "testName")
@Override
public void readPaginatedList(String testName) throws Exception {
//FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
// Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
- */
+
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// 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).
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Store the ID returned from this create operation
// for additional tests below.
}
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void createWithDisplayname(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// 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).
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Store the ID returned from this create operation
// for additional tests below.
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void createForUniqueRole(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
// Submit the request to the service and store the response.
logger.debug(testName + ": status = " + statusCode);
logger.debug(testName + ": " + res);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"createWithDisplayname"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"createWithDisplayname"})
public void createForUniqueDisplayRole(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
// Submit the request to the service and store the response.
logger.debug(testName + ": status = " + statusCode);
logger.debug(testName + ": " + res);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
if (statusCode != Response.Status.BAD_REQUEST.getStatusCode()) {
// If the test fails then we've just created a Role that we need to delete, so
// store the ID returned from this create operation.
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void createWithoutRoleName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
// Submit the request to the service and store the response.
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createWithDisplayname"})
+// @Test(dataProvider = "testName",
+// dependsOnMethods = {"createWithDisplayname"})
public void createList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
// Submit the request to the service and store the response.
true);
ClientResponse<Response> res = client.create(role1);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
verifyResourceId = extractId(res);
allResourceIdsCreated.add(verifyResourceId);
true);
res = client.create(role2);
statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
allResourceIdsCreated.add(extractId(res));
Role role3 = createRoleInstance("ROLE_MOVINGIMAGE_ADMIN_TEST",
true);
res = client.create(role3);
statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
allResourceIdsCreated.add(extractId(res));
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createForUniqueRole"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"createForUniqueRole"})
public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupRead();
// Submit the request to the service and store the response.
RoleClient client = new RoleClient();
ClientResponse<Role> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
Role output = (Role) res.getEntity();
Assert.assertNotNull(output);
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void readToVerify(String testName) throws Exception {
-
// Perform setup.
setupRead();
// Submit the request to the service and store the response.
RoleClient client = new RoleClient();
ClientResponse<Role> res = client.read(verifyResourceId);
- assertStatusCode(res, testName);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
Role output = (Role) res.getEntity();
Assert.assertNotNull(output);
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"read"})
public void readNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupReadNonExistent();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"createList", "read"})
public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupReadList();
// Submit the request to the service and store the response.
RoleClient client = new RoleClient();
ClientResponse<RolesList> res = client.readList();
- assertStatusCode(res, testName);
- RolesList list = res.getEntity();
-
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = true;
- if (iterateThroughList && logger.isDebugEnabled()) {
- printList(testName, list);
+ try {
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ assertStatusCode(res, testName);
+ RolesList list = res.getEntity();
+ // Optionally output additional data about list members for debugging.
+ boolean iterateThroughList = true;
+ if (iterateThroughList && logger.isDebugEnabled()) {
+ printList(testName, list);
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void searchRoleName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupReadList();
// Submit the request to the service and store the response.
RoleClient client = new RoleClient();
ClientResponse<RolesList> res = client.readSearchList("movingImage");
- assertStatusCode(res, testName);
- RolesList list = res.getEntity();
- int EXPECTED_ITEMS = 1;
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": received = " + list.getRole().size()
- + " expected=" + EXPECTED_ITEMS);
- }
- Assert.assertEquals(EXPECTED_ITEMS, list.getRole().size());
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = true;
- if (iterateThroughList && logger.isDebugEnabled()) {
- printList(testName, list);
+ try {
+ assertStatusCode(res, testName);
+ RolesList list = res.getEntity();
+ int EXPECTED_ITEMS = 1;
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": received = " + list.getRole().size()
+ + " expected=" + EXPECTED_ITEMS);
+ }
+ Assert.assertEquals(EXPECTED_ITEMS, list.getRole().size());
+ // Optionally output additional data about list members for debugging.
+ boolean iterateThroughList = true;
+ if (iterateThroughList && logger.isDebugEnabled()) {
+ printList(testName, list);
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read", "readList", "readNonExistent"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"read", "readList", "readNonExistent"})
public void update(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupUpdate();
RoleClient client = new RoleClient();
// Submit the request to the service and store the response.
ClientResponse<Role> res = client.update(knownResourceId, roleToUpdate);
- assertStatusCode(res, testName);
+ int statusCode = res.getStatus();
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+
Role roleUpdated = (Role) res.getEntity();
Assert.assertNotNull(roleUpdated);
"Data in updated object did not match submitted data.");
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read", "readList", "readNonExistent"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void verifyProtectionReadOnly(String testName) throws Exception {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
- setupCreate();
+ setupCreate();
// Submit the request to the service and store the response.
RoleClient client = new RoleClient();
role.setPermsProtection(RoleClient.IMMUTABLE);
ClientResponse<Response> res = client.create(role);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Store the ID returned from this create operation
// for additional tests below.
// Submit the request to the service and store the response.
ClientResponse<Role> roleRes = client.read(testResourceId);
- assertStatusCode(roleRes, testName);
+ statusCode = roleRes.getStatus();
+
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
Role roleRead = (Role) roleRes.getEntity();
Assert.assertNotNull(roleRead);
String mdProtection = roleRead.getMetadataProtection();
// Submit the request to the service and store the response.
roleRes = client.update(testResourceId, roleToUpdate);
- assertStatusCode(roleRes, testName);
+ statusCode = roleRes.getStatus();
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+
Role roleUpdated = (Role) roleRes.getEntity();
Assert.assertNotNull(roleUpdated);
if (logger.isDebugEnabled()) {
"Role allowed update of the perms protection flag.");
}
-
-
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read", "readList", "readNonExistent"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void updateNotAllowed(String testName) throws Exception {
// Perform setup.
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
*/
+
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
public void updateNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupUpdateNonExistent();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"updateNotAllowed", "testSubmitRequest", "verifyProtectionReadOnly"})
public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- // Submit the request to the service and store the response.
- RoleClient client = new RoleClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ // Do nothing since other tests like "updateNotAllowed" need the "known resource" that this test
+ // deletes. Once all those tests get run, the "localDelete" method will call the base class' delete
+ // method that will delete the "known resource".
+ }
+
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"updateNotAllowed", "createForUniqueRole", "createForUniqueDisplayRole"})
+ public void localDelete(String testName) throws Exception {
+ super.delete(testName);
}
// Failure outcomes
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"delete"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"delete"})
public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupDeleteNonExistent();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
// ---------------------------------------------------------------
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void searchWorkflowDeleted(String testName) throws Exception {
// Fixme: null test for now, overriding test in base class
}
* @throws Exception
*/
- @Test(dependsOnMethods = {"create"})
- public void testSubmitRequest() throws Exception {
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testSubmitRequest: url=" + url
- + " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
- }
-
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
* @param list the list
* @return the int
*/
- private int printList(String testName, RolesList list) {
-
- int i = 0;
-
+ protected void printList(String testName, RolesList list) {
for (Role role : list.getRole()) {
logger.debug(testName + " role csid=" + role.getCsid()
+ " name=" + role.getRoleName()
+ " desc=" + role.getDescription());
- i++;
}
- return i;
}
+
+ @Override
+ protected Role createInstance(String commonPartName, String identifier) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Role updateInstance(Role commonPartObject) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(Role original, Role updated)
+ throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected Class<RolesList> getCommonListType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
+ * refer to this method in their @Test annotation declarations.
+ */
+ @Override
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {
+ "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
+ public void CRUDTests(String testName) {
+ // Do nothing. Simply here to for a TestNG execution order for our tests
+ }
}
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
<dependency>\r
<groupId>commons-cli</groupId>\r
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
<scope>test</scope>\r
</dependency>\r
<!-- javax -->\r
*/
package org.collectionspace.services.authorization;
-import org.collectionspace.services.authorization.perms.FooPermissionsList;
import org.collectionspace.services.authorization.perms.Permission;
import org.collectionspace.services.authorization.perms.PermissionsList;
import org.collectionspace.services.authorization.storage.AuthorizationDelegate;
return result;
}
- @GET
- @Path("{csid}/foo")
- @Produces("application/xml")
- public FooPermissionsList getPermissionFooList(@Context UriInfo ui) {
- FooPermissionsList result = new FooPermissionsList();
- return result;
- }
-
@PUT
@Path("{csid}")
public Permission updatePermission(@PathParam("csid") String csid,Permission theUpdate) {
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
<scope>test</scope>
</dependency>
<!-- javax -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.BatchClient;
-import org.collectionspace.services.client.BatchProxy;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.batch.BatchCommon;
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-public class BatchServiceTest extends AbstractServiceTestImpl {
+public class BatchServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, BatchCommon> {
private final String CLASS_NAME = BatchServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
final String SERVICE_PATH_COMPONENT = "batch";
- private String knownResourceId = null;
@Override
public String getServicePathComponent() {
return new BatchClient();
}
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void create(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupCreate();
- BatchClient client = new BatchClient();
- PoxPayloadOut multipart = createBatchInstance(createIdentifier());
- ClientResponse<Response> res = client.create(multipart);
- assertStatusCode(res, testName);
- if (knownResourceId == null) {
- knownResourceId = extractId(res); // Store the ID returned from the first resource created for additional tests below.
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
- allResourceIdsCreated.add(extractId(res)); // Store the IDs from every resource created by tests so they can be deleted after tests have been run.
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
- public void createList(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- for (int i = 0; i < 3; i++) {
- create(testName);
- }
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
- public void read(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupRead();
- BatchClient client = new BatchClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- BatchCommon batch = (BatchCommon) extractPart(input, client.getCommonPartName(), BatchCommon.class);
- Assert.assertNotNull(batch);
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"createList", "read"})
- public void readList(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupReadList();
- BatchClient client = new BatchClient();
- ClientResponse<AbstractCommonList> res = client.readList();
- assertStatusCode(res, testName);
- String bar = "\r\n\r\n=================================\r\n\r\n";
- System.out.println(bar+" res: "+res);
- AbstractCommonList list = res.getEntity();
- System.out.println(bar+" list: "+list);
-
- if(logger.isTraceEnabled()){
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"read"})
- public void update(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupUpdate();
- BatchClient client = new BatchClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
- logger.debug("got object to update with ID: " + knownResourceId);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- BatchCommon batch = (BatchCommon) extractPart(input, client.getCommonPartName(), BatchCommon.class);
- Assert.assertNotNull(batch);
-
- batch.setName("updated-" + batch.getName());
- logger.debug("Object to be updated:"+objectAsXmlString(batch, BatchCommon.class));
- PoxPayloadOut output = new PoxPayloadOut(BatchClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(batch, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
- res = client.update(knownResourceId, output);
- assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
- BatchCommon updatedBatch = (BatchCommon) extractPart(input, client.getCommonPartName(), BatchCommon.class);
- Assert.assertNotNull(updatedBatch);
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupUpdateNonExistent();
- // 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 update(), below.
- BatchClient client = new BatchClient();
- PoxPayloadOut multipart = createBatchInstance(NON_EXISTENT_ID);
- ClientResponse<String> res = client.update(NON_EXISTENT_ID, multipart);
- assertStatusCode(res, testName);
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
- public void delete(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupDelete();
- BatchClient client = new BatchClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- assertStatusCode(res, testName);
- }
-
- // ---------------------------------------------------------------
- // Failure outcome tests : means we expect response to fail, but test to succeed
- // ---------------------------------------------------------------
-
- // Failure outcome
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"read"})
- public void readNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupReadNonExistent();
- BatchClient client = new BatchClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
- assertStatusCode(res, testName);
- }
-
- // Failure outcome
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupDeleteNonExistent();
- BatchClient client = new BatchClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- assertStatusCode(res, testName);
- }
-
- // Failure outcomes
- // Placeholders until the tests below can be implemented. See Issue CSPACE-401.
-
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- }
-
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- }
-
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- }
-
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- }
-
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- }
-
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- }
-
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
-
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() {
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode(); // Expected status code: 200 OK
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
- logger.debug("testSubmitRequest: url=" + url + " status=" + statusCode);
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
- }
-
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
@Override
protected PoxPayloadOut createInstance(String identifier) {
- BatchClient client = new BatchClient();
return createBatchInstance(identifier);
}
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ PoxPayloadOut result = createBatchInstance(identifier);
+ return result;
+ }
+
private PoxPayloadOut createBatchInstance(String exitNumber) {
String identifier = "batchNumber-" + exitNumber;
BatchCommon batch = new BatchCommon();
return multipart;
}
+
+ @Override
+ protected BatchCommon updateInstance(BatchCommon batchCommon) {
+ BatchCommon result = new BatchCommon();
+
+ result.setName("updated-" + batchCommon.getName());
+ result.setNotes("updated-" + batchCommon.getNotes());
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(BatchCommon original,
+ BatchCommon updated) throws Exception {
+ Assert.assertEquals(updated.getName(), original.getName());
+ Assert.assertEquals(updated.getNotes(), original.getNotes());
+ }
+
+ /*
+ * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
+ * refer to this method in their @Test annotation declarations.
+ */
+ @Override
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {
+ "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
+ public void CRUDTests(String testName) {
+ // Do nothing. Simply here to for a TestNG execution order for our tests
+ }
}
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<!-- javax -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-public class BlobAuthRefsTest extends BaseServiceTest {
+public class BlobAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
private final String CLASS_NAME = BlobAuthRefsTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
}
@Override
- protected AbstractCommonList getAbstractCommonList(ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
private PoxPayloadOut createBlobInstance(String depositorRefName) {
+ BlobClient blobClient = new BlobClient();
this.depositorRefName = depositorRefName;
this.blobName = "testblob-"+createIdentifier();
BlobsCommon blob = new BlobsCommon();
blob.setName(this.blobName);
PoxPayloadOut multipart = new PoxPayloadOut(BlobClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = multipart.addPart(blob, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(new BlobClient().getCommonPartName());
+ PayloadOutputPart commonPart = multipart.addPart(blobClient.getCommonPartName(), blob);
logger.debug("to be created, blob common: " + objectAsXmlString(blob, BlobsCommon.class));
return multipart;
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+ @Test(dataProvider = "testName")
public void createWithAuthRefs(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
- String identifier = createIdentifier(); // Submit the request to the service and store the response.
createPersonRefs();// Create all the person refs and entities
// Create a new Loans In resource. One or more fields in this resource will be PersonAuthority
// references, and will refer to Person resources by their refNames.
BlobClient blobClient = new BlobClient();
PoxPayloadOut multipart = createBlobInstance(depositorRefName);
ClientResponse<Response> res = blobClient.create(multipart);
- assertStatusCode(res, testName);
- if (knownResourceId == null) {// Store the ID returned from the first resource created for additional tests below.
- knownResourceId = extractId(res);
+ try {
+ assertStatusCode(res, testName);
+ if (knownResourceId == null) {// Store the ID returned from the first resource created for additional tests below.
+ knownResourceId = extractId(res);
+ }
+ blobIdsCreated.add(extractId(res));// Store the IDs from every resource created; delete on cleanup
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- blobIdsCreated.add(extractId(res));// Store the IDs from every resource created; delete on cleanup
}
protected void createPersonRefs() {
// Create a temporary PersonAuthority resource, and its corresponding refName by which it can be identified.
PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
ClientResponse<Response> res = personAuthClient.create(multipart);
- assertStatusCode(res, "createPersonRefs (not a surefire test)");
- personAuthCSID = extractId(res);
- String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
- // Create temporary Person resources, and their corresponding refNames by which they can be identified.
- String csid = "";
-
- csid = createPerson("Owen the Cur", "Owner", "owenCurOwner", authRefName);
- personIdsCreated.add(csid);
- depositorRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
-
- csid = createPerson("Davenport", "Depositor", "davenportDepositor", authRefName);
- personIdsCreated.add(csid);
- depositorRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
+ try {
+ assertStatusCode(res, "createPersonRefs (not a surefire test)");
+ personAuthCSID = extractId(res);
+ String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
+ // Create temporary Person resources, and their corresponding refNames by which they can be identified.
+ String csid = "";
+
+ csid = createPerson("Owen the Cur", "Owner", "owenCurOwner", authRefName);
+ personIdsCreated.add(csid);
+ depositorRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
+
+ csid = createPerson("Davenport", "Depositor", "davenportDepositor", authRefName);
+ personIdsCreated.add(csid);
+ depositorRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
}
protected String createPerson(String firstName, String surName, String shortId, String authRefName) {
+ String result = null;
+
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
Map<String, String> personInfo = new HashMap<String, String>();
personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance(personAuthCSID, authRefName, personInfo, personAuthClient.getItemCommonPartName());
ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
- assertStatusCode(res, "createPerson (not a surefire test)");
- return extractId(res);
+ try {
+ assertStatusCode(res, "createPerson (not a surefire test)");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
+
+ return result;
}
// @Test annotation commented out by Aron 2010-12-02 until blob payload is set to the
//
// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"createWithAuthRefs"})
public void readAndCheckAuthRefs(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
testSetup(STATUS_OK, ServiceRequestType.READ);
BlobClient blobClient = new BlobClient();
ClientResponse<String> res = blobClient.read(knownResourceId);
- assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- BlobsCommon blob = (BlobsCommon) extractPart(input, blobClient.getCommonPartName(), BlobsCommon.class);
- Assert.assertNotNull(blob);
- logger.debug(objectAsXmlString(blob, BlobsCommon.class));
+ BlobsCommon blob = null;
+ try {
+ assertStatusCode(res, testName);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ blob = (BlobsCommon) extractPart(input, blobClient.getCommonPartName(), BlobsCommon.class);
+ Assert.assertNotNull(blob);
+ logger.debug(objectAsXmlString(blob, BlobsCommon.class));
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
// Check a couple of fields
Assert.assertEquals(blob.getName(), blobName);
// Get the auth refs and check them
ClientResponse<AuthorityRefList> res2 = blobClient.getAuthorityRefs(knownResourceId);
- assertStatusCode(res2, testName);
- AuthorityRefList list = res2.getEntity();
- List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
- int numAuthRefsFound = items.size();
- logger.debug("Authority references, found " + numAuthRefsFound);
- //Assert.assertEquals(numAuthRefsFound, NUM_AUTH_REFS_EXPECTED,
- // "Did not find all expected authority references! " +
- // "Expected " + NUM_AUTH_REFS_EXPECTED + ", found " + numAuthRefsFound);
- if (logger.isDebugEnabled()) {
- int i = 0;
- for (AuthorityRefList.AuthorityRefItem item : items) {
- logger.debug(testName + ": list-item[" + i + "] Field:" + item.getSourceField() + "= " + item.getAuthDisplayName() + item.getItemDisplayName());
- logger.debug(testName + ": list-item[" + i + "] refName=" + item.getRefName());
- logger.debug(testName + ": list-item[" + i + "] URI=" + item.getUri());
- i++;
+ try {
+ assertStatusCode(res2, testName);
+ AuthorityRefList list = res2.getEntity();
+ List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
+ int numAuthRefsFound = items.size();
+ logger.debug("Authority references, found " + numAuthRefsFound);
+ //Assert.assertEquals(numAuthRefsFound, NUM_AUTH_REFS_EXPECTED,
+ // "Did not find all expected authority references! " +
+ // "Expected " + NUM_AUTH_REFS_EXPECTED + ", found " + numAuthRefsFound);
+ if (logger.isDebugEnabled()) {
+ int i = 0;
+ for (AuthorityRefList.AuthorityRefItem item : items) {
+ logger.debug(testName + ": list-item[" + i + "] Field:" + item.getSourceField() + "= " + item.getAuthDisplayName() + item.getItemDisplayName());
+ logger.debug(testName + ": list-item[" + i + "] refName=" + item.getRefName());
+ logger.debug(testName + ": list-item[" + i + "] URI=" + item.getUri());
+ i++;
+ }
+ }
+ } finally {
+ if (res2 != null) {
+ res2.releaseConnection();
}
}
}
}
}
}
-
}
--- /dev/null
+package org.collectionspace.services.client.test;\r
+\r
+import java.awt.Color;\r
+import java.awt.Font;\r
+import java.awt.Graphics;\r
+import java.awt.image.BufferedImage;\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.net.MalformedURLException;\r
+import java.net.URL;\r
+import java.util.Random;\r
+\r
+import javax.imageio.ImageIO;\r
+import javax.ws.rs.core.Response;\r
+\r
+import org.collectionspace.services.client.BlobClient;\r
+import org.collectionspace.services.client.CollectionSpaceClient;\r
+import org.collectionspace.services.common.profile.Profiler;\r
+import org.collectionspace.services.jaxb.AbstractCommonList;\r
+import org.jboss.resteasy.client.ClientResponse;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.testng.annotations.Test;\r
+\r
+public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {\r
+\r
+ private final Logger logger = LoggerFactory.getLogger(BlobScaleTest.class);\r
+ \r
+ private static final int IMAGE_SIZE = 1000;\r
+ private static final int IMAGE_EDGE = -15;\r
+ private static final int MIN_FONTSIZE = 15;\r
+ private static final int MAX_FONTSIZE = 60;\r
+ private static final String IMAGES_TO_CREATE_PROP = "imagesToCreate";\r
+ private static final int DEFAULT_IMAGES_TO_CREATE = 1;\r
+ private static final String GENERATED_IMAGES = "target/generated_images";\r
+\r
+ private static Random generator = new Random(System.currentTimeMillis());\r
+ \r
+ @Override\r
+ protected CollectionSpaceClient getClientInstance() {\r
+ return new BlobClient();\r
+ }\r
+\r
+ @Override\r
+ protected String getServicePathComponent() {\r
+ return BlobClient.SERVICE_PATH_COMPONENT;\r
+ }\r
+\r
+ @Override\r
+ protected String getServiceName() {\r
+ return BlobClient.SERVICE_NAME;\r
+ }\r
+\r
+ private int getImagesToCreate() {\r
+ int result = DEFAULT_IMAGES_TO_CREATE;\r
+ \r
+ String imagesToCreate = System.getProperty(IMAGES_TO_CREATE_PROP);\r
+ try {\r
+ result = Integer.parseInt(imagesToCreate);\r
+ } catch (NumberFormatException np) {\r
+ logger.info("No value (or a bad value) for system property '"\r
+ + IMAGES_TO_CREATE_PROP\r
+ + "' was defined, so we'll use the default instead.");\r
+ } finally {\r
+ logger.info("Testing blob scaling by creating "\r
+ + result\r
+ + " images.");\r
+ }\r
+ \r
+ return result;\r
+ }\r
+ \r
+ @Test(dataProvider = "testName")\r
+ public void scaleTest(String testName) throws MalformedURLException {\r
+ this.createDirectory(GENERATED_IMAGES);\r
+ setupCreate();\r
+ int imagesToCreate = getImagesToCreate();\r
+ BlobClient client = new BlobClient();\r
+ Profiler profiler = new Profiler(this, 1);\r
+ \r
+ for (int i = 0; i < imagesToCreate; i++, profiler.reset()) {\r
+ File jpegFile = createJpeg(GENERATED_IMAGES); \r
+ URL url = jpegFile.toURI().toURL();\r
+ \r
+ profiler.start();\r
+ ClientResponse<Response> res = client.createBlobFromURI(url.toString());\r
+ try {\r
+ profiler.stop();\r
+ assertStatusCode(res, testName);\r
+ logger.debug(\r
+ i + ": Uploaded image to Nuxeo in "\r
+ + profiler.getCumulativeTime()\r
+ + " milleseconds "\r
+ + " - "\r
+ + " : "\r
+ + jpegFile.getAbsolutePath());\r
+ \r
+ String csid = extractId(res);\r
+ allResourceIdsCreated.add(csid);\r
+ } finally {\r
+ if (res != null) {\r
+ res.releaseConnection();\r
+ }\r
+ }\r
+ }\r
+ }\r
+ \r
+ private void createDirectory(String dirName) {\r
+ boolean success = (\r
+ new File(dirName)).mkdir();\r
+ if (success) {\r
+ logger.debug("Directory: " \r
+ + dirName + " created");\r
+ } \r
+ }\r
+ \r
+ public File createJpeg(String destDir) {\r
+ File result = null;\r
+\r
+ BufferedImage image = new BufferedImage(IMAGE_SIZE, IMAGE_SIZE, BufferedImage.TYPE_INT_RGB); \r
+ Graphics g = image.getGraphics();\r
+ for (int i = 0; i < IMAGE_SIZE; i = i + 10) {\r
+ int x = random(IMAGE_EDGE, IMAGE_SIZE);\r
+ int y = random(IMAGE_EDGE, IMAGE_SIZE);\r
+ g.drawString(Integer.toString(random(-123456789, 123456789)), x, y);\r
+ Color c = new Color(random(0, 255), random(0, 255), random(0, 255));\r
+ g.setColor(c);\r
+\r
+ Font currentFont = g.getFont();\r
+ Font newFont = new Font(currentFont.getFontName(), currentFont.getStyle(),\r
+ random(MIN_FONTSIZE, MAX_FONTSIZE));\r
+ g.setFont(newFont);\r
+ }\r
+ try { \r
+ ImageIO.write(image, "jpg", result = new File(destDir\r
+ + File.separator\r
+ + System.currentTimeMillis()\r
+ + ".jpg"));\r
+ } catch (IOException e) { \r
+ e.printStackTrace(); \r
+ } \r
+\r
+ return result;\r
+ }\r
+\r
+ public int random(int min, int max) {\r
+ return min + (int)(generator.nextFloat() * ((max - min) + 1));\r
+ }\r
+ \r
+\r
+}\r
import java.io.File;
import java.math.BigDecimal;
-import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
-import org.collectionspace.services.client.BlobProxy;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.BlobClient;
import org.collectionspace.services.client.PayloadOutputPart;
-import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.blob.BlobsCommon;
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-public class BlobServiceTest extends AbstractGenericServiceTestImpl<BlobsCommon> {
+public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, BlobsCommon> {
private final String CLASS_NAME = BlobServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
- private String knownResourceId = null;
private final static String KNOWN_IMAGE_FILENAME = "01-03-09_1546.jpg";
private final static int WIDTH_DIMENSION_INDEX = 0;
}
@Override
- protected CollectionSpaceClient<AbstractCommonList, BlobProxy> getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() {
return new BlobClient();
}
@Override
- protected AbstractCommonList getAbstractCommonList(ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
return response.getEntity(AbstractCommonList.class);
}
private boolean isBlobCleanup() {
return blobCleanup;
}
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void create(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupCreate();
- BlobClient client = new BlobClient();
- PoxPayloadOut multipart = createBlobInstance(createIdentifier());
- ClientResponse<Response> res = client.create(multipart);
- assertStatusCode(res, testName);
- if (knownResourceId == null) {
- knownResourceId = extractId(res); // Store the ID returned from the first resource created for additional tests below.
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
- allResourceIdsCreated.add(extractId(res)); // Store the IDs from every resource created by tests so they can be deleted after tests have been run.
- }
-
+
/**
* Looks in the .../src/test/resources/blobs directory for files from which to create Blob
* instances.
OutputPart outputPart = form.addFormData("file", child, MediaType.valueOf(mimeType));
res = client.createBlobFromFormData(form);
}
- assertStatusCode(res, testName);
- if (isBlobCleanup() == true) {
- allResourceIdsCreated.add(extractId(res));
- }
+ try {
+ assertStatusCode(res, testName);
+ if (isBlobCleanup() == true) {
+ allResourceIdsCreated.add(extractId(res));
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
}
}
} else {
}
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"createBlobWithURI"})
+ /*
+ * For a known image file, make sure we're getting back the correct metadata about it.
+ */
+ @Test(dataProvider = "testName", dependsOnMethods = {"createBlobWithURI"})
public void testImageDimensions(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
setupCreate();
String currentDir = this.getResourceDir();
File file = new File(blobsDirPath);
URL fileUrl = file.toURI().toURL();
String uri = fileUrl.toString();
-
+ //
+ // Create the blob
+ //
BlobClient client = new BlobClient();
ClientResponse<Response> res = null;
res = client.createBlobFromURI(uri);
- assertStatusCode(res, testName);
-
- String blobCsid = extractId(res);
- if (isBlobCleanup() == true) {
- allResourceIdsCreated.add(blobCsid);
- }
-
+ String blobCsid = null;
+ try {
+ assertStatusCode(res, testName);
+ blobCsid = extractId(res);
+ if (isBlobCleanup() == true) {
+ allResourceIdsCreated.add(blobCsid);
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
+ //
+ // Read the blob back to get the new dimension data
+ //
setupRead();
ClientResponse<String> readResponse = client.read(blobCsid);
- assertStatusCode(readResponse, testName);
+ BlobsCommon blobsCommon = null;
+ try {
+ assertStatusCode(readResponse, testName);
+ blobsCommon = this.extractCommonPartValue(readResponse);
+ Assert.assertNotNull(blobsCommon);
+ } finally {
+ if (readResponse != null) {
+ readResponse.releaseConnection();
+ }
+ }
- BlobsCommon blobsCommon = this.extractCommonPartValue(readResponse);
- Assert.assertTrue(blobsCommon != null);
Assert.assertEquals(blobsCommon.getLength(), KNOWN_IMAGE_SIZE, "The known image blob was not the expected size of " + KNOWN_IMAGE_SIZE);
MeasuredPartGroup measuredImagePart = blobsCommon.getMeasuredPartGroupList().getMeasuredPartGroup().get(0);
Assert.assertTrue(heightDimension.getValue().compareTo(KNOWN_IMAGE_HEIGHT) == 0);
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"CRUDTests"})
public void createBlobWithURI(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
createBlob(testName, true /*with URI*/, null);
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ dependsOnMethods = {"CRUDTests"})
public void createBlobWithURL(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
createBlob(testName, true /*with URI*/, "http://farm6.static.flickr.com/5289/5688023100_15e00cde47_o.jpg");
}
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
dependsOnMethods = {"createBlobWithURI"})
public void createBlobWithPost(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
createBlob(testName, false /*with POST*/, null);
}
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
- public void createList(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- for (int i = 0; i < 3; i++) {
- create(testName);
- }
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
- public void read(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupRead();
- BlobClient client = new BlobClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- BlobsCommon blob = (BlobsCommon) extractPart(input, client.getCommonPartName(), BlobsCommon.class);
- Assert.assertNotNull(blob);
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"createList", "read"})
- public void readList(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupReadList();
- BlobClient client = new BlobClient();
- ClientResponse<AbstractCommonList> res = client.readList();
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
- if (logger.isDebugEnabled()) {
- List<AbstractCommonList.ListItem> items =
- list.getListItem();
- int i = 0;
- for(AbstractCommonList.ListItem item : items){
- logger.debug(testName + ": list-item[" + i + "] " +
- item.toString());
- i++;
- }
- }
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"read"})
- public void update(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupUpdate();
- BlobClient client = new BlobClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
- logger.debug("got object to update with ID: " + knownResourceId);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- BlobsCommon blob = (BlobsCommon) extractPart(input, client.getCommonPartName(), BlobsCommon.class);
- Assert.assertNotNull(blob);
-
- blob.setName("updated-" + blob.getName());
- logger.debug("Object to be updated:"+objectAsXmlString(blob, BlobsCommon.class));
- PoxPayloadOut output = new PoxPayloadOut(BlobClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(blob, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
- res = client.update(knownResourceId, output);
- assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
- BlobsCommon updatedBlob = (BlobsCommon) extractPart(input, client.getCommonPartName(), BlobsCommon.class);
- Assert.assertNotNull(updatedBlob);
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupUpdateNonExistent();
- // 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 update(), below.
- BlobClient client = new BlobClient();
- PoxPayloadOut multipart = createBlobInstance(NON_EXISTENT_ID);
- ClientResponse<String> res = client.update(NON_EXISTENT_ID, multipart);
- assertStatusCode(res, testName);
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
- public void delete(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupDelete();
- BlobClient client = new BlobClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- assertStatusCode(res, testName);
- }
-
- // ---------------------------------------------------------------
- // Failure outcome tests : means we expect response to fail, but test to succeed
- // ---------------------------------------------------------------
-
- // Failure outcome
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"read"})
- public void readNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupReadNonExistent();
- BlobClient client = new BlobClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
- assertStatusCode(res, testName);
- }
-
- // Failure outcome
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupDeleteNonExistent();
- BlobClient client = new BlobClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- assertStatusCode(res, testName);
- }
-
- // Failure outcomes
- // Placeholders until the tests below can be implemented. See Issue CSPACE-401.
-
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- }
-
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- }
-
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- }
-
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- }
-
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- }
-
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- }
-
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
-
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() {
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode(); // Expected status code: 200 OK
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
- logger.debug("testSubmitRequest: url=" + url + " status=" + statusCode);
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
- }
-
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
}
private PoxPayloadOut createBlobInstance(String exitNumber) {
+ BlobClient client = new BlobClient();
String identifier = "blobNumber-" + exitNumber;
BlobsCommon blob = new BlobsCommon();
blob.setName(identifier);
PoxPayloadOut multipart = new PoxPayloadOut(BlobClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = multipart.addPart(blob, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(new BlobClient().getCommonPartName());
+ PayloadOutputPart commonPart = multipart.addPart(client.getCommonPartName(), blob);
if (logger.isDebugEnabled()) {
logger.debug("to be created, blob common");
return multipart;
}
+
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ return createInstance(identifier);
+ }
+
+ /*
+ * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
+ * refer to this method in their @Test annotation declarations.
+ */
+ @Override
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {
+ "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
+ public void CRUDTests(String testName) {
+ // Do nothing. Simply here to for a TestNG execution order for our tests
+ }
+
+ @Override
+ protected BlobsCommon updateInstance(BlobsCommon blobsCommon) {
+ BlobsCommon result = new BlobsCommon();
+
+ result.setName("updated-" + blobsCommon.getName());
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(BlobsCommon original,
+ BlobsCommon updated) throws Exception {
+ Assert.assertEquals(updated.getName(), original.getName());
+ }
}
\r
#packages\r
log4j.logger.org.collectionspace=DEBUG\r
+log4j.logger.perf.collectionspace=TRACE\r
+\r
log4j.logger.org.apache=INFO\r
log4j.logger.httpclient=INFO\r
log4j.logger.org.jboss.resteasy=INFO\r
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<!-- javax -->
</parent>\r
\r
<modelVersion>4.0.0</modelVersion>\r
- <groupId>org.collectionspace.services</groupId>\r
<artifactId>org.collectionspace.services.client</artifactId>\r
<name>services.client</name>\r
<packaging>jar</packaging>\r
<artifactId>slf4j-log4j12</artifactId>\r
<scope>provided</scope>\r
</dependency>\r
+ \r
<!-- CollectionSpace dependencies -->\r
-<!-- <dependency>\r
- <groupId>org.collectionspace.services</groupId>\r
- <artifactId>org.collectionspace.services.common</artifactId>\r
- <version>${project.version}</version>\r
- <optional>true</optional>\r
- </dependency> -->\r
+\r
<dependency>\r
<groupId>org.collectionspace.services</groupId>\r
<artifactId>org.collectionspace.services.jaxb</artifactId>\r
<version>${project.version}</version>\r
</dependency>\r
\r
-<!-- External dependencies --> \r
+<!-- External dependencies -->\r
+\r
<dependency>\r
<groupId>org.apache.maven.plugins</groupId>\r
<artifactId>maven-surefire-plugin</artifactId>\r
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
+ <scope>compile</scope>\r
</dependency>\r
\r
<!-- javax -->\r
package org.collectionspace.services.client;\r
\r
import org.collectionspace.services.jaxb.AbstractCommonList;\r
-import org.jboss.resteasy.client.ClientResponse;\r
\r
-public abstract class AbstractCommonListPoxServiceClientImpl<P \r
- extends CollectionSpaceCommonListPoxProxy> extends\r
- AbstractPoxServiceClientImpl<AbstractCommonList, P> {\r
-\r
- /*\r
- * Proxied service calls.\r
- */\r
- \r
- /**\r
- * @return\r
- * @see org.collectionspace.hello.client.IntakeProxy#getIntake()\r
- */\r
- public ClientResponse<AbstractCommonList> readList() {\r
- return getProxy().readList();\r
- }\r
-\r
- /**\r
- * @param csid\r
- * @return\r
- * @see org.collectionspace.hello.client.IntakeProxy#getIntake(java.lang.String)\r
- */\r
- @Override\r
- public ClientResponse<String> read(String csid) {\r
- return getProxy().read(csid);\r
- }\r
+/**\r
+ * \r
+ * @author remillet\r
+ *\r
+ * All clients returning AbstractCommonList types should extend this class.\r
+ * \r
+ * @param <P>\r
+ */\r
+public abstract class AbstractCommonListPoxServiceClientImpl<P extends CollectionSpaceCommonListPoxProxy>\r
+ extends AbstractPoxServiceClientImpl<AbstractCommonList, P> {\r
+ //\r
+ // All clients returning AbstractCommonList types should extend this class.\r
+ //\r
}\r
-package org.collectionspace.services.common;\r
+package org.collectionspace.services.client;\r
\r
import java.util.List;\r
\r
package org.collectionspace.services.client;\r
\r
import javax.ws.rs.core.Response;\r
+import org.jboss.resteasy.client.ClientResponse;\r
\r
import org.collectionspace.services.jaxb.AbstractCommonList;\r
-import org.jboss.resteasy.client.ClientResponse;\r
\r
/*\r
- * LT = List type\r
+ * CLT = List type\r
* P = Proxy type\r
*/\r
-public abstract class AbstractPoxServiceClientImpl<LT extends AbstractCommonList, P extends CollectionSpacePoxProxy<LT>>\r
- extends AbstractServiceClientImpl<LT, P> \r
- implements CollectionSpacePoxClient<LT, P> {\r
+public abstract class AbstractPoxServiceClientImpl<CLT extends AbstractCommonList, P extends CollectionSpacePoxProxy<CLT>>\r
+ extends AbstractServiceClientImpl<CLT, PoxPayloadOut, String, P> \r
+ implements CollectionSpacePoxClient<CLT, P> {\r
\r
@Override\r
public ClientResponse<Response> create(PoxPayloadOut xmlPayload) {\r
public ClientResponse<String> read(String csid) {\r
return getProxy().read(csid);\r
}\r
-\r
+ \r
+ public ClientResponse<CLT> readList() {\r
+ CollectionSpaceProxy<CLT> proxy = (CollectionSpaceProxy<CLT>)getProxy();\r
+ return proxy.readList();\r
+ } \r
+ \r
+ @Override\r
+ public ClientResponse<CLT> readIncludeDeleted(Boolean includeDeleted) {\r
+ CollectionSpacePoxProxy<CLT> proxy = getProxy();\r
+ return proxy.readIncludeDeleted(includeDeleted.toString());\r
+ }\r
+ \r
@Override\r
public ClientResponse<String> readIncludeDeleted(String csid, Boolean includeDeleted) {\r
return getProxy().readIncludeDeleted(csid, includeDeleted.toString());\r
return getProxy().update(csid, xmlPayload.getBytes());\r
}\r
\r
- @Override\r
- public ClientResponse<LT> readIncludeDeleted(Boolean includeDeleted) {\r
- CollectionSpacePoxProxy<LT> proxy = getProxy();\r
- return proxy.readIncludeDeleted(includeDeleted.toString());\r
- }\r
\r
@Override\r
- public ClientResponse<LT> keywordSearchIncludeDeleted(String keywords, Boolean includeDeleted) {\r
- CollectionSpacePoxProxy<LT> proxy = getProxy();\r
+ public ClientResponse<CLT> keywordSearchIncludeDeleted(String keywords, Boolean includeDeleted) {\r
+ CollectionSpacePoxProxy<CLT> proxy = getProxy();\r
return proxy.keywordSearchIncludeDeleted(keywords, includeDeleted.toString());\r
}\r
\r
@Override\r
- public ClientResponse<LT> advancedSearchIncludeDeleted(String whereClause, Boolean includeDeleted) {\r
- CollectionSpacePoxProxy<LT> proxy = getProxy();\r
+ public ClientResponse<CLT> advancedSearchIncludeDeleted(String whereClause, Boolean includeDeleted) {\r
+ CollectionSpacePoxProxy<CLT> proxy = getProxy();\r
return proxy.advancedSearchIncludeDeleted(whereClause, includeDeleted.toString());\r
}\r
\r
\r
import org.collectionspace.services.common.authorityref.AuthorityRefList;\r
import org.collectionspace.services.jaxb.AbstractCommonList;\r
-import org.collectionspace.services.workflow.WorkflowCommon;\r
+\r
import org.jboss.resteasy.client.ClientResponse; //import org.collectionspace.services.common.context.ServiceContext;\r
import org.jboss.resteasy.client.ProxyFactory;\r
import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor;\r
* http://issues.collectionspace.org/browse/CSPACE-1684\r
* @param <CommonListType> \r
* @param <ListType> \r
+ * \r
+ * CLT - List type\r
+ * REQUEST_PT - Request payload type\r
+ * RESPONSE_PT - Response payload type\r
+ * P - Proxy type\r
*/\r
-public abstract class AbstractServiceClientImpl<LT, P extends CollectionSpaceProxy<LT>>\r
- implements CollectionSpaceClient<LT, P> {\r
+public abstract class AbstractServiceClientImpl<CLT, REQUEST_PT, RESPONSE_PT, P extends CollectionSpaceProxy<CLT>>\r
+ implements CollectionSpaceClient<CLT, REQUEST_PT, RESPONSE_PT, P> {\r
\r
/** The logger. */\r
protected final Logger logger = LoggerFactory.getLogger(AbstractServiceClientImpl.class);\r
return result;\r
}\r
\r
+ /*\r
+ * Subclasses can override this method to return their AbstractCommonList subclass\r
+ */\r
+ protected Class<CLT> getCommonListType() {\r
+ return (Class<CLT>) AbstractCommonList.class;\r
+ }\r
+ \r
/**\r
* Gets the common part name.\r
*\r
* these methods with their specific "common" list return types. Otherwise, only the info\r
* in the AbstractCommonList type will be returned to the callers\r
*/\r
+\r
\r
/*\r
* (non-Javadoc)\r
* .lang.String, java.lang.String)\r
*/\r
@Override\r
- public ClientResponse<AbstractCommonList> readList(Long pageSize,\r
+ public ClientResponse<CLT> readList(Long pageSize,\r
Long pageNumber) {\r
return getProxy().readList(pageSize, pageNumber);\r
}\r
* .lang.String, java.lang.String)\r
*/\r
@Override\r
- public ClientResponse<AbstractCommonList> readList(String sortBy, Long pageSize,\r
+ public ClientResponse<CLT> readList(String sortBy, Long pageSize,\r
Long pageNumber) {\r
return getProxy().readList(sortBy, pageSize, pageNumber);\r
}\r
package org.collectionspace.services.client;\r
\r
import javax.ws.rs.core.Response;\r
+import org.jboss.resteasy.client.ClientResponse;\r
\r
import org.collectionspace.services.common.authorityref.AuthorityRefDocList;\r
import org.collectionspace.services.common.authorityref.AuthorityRefList;\r
import org.collectionspace.services.jaxb.AbstractCommonList;\r
-import org.jboss.resteasy.client.ClientResponse;\r
\r
/*\r
* LT - List type\r
* ILT - Authority item list type\r
* P - Proxy type\r
*/\r
-public interface AuthorityClient<P extends AuthorityProxy> \r
+public interface AuthorityClient<AUTHORITY_ITEM_TYPE, P extends AuthorityProxy> \r
extends CollectionSpacePoxClient<AbstractCommonList, P> {\r
\r
/** The uri path element for items in an authority */\r
*/\r
\r
String getItemCommonPartName();\r
+ \r
+ // Get the inAuthorityCsid (the item's parent)\r
+ String getInAuthority(AUTHORITY_ITEM_TYPE item);\r
+ \r
+ // Get the inAuthorityCsid (the item's parent)\r
+ void setInAuthority(AUTHORITY_ITEM_TYPE item, String inAuthorityCsid);\r
\r
//(C)reate Item\r
ClientResponse<Response> createItem(String vcsid, PoxPayloadOut poxPayloadOut);\r
/*\r
* P - Proxy type\r
*/\r
-public abstract class AuthorityClientImpl<P extends AuthorityProxy>\r
- extends AbstractCommonListPoxServiceClientImpl<P>\r
- implements AuthorityClient<P> {\r
+public abstract class AuthorityClientImpl<AUTHORITY_ITEM_TYPE, P extends AuthorityProxy>\r
+ extends AbstractPoxServiceClientImpl<AbstractCommonList, P>\r
+ implements AuthorityClient<AUTHORITY_ITEM_TYPE, P> {\r
\r
private static final String INCLUDE_DELETE_TRUE = Boolean.TRUE.toString();\r
/*\r
import javax.ws.rs.Produces;\r
import javax.ws.rs.QueryParam;\r
import javax.ws.rs.core.Response;\r
+import org.jboss.resteasy.client.ClientResponse;\r
\r
import org.collectionspace.services.client.workflow.WorkflowClient;\r
import org.collectionspace.services.common.authorityref.AuthorityRefDocList;\r
import org.collectionspace.services.common.authorityref.AuthorityRefList;\r
import org.collectionspace.services.jaxb.AbstractCommonList;\r
-import org.jboss.resteasy.client.ClientResponse;\r
\r
/*\r
* ILT = Item list type\r
import javax.ws.rs.core.Response;
import org.apache.commons.httpclient.HttpClient;
-import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.client.ClientResponse;
+import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.common.authorityref.AuthorityRefList;
+
/**
* LT - List Type
+ * REQUEST_PT - Request payload type
+ * RESPONSE_PT - Response payload type
* P - Proxy type
*/
-public interface CollectionSpaceClient<LT, P extends CollectionSpaceProxy<LT>> {
+public interface CollectionSpaceClient<CLT, REQUEST_TYPE, RESPONSE_TYPE, P extends CollectionSpaceProxy<CLT>> {
public static final String AUTH_PROPERTY = "cspace.auth";
public static final String PASSWORD_PROPERTY = "cspace.password";
* Common proxied service calls
*/
+ public ClientResponse<Response> create(REQUEST_TYPE payload);
+
+ public ClientResponse<RESPONSE_TYPE> read(String csid);
+
+ public ClientResponse<RESPONSE_TYPE> update(String csid, REQUEST_TYPE payload);
+
/**
* Read list.
*
* @param pageNumber the page number
* @return the client response
*/
- public ClientResponse<AbstractCommonList> readList(
+ public ClientResponse<CLT> readList(
Long pageSize,
Long pageNumber);
+
+ public ClientResponse<CLT> readList();
/**
* Read list.
* @param pageNumber the page number
* @return the client response
*/
- public ClientResponse<AbstractCommonList> readList(
+ public ClientResponse<CLT> readList(
String sortBy,
Long pageSize,
Long pageNumber);
package org.collectionspace.services.client;\r
\r
-import javax.ws.rs.core.Response;\r
-\r
import org.collectionspace.services.jaxb.AbstractCommonList;\r
import org.jboss.resteasy.client.ClientResponse;\r
\r
/*\r
* <LT> = List type\r
+ * <PT> = Payload type\r
* <P> = Proxy type\r
*/\r
public interface CollectionSpacePoxClient<LT extends AbstractCommonList, P extends CollectionSpacePoxProxy<LT>>\r
- extends CollectionSpaceClient<LT, P> {\r
+ extends CollectionSpaceClient<LT, PoxPayloadOut, String, P> {\r
/*\r
* Common service calls\r
*/\r
- public ClientResponse<Response> create(PoxPayloadOut xmlPayload);\r
- \r
- /*\r
- * GET resource with workflow 'deleted' state\r
- */\r
- public ClientResponse<String> read(String csid);\r
\r
public ClientResponse<String> readIncludeDeleted(String csid, Boolean includeDeleted); \r
\r
- public ClientResponse<String> update(String csid, PoxPayloadOut xmlPayload);\r
- \r
/*\r
* GET list with workflow 'deleted' state\r
*/\r
import javax.ws.rs.Produces;\r
import javax.ws.rs.QueryParam;\r
import javax.ws.rs.core.Response;\r
+import org.jboss.resteasy.client.ClientResponse;\r
\r
import org.collectionspace.services.client.workflow.WorkflowClient;\r
import org.collectionspace.services.jaxb.AbstractCommonList;\r
-import org.jboss.resteasy.client.ClientResponse;\r
\r
public interface CollectionSpacePoxProxy<LT extends AbstractCommonList> extends\r
CollectionSpaceProxy<LT> {\r
\r
import org.collectionspace.services.client.workflow.WorkflowClient;\r
import org.collectionspace.services.common.authorityref.AuthorityRefList;\r
-import org.collectionspace.services.jaxb.AbstractCommonList;\r
\r
import org.jboss.resteasy.client.ClientResponse;\r
\r
* The Interface CollectionSpaceProxy.\r
* FIXME: http://issues.collectionspace.org/browse/CSPACE-1684\r
*/\r
-public interface CollectionSpaceProxy<LT> {\r
+public interface CollectionSpaceProxy<CLT> {\r
\r
//(D)elete\r
@DELETE\r
* (R)read List operations\r
*/\r
\r
+ @GET\r
+ @Produces({"application/xml"})\r
+ ClientResponse<CLT> readList();\r
+ \r
/**\r
* Read list.\r
*\r
*/\r
@GET\r
@Produces({"application/xml"})\r
- ClientResponse<AbstractCommonList> readList(\r
+ ClientResponse<CLT> readList(\r
@QueryParam(IClientQueryParams.PAGE_SIZE_PARAM) Long pageSize,\r
@QueryParam(IClientQueryParams.START_PAGE_PARAM) Long pageNumber);\r
\r
*/\r
@GET\r
@Produces({"application/xml"})\r
- ClientResponse<AbstractCommonList> readList(\r
+ ClientResponse<CLT> readList(\r
@QueryParam(IClientQueryParams.SORT_BY_PARAM) String sortBy,\r
@QueryParam(IClientQueryParams.PAGE_SIZE_PARAM) Long pageSize,\r
@QueryParam(IClientQueryParams.START_PAGE_PARAM) Long pageNumber); \r
*/
package org.collectionspace.services.client;
+import javax.ws.rs.core.Response;
+
+import org.jboss.resteasy.client.ClientResponse;
+import org.collectionspace.services.jaxb.AbstractCommonList;
+
/**
* A CollectionObjectClient.
* @version $Revision:$
*/
-public class TestServiceClient extends AbstractServiceClientImpl<Object, TestServiceProxy> {
+
+public final class TestServiceClient extends AbstractServiceClientImpl<AbstractCommonList, Object, Object, TestServiceProxy> {
/**
*
public Class<TestServiceProxy> getProxyClass() {
// TODO Auto-generated method stub
return TestServiceProxy.class;
+ }
+
+ @Override
+ public ClientResponse<Response> create(Object payload) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ClientResponse<Object> update(String csid, Object payload) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ClientResponse<Object> read(String csid) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ClientResponse<AbstractCommonList> readList() {
+ throw new UnsupportedOperationException();
}
}
package org.collectionspace.services.client;\r
\r
-public interface TestServiceProxy extends CollectionSpaceProxy<Object> {\r
+import org.collectionspace.services.jaxb.AbstractCommonList;\r
+\r
+public interface TestServiceProxy extends CollectionSpaceProxy<AbstractCommonList> {\r
\r
}\r
--- /dev/null
+package org.collectionspace.services.client.test;\r
+\r
+import java.util.List;\r
+\r
+import javax.ws.rs.core.Response;\r
+import org.jboss.resteasy.client.ClientResponse;\r
+\r
+import org.collectionspace.services.client.AbstractCommonListUtils;\r
+import org.collectionspace.services.client.AuthorityClient;\r
+import org.collectionspace.services.client.AuthorityClientImpl;\r
+import org.collectionspace.services.client.AuthorityProxy;\r
+import org.collectionspace.services.client.PayloadInputPart;\r
+import org.collectionspace.services.client.PayloadOutputPart;\r
+import org.collectionspace.services.client.PoxPayloadOut;\r
+import org.collectionspace.services.jaxb.AbstractCommonList;\r
+\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.testng.Assert;\r
+import org.testng.annotations.Test;\r
+\r
+/**\r
+ * \r
+ * @author remillet\r
+ *\r
+ * @param <AUTHORITY_COMMON_TYPE>\r
+ * @param <AUTHORITY_ITEM_TYPE>\r
+ * \r
+ * All CRUD related authority test classes should extend this class.\r
+ * \r
+ */\r
+public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHORITY_ITEM_TYPE> \r
+ extends AbstractPoxServiceTestImpl<AbstractCommonList, AUTHORITY_COMMON_TYPE> {\r
+\r
+ private final Logger logger = LoggerFactory.getLogger(AbstractAuthorityServiceTest.class);\r
+ \r
+ protected String knownResourceShortIdentifer = null;\r
+ protected static final String READITEMS_SHORT_IDENTIFIER = "resourceWithItems"; \r
+ protected String knownAuthorityWithItems = null;\r
+ \r
+ protected String knownResourceRefName = null;\r
+ protected String knownItemResourceId = null;\r
+ protected String knownItemResourceShortIdentifer = null; \r
+ protected int nItemsToCreateInList = 5;\r
+ \r
+ public abstract void authorityTests(String testName);\r
+ protected abstract String createItemInAuthority(String authorityId);\r
+ \r
+ protected abstract AUTHORITY_ITEM_TYPE updateItemInstance(final AUTHORITY_ITEM_TYPE authorityItem); \r
+ protected abstract void compareUpdatedItemInstances(AUTHORITY_ITEM_TYPE original, AUTHORITY_ITEM_TYPE updated) throws Exception;\r
+ \r
+ protected void setKnownItemResource(String id, String shortIdentifer ) {\r
+ knownItemResourceId = id;\r
+ knownItemResourceShortIdentifer = shortIdentifer;\r
+ }\r
+\r
+ protected void setKnownResource(String id, String shortIdentifer,\r
+ String refName) {\r
+ knownResourceId = id;\r
+ knownResourceShortIdentifer = shortIdentifer;\r
+ knownResourceRefName = refName;\r
+ }\r
+\r
+ /**\r
+ * Returns the root URL for a service.\r
+ *\r
+ * This URL consists of a base URL for all services, followed by\r
+ * a path component for the owning vocabulary, followed by the \r
+ * path component for the items.\r
+ *\r
+ * @return The root URL for a service.\r
+ */\r
+ protected String getItemServiceRootURL(String parentResourceIdentifier) {\r
+ return getResourceURL(parentResourceIdentifier) + "/" + getServicePathItemsComponent();\r
+ }\r
+\r
+ /**\r
+ * Returns the URL of a specific resource managed by a service, and\r
+ * designated by an identifier (such as a universally unique ID, or UUID).\r
+ *\r
+ * @param resourceIdentifier An identifier (such as a UUID) for a resource.\r
+ *\r
+ * @return The URL of a specific resource managed by a service.\r
+ */\r
+ protected String getItemResourceURL(String parentResourceIdentifier, String resourceIdentifier) {\r
+ return getItemServiceRootURL(parentResourceIdentifier) + "/" + resourceIdentifier;\r
+ }\r
+ \r
+ /**\r
+ * For authorities we override this method so we can save the shortid.\r
+ */\r
+ @Override\r
+ protected String createWithIdentifier(String testName, String identifier) throws Exception {\r
+ String csid = createResource(testName, identifier);\r
+ // Store the ID returned from the first resource created\r
+ // for additional tests below.\r
+ if (getKnowResourceId() == null) {\r
+ setKnownResource(csid, identifier /*shortId*/, null /*refname*/ );\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug(testName + ": Setting knownResourceId=" + getKnowResourceId());\r
+ }\r
+ }\r
+ \r
+ return identifier;\r
+ } \r
+ \r
+ @Test(dependsOnMethods = {"readItem", "CRUDTests"})\r
+ public void testItemSubmitRequest() {\r
+\r
+ // Expected status code: 200 OK\r
+ final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();\r
+\r
+ // Submit the request to the service and store the response.\r
+ String method = ServiceRequestType.READ.httpMethodName();\r
+ String url = getItemResourceURL(knownResourceId, knownItemResourceId);\r
+ int statusCode = submitRequest(method, url);\r
+\r
+ // Check the status code of the response: does it match\r
+ // the expected response(s)?\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug("testItemSubmitRequest: url=" + url\r
+ + " status=" + statusCode);\r
+ }\r
+ Assert.assertEquals(statusCode, EXPECTED_STATUS);\r
+ } \r
+\r
+ \r
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,\r
+ dependsOnMethods = {"readItem"})\r
+ public void verifyIgnoredUpdateWithInAuthority(String testName) throws Exception {\r
+ // Perform setup.\r
+ setupUpdate();\r
+\r
+ // Submit the request to the service and store the response.\r
+ AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = \r
+ (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
+ ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);\r
+ int statusCode = res.getStatus();\r
+\r
+ // Check the status code of the response: does it match\r
+ // the expected response(s)?\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug(testName + " read authority:" + knownResourceId + "/Item:"\r
+ + knownItemResourceId + " status = " + statusCode);\r
+ }\r
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
+ invalidStatusCodeMessage(testRequestType, statusCode));\r
+ Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());\r
+\r
+ AUTHORITY_ITEM_TYPE vitem = extractItemCommonPartValue(res);\r
+ Assert.assertNotNull(vitem);\r
+ // Try to Update with new parent vocab (use self, for test).\r
+ Assert.assertEquals(client.getInAuthority(vitem), knownResourceId,\r
+ "VocabularyItem inAuthority does not match knownResourceId.");\r
+ client.setInAuthority(vitem, knownItemResourceId);\r
+\r
+ // Submit the updated resource to the service and store the response.\r
+ PoxPayloadOut output = this.createItemRequestTypeInstance(vitem);\r
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);\r
+ statusCode = res.getStatus();\r
+\r
+ // Check the status code of the response: does it match the expected response(s)?\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug(testName + ": status = " + statusCode);\r
+ }\r
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
+ invalidStatusCodeMessage(testRequestType, statusCode));\r
+ Assert.assertEquals(statusCode, testExpectedStatusCode);\r
+\r
+ // Retrieve the updated resource and verify that the parent did not change\r
+ res = client.readItem(knownResourceId, knownItemResourceId);\r
+ AUTHORITY_ITEM_TYPE updatedVocabularyItem = extractItemCommonPartValue(res);\r
+ Assert.assertNotNull(updatedVocabularyItem);\r
+\r
+ // Verify that the updated resource received the correct data.\r
+ Assert.assertEquals(client.getInAuthority(updatedVocabularyItem),\r
+ knownResourceId,\r
+ "VocabularyItem allowed update to the parent (inAuthority).");\r
+ }\r
+ \r
+ @Test(dataProvider = "testName",\r
+ dependsOnMethods = {"CRUDTests"})\r
+ public void createItem(String testName) {\r
+ // Perform setup.\r
+ setupCreate();\r
+\r
+ String newID = createItemInAuthority(knownResourceId);\r
+\r
+ // Store the ID returned from the first item resource created\r
+ // for additional tests below.\r
+ if (knownItemResourceId == null) {\r
+ knownItemResourceId = newID;\r
+ if (null != testName && logger.isDebugEnabled()) {\r
+ logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);\r
+ }\r
+ }\r
+ }\r
+ \r
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,\r
+ dependsOnMethods = {"createItem"})\r
+ public void createItemList(String testName) throws Exception {\r
+ knownAuthorityWithItems = createResource(testName, READITEMS_SHORT_IDENTIFIER);\r
+ for (int j = 0; j < nItemsToCreateInList; j++) {\r
+ createItemInAuthority(knownAuthorityWithItems);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Read by name.\r
+ *\r
+ * @param testName the test name\r
+ * @throws Exception the exception\r
+ */\r
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,\r
+ dependsOnMethods = {"CRUDTests"})\r
+ public void readByName(String testName) throws Exception {\r
+ // Perform setup.\r
+ setupRead();\r
+\r
+ // Submit the request to the service and store the response.\r
+ AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
+ ClientResponse<String> res = client.readByName(getKnowResourceIdentifier());\r
+ int statusCode = res.getStatus();\r
+\r
+ // Check the status code of the response: does it match\r
+ // the expected response(s)?\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug(testName + ": status = " + statusCode);\r
+ }\r
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
+ invalidStatusCodeMessage(testRequestType, statusCode));\r
+ Assert.assertEquals(statusCode, testExpectedStatusCode);\r
+ \r
+ AUTHORITY_COMMON_TYPE commonPart = extractCommonPartValue(res);\r
+ Assert.assertNotNull(commonPart);\r
+ }\r
+ \r
+ /**\r
+ * Extracts the common part item from a service's item payload.\r
+ * \r
+ * @param res\r
+ * @return\r
+ * @throws Exception\r
+ */\r
+ public AUTHORITY_ITEM_TYPE extractItemCommonPartValue(ClientResponse<String> res) throws Exception {\r
+ AUTHORITY_ITEM_TYPE result = null;\r
+ \r
+ AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
+ PayloadInputPart payloadInputPart = extractPart(res, client.getItemCommonPartName());\r
+ if (payloadInputPart != null) {\r
+ result = (AUTHORITY_ITEM_TYPE) payloadInputPart.getBody();\r
+ }\r
+ Assert.assertNotNull(result,\r
+ "Part or body of part " + client.getCommonPartName() + " was unexpectedly null.");\r
+ \r
+ return result;\r
+ }\r
+ \r
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,\r
+ dependsOnMethods = {"readItem"})\r
+ public void readItemNonExistent(String testName) {\r
+ // Perform setup.\r
+ setupReadNonExistent();\r
+\r
+ // Submit the request to the service and store the response.\r
+ AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
+ ClientResponse<String> res = client.readItem(knownResourceId, NON_EXISTENT_ID);\r
+ int statusCode = res.getStatus();\r
+\r
+ // Check the status code of the response: does it match\r
+ // the expected response(s)?\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug(testName + ": status = " + statusCode);\r
+ }\r
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
+ invalidStatusCodeMessage(testRequestType, statusCode));\r
+ Assert.assertEquals(statusCode, testExpectedStatusCode);\r
+ }\r
+ \r
+ @Test(dataProvider = "testName",\r
+ dependsOnMethods = {"createItem"})\r
+ public void readItem(String testName) throws Exception {\r
+ // Perform setup.\r
+ setupRead();\r
+\r
+ // Submit the request to the service and store the response.\r
+ AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
+ ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);\r
+ int statusCode = res.getStatus();\r
+\r
+ // Check the status code of the response: does it match\r
+ // the expected response(s)?\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug(testName + ": status = " + statusCode);\r
+ }\r
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
+ invalidStatusCodeMessage(testRequestType, statusCode));\r
+ Assert.assertEquals(statusCode, testExpectedStatusCode);\r
+\r
+ AUTHORITY_ITEM_TYPE itemCommonPart = extractItemCommonPartValue(res);\r
+ Assert.assertNotNull(itemCommonPart);\r
+ Assert.assertEquals(client.getInAuthority(itemCommonPart), knownResourceId);\r
+ verifyReadItemInstance(itemCommonPart);\r
+ }\r
+ \r
+ protected abstract void verifyReadItemInstance(AUTHORITY_ITEM_TYPE item) throws Exception;\r
+ \r
+ @Test(dataProvider = "testName",\r
+ dependsOnMethods = {"testItemSubmitRequest", "updateItem", "verifyIgnoredUpdateWithInAuthority"}) \r
+ public void deleteItem(String testName) throws Exception {\r
+ // Perform setup.\r
+ setupDelete();\r
+\r
+ // Submit the request to the service and store the response.\r
+ AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
+ ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);\r
+ int statusCode = res.getStatus();\r
+\r
+ // Check the status code of the response: does it match\r
+ // the expected response(s)?\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug("delete: status = " + statusCode);\r
+ }\r
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
+ invalidStatusCodeMessage(testRequestType, statusCode));\r
+ Assert.assertEquals(statusCode, testExpectedStatusCode);\r
+ }\r
+ \r
+ protected void readItemListInt(String vcsid, String shortId, String testName) {\r
+ // Perform setup.\r
+ setupReadList();\r
+\r
+ // Submit the request to the service and store the response.\r
+ AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
+ ClientResponse<AbstractCommonList> res = null;\r
+ if (vcsid != null) {\r
+ res = client.readItemList(vcsid, null, null);\r
+ } else if (shortId != null) {\r
+ res = client.readItemListForNamedAuthority(shortId, null, null);\r
+ } else {\r
+ Assert.fail("Internal Error: readItemList both vcsid and shortId are null!");\r
+ }\r
+ AbstractCommonList list = res.getEntity();\r
+ int statusCode = res.getStatus();\r
+\r
+ // Check the status code of the response: does it match\r
+ // the expected response(s)?\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug(" " + testName + ": status = " + statusCode);\r
+ }\r
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
+ invalidStatusCodeMessage(testRequestType, statusCode));\r
+ Assert.assertEquals(statusCode, testExpectedStatusCode);\r
+\r
+ List<AbstractCommonList.ListItem> items = list.getListItem();\r
+ int nItemsReturned = items.size();\r
+ long nItemsTotal = list.getTotalItems();\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug(" " + testName + ": Expected "\r
+ + nItemsToCreateInList + " items; got: " + nItemsReturned + " of: " + nItemsTotal);\r
+ }\r
+ Assert.assertEquals(nItemsTotal, nItemsToCreateInList);\r
+\r
+ if(logger.isTraceEnabled()){\r
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);\r
+ }\r
+ }\r
+ \r
+ @Test(dataProvider = "testName",\r
+ dependsOnMethods = {"createItemList"})\r
+ public void readItemList(String testName) {\r
+ readItemListInt(knownAuthorityWithItems, null, testName);\r
+ }\r
+\r
+ @Test(dataProvider = "testName",\r
+ dependsOnMethods = {"readItem"})\r
+ public void readItemListByName(String testName) {\r
+ readItemListInt(null, READITEMS_SHORT_IDENTIFIER, testName);\r
+ }\r
+\r
+ @Test(dataProvider = "testName",\r
+ dependsOnMethods = {"deleteItem"})\r
+ public void deleteNonExistentItem(String testName) {\r
+ // Perform setup.\r
+ setupDeleteNonExistent();\r
+\r
+ // Submit the request to the service and store the response.\r
+ AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
+ ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);\r
+ int statusCode = res.getStatus();\r
+\r
+ // Check the status code of the response: does it match\r
+ // the expected response(s)?\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug(testName + ": status = " + statusCode);\r
+ }\r
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
+ invalidStatusCodeMessage(testRequestType, statusCode));\r
+ Assert.assertEquals(statusCode, testExpectedStatusCode);\r
+ }\r
+ \r
+ protected String getServicePathItemsComponent() {\r
+ return AuthorityClient.ITEMS;\r
+ }\r
+ \r
+ public PoxPayloadOut createItemRequestTypeInstance(AUTHORITY_ITEM_TYPE itemTypeInstance) {\r
+ PoxPayloadOut result = null;\r
+ \r
+ AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
+ PoxPayloadOut payloadOut = new PoxPayloadOut(this.getServicePathItemsComponent());\r
+ PayloadOutputPart part = payloadOut.addPart(client.getItemCommonPartName(), itemTypeInstance);\r
+ result = payloadOut;\r
+ \r
+ return result;\r
+ }\r
+\r
+ /**\r
+ * Update an Authority item.\r
+ * \r
+ * @param testName\r
+ * @throws Exception\r
+ */\r
+ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,\r
+ dependsOnMethods = {"readItem", "CRUDTests", "verifyIgnoredUpdateWithInAuthority"})\r
+ public void updateItem(String testName) throws Exception {\r
+ // Perform setup.\r
+ setupUpdate();\r
+ AUTHORITY_ITEM_TYPE theUpdate = null;\r
+\r
+ // Retrieve the contents of a resource to update.\r
+ AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client =\r
+ (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
+ ClientResponse<String> res =\r
+ client.readItem(knownResourceId, knownItemResourceId);\r
+ try {\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug(testName + ": read status = " + res.getStatus());\r
+ }\r
+ Assert.assertEquals(res.getStatus(), testExpectedStatusCode);\r
+ \r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug("got Authority item to update with ID: "\r
+ + knownItemResourceId\r
+ + " in authority: " + knownResourceId);\r
+ }\r
+ AUTHORITY_ITEM_TYPE authorityItem = extractItemCommonPartValue(res);\r
+ Assert.assertNotNull(authorityItem);\r
+\r
+ // Update the contents of this resource.\r
+ theUpdate = updateItemInstance(authorityItem);\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug("\n\nTo be updated fields: CSID = " + knownItemResourceId + "\n"\r
+ + objectAsXmlString(theUpdate));\r
+ }\r
+ } finally {\r
+ res.releaseConnection();\r
+ }\r
+\r
+ // Submit the updated resource to the service and store the response.\r
+ PoxPayloadOut output = this.createItemRequestTypeInstance(theUpdate);\r
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);\r
+ try {\r
+ int statusCode = res.getStatus();\r
+ \r
+ // Check the status code of the response: does it match the expected response(s)?\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug("updateItem: status = " + statusCode);\r
+ }\r
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
+ invalidStatusCodeMessage(testRequestType, statusCode));\r
+ Assert.assertEquals(statusCode, testExpectedStatusCode);\r
+ \r
+ // Retrieve the updated resource and verify that its contents exist.\r
+ AUTHORITY_ITEM_TYPE updatedVocabularyItem = extractItemCommonPartValue(res);\r
+ Assert.assertNotNull(updatedVocabularyItem);\r
+\r
+ compareUpdatedItemInstances(theUpdate, updatedVocabularyItem);\r
+ } finally {\r
+ res.releaseConnection();\r
+ }\r
+ }\r
+ \r
+ protected abstract PoxPayloadOut createNonExistenceItemInstance(String commonPartName, String identifier);\r
+ \r
+ /* (non-Javadoc)\r
+ * @see org.collectionspace.services.client.test.ServiceTest#updateNonExistent(java.lang.String)\r
+ */\r
+ @Test(dataProvider = "testName",\r
+ dependsOnMethods = {"create", "update", "updateNonExistent"})\r
+ public void updateNonExistentItem(String testName) throws Exception {\r
+ // Perform setup.\r
+ setupUpdateNonExistent();\r
+\r
+ // Submit the request to the service and store the response.\r
+ // Note: The ID used in this 'create' call may be arbitrary.\r
+ // The only relevant ID may be the one used in update(), below.\r
+ AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client =\r
+ (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
+ PoxPayloadOut multipart = createNonExistenceItemInstance(client.getItemCommonPartName(), NON_EXISTENT_ID);\r
+ ClientResponse<String> res =\r
+ client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);\r
+ try {\r
+ int statusCode = res.getStatus();\r
+ \r
+ // Check the status code of the response: does it match\r
+ // the expected response(s)?\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug(testName + ": status = " + statusCode);\r
+ }\r
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
+ invalidStatusCodeMessage(testRequestType, statusCode));\r
+ Assert.assertEquals(statusCode, testExpectedStatusCode);\r
+ } finally {\r
+ res.releaseConnection();\r
+ }\r
+ }\r
+ \r
+ //\r
+ // Methods to persuade TestNG to follow the correct test dependency path\r
+ //\r
+ \r
+ @Test(dataProvider = "testName",\r
+ dependsOnMethods = {"createItem"})\r
+ public void baseAuthorityTests(String testName) {\r
+ // Do nothing. Here just to setup a test dependency chain.\r
+ }\r
+ \r
+ /*\r
+ * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may\r
+ * refer to this method in their @Test annotation declarations.\r
+ */\r
+ @Override\r
+ @Test(dataProvider = "testName",\r
+ dependsOnMethods = {\r
+ "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"}) \r
+ public void CRUDTests(String testName) {\r
+ // TODO Auto-generated method stub\r
+ }\r
+ \r
+}\r
+++ /dev/null
-package org.collectionspace.services.client.test;\r
-\r
-import org.collectionspace.services.client.CollectionSpaceClient;\r
-import org.collectionspace.services.client.CollectionSpaceCommonListPoxProxy;\r
-import org.collectionspace.services.client.PayloadInputPart;\r
-import org.collectionspace.services.client.PoxPayloadIn;\r
-import org.collectionspace.services.jaxb.AbstractCommonList;\r
-import org.jboss.resteasy.client.ClientResponse;\r
-import org.testng.Assert;\r
-\r
-/*\r
- * CPT - Common Part Type\r
- */\r
-public abstract class AbstractGenericServiceTestImpl<CPT> extends AbstractServiceTestImpl {\r
- public CPT getCommonTypeInstance() {\r
- CPT result = null;\r
- return result;\r
- }\r
- \r
- public CPT extractCommonPartValue(ClientResponse<String> res)\r
- throws Exception {\r
- CollectionSpaceClient<AbstractCommonList, CollectionSpaceCommonListPoxProxy> client = this.getClientInstance();\r
- PayloadInputPart payloadInputPart = extractPart(res, client.getCommonPartName());\r
- Object obj = null;\r
- if (payloadInputPart != null) {\r
- obj = payloadInputPart.getBody();\r
- }\r
- Assert.assertNotNull(obj,\r
- "Body of " + client.getCommonPartName() + " part was unexpectedly null.");\r
- CPT commonPartTypeInstance = (CPT) obj;\r
- Assert.assertNotNull(commonPartTypeInstance,\r
- client.getCommonPartName() + " part was unexpectedly null.");\r
- return commonPartTypeInstance;\r
- }\r
- \r
- private PayloadInputPart extractPart(ClientResponse<String> res, String partLabel)\r
- throws Exception {\r
- if (getLogger().isDebugEnabled()) {\r
- getLogger().debug("Reading part " + partLabel + " ...");\r
- }\r
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());\r
- PayloadInputPart payloadInputPart = input.getPart(partLabel);\r
- Assert.assertNotNull(payloadInputPart,\r
- "Part " + partLabel + " was unexpectedly null.");\r
- return payloadInputPart;\r
- }\r
- \r
- \r
-}\r
--- /dev/null
+package org.collectionspace.services.client.test;\r
+\r
+import org.collectionspace.services.client.CollectionSpaceClient;\r
+import org.collectionspace.services.client.PayloadInputPart;\r
+import org.collectionspace.services.client.PayloadOutputPart;\r
+import org.collectionspace.services.client.PoxPayloadIn;\r
+import org.collectionspace.services.client.PoxPayloadOut;\r
+import org.collectionspace.services.client.AbstractCommonListUtils;\r
+import org.collectionspace.services.jaxb.AbstractCommonList;\r
+\r
+import org.jboss.resteasy.client.ClientResponse;\r
+import org.testng.Assert;\r
+\r
+/*\r
+ * <CLT> - Common list type\r
+ * <CPT> - Common part type\r
+ */\r
+public abstract class AbstractPoxServiceTestImpl<CLT extends AbstractCommonList, CPT>\r
+ extends AbstractServiceTestImpl<CLT, CPT, PoxPayloadOut, String> {\r
+ \r
+ @Override\r
+ public CPT extractCommonPartValue(ClientResponse<String> res) throws Exception {\r
+ CPT result = null;\r
+ \r
+ CollectionSpaceClient client = getClientInstance();\r
+ PayloadInputPart payloadInputPart = extractPart(res, client.getCommonPartName());\r
+ if (payloadInputPart != null) {\r
+ result = (CPT) payloadInputPart.getBody();\r
+ }\r
+ Assert.assertNotNull(result,\r
+ "Part or body of part " + client.getCommonPartName() + " was unexpectedly null.");\r
+ \r
+ return result;\r
+ }\r
+ \r
+ protected void printList(String testName, CLT list) {\r
+ if (getLogger().isTraceEnabled()){\r
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, getLogger(), testName);\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public CPT extractCommonPartValue(PoxPayloadOut payloadOut) throws Exception {\r
+ CPT result = null;\r
+ \r
+ CollectionSpaceClient client = getClientInstance();\r
+ PayloadOutputPart payloadOutputPart = payloadOut.getPart(client.getCommonPartName());\r
+ if (payloadOutputPart != null) {\r
+ result = (CPT) payloadOutputPart.getBody();\r
+ }\r
+ Assert.assertNotNull(result,\r
+ "Part or body of part " + client.getCommonPartName() + " was unexpectedly null.");\r
+ \r
+ return result;\r
+ } \r
+ \r
+ @Override\r
+ public PoxPayloadOut createRequestTypeInstance(CPT commonPartTypeInstance) {\r
+ PoxPayloadOut result = null;\r
+ \r
+ CollectionSpaceClient client = this.getClientInstance();\r
+ PoxPayloadOut payloadOut = new PoxPayloadOut(this.getServicePathComponent());\r
+ PayloadOutputPart part = payloadOut.addPart(client.getCommonPartName(), commonPartTypeInstance);\r
+ result = payloadOut;\r
+ \r
+ return result;\r
+ }\r
+ \r
+ protected PayloadInputPart extractPart(ClientResponse<String> res, String partLabel)\r
+ throws Exception {\r
+ if (getLogger().isDebugEnabled()) {\r
+ getLogger().debug("Reading part " + partLabel + " ...");\r
+ }\r
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());\r
+ PayloadInputPart payloadInputPart = input.getPart(partLabel);\r
+ Assert.assertNotNull(payloadInputPart,\r
+ "Part " + partLabel + " was unexpectedly null.");\r
+ return payloadInputPart;\r
+ }\r
+}\r
package org.collectionspace.services.client.test;
import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.workflow.WorkflowCommon;
-import org.collectionspace.services.client.AbstractPoxServiceClientImpl;
import org.collectionspace.services.client.AuthorityClient;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.CollectionSpacePoxClient;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
-import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import javax.activation.MimetypesFileTypeMap;
import javax.ws.rs.core.Response;
/**
*
* For Javadoc descriptions of this class's methods, see the ServiceTest interface.
*
+ * <CLT> - Common list type
+ * <CPT> - Common part type
+ *
* $LastChangedRevision$
* $LastChangedDate$
*/
// FIXME: http://issues.collectionspace.org/browse/CSPACE-1685
-public abstract class AbstractServiceTestImpl extends BaseServiceTest implements ServiceTest {
-
+public abstract class AbstractServiceTestImpl<CLT, CPT, REQUEST_TYPE, RESPONSE_TYPE>
+ extends BaseServiceTest<CLT> implements ServiceTest {
/** The logger. */
private final Logger logger = LoggerFactory.getLogger(AbstractServiceTestImpl.class);
- // A non-existent logger.
- static private final Logger LOGGER_NULL = null;
+
/** The Constant DEFAULT_LIST_SIZE. */
static protected final int DEFAULT_LIST_SIZE = 10;
static protected final int DEFAULT_PAGINATEDLIST_SIZE = 10;
+
+ /** The path to test resources */
static protected final String RESOURCE_PATH = "src" + File.separator
+ "test" + File.separator
+ "resources";
+ /** Misc constants */
protected static final String BLOBS_DIR = "blobs";
- static protected final String DEFAULT_MIME = "application/octet-stream; charset=ISO-8859-1";
- static private final String NO_TEST_CLEANUP = "noTestCleanup";
static protected final String NO_BLOB_CLEANUP = "noBlobCleanup";
static protected final String NO_MEDIA_CLEANUP = "noMediaCleanup";
- private final static String NON_EXISTENT_KEYWORD = "jlmbsoqjlmbsoq";
-
- protected String getMimeType(File theFile) {
- String result = null;
- result = new MimetypesFileTypeMap().getContentType(theFile);
- if (result == null) {
- logger.debug("Could not get MIME type for file at: " + theFile.getAbsolutePath());
- result = DEFAULT_MIME;
- }
-
- return result;
-
- }
-
- /* Use this to keep track of resources to delete */
- protected List<String> allResourceIdsCreated = new ArrayList<String>();
- /* Use this to track authority items */
- protected Map<String, String> allResourceItemIdsCreated = new HashMap<String, String>(); /* itemCsid, parentCsid */
-
+ private final static String NON_EXISTENT_KEYWORD = "jlmbsoqjlmbsoq" + System.currentTimeMillis();
private String EMPTY_SORT_BY_ORDER = "";
-
- /**
- * Gets the logger.
- *
- * @return the logger
- */
- protected Logger getLogger() {
- return this.logger;
- }
-
+
+ /** Error messages */
+ private final static String ERROR_WORKFLOW_TRANSITION = "Workflow transition to 'deleted' did not take place!";
+
protected String getResourceDir() {
String result = null;
String currentDirectory = System.getProperty("user.dir");
result = currentDirectory + File.separator + RESOURCE_PATH;
return result;
}
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
+
+ /*
+ * Use this method in TestNG "@Test" methods that need to be overridden. Because of an issue in TestNG 5.6 (and earlier),
+ * we can't just mark the methods as "abstract". Subclasses must override the @Test methods *without* the "@Test" annotation.
*/
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
+ private void mustOverride(String testName) throws Exception {
+ throw new RuntimeException("This method must be implemented by a subclass.");
}
-
- // ---------------------------------------------------------------
- // CRUD tests : CREATE tests
- //
- // (See below for utility methods in support of create list tests.)
- // ---------------------------------------------------------------
- // Success outcomes
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
+
+ /*
+ * We use this method to force a TestNG execution order for our tests
*/
- @Override
- public abstract void create(String testName) throws Exception;
-
- /**
- * Sets up create tests.
+ public abstract void CRUDTests(String testName);
+
+ /*
+ * We use this method to force a TestNG execution order for our tests
+ */
+ @Test(dataProvider = "testName", dependsOnMethods = {
+ "create", "read", "update", "delete", "testSubmitRequest", "createList", "readList", "readNonExistent"})
+ public void baseCRUDTests(String testName) {
+ // Do nothing -see "dependsOnMethods" in @Test annotation above.
+ }
+
+ /*
+ * Sub-classes can override for the workflow tests.
*/
- protected void setupCreate() {
- EXPECTED_STATUS_CODE = STATUS_CREATED;
- REQUEST_TYPE = ServiceRequestType.CREATE;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
+ protected REQUEST_TYPE createInstance(String identifier) {
+ String commonPartName = getClientInstance().getCommonPartName();
+ return createInstance(commonPartName, identifier);
}
-
+
/**
- * Checks if 'theFile' is something we can turn into a Blob instance. It can't
- * be read-protected, hidden, or a directory.
- *
- * @param theFile the the file
- * @return true, if is blobable
+ * Sub-classes must override this method for the "Create" tests to work properly
*/
- protected boolean isBlobbable(File theFile) {
- boolean result = true;
- if (theFile.isDirectory() || theFile.isHidden() || !theFile.canRead()) {
- result = false;
+ protected abstract REQUEST_TYPE createInstance(String commonPartName, String identifier);
+
+ protected REQUEST_TYPE createNonExistenceInstance(String commonPartName, String identifier) {
+ return createInstance(commonPartName, identifier);
+ }
+
+ @Override
+ @Test(dataProvider = "testName")
+ public void create(String testName) throws Exception {
+ String identifier = getKnowResourceIdentifier();
+ createWithIdentifier(testName, identifier);
+ }
+
+ protected String createWithIdentifier(String testName, String identifier) throws Exception {
+ String csid = createResource(testName, identifier);
+ // Store the ID returned from the first resource created
+ // for additional tests below.
+ if (getKnowResourceId() == null) {
+ knownResourceId = csid;
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": knownResourceId=" + getKnowResourceId());
+ }
}
- return result;
+
+ return identifier;
}
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#createList(java.lang.String)
- */
+
+ protected String createResource(String testName, String identifier) throws Exception {
+ String result = null;
+
+ setupCreate();
+ CollectionSpaceClient client = this.getClientInstance();
+ REQUEST_TYPE payload = createInstance(client.getCommonPartName(), identifier);
+ ClientResponse<Response> res = client.create(payload);
+ try {
+ int statusCode = res.getStatus();
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": HTTP status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ result = extractId(res);
+ // Store the IDs from every resource created by tests,
+ // so they can be deleted after tests have been run.
+ allResourceIdsCreated.add(result);
+ } finally {
+ res.releaseConnection();
+ }
+
+ return result;
+ }
+
@Override
- public abstract void createList(String testName) throws Exception;
+ @Test(dataProvider = "testName", dependsOnMethods = {"create"})
+ public void read(String testName) throws Exception {
+ // Perform setup.
+ setupRead();
- // Note: No setup is required for createList(), as it currently
- // just invokes create() multiple times.
- // Failure outcomes
+ // Submit the request to the service and store the response.
+ CollectionSpaceClient client = this.getClientInstance();
+ ClientResponse<RESPONSE_TYPE> res = client.read(getKnowResourceId());
+ int statusCode = res.getStatus();
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#createWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public abstract void createWithEmptyEntityBody(String testName)
- throws Exception;
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
- /**
- * Sets up create tests with empty entity body.
- */
- protected void setupCreateWithEmptyEntityBody() {
- EXPECTED_STATUS_CODE = STATUS_BAD_REQUEST;
- REQUEST_TYPE = ServiceRequestType.CREATE;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
+ RESPONSE_TYPE output = (RESPONSE_TYPE) res.getEntity();
+ Assert.assertNotNull(output);
+
+ //
+ // Now compare with the expected field values
+ //
+ REQUEST_TYPE expectedResult = createInstance("read_test");
+ compareReadInstances(extractCommonPartValue(expectedResult), extractCommonPartValue(res));
}
+
+ @Override
+ @Test(dataProvider = "testName", dependsOnMethods = {"create", "read", "update", "readWorkflow"})
+ public void delete(String testName) throws Exception {
+ setupDelete();
+ CollectionSpaceClient client = this.getClientInstance();
+ ClientResponse<Response> res = client.delete(getKnowResourceId());
+ int statusCode = res.getStatus();
- /**
- * Sets up create tests with empty entity body.
- */
- protected void setupCreateWithInvalidBody() {
- EXPECTED_STATUS_CODE = STATUS_BAD_REQUEST;
- REQUEST_TYPE = ServiceRequestType.CREATE;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
-
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#createWithMalformedXml(java.lang.String)
- */
+
@Override
- public abstract void createWithMalformedXml(String testName) throws Exception;
+ @Test(dataProvider = "testName")
+ public void readNonExistent(String testName) throws Exception {
+ // Perform setup.
+ setupReadNonExistent();
- /**
- * Sets up create tests with malformed xml.
- */
- protected void setupCreateWithMalformedXml() {
- EXPECTED_STATUS_CODE = STATUS_BAD_REQUEST;
- REQUEST_TYPE = ServiceRequestType.CREATE;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
+ // Submit the request to the service and store the response.
+ CollectionSpaceClient client = this.getClientInstance();
+ ClientResponse<RESPONSE_TYPE> res = client.read(NON_EXISTENT_ID);
+ int statusCode = res.getStatus();
+ try {
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ } finally {
+ res.releaseConnection();
+ }
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#createWithWrongXmlSchema(java.lang.String)
- */
@Override
- public abstract void createWithWrongXmlSchema(String testName) throws Exception;
+ @Test(dataProvider = "testName", dependsOnMethods = {"delete"})
+ public void deleteNonExistent(String testName) throws Exception {
+ // Perform setup.
+ setupDeleteNonExistent();
- /**
- * Sets up create tests with wrong xml schema.
- */
- protected void setupCreateWithWrongXmlSchema() {
- EXPECTED_STATUS_CODE = STATUS_BAD_REQUEST;
- REQUEST_TYPE = ServiceRequestType.CREATE;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
- }
+ // Submit the request to the service and store the response.
+ CollectionSpaceClient client = this.getClientInstance();
+ ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
+ int statusCode = res.getStatus();
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ }
+
// ---------------------------------------------------------------
- // CRUD tests : READ tests
+ // Abstract CRUD tests : TestNG requires an empty method here. De-
+ // claring them as "abstract" will not work.
+ //
// ---------------------------------------------------------------
- // Success outcomes
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#read(java.lang.String)
- */
+
+// protected abstract Class<CPT> getCommonPartTypeClass();
+
+ public CPT extractCommonPartValue(ClientResponse<RESPONSE_TYPE> res) throws Exception {
+ CPT result = null;
+ result = (CPT) res.getEntity();
+ return result;
+ }
+
+ public CPT extractCommonPartValue(REQUEST_TYPE req) throws Exception {
+ return (CPT)req;
+ }
+
+ public REQUEST_TYPE createRequestTypeInstance(CPT commonPartTypeInstance) {
+ return (REQUEST_TYPE)commonPartTypeInstance;
+ }
+
+ //
+ // This method is called by public void update(String testName). Subclasses need
+ // to override this method that should update the common part -e.g., CollectionObjectsCommon, DimensionsCommon, etc)
+ //
+ protected abstract CPT updateInstance(final CPT commonPartObject);
+
+ protected abstract void compareUpdatedInstances(CPT original, CPT updated) throws Exception;
+
+ protected void compareReadInstances(CPT original, CPT fromRead) throws Exception {
+ // Do nothing by default. Subclass can override if they want other behavior.
+ }
+
@Override
- public abstract void read(String testName) throws Exception;
+ @Test(dataProvider = "testName", dependsOnMethods = {"create", "read"})
+ public void update(String testName) throws Exception {
+ // Perform setup.
+ setupUpdate();
- /**
- * Sets up read tests.
- */
- protected void setupRead() {
- EXPECTED_STATUS_CODE = STATUS_OK;
- REQUEST_TYPE = ServiceRequestType.READ;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
- }
+ // Retrieve the contents of a resource to update.
+ CollectionSpaceClient client = this.getClientInstance();
+ ClientResponse<RESPONSE_TYPE> res = client.read(getKnowResourceId());
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
- // Failure outcomes
+ if (logger.isDebugEnabled()) {
+ logger.debug("Got object to update with CSID= " + getKnowResourceId());
+ }
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#readNonExistent(java.lang.String)
- */
- @Override
- public abstract void readNonExistent(String testName) throws Exception;
+ CPT commonPartObject = this.extractCommonPartValue(res);
+ Assert.assertNotNull(commonPartObject);
+ CPT theUpdate = updateInstance(commonPartObject);
+ if (logger.isDebugEnabled()) {
+ logger.debug("\n\nTo be updated fields: CSID = " + getKnowResourceId() + "\n"
+ + objectAsXmlString(theUpdate));
+ }
- /**
- * Sets up read non existent tests.
- */
- protected void setupReadNonExistent() {
- EXPECTED_STATUS_CODE = STATUS_NOT_FOUND;
- REQUEST_TYPE = ServiceRequestType.READ;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
- }
+ // Submit the request to the service and store the response.
+ REQUEST_TYPE output = this.createRequestTypeInstance(theUpdate);
+ res = client.update(getKnowResourceId(), output);
+ int statusCode = res.getStatus();
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ CPT updatedCommonPartObject = this.extractCommonPartValue(res);
+ Assert.assertNotNull(updatedCommonPartObject);
+
+ compareUpdatedInstances(theUpdate, updatedCommonPartObject);
+ }
+
// ---------------------------------------------------------------
- // CRUD tests : READ (list, or multiple) tests
//
- // (See below for utility methods in support of list tests.)
+ // Generic tests that apply to most services
+ //
// ---------------------------------------------------------------
- // Success outcomes
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#readList(java.lang.String)
- */
- @Override
- public abstract void readList(String testName) throws Exception;
/**
- * Sets up read list tests.
+ * A non-RESTEasy HTTP request test.
*/
- protected void setupReadList() {
- EXPECTED_STATUS_CODE = STATUS_OK;
- REQUEST_TYPE = ServiceRequestType.READ_LIST;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
- }
+ protected void testSubmitRequest(String csid) {
+ // Expected status code: 200 OK
+ final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
- // Failure outcomes
- // None tested at present.
- // ---------------------------------------------------------------
- // CRUD tests : UPDATE tests
- // ---------------------------------------------------------------
- // Success outcomes
+ // Submit the request to the service and store the response.
+ String method = ServiceRequestType.READ.httpMethodName();
+ String url = getResourceURL(csid);
+ int statusCode = submitRequest(method, url);
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#update(java.lang.String)
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug("testSubmitRequest: url=" + url
+ + " status=" + statusCode);
+ }
+ Assert.assertEquals(statusCode, EXPECTED_STATUS);
+ }
+
+ /**
+ * A non-RESTEasy HTTP request test.
*/
- @Override
- public abstract void update(String testName) throws Exception;
+ @Test(dependsOnMethods = {"create", "read"})
+ public void testSubmitRequest() {
+ testSubmitRequest(getKnowResourceId());
+ }
/**
- * Sets up update tests.
+ * Creates the list.
+ *
+ * @param testName the test name
+ * @param listSize the list size
+ * @throws Exception the exception
*/
- protected void setupUpdate() {
- EXPECTED_STATUS_CODE = STATUS_OK;
- REQUEST_TYPE = ServiceRequestType.UPDATE;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
+ protected void createPaginatedList(String testName, int listSize) throws Exception {
+ for (int i = 0; i < listSize; i++) {
+ String identifier = createIdentifier();
+ createWithIdentifier(testName, identifier);
+ }
}
-
- // Failure outcomes
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#updateWithEmptyEntityBody(java.lang.String)
+
+ /**
+ * Create a list of records
*/
@Override
- public abstract void updateWithEmptyEntityBody(String testName) throws Exception;
+ @Test(dataProvider = "testName", dependsOnMethods = {"create"})
+ public void createList(String testName) throws Exception {
+ createPaginatedList(testName, DEFAULT_LIST_SIZE);
+ }
+
+ protected void printList(String testName, CLT list) {
+ // By default, do nothing. Tests can override this method to produce additional
+ // output after the "readList" test has run.
+ }
+
+ @Override
+ @Test(dataProvider = "testName", dependsOnMethods = {"read"})
+ public void readList(String testName) throws Exception {
+ // Perform setup.
+ setupReadList();
+ // Submit the request to the service and store the response.
+ CollectionSpaceClient client = this.getClientInstance();
+ ClientResponse<CLT> res = client.readList();
+ CLT 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(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ // Optionally output additional data about list members for debugging.
+ boolean iterateThroughList = true;
+ if (iterateThroughList && logger.isDebugEnabled()) {
+ printList(testName, list);
+ }
+ }
+
+
/**
- * Sets up update tests with an empty entity body.
+ * Read paginated list.
+ *
+ * @param testName the test name
+ * @throws Exception the exception
*/
- protected void setupUpdateWithEmptyEntityBody() {
- EXPECTED_STATUS_CODE = STATUS_BAD_REQUEST;
- REQUEST_TYPE = ServiceRequestType.UPDATE;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
+ @Test(dataProvider = "testName", dependsOnMethods = {"read"})
+ public void readPaginatedList(String testName) throws Exception {
+ // Perform setup.
+ setupReadList();
+ CollectionSpaceClient client = this.getClientInstance();
+
+ // Get the current total number of items.
+ // If there are no items then create some
+ AbstractCommonList list = (AbstractCommonList) this.readList(testName,
+ client,
+ 1 /*pgSz*/,
+ 0 /*pgNum*/,
+ testExpectedStatusCode);
+ if (list == null || list.getTotalItems() == 0) {
+ this.createPaginatedList(testName, DEFAULT_PAGINATEDLIST_SIZE);
+ setupReadList();
+ list = (AbstractCommonList) this.readList(testName,
+ client,
+ 1 /*pgSz*/,
+ 0 /*pgNum*/,
+ testExpectedStatusCode);
+ }
+
+ // Print out the current list size to be paginated
+ Assert.assertNotNull(list);
+ long totalItems = list.getTotalItems();
+ Assert.assertFalse(totalItems == 0);
+ if (getLogger().isDebugEnabled() == true) {
+ getLogger().debug(testName + ":" + "created list of "
+ + totalItems + " to be paginated.");
+ }
+
+ long pageSize = totalItems / 3; //create up to 3 pages to iterate over
+ long pagesTotal = pageSize > 0 ? (totalItems / pageSize) : 0;
+ for (int i = 0; i < pagesTotal; i++) {
+ list = (AbstractCommonList) this.readList(testName, client, pageSize, i, testExpectedStatusCode);
+ assertPaginationInfo(testName,
+ list,
+ i, //expected page number
+ pageSize, //expected page size
+ pageSize, //expected num of items in page
+ totalItems);//expected total num of items
+ }
+
+ // if there are any remainders be sure to paginate them as well
+ long mod = pageSize != 0 ? totalItems % pageSize : totalItems;
+ if (mod != 0) {
+ list = (AbstractCommonList) this.readList(testName, client, pageSize, pagesTotal, testExpectedStatusCode);
+ assertPaginationInfo(testName,
+ list,
+ pagesTotal, //expected page number
+ pageSize, //expected page size
+ mod, //expected num of items in page
+ totalItems);//expected total num of items
+ }
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#updateWithMalformedXml(java.lang.String)
+ /*
+ * This test assumes that no objects exist yet.
+ *
+ * http://localhost:8180/cspace-services/intakes?wf_deleted=false
*/
- @Override
- public abstract void updateWithMalformedXml(String testName) throws Exception;
+ @Test(dataProvider = "testName", dependsOnMethods = {"update"})
+ public void readWorkflow(String testName) throws Exception {
+ try {
+ //
+ // Get the total count of non-deleted existing records
+ //
+ long existingRecords = readIncludeDeleted(testName, Boolean.FALSE);
- /**
- * Sets up update tests with malformed xml.
- */
- protected void setupUpdateWithMalformedXml() {
- EXPECTED_STATUS_CODE = STATUS_BAD_REQUEST;
- REQUEST_TYPE = ServiceRequestType.UPDATE;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
+ //
+ // Create 3 new objects
+ //
+ final int OBJECTS_TO_CREATE = 3;
+ for (int i = 0; i < OBJECTS_TO_CREATE; i++) {
+ this.createWorkflowTarget(testName);
+ }
+
+ //
+ // Mark one as soft deleted
+ //
+ int existingTestCreated = allResourceIdsCreated.size(); // assumption is that no other test created records were soft deleted
+ String csid = allResourceIdsCreated.get(existingTestCreated - 1); //0-based index to get the last one added
+ this.setupUpdate();
+ this.updateLifeCycleState(testName, csid, WorkflowClient.WORKFLOWSTATE_DELETED);
+ //
+ // Read the list of existing non-deleted records
+ //
+ long updatedTotal = readIncludeDeleted(testName, Boolean.FALSE);
+ Assert.assertEquals(updatedTotal, existingRecords + OBJECTS_TO_CREATE - 1, "Deleted items seem to be returned in list results.");
+
+ //
+ // Next, test that a GET with WorkflowClient.WORKFLOWSTATE_DELETED query param set to 'false' returns a 404
+ //
+ int trials = 0;
+ int result = 0;
+ while (trials < 30) {
+ CollectionSpacePoxClient client = this.assertPoxClient();
+ ClientResponse<String> res = client.readIncludeDeleted(csid, Boolean.FALSE);
+ result = res.getStatus();
+ if (result == STATUS_NOT_FOUND) {
+ logger.info("Workflow transition to 'deleted' is complete");
+ break;
+ } else {
+ /*
+ * This should never happen, but if it does we need a full stack trace to help track it down.
+ */
+ try {
+ throw new RuntimeException(ERROR_WORKFLOW_TRANSITION);
+ } catch (RuntimeException e) {
+ logger.info(ERROR_WORKFLOW_TRANSITION, e);
+ }
+ }
+ trials++;
+ }
+ Assert.assertEquals(result, STATUS_NOT_FOUND);
+
+ } catch (UnsupportedOperationException e) {
+ logger.warn(this.getClass().getName() + " did not implement createWorkflowTarget() method. No workflow tests performed.");
+ return;
+ }
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#updateWithWrongXmlSchema(java.lang.String)
+ /*
+ * Test that searches honor the workflow deleted state.
*/
- @Override
- public abstract void updateWithWrongXmlSchema(String testName) throws Exception;
+ @Test(dataProvider = "testName")
+ public void searchWorkflowDeleted(String testName) throws Exception {
+
+ // FIXME: Temporarily avoid running test if client is of an authority service
+ CollectionSpacePoxClient client = this.assertPoxClient();
+ if (isAuthorityClient(client)) {
+ return;
+ }
+
+ try {
+ //
+ // Create 3 new objects
+ //
+ final int OBJECTS_TO_CREATE = 3;
+ final String KEYWORD = NON_EXISTENT_KEYWORD + createIdentifier();
+ for (int i = 0; i < OBJECTS_TO_CREATE; i++) {
+ this.createWorkflowTarget(testName, KEYWORD);
+ }
+
+ //
+ // Mark one as soft deleted
+ //
+ int existingTestCreated = allResourceIdsCreated.size(); // assumption is that no other test created records were soft deleted
+ String csid = allResourceIdsCreated.get(existingTestCreated - 1); //0-based index to get the last one added
+ this.setupUpdate();
+ this.updateLifeCycleState(testName, csid, WorkflowClient.WORKFLOWSTATE_DELETED);
+
+ //
+ // Search for the newly-created records, excluding the soft deleted record.
+ //
+ // Send the search request and receive a response
+ ClientResponse<AbstractCommonList> res = client.keywordSearchIncludeDeleted(KEYWORD, Boolean.FALSE);
+ int result = res.getStatus();
+ Assert.assertEquals(result, STATUS_OK);
+
+ AbstractCommonList list = res.getEntity();
+ long itemsMatchedBySearch = list.getTotalItems();
+ Assert.assertEquals(itemsMatchedBySearch, OBJECTS_TO_CREATE - 1,
+ "The number of items marked for delete is not correct.");
+ //
+ // Search for the newly-created records, including the soft deleted record.
+ //
+ // Send the search request and receive a response
+ res = client.keywordSearchIncludeDeleted(KEYWORD, Boolean.TRUE);
+ result = res.getStatus();
+ Assert.assertEquals(result, STATUS_OK);
+ list = res.getEntity();
+ itemsMatchedBySearch = list.getTotalItems();
+ Assert.assertEquals(itemsMatchedBySearch, OBJECTS_TO_CREATE,
+ "Deleted item was not returned in list results, even though it was requested to be included.");
+
+ } catch (UnsupportedOperationException e) {
+ logger.warn(this.getClass().getName() + " did not implement createWorkflowTarget() method. No workflow tests performed.");
+ return;
+ }
+ }
+
+ // ---------------------------------------------------------------
+ // Utility methods to support the test cases.
+ //
+ // ---------------------------------------------------------------
+
/**
- * Sets up update tests with wrong xml schema.
+ * Checks if 'theFile' is something we can turn into a Blob instance. It can't
+ * be read-protected, hidden, or a directory.
+ *
+ * @param theFile the the file
+ * @return true, if is blobable
*/
- protected void setupUpdateWithWrongXmlSchema() {
- EXPECTED_STATUS_CODE = STATUS_BAD_REQUEST;
- REQUEST_TYPE = ServiceRequestType.UPDATE;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
+ protected boolean isBlobbable(File theFile) {
+ boolean result = true;
+ if (theFile.isDirectory() || theFile.isHidden() || !theFile.canRead()) {
+ result = false;
+ }
+ return result;
}
/* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#updateNonExistent(java.lang.String)
+ * @see org.collectionspace.services.client.test.ServiceTest#createWithEmptyEntityBody(java.lang.String)
*/
@Override
- public abstract void updateNonExistent(String testName) throws Exception;
-
- /**
- * Sets up update non existent tests
- */
- protected void setupUpdateNonExistent() {
- EXPECTED_STATUS_CODE = STATUS_NOT_FOUND;
- REQUEST_TYPE = ServiceRequestType.UPDATE;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
+ public void createWithEmptyEntityBody(String testName) throws Exception {
+ //FIXME: Should this test really be empty? If so, please comment accordingly.
}
- // ---------------------------------------------------------------
- // CRUD tests : DELETE tests
- // ---------------------------------------------------------------
- // Success outcomes
-
/* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#delete(java.lang.String)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
*/
@Override
- public abstract void delete(String testName) throws Exception;
-
- /**
- * Sets up delete tests.
- */
- protected void setupDelete() {
- EXPECTED_STATUS_CODE = STATUS_OK;
- REQUEST_TYPE = ServiceRequestType.DELETE;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
+ public void createWithMalformedXml(String testName) throws Exception {
+ //FIXME: Should this test really be empty? If so, please comment accordingly.
}
- // Failure outcomes
-
/* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#deleteNonExistent(java.lang.String)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
*/
@Override
- public abstract void deleteNonExistent(String testName) throws Exception;
+ public void createWithWrongXmlSchema(String testName) throws Exception {
+ //FIXME: Should this test really be empty? If so, please comment accordingly.
+ }
- /**
- * Sets up delete non existent tests.
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.ServiceTest#updateNonExistent(java.lang.String)
*/
- protected void setupDeleteNonExistent() {
- EXPECTED_STATUS_CODE = STATUS_NOT_FOUND;
- REQUEST_TYPE = ServiceRequestType.DELETE;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
+ @Override
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"create", "update"})
+ public void updateNonExistent(String testName) throws Exception {
+ // Perform setup.
+ setupUpdateNonExistent();
+
+ // 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 update(), below.
+ CollectionSpaceClient client = this.getClientInstance();
+ REQUEST_TYPE multipart = createNonExistenceInstance(client.getCommonPartName(), NON_EXISTENT_ID);
+ ClientResponse<String> 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(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
-
+
// ---------------------------------------------------------------
// Utility methods to clean up resources created during tests.
// ---------------------------------------------------------------
- /**
- * Deletes all resources created by tests, after all tests have been run.
- *
- * This cleanup method will always be run, even if one or more tests fail.
- * For this reason, it attempts to remove all resources created
- * at any point during testing, even if some of those resources
- * may be expected to be deleted by certain tests.
- */
- @AfterClass(alwaysRun = true)
- public void cleanUp() {
- String noTestCleanup = System.getProperty(NO_TEST_CLEANUP);
- if (Boolean.TRUE.toString().equalsIgnoreCase(noTestCleanup)) {
- if (logger.isDebugEnabled()) {
- logger.debug("Skipping Cleanup phase ...");
- }
- return;
- }
- if (logger.isDebugEnabled()) {
- logger.debug("Cleaning up temporary resources created for testing ...");
- }
- CollectionSpaceClient client = this.getClientInstance();
- //
- // First, check to see if we need to cleanup any authority items
- //
- if (this.isAuthorityClient(client) == true) {
- AuthorityClient authorityClient = (AuthorityClient) client;
- for (Map.Entry<String, String> entry : allResourceItemIdsCreated.entrySet()) {
- String itemResourceId = entry.getKey();
- String authorityResourceId = entry.getValue();
- // Note: Any non-success responses are ignored and not reported.
- authorityClient.deleteItem(authorityResourceId, itemResourceId).releaseConnection();
- }
- }
- //
- // Next, delete all other entities include possible authorities.
- //
- for (String resourceId : allResourceIdsCreated) {
- // Note: Any non-success responses are ignored and not reported.
- client.delete(resourceId).releaseConnection();
- }
- }
// ---------------------------------------------------------------
// Utility methods in support of list tests.
* @return the abstract common list
* @throws Exception the exception
*/
- private AbstractCommonList readList(String testName,
+ private CLT readList(String testName,
CollectionSpaceClient client,
long pageSize,
long pageNumber,
int expectedStatus) throws Exception {
return readList(testName, client, EMPTY_SORT_BY_ORDER, pageSize, pageNumber, expectedStatus);
-
}
/**
* @return the abstract common list
* @throws Exception the exception
*/
- private AbstractCommonList readList(String testName,
+ private CLT readList(String testName,
CollectionSpaceClient client,
String sortBy,
long pageSize,
long pageNumber,
int expectedStatus) throws Exception {
- ClientResponse<AbstractCommonList> response =
+ ClientResponse<CLT> response =
client.readList(sortBy, pageSize, pageNumber);
- AbstractCommonList result = null;
+ CLT result = null;
try {
int statusCode = response.getStatus();
}
Assert.assertEquals(statusCode, expectedStatus);
- result = this.getAbstractCommonList(response);
+ result = this.getCommonList(response);
} finally {
response.releaseConnection();
}
return result;
}
- /**
- * Creates the list.
- *
- * @param testName the test name
- * @param listSize the list size
- * @throws Exception the exception
- */
- protected void createPaginatedList(String testName, int listSize) throws Exception {
- for (int i = 0; i < listSize; i++) {
- create(testName);
- }
- }
-
/*@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void leafCreate(String testName) throws Exception {
this.create(testName);
long expectedPageSize,
long expectedListSize,
long expectedTotalItems) {
- Assert.assertNotNull(list);
-
- long pageNum = list.getPageNum();
- Assert.assertEquals(pageNum, expectedPageNum);
- if (getLogger().isDebugEnabled() == true) {
- getLogger().debug(testName + ":" + "page number is " + pageNum);
- }
-
- long pageSizeReturned = list.getPageSize();
- Assert.assertEquals(pageSizeReturned, expectedPageSize);
- if (getLogger().isDebugEnabled() == true) {
- getLogger().debug(testName + ":" + "page size is " + list.getPageSize());
- }
-
- long itemsInPage = list.getItemsInPage();
- Assert.assertEquals(itemsInPage, expectedListSize);
- if (getLogger().isDebugEnabled() == true) {
- getLogger().debug(testName + ":" + "actual items in page was/were " + itemsInPage);
- }
-
- long totalItemsReturned = list.getTotalItems();
- Assert.assertEquals(totalItemsReturned, expectedTotalItems);
- if (getLogger().isDebugEnabled() == true) {
- getLogger().debug(testName + ":" + "total number of items is " + list.getTotalItems());
- }
- }
-
- /**
- * Read paginated list.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName") /*, dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"leafCreate"}) */
-
- public void readPaginatedList(String testName) throws Exception {
- // Perform setup.
- setupReadList();
- CollectionSpaceClient client = this.getClientInstance();
-
- // Get the current total number of items.
- // If there are no items then create some
- AbstractCommonList list = (AbstractCommonList) this.readList(testName,
- client,
- 1 /*pgSz*/,
- 0 /*pgNum*/,
- EXPECTED_STATUS_CODE);
- if (list == null || list.getTotalItems() == 0) {
- this.createPaginatedList(testName, DEFAULT_PAGINATEDLIST_SIZE);
- setupReadList();
- list = (AbstractCommonList) this.readList(testName,
- client,
- 1 /*pgSz*/,
- 0 /*pgNum*/,
- EXPECTED_STATUS_CODE);
+ Assert.assertNotNull(list);
+
+ long pageNum = list.getPageNum();
+ Assert.assertEquals(pageNum, expectedPageNum);
+ if (getLogger().isDebugEnabled() == true) {
+ getLogger().debug(testName + ":" + "page number is " + pageNum);
}
- // Print out the current list size to be paginated
- Assert.assertNotNull(list);
- long totalItems = list.getTotalItems();
- Assert.assertFalse(totalItems == 0);
+ long pageSizeReturned = list.getPageSize();
+ Assert.assertEquals(pageSizeReturned, expectedPageSize);
if (getLogger().isDebugEnabled() == true) {
- getLogger().debug(testName + ":" + "created list of "
- + totalItems + " to be paginated.");
+ getLogger().debug(testName + ":" + "page size is " + list.getPageSize());
}
- long pageSize = totalItems / 3; //create up to 3 pages to iterate over
- long pagesTotal = pageSize > 0 ? (totalItems / pageSize) : 0;
- for (int i = 0; i < pagesTotal; i++) {
- list = (AbstractCommonList) this.readList(testName, client, pageSize, i, EXPECTED_STATUS_CODE);
- assertPaginationInfo(testName,
- list,
- i, //expected page number
- pageSize, //expected page size
- pageSize, //expected num of items in page
- totalItems);//expected total num of items
+ long itemsInPage = list.getItemsInPage();
+ Assert.assertEquals(itemsInPage, expectedListSize);
+ if (getLogger().isDebugEnabled() == true) {
+ getLogger().debug(testName + ":" + "actual items in page was/were " + itemsInPage);
}
- // if there are any remainders be sure to paginate them as well
- long mod = pageSize != 0 ? totalItems % pageSize : totalItems;
- if (mod != 0) {
- list = (AbstractCommonList) this.readList(testName, client, pageSize, pagesTotal, EXPECTED_STATUS_CODE);
- assertPaginationInfo(testName,
- list,
- pagesTotal, //expected page number
- pageSize, //expected page size
- mod, //expected num of items in page
- totalItems);//expected total num of items
+ long totalItemsReturned = list.getTotalItems();
+ Assert.assertEquals(totalItemsReturned, expectedTotalItems);
+ if (getLogger().isDebugEnabled() == true) {
+ getLogger().debug(testName + ":" + "total number of items is " + list.getTotalItems());
}
}
+
@SuppressWarnings("rawtypes")
protected void updateLifeCycleState(String testName, String resourceId, String lifeCycleState) throws Exception {
//
CollectionSpaceClient client = this.getClientInstance();
ClientResponse<String> res = client.getWorkflow(resourceId);
- assertStatusCode(res, testName);
- logger.debug("Got object to update life cycle state with ID: " + resourceId);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- WorkflowCommon workflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
- Assert.assertNotNull(workflowCommons);
+ WorkflowCommon workflowCommons = null;
+ try {
+ assertStatusCode(res, testName);
+ logger.debug("Got object to update life cycle state with ID: " + resourceId);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ workflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
+ Assert.assertNotNull(workflowCommons);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
//
// Mark it for a soft delete.
//
//
// Perform the update
//
+ WorkflowCommon updatedWorkflowCommons = null;
res = client.updateWorkflow(resourceId, output);
- assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
- WorkflowCommon updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
- Assert.assertNotNull(updatedWorkflowCommons);
+ try {
+ assertStatusCode(res, testName);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
+ Assert.assertNotNull(updatedWorkflowCommons);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
//
// Read the updated object and make sure it was updated correctly.
//
int trials = 0;
while (trials < 30) {
res = client.getWorkflow(resourceId);
- assertStatusCode(res, testName);
- logger.debug("Got workflow state of updated object with ID: " + resourceId);
- input = new PoxPayloadIn(res.getEntity());
- updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
- Assert.assertNotNull(workflowCommons);
- String currentWorkflowState = updatedWorkflowCommons.getCurrentLifeCycleState();
- if (currentWorkflowState.equalsIgnoreCase(lifeCycleState)) {
- logger.debug("Expected workflow state found: " + lifeCycleState);
- break;
+ try {
+ assertStatusCode(res, testName);
+ logger.debug("Got workflow state of updated object with ID: " + resourceId);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
+ Assert.assertNotNull(workflowCommons);
+ String currentWorkflowState = updatedWorkflowCommons.getCurrentLifeCycleState();
+ if (currentWorkflowState.equalsIgnoreCase(lifeCycleState)) {
+ logger.debug("Expected workflow state found: " + lifeCycleState);
+ break;
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
trials++;
}
-
+ //
+ // Finally, assert the state change happened as expected.
+ //
Assert.assertEquals(updatedWorkflowCommons.getCurrentLifeCycleState(), lifeCycleState);
}
}
protected long readIncludeDeleted(String testName, Boolean includeDeleted) {
- long result = 0;
- // Perform setup.
- setupReadList();
-
- //
- // Ask for a list of all resources filtered by the incoming 'includeDeleted' workflow param
- //
- CollectionSpacePoxClient client = assertPoxClient();
- ClientResponse<AbstractCommonList> res = client.readIncludeDeleted(includeDeleted);
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
- //
- // Now check that list size is correct
- //
- /*
- List<AbstractCommonList.ListItem> items =
- list.getListItem();
- result = items.size();
- */
- result = list.getTotalItems();
+ long result = 0;
+ // Perform setup.
+ setupReadList();
+
+ //
+ // Ask for a list of all resources filtered by the incoming 'includeDeleted' workflow param
+ //
+ CollectionSpacePoxClient client = assertPoxClient();
+ ClientResponse<AbstractCommonList> res = client.readIncludeDeleted(includeDeleted);
+ try {
+ //
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ //
+ assertStatusCode(res, testName);
+ AbstractCommonList list = res.getEntity();
+ //
+ // Now check that list size is correct
+ //
+ result = list.getTotalItems();
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
- return result;
+ return result;
}
protected long readItemsIncludeDeleted(String testName, String parentCsid, Boolean includeDeleted) {
long result = 0;
// Perform setup.
setupReadList();
-
//
// Ask for a list of all resources filtered by the incoming 'includeDeleted' workflow param
//
null, /* partial terms */
null, /* keywords */
includeDeleted);
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
-
- result = list.getTotalItems();
-
- return result;
- }
-
- /*
- * This test assumes that no objects exist yet.
- *
- * http://localhost:8180/cspace-services/intakes?wf_deleted=false
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void readWorkflow(String testName) throws Exception {
- try {
- //
- // Get the total count of non-deleted existing records
- //
- long existingRecords = readIncludeDeleted(testName, Boolean.FALSE);
-
- //
- // Create 3 new objects
- //
- final int OBJECTS_TO_CREATE = 3;
- for (int i = 0; i < OBJECTS_TO_CREATE; i++) {
- this.createWorkflowTarget(testName);
- }
-
- //
- // Mark one as soft deleted
- //
- int existingTestCreated = allResourceIdsCreated.size(); // assumption is that no other test created records were soft deleted
- String csid = allResourceIdsCreated.get(existingTestCreated - 1); //0-based index to get the last one added
- this.setupUpdate();
- this.updateLifeCycleState(testName, csid, WorkflowClient.WORKFLOWSTATE_DELETED);
- //
- // Read the list of existing non-deleted records
- //
- long updatedTotal = readIncludeDeleted(testName, Boolean.FALSE);
- Assert.assertEquals(updatedTotal, existingRecords + OBJECTS_TO_CREATE - 1, "Deleted items seem to be returned in list results.");
-
- //
- // Next, test that a GET with WorkflowClient.WORKFLOWSTATE_DELETED query param set to 'false' returns a 404
- //
- int trials = 0;
- int result = 0;
- while (trials < 30) {
- CollectionSpacePoxClient client = this.assertPoxClient();
- ClientResponse<String> res = client.readIncludeDeleted(csid, Boolean.FALSE);
- result = res.getStatus();
- if (result == STATUS_NOT_FOUND) {
- logger.info("Workflow transition to 'deleted' is complete");
- break;
- }
- trials++;
- }
- Assert.assertEquals(result, STATUS_NOT_FOUND);
-
- } catch (UnsupportedOperationException e) {
- logger.warn(this.getClass().getName() + " did not implement createWorkflowTarget() method. No workflow tests performed.");
- return;
- }
- }
-
- /*
- * Test that searches honor the workflow deleted state.
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void searchWorkflowDeleted(String testName) throws Exception {
-
- // FIXME: Temporarily avoid running test if client is of an authority service
- CollectionSpacePoxClient client = this.assertPoxClient();
- if (isAuthorityClient(client)) {
- return;
- }
-
try {
-
- //
- // Create 3 new objects
- //
- final int OBJECTS_TO_CREATE = 3;
- final String KEYWORD = NON_EXISTENT_KEYWORD + createIdentifier();
- for (int i = 0; i < OBJECTS_TO_CREATE; i++) {
- this.createWorkflowTarget(testName, KEYWORD);
+ assertStatusCode(res, testName);
+ AbstractCommonList list = res.getEntity();
+ result = list.getTotalItems();
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
}
-
- //
- // Mark one as soft deleted
- //
- int existingTestCreated = allResourceIdsCreated.size(); // assumption is that no other test created records were soft deleted
- String csid = allResourceIdsCreated.get(existingTestCreated - 1); //0-based index to get the last one added
- this.setupUpdate();
- this.updateLifeCycleState(testName, csid, WorkflowClient.WORKFLOWSTATE_DELETED);
-
- //
- // Search for the newly-created records, excluding the soft deleted record.
- //
- // Send the search request and receive a response
- ClientResponse<AbstractCommonList> res = client.keywordSearchIncludeDeleted(KEYWORD, Boolean.FALSE);
- int result = res.getStatus();
- assertStatusCode(res, testName);
-
- AbstractCommonList list = res.getEntity();
- long itemsMatchedBySearch = list.getTotalItems();
- Assert.assertEquals(itemsMatchedBySearch, OBJECTS_TO_CREATE - 1,
- "Deleted items seem to be returned in list results.");
-
- //
- // Search for the newly-created records, including the soft deleted record.
- //
- // Send the search request and receive a response
- res = client.keywordSearchIncludeDeleted(KEYWORD, Boolean.TRUE);
- result = res.getStatus();
- assertStatusCode(res, testName);
-
- list = res.getEntity();
- itemsMatchedBySearch = list.getTotalItems();
- Assert.assertEquals(itemsMatchedBySearch, OBJECTS_TO_CREATE,
- "Deleted item was not returned in list results, even though it was requested to be included.");
-
- } catch (UnsupportedOperationException e) {
- logger.warn(this.getClass().getName() + " did not implement createWorkflowTarget() method. No workflow tests performed.");
- return;
}
+
+ return result;
}
- protected String createTestObject(String testName) throws Exception {
+ protected String createTestObject() throws Exception {
String identifier = createIdentifier();
- String result = createTestObject(testName, identifier);
+ String result = createTestObject(identifier);
return result;
-
}
- protected String createTestObject(String testName, String identifier) throws Exception {
+ protected String createTestObject(String identifier) throws Exception {
String result = null;
- CollectionSpacePoxClient client = (CollectionSpacePoxClient) getClientInstance();
- PoxPayloadOut multipart = createInstance(identifier);
- ClientResponse<Response> res = client.create(multipart);
+ CollectionSpaceClient client = getClientInstance();
+ REQUEST_TYPE payload = createInstance(identifier);
+ ClientResponse<Response> res = client.create(payload);
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, STATUS_CREATED);
protected String createWorkflowTarget(String testName) throws Exception {
String result = null;
- result = createTestObject(testName);
+ result = createTestObject();
return result;
}
protected String createWorkflowTarget(String testName, String keyword) throws Exception {
String result = null;
- result = createTestObject(testName, keyword);
+ result = createTestObject(keyword);
return result;
}
- /*
- * Sub-classes must override for the workflow tests.
- */
- protected PoxPayloadOut createInstance(String identifier) {
- logger.warn("Sub-class test clients should override this method");
-
-
- throw new UnsupportedOperationException();
-
-
-
- }
-
- /*
- * Test classes for authority services should override these method and return 'true'
- */
- protected boolean isAuthorityClient(CollectionSpaceClient theClient) {
- return AuthorityClient.class.isInstance(theClient);
- }
-
protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) {
logger.warn("Sub-class test clients should override this method");
-
-
throw new UnsupportedOperationException();
-
-
}
final protected String createWorkflowItemTarget(String testName, String parentCsid) throws Exception {
String result = null;
-
result = createTestItemObject(testName, parentCsid);
-
-
-
return result;
-
-
}
protected String createTestItemObject(String testName, String parentCsid) throws Exception {
PoxPayloadOut multipart = createItemInstance(parentCsid, identifier);
ClientResponse<Response> res = client.createItem(parentCsid, multipart);
-
-
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, STATUS_CREATED);
result = extractId(res);
allResourceItemIdsCreated.put(result, parentCsid);
-
-
return result;
-
-
}
/*
*
* http://localhost:8180/cspace-services/intakes?wf_deleted=false
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+ @Test(dataProvider = "testName")
public void readAuthorityItemWorkflow(String testName) throws Exception {
//
// Run this test only if the client is an AuthorityClient //FIXME: REM - Replace this will an AuthorityServiceTest class
final int OBJECTS_TO_CREATE = 3;
String lastCreatedItem = null;
-
- for (int i = 0; i
- < OBJECTS_TO_CREATE; i++) {
+ for (int i = 0; i < OBJECTS_TO_CREATE; i++) {
lastCreatedItem = this.createWorkflowItemTarget(testName, parentCsid);
-
-
} //
// Mark one item as soft deleted
//
String csid = lastCreatedItem;
-
this.setupUpdate();
-
this.updateItemLifeCycleState(testName, parentCsid, csid, WorkflowClient.WORKFLOWSTATE_DELETED);
//
// Read the list of existing non-deleted records
//
-
long updatedTotal = readItemsIncludeDeleted(testName, parentCsid, Boolean.FALSE);
Assert.assertEquals(updatedTotal, OBJECTS_TO_CREATE - 1, "Deleted items seem to be returned in list results.");
AuthorityClient client = (AuthorityClient) this.getClientInstance();
ClientResponse<String> res = client.readItem(parentCsid, csid, Boolean.FALSE);
-
int result = res.getStatus();
Assert.assertEquals(result, STATUS_NOT_FOUND);
-
-
} catch (UnsupportedOperationException e) {
logger.warn(this.getClass().getName() + " did not implement createWorkflowTarget() method. No workflow tests performed.");
-
-
return;
-
-
}
}
}
//
AuthorityClient client = (AuthorityClient) this.getClientInstance();
ClientResponse<String> res = client.readItemWorkflow(parentCsid, itemCsid);
- assertStatusCode(res, testName);
- logger.debug("Got object to update life cycle state with ID: " + itemCsid);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- WorkflowCommon workflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
- Assert.assertNotNull(workflowCommons);
+ WorkflowCommon workflowCommons = null;
+ try {
+ assertStatusCode(res, testName);
+ logger.debug("Got object to update life cycle state with ID: " + itemCsid);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ workflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
+ Assert.assertNotNull(workflowCommons);
+ logger.debug("Current workflow state:" + objectAsXmlString(workflowCommons, WorkflowCommon.class));
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
//
- // Mark it for a soft delete.
+ // Mark it for a state change.
//
- logger.debug(
- "Current workflow state:" + objectAsXmlString(workflowCommons, WorkflowCommon.class));
workflowCommons.setCurrentLifeCycleState(lifeCycleState);
PoxPayloadOut output = new PoxPayloadOut(WorkflowClient.SERVICE_PAYLOAD_NAME);
PayloadOutputPart commonPart = output.addPart(WorkflowClient.SERVICE_COMMONPART_NAME, workflowCommons);
//
- // Perform the update
+ // Perform the state change update
//
res = client.updateItemWorkflow(parentCsid, itemCsid, output);
- assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
- WorkflowCommon updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
- Assert.assertNotNull(updatedWorkflowCommons);
+ WorkflowCommon updatedWorkflowCommons = null;
+ try {
+ assertStatusCode(res, testName);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
+ Assert.assertNotNull(updatedWorkflowCommons);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
int trials = 0;
boolean passed = false;
// Read the updated object and make sure it was updated correctly.
//
res = client.readItemWorkflow(parentCsid, itemCsid);
- assertStatusCode(res, testName);
- logger.debug(
- "Got workflow state of updated object with ID: " + itemCsid);
- input = new PoxPayloadIn(res.getEntity());
- updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
- Assert.assertNotNull(workflowCommons);
- String currentState = updatedWorkflowCommons.getCurrentLifeCycleState();
- if (currentState.equalsIgnoreCase(lifeCycleState)) {
- logger.debug("Expected workflow state found: " + lifeCycleState);
- break;
+ try {
+ assertStatusCode(res, testName);
+ logger.debug(
+ "Got workflow state of updated object with ID: " + itemCsid);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
+ Assert.assertNotNull(workflowCommons);
+ String currentState = updatedWorkflowCommons.getCurrentLifeCycleState();
+ if (currentState.equalsIgnoreCase(lifeCycleState)) {
+ logger.debug("Expected workflow state found: " + lifeCycleState);
+ break;
+ }
+ logger.debug("Workflow state not yet updated for object with id: " + itemCsid + " state is=" +
+ currentState);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- logger.debug("Workflow state not yet updated for object with id: " + itemCsid + " state is=" +
- currentState);
trials++;
}
+ //
+ // Finally check to see if the state change was updated as expected.
+ //
Assert.assertEquals(updatedWorkflowCommons.getCurrentLifeCycleState(), lifeCycleState);
}
+
}
import java.io.InputStream;\r
import java.io.StringWriter;\r
import java.lang.reflect.Method;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
import java.util.List;\r
+import java.util.Map;\r
+import java.util.Random;\r
\r
+import javax.activation.MimetypesFileTypeMap;\r
import javax.ws.rs.core.MultivaluedMap;\r
import javax.ws.rs.core.Response;\r
import javax.xml.bind.JAXBContext;\r
import org.apache.commons.httpclient.methods.PutMethod;\r
import org.apache.commons.httpclient.methods.StringRequestEntity;\r
import org.apache.commons.io.FileUtils;\r
+\r
import org.jboss.resteasy.client.ClientResponse;\r
import org.slf4j.Logger;\r
import org.slf4j.LoggerFactory;\r
import org.testng.Assert;\r
+import org.testng.annotations.AfterClass;\r
+import org.testng.annotations.BeforeMethod;\r
import org.testng.annotations.DataProvider;\r
import org.w3c.dom.Document;\r
\r
+import org.collectionspace.services.client.AuthorityClient;\r
import org.collectionspace.services.client.CollectionSpaceClient;\r
import org.collectionspace.services.client.PayloadInputPart;\r
import org.collectionspace.services.client.PoxPayloadIn;\r
import org.collectionspace.services.client.TestServiceClient;\r
-\r
import org.collectionspace.services.jaxb.AbstractCommonList;\r
\r
/**\r
\r
// FIXME: http://issues.collectionspace.org/browse/CSPACE-1685\r
\r
-public abstract class BaseServiceTest {\r
-\r
+/*\r
+ * <CLT> - Common list type\r
+ */\r
+public abstract class BaseServiceTest<CLT> {\r
+ //A default MIME type result\r
+ static protected final String DEFAULT_MIME = "application/octet-stream; charset=ISO-8859-1";\r
//Maven's base directory -i.e., the one containing the current pom.xml\r
protected static final String MAVEN_BASEDIR_PROPERTY = "maven.basedir";\r
/** The Constant logger. */\r
private static final Logger logger = LoggerFactory.getLogger(BaseServiceTest.class);\r
/** The Constant serviceClient. */\r
protected static final TestServiceClient serviceClient = new TestServiceClient();\r
+ \r
+ protected String knownResourceIdentifier = null;\r
+ /** Use this to keep track of a single known resource */\r
+ protected String knownResourceId = null;\r
+ /* Use this to keep track of resources to delete */\r
+ protected List<String> allResourceIdsCreated = new ArrayList<String>();\r
+ /* Use this to track authority items */\r
+ protected Map<String, String> allResourceItemIdsCreated = new HashMap<String, String>(); /* itemCsid, parentCsid */\r
+ /* A runtime/command-line parameter to indicate if we should delete all the test related resource objects */\r
+ static private final String NO_TEST_CLEANUP = "noTestCleanup";\r
+ /* A random number generator */\r
+ static private final Random random = new Random(System.currentTimeMillis());\r
+ \r
+ \r
/** The non-existent id. */\r
protected final String NON_EXISTENT_ID = createNonExistentIdentifier();\r
/** The expected status code. */\r
- protected int EXPECTED_STATUS_CODE = 0;\r
+ protected int testExpectedStatusCode = 0;\r
/** The request type type. */\r
- protected ServiceRequestType REQUEST_TYPE = ServiceRequestType.NON_EXISTENT;\r
+ protected ServiceRequestType testRequestType = ServiceRequestType.NON_EXISTENT;\r
+ \r
/** The Constant XML_DECLARATION. */\r
protected static final String XML_DECLARATION = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";\r
/** The Constant MALFORMED_XML_DATA. */\r
+ "<wrong_schema>wrong schema contents</wrong_schema>";\r
/** The null charset. */\r
private static final String NULL_CHARSET = null;\r
-\r
- private static final String BANNER_SEPARATOR_LINE =\r
- "===================================================";\r
- private static final String BANNER_PREFIX =\r
- "\n" + BANNER_SEPARATOR_LINE + "\n";\r
- private static final String BANNER_SUFFIX =\r
- "\n" + BANNER_SEPARATOR_LINE;\r
+ \r
+ /** A visual separator for our test banners */\r
+ private static final String BANNER_SEPARATOR_LINE = "===================================================";\r
+ private static final String BANNER_PREFIX = "\n" + BANNER_SEPARATOR_LINE + "\n";\r
+ private static final String BANNER_SUFFIX = "\n" + BANNER_SEPARATOR_LINE; \r
\r
// A Unicode UTF-8 data fragment for use in test payloads: a random sequence,\r
// unlikely to be encountered in actual collections data, and capable of\r
// Ω : Greek capital letter Omega (U+03A9)\r
private final static String UTF8_DATA_FRAGMENT = "utf-8-data-fragment:"\r
+ '\u0394' + '\u04C1' + '\u0174' +'\u03A9';\r
- \r
+ //\r
+ // Status constants\r
+ //\r
protected static final int STATUS_BAD_REQUEST =\r
Response.Status.BAD_REQUEST.getStatusCode();\r
protected static final int STATUS_CREATED =\r
protected static final int STATUS_NOT_FOUND =\r
Response.Status.NOT_FOUND.getStatusCode();\r
protected static final int STATUS_OK =\r
- Response.Status.OK.getStatusCode();\r
+ Response.Status.OK.getStatusCode();\r
+ protected static final int STATUS_FORBIDDEN =\r
+ Response.Status.FORBIDDEN.getStatusCode();\r
\r
/**\r
* Instantiates a new base service test.\r
super();\r
}\r
\r
+ /*\r
+ * A getter for retrieving the tests logger\r
+ */\r
+ protected Logger getLogger() {\r
+ return this.logger;\r
+ }\r
+ \r
+ @BeforeMethod\r
+ protected void beforeMethod(Method m) {\r
+ logTestBanner(getLogger(), m.getName()); \r
+ }\r
+ \r
/**\r
* Gets the client.\r
*\r
*/\r
abstract protected CollectionSpaceClient getClientInstance();\r
\r
- /**\r
- * Gets the abstract common list.\r
- *\r
- * @param response the response\r
- * @return the abstract common list\r
+ /*\r
+ * Subclasses can override this method to return their AbstractCommonList subclass\r
*/\r
- abstract protected AbstractCommonList getAbstractCommonList(\r
- ClientResponse<AbstractCommonList> response);\r
+ protected Class<CLT> getCommonListType() {\r
+ return (Class<CLT>)AbstractCommonList.class;\r
+ }\r
\r
+ protected CLT getCommonList(\r
+ ClientResponse<CLT> response) {\r
+ return response.getEntity(getCommonListType());\r
+ }\r
+ \r
/**\r
* Returns the name of the currently running test.\r
*\r
* of those values between tests.\r
*/\r
protected void clearSetup() {\r
- EXPECTED_STATUS_CODE = 0;\r
- REQUEST_TYPE = ServiceRequestType.NON_EXISTENT;\r
+ testExpectedStatusCode = 0;\r
+ testRequestType = ServiceRequestType.NON_EXISTENT;\r
}\r
\r
+ /**\r
+ * Sets up create tests.\r
+ */\r
+ protected void setupCreate() {\r
+ testExpectedStatusCode = STATUS_CREATED;\r
+ testRequestType = ServiceRequestType.CREATE;\r
+ testSetup(testExpectedStatusCode, testRequestType);\r
+ }\r
+ \r
/**\r
* Initializes setup values for a given test.\r
*\r
int expectedStatusCode,\r
ServiceRequestType reqType) {\r
clearSetup();\r
- EXPECTED_STATUS_CODE = expectedStatusCode;\r
- REQUEST_TYPE = reqType;\r
+ testExpectedStatusCode = expectedStatusCode;\r
+ testRequestType = reqType;\r
}\r
\r
/**\r
}\r
\r
/**\r
- * Creates the identifier.\r
- *\r
- * @return the string\r
+ * Tests can override this method to customize their identifiers.\r
*/\r
- static protected String createIdentifier() {\r
- long identifier = System.currentTimeMillis();\r
+ protected String createIdentifier() {\r
+ long identifier = System.currentTimeMillis() + random.nextInt();\r
return Long.toString(identifier);\r
}\r
+ \r
+ /**\r
+ * Tests can override this method to customize their identifiers.\r
+ */\r
+ protected String getKnowResourceIdentifier() {\r
+ if (knownResourceIdentifier == null) {\r
+ knownResourceIdentifier = createIdentifier();\r
+ }\r
+ return knownResourceIdentifier;\r
+ }\r
+ \r
+ /**\r
+ * Tests can override this method if they have a different knownResourceId\r
+ * @return\r
+ */\r
+ protected String getKnowResourceId() {\r
+ return this.knownResourceId;\r
+ }\r
\r
/**\r
* Creates the non existent identifier.\r
}\r
return sw.toString();\r
}\r
+ \r
+ static protected String objectAsXmlString(Object o) {\r
+ StringWriter sw = new StringWriter();\r
+ try {\r
+ JAXBContext jc = JAXBContext.newInstance(o.getClass());\r
+ Marshaller m = jc.createMarshaller();\r
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,\r
+ Boolean.TRUE);\r
+ m.marshal(o, sw);\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ return sw.toString();\r
+ } \r
\r
/**\r
* getObjectFromFile get object of given class from given file (in classpath)\r
return sb.toString();\r
}\r
\r
+ /**\r
+ * Returns a 'banner', consisting of a text label inside a pair of prefix\r
+ * and suffix strings.\r
+ *\r
+ * @param label The label to be output inside the banner.\r
+ *\r
+ * @return The banner.\r
+ */\r
+ protected static String getBannerStr(String label) {\r
+ StringBuffer sb = new StringBuffer();\r
+ sb.append(BANNER_PREFIX);\r
+ sb.append(label);\r
+ sb.append(BANNER_SUFFIX);\r
+ return sb.toString();\r
+ }\r
+ \r
/**\r
* Returns a test-specific banner.\r
*\r
*\r
* @return A test-specific banner.\r
*/\r
- protected static String testBanner(String testName) {\r
+ private static String getNameBanner(String testName) {\r
testName = (testName == null || testName.trim().isEmpty()) ?\r
" Test = no test name specified" : " Test = " + testName;\r
- return banner(testName);\r
+ return testName;\r
}\r
\r
/**\r
*\r
* @return A test-specific banner.\r
*/\r
- protected static String testBanner(String testName, String testClass) {\r
- testName = (testName == null || testName.trim().isEmpty()) ?\r
- " Test = no test name specified" : " Test = " + testName;\r
+ private static String getBanner(String testName, String testClass) {\r
+ testName = getNameBanner(testName);\r
testClass = (testClass == null || testClass.trim().isEmpty()) ?\r
"Class = no test class specified" : "Class = " + classNameFromPackageName(testClass);\r
String testLabel = testClass + "\n" + testName;\r
- return banner(testLabel);\r
+ return getBannerStr(testLabel);\r
}\r
-\r
- /**\r
- * Returns a 'banner', consisting of a text label inside a pair of prefix\r
- * and suffix strings.\r
- *\r
- * @param label The label to be output inside the banner.\r
- *\r
- * @return The banner.\r
- */\r
- protected static String banner(String label) {\r
- StringBuffer sb = new StringBuffer();\r
- sb.append(BANNER_PREFIX);\r
- sb.append(label);\r
- sb.append(BANNER_SUFFIX);\r
- return sb.toString();\r
+ \r
+ protected static String getTestBanner(String testName, String testClassName) {\r
+ return getBanner(testName, testClassName);\r
+ }\r
+ \r
+ protected String getTestBanner(String testName) {\r
+ return getTestBanner(testName, this.getClass().getCanonicalName());\r
+ }\r
+ \r
+ protected void logTestBanner(Logger logger, String testName) {\r
+ if (logger.isDebugEnabled() == true) {\r
+ logger.debug(getTestBanner(testName));\r
+ }\r
}\r
\r
protected static String classNameFromPackageName(String className) {\r
return className;\r
}\r
\r
- public void assertStatusCode(ClientResponse<?> res, String testName) {\r
+ public int assertStatusCode(ClientResponse<?> res, String testName) {\r
int statusCode = res.getStatus();\r
+ \r
// Check the status code of the response: does it match the expected response(s)?\r
logger.debug(testName + ": status = " + statusCode);\r
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);\r
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
+ invalidStatusCodeMessage(testRequestType, statusCode));\r
+ Assert.assertEquals(statusCode, testExpectedStatusCode);\r
+ \r
+ return statusCode;\r
}\r
\r
public static String getUTF8DataFragment() {\r
return UTF8_DATA_FRAGMENT;\r
}\r
\r
+ protected String getMimeType(File theFile) {\r
+ String result = null;\r
+ result = new MimetypesFileTypeMap().getContentType(theFile);\r
+ if (result == null) {\r
+ logger.debug("Could not get MIME type for file at: " + theFile.getAbsolutePath());\r
+ result = DEFAULT_MIME;\r
+ }\r
+\r
+ return result;\r
+ }\r
+\r
+ /*\r
+ * Test classes for authority services should override these method and return 'true'\r
+ */\r
+ protected boolean isAuthorityClient(CollectionSpaceClient theClient) {\r
+ return AuthorityClient.class.isInstance(theClient);\r
+ }\r
+ \r
+ /**\r
+ * Deletes all resources created by tests, after all tests have been run.\r
+ *\r
+ * This cleanup method will always be run, even if one or more tests fail.\r
+ * For this reason, it attempts to remove all resources created\r
+ * at any point during testing, even if some of those resources\r
+ * may be expected to be deleted by certain tests.\r
+ */\r
+ @AfterClass(alwaysRun = true)\r
+ public void cleanUp() {\r
+ String noTestCleanup = System.getProperty(NO_TEST_CLEANUP);\r
+ if (Boolean.TRUE.toString().equalsIgnoreCase(noTestCleanup)) {\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug("Skipping Cleanup phase ...");\r
+ }\r
+ return;\r
+ }\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug("Cleaning up temporary resources created for testing ...");\r
+ }\r
+ CollectionSpaceClient client = this.getClientInstance();\r
+ //\r
+ // First, check to see if we need to cleanup any authority items\r
+ //\r
+ if (this.isAuthorityClient(client) == true) {\r
+ AuthorityClient authorityClient = (AuthorityClient) client;\r
+ for (Map.Entry<String, String> entry : allResourceItemIdsCreated.entrySet()) {\r
+ String itemResourceId = entry.getKey();\r
+ String authorityResourceId = entry.getValue();\r
+ // Note: Any non-success responses are ignored and not reported.\r
+ authorityClient.deleteItem(authorityResourceId, itemResourceId).releaseConnection();\r
+ }\r
+ }\r
+ //\r
+ // Next, delete all other entities include possible authorities.\r
+ //\r
+ for (String resourceId : allResourceIdsCreated) {\r
+ // Note: Any non-success responses are ignored and not reported.\r
+ client.delete(resourceId).releaseConnection();\r
+ }\r
+ }\r
+ \r
+ //\r
+ // Status code setup methods for tests\r
+ //\r
+ \r
+ /**\r
+ * Sets up create tests with malformed xml.\r
+ */\r
+ protected void setupCreateWithMalformedXml() {\r
+ testExpectedStatusCode = STATUS_BAD_REQUEST;\r
+ testRequestType = ServiceRequestType.CREATE;\r
+ testSetup(testExpectedStatusCode, testRequestType);\r
+ }\r
+\r
+ /**\r
+ * Sets up create tests with wrong xml schema.\r
+ */\r
+ protected void setupCreateWithWrongXmlSchema() {\r
+ testExpectedStatusCode = STATUS_BAD_REQUEST;\r
+ testRequestType = ServiceRequestType.CREATE;\r
+ testSetup(testExpectedStatusCode, testRequestType);\r
+ }\r
+ \r
+ /**\r
+ * Sets up read tests.\r
+ */\r
+ protected void setupRead() {\r
+ testExpectedStatusCode = STATUS_OK;\r
+ testRequestType = ServiceRequestType.READ;\r
+ testSetup(testExpectedStatusCode, testRequestType);\r
+ }\r
+\r
+ /**\r
+ * Sets up read tests.\r
+ */\r
+ protected void setupForbidden() {\r
+ testExpectedStatusCode = STATUS_FORBIDDEN;\r
+ testRequestType = ServiceRequestType.READ;\r
+ testSetup(testExpectedStatusCode, testRequestType);\r
+ }\r
+\r
+ /**\r
+ * Sets up read non existent tests.\r
+ */\r
+ protected void setupReadNonExistent() {\r
+ testExpectedStatusCode = STATUS_NOT_FOUND;\r
+ testRequestType = ServiceRequestType.READ;\r
+ testSetup(testExpectedStatusCode, testRequestType);\r
+ }\r
+\r
+ /**\r
+ * Sets up read list tests.\r
+ */\r
+ protected void setupReadList() {\r
+ testExpectedStatusCode = STATUS_OK;\r
+ testRequestType = ServiceRequestType.READ_LIST;\r
+ testSetup(testExpectedStatusCode, testRequestType);\r
+ }\r
+\r
+ /**\r
+ * Sets up update tests.\r
+ */\r
+ protected void setupUpdate() {\r
+ testExpectedStatusCode = STATUS_OK;\r
+ testRequestType = ServiceRequestType.UPDATE;\r
+ testSetup(testExpectedStatusCode, testRequestType);\r
+ }\r
+ \r
+ /**\r
+ * Sets up update tests with an empty entity body.\r
+ */\r
+ protected void setupUpdateWithEmptyEntityBody() {\r
+ testExpectedStatusCode = STATUS_BAD_REQUEST;\r
+ testRequestType = ServiceRequestType.UPDATE;\r
+ testSetup(testExpectedStatusCode, testRequestType);\r
+ }\r
+\r
+ /**\r
+ * Sets up update tests with malformed xml.\r
+ */\r
+ protected void setupUpdateWithMalformedXml() {\r
+ testExpectedStatusCode = STATUS_BAD_REQUEST;\r
+ testRequestType = ServiceRequestType.UPDATE;\r
+ testSetup(testExpectedStatusCode, testRequestType);\r
+ }\r
+ \r
+ /**\r
+ * Sets up update tests with wrong xml schema.\r
+ */\r
+ protected void setupUpdateWithWrongXmlSchema() {\r
+ testExpectedStatusCode = STATUS_BAD_REQUEST;\r
+ testRequestType = ServiceRequestType.UPDATE;\r
+ testSetup(testExpectedStatusCode, testRequestType);\r
+ }\r
+ \r
+ /**\r
+ * Sets up update non existent tests\r
+ */\r
+ protected void setupUpdateNonExistent() {\r
+ testExpectedStatusCode = STATUS_NOT_FOUND;\r
+ testRequestType = ServiceRequestType.UPDATE;\r
+ testSetup(testExpectedStatusCode, testRequestType);\r
+ }\r
+\r
+ /**\r
+ * Sets up delete tests.\r
+ */\r
+ protected void setupDelete() {\r
+ testExpectedStatusCode = STATUS_OK;\r
+ testRequestType = ServiceRequestType.DELETE;\r
+ testSetup(testExpectedStatusCode, testRequestType);\r
+ }\r
+\r
+ // Failure outcomes\r
+\r
+ /**\r
+ * Sets up delete non existent tests.\r
+ */\r
+ protected void setupDeleteNonExistent() {\r
+ testExpectedStatusCode = STATUS_NOT_FOUND;\r
+ testRequestType = ServiceRequestType.DELETE;\r
+ testSetup(testExpectedStatusCode, testRequestType);\r
+ }\r
+ \r
+ /**\r
+ * Sets up create tests with empty entity body.\r
+ */\r
+ protected void setupCreateWithEmptyEntityBody() {\r
+ testExpectedStatusCode = STATUS_BAD_REQUEST;\r
+ testRequestType = ServiceRequestType.CREATE;\r
+ testSetup(testExpectedStatusCode, testRequestType);\r
+ }\r
+\r
+ /**\r
+ * Sets up create tests with empty entity body.\r
+ */\r
+ protected void setupCreateWithInvalidBody() {\r
+ testExpectedStatusCode = STATUS_BAD_REQUEST;\r
+ testRequestType = ServiceRequestType.CREATE;\r
+ testSetup(testExpectedStatusCode, testRequestType);\r
+ }\r
+ \r
+ /**\r
+ * Sets up create tests with empty entity body.\r
+ */\r
+ protected void setupUpdateWithInvalidBody() {\r
+ testExpectedStatusCode = STATUS_BAD_REQUEST;\r
+ testRequestType = ServiceRequestType.UPDATE;\r
+ testSetup(testExpectedStatusCode, testRequestType);\r
+ }\r
+ \r
+ public void updateWithEmptyEntityBody(String testName) throws Exception {\r
+ //FIXME: Should this test really be empty? If so, please comment accordingly.\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)\r
+ */\r
+ public void updateWithMalformedXml(String testName) throws Exception {\r
+ //FIXME: Should this test really be empty? If so, please comment accordingly.\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)\r
+ */\r
+ public void updateWithWrongXmlSchema(String testName) throws Exception {\r
+ //FIXME: Should this test really be empty? If so, please comment accordingly.\r
+ }\r
+ \r
}\r
import java.util.Arrays;
import javax.ws.rs.core.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* ServiceRequestType, identifies types of service requests
* and the valid HTTP status codes that can be returned from
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
+ /*
+ * We use this method to force a TestNG execution order for our tests. The "leaf" methods
+ * should look something like this:
+ *
+ //
+ // For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
+ // refer to this method in their @Test annotation declarations.
+ //
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {
+ "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
+ public void CRUDTests() {
+ // Do nothing. Simply here to for a TestNG execution order for our tests
+ }
+ *
+ * For an example, see the CollectionObjectServiceTest class.
+ *
+ */
+ public void CRUDTests(String testName);
+
// Success outcomes
+ public void searchWorkflowDeleted(String testName) throws Exception;
+
/**
* Tests creation of a new resource.
*
* @throws Exception
*/
public void create(String testName) throws Exception;
-
+
/**
* Tests creation of a list of two or more new resources by repeatedly
* calling create(), and relies on the latter's test assertion(s).
*/
public void updateNonExistent(String testName) throws Exception;
-
// ---------------------------------------------------------------
// CRUD tests : DELETE tests
// ---------------------------------------------------------------
*/
package org.collectionspace.services.client.workflow;
+import javax.ws.rs.core.Response;
+
import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.collectionspace.services.client.AbstractPoxServiceClientImpl;
+import org.collectionspace.services.client.AbstractCommonListPoxServiceClientImpl;
+import org.jboss.resteasy.client.ClientResponse;
/**
* WorkflowClient.java
* $LastChangedDate: 2010-05-17 18:25:37 -0700 (Mon, 17 May 2010) $
*
*/
-public class WorkflowClient extends AbstractPoxServiceClientImpl<AbstractCommonList, WorkflowProxy> {
+public class WorkflowClient extends AbstractCommonListPoxServiceClientImpl<WorkflowProxy> {
public static final String SERVICE_NAME = "workflow";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
@Override
public String getServicePathComponent() {
return SERVICE_PATH_COMPONENT;
- }
+ }
@Override
public Class<WorkflowProxy> getProxyClass() {
// TODO Auto-generated method stub
return WorkflowProxy.class;
}
+
+ /*
+ * Proxied service calls
+ */
+
+ @Override
+ public ClientResponse<AbstractCommonList> readList() {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.AbstractServiceClientImpl#delete(java.lang.String)
+ */
+ @Override
+ public ClientResponse<Response> delete(String csid) {
+ throw new UnsupportedOperationException();
+ }
+
}
package org.collectionspace.services.client.workflow;
import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import org.collectionspace.services.client.CollectionSpacePoxProxy;
-import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.jboss.resteasy.client.ClientResponse;
+import org.collectionspace.services.client.CollectionSpaceCommonListPoxProxy;
/**
* @version $Revision: 2108 $
@Path(WorkflowClient.SERVICE_PATH + "/")
@Produces({"application/xml"})
@Consumes({"application/xml"})
-public interface WorkflowProxy extends CollectionSpacePoxProxy<AbstractCommonList> {
+public interface WorkflowProxy extends CollectionSpaceCommonListPoxProxy {
}
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
<dependency>\r
<groupId>org.jboss.resteasy</groupId>\r
return CollectionObjectProxy.class;
}
-
/**
* Roundtrip.
*
getLogger().debug("<<<<Roundtrip stop.");
return result;
}
-
- /**
- * Keyword search.
- *
- * @param keywords the keywords
- *
- * @see org.collectionspace.services.client.CollectionObjectProxy#keywordSearch()
- * @return the client response< collectionobjects common list>
- */
- /*
- public ClientResponse<CollectionobjectsCommonList> keywordSearch(String keywords) {
- return getProxy().keywordSearch(keywords);
- }
- *
- */
}
import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
* $LastChangedRevision: 1327 $
* $LastChangedDate: 2010-02-12 10:35:11 -0800 (Fri, 12 Feb 2010) $
*/
-public class CollectionObjectAuthRefsTest extends BaseServiceTest {
+public class CollectionObjectAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
@Override
protected CollectionSpaceClient getClientInstance() {
/** The organization authority name. */
final String ORG_AUTHORITY_NAME = "TestOrgAuth";
- /** The known resource id. */
- private String knownResourceId = null;
-
/** The collection object ids created. */
private List<String> collectionObjectIdsCreated = new ArrayList<String>();
/** The number of authority references expected. */
private final int NUM_AUTH_REFS_EXPECTED = 4;
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
- }
-
+
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
- public void createWithAuthRefs(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
-
+ @Test(dataProvider="testName")
+ public void createWithAuthRefs(String testName) throws Exception {
// Create all the person refs and entities
createPersonRefs();
// Submit the request to the service and store the response.
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
+ testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
ClientResponse<Response> res = collectionObjectClient.create(multipart);
-
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
+ String newCsid = null;
+ try {
+ assertStatusCode(res, testName);
+ newCsid = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
// Store the ID returned from the first resource created
// for additional tests below.
if (knownResourceId == null){
- knownResourceId = extractId(res);
+ knownResourceId = newCsid;
if (logger.isDebugEnabled()) {
logger.debug(testName + ": knownResourceId=" + knownResourceId);
}
ClientResponse<Response> res = personAuthClient.create(multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
personAuthCSID = extractId(res);
personAuthRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
return extractId(res);
}
ClientResponse<Response> res = orgAuthClient.create(multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
orgAuthCSID = extractId(res);
orgAuthRefName = OrgAuthorityClientUtils.getAuthorityRefName(orgAuthCSID, null);
ClientResponse<Response> res = orgAuthClient.createItem(orgAuthCSID, multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
return extractId(res);
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ @Test(dataProvider="testName",
dependsOnMethods = {"createWithAuthRefs"})
public void readAndCheckAuthRefs(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
testSetup(STATUS_OK, ServiceRequestType.READ);
-
- // Submit the request to the service and store the response.
+ //
+ // First read the object
+ //
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
ClientResponse<String> res = collectionObjectClient.read(knownResourceId);
- assertStatusCode(res, testName);
-
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- CollectionobjectsCommon collectionObject = (CollectionobjectsCommon) extractPart(input,
- collectionObjectClient.getCommonPartName(), CollectionobjectsCommon.class);
- Assert.assertNotNull(collectionObject);
-
- // Get all of the auth refs and check that the expected number is returned
+ CollectionobjectsCommon collectionObject = null;
+ try {
+ assertStatusCode(res, testName);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ collectionObject = (CollectionobjectsCommon) extractPart(input,
+ collectionObjectClient.getCommonPartName(), CollectionobjectsCommon.class);
+ Assert.assertNotNull(collectionObject);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
+ //
+ // Next, get all of the auth refs and check that the expected number is returned
+ //
ClientResponse<AuthorityRefList> res2 = collectionObjectClient.getAuthorityRefs(knownResourceId);
- assertStatusCode(res2, testName);
-
- AuthorityRefList list = res2.getEntity();
+ AuthorityRefList list = null;
+ try {
+ assertStatusCode(res2, testName);
+ list = res2.getEntity();
+ } finally {
+ if (res2 != null) {
+ res2.releaseConnection();
+ }
+ }
List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
int numAuthRefsFound = items.size();
import javax.ws.rs.core.Response;
import org.collectionspace.services.CollectionObjectJAXBSchema;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.CollectionObjectClient;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.client.ClientResponse;
* $LastChangedRevision: 1327 $ $LastChangedDate: 2010-02-12 10:35:11 -0800
* (Fri, 12 Feb 2010) $
*/
-public class CollectionObjectSearchTest extends BaseServiceTest {
+public class CollectionObjectSearchTest extends BaseServiceTest<AbstractCommonList> {
/** The logger. */
private final String CLASS_NAME = CollectionObjectSearchTest.class
protected CollectionSpaceClient getClientInstance() {
return new CollectionObjectClient();
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.collectionspace.services.client.test.BaseServiceTest#
- * getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
- }
-
+
/**
* Creates one or more resources containing a "noise" keyword, which should
* NOT be retrieved by keyword searches.
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, groups = { "advancedSearch" })
public void advancedSearch(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Create one or more keyword retrievable resources, each containing
// a specified keyword.
String theKeyword = KEYWORD + "COW";
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Verify that the number of resources matched by the search
// is identical to the expected result
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, groups = { "oneKeyword" })
public void searchWithOneKeyword(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Create one or more keyword retrievable resources, each containing
// a specified keyword.
long numKeywordRetrievableResources = (long) (numNoiseWordResources * pctNonNoiseWordResources);
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Verify that the number of resources matched by the search
// is identical to the expected result
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void searchWithTwoKeywordsInSameField(String testName)
throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Create one or more keyword retrievable resources, each containing
// two specified keywords.
long numKeywordRetrievableResources = (long) (numNoiseWordResources * pctNonNoiseWordResources);
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Verify that the number of resources matched by the search
// is identical to the expected result
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Verify that the number of resources matched by the search
// is identical to the expected result
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void searchWithTwoKeywordsAcrossTwoFields(String testName)
throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Create one or more keyword retrievable resources, each containing
// two specified keywords.
long numKeywordRetrievableResources = 5;
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Verify that the number of resources matched by the search
// is identical to the expected result
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Verify that the number of resources matched by the search
// is identical to the expected result
// }
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, groups = { "utf8" })
public void searchWithUTF8Keyword(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Create one or more keyword retrievable resources, each containing
// two specified keywords.
long numKeywordRetrievableResources = 2;
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Verify that the number of resources matched by the search
// is identical to the expected result
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void keywordSearchNonExistentKeyword(String testName)
throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Set the expected status code and group of valid status codes
testSetup(STATUS_OK, ServiceRequestType.SEARCH);
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Verify that the number of resources matched by the search
// is identical to the expected result
ClientResponse<Response> res = client.create(multipart);
try {
int statusCode = res.getStatus();
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
String id = extractId(res);
allResourceIdsCreated.add(id);
if (logger.isDebugEnabled()) {
import javax.ws.rs.core.Response;
//import org.collectionspace.services.client.AbstractServiceClientImpl;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.CollectionObjectClient;
import org.collectionspace.services.client.CollectionObjectFactory;
import org.collectionspace.services.client.CollectionSpaceClient;
-import org.collectionspace.services.client.PayloadInputPart;
import org.collectionspace.services.client.PayloadOutputPart;
-import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.collectionobject.BriefDescriptionList;
import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
import org.collectionspace.services.collectionobject.TitleGroupList;
import org.collectionspace.services.collectionobject.TitleTranslationSubGroup;
import org.collectionspace.services.collectionobject.TitleTranslationSubGroupList;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.client.ClientResponse;
* $LastChangedRevision$
* $LastChangedDate$
*/
-public class CollectionObjectServiceTest extends AbstractServiceTestImpl {
+public class CollectionObjectServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, CollectionobjectsCommon> {
/** The logger. */
private final String CLASS_NAME = CollectionObjectServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
- // Instance variables specific to this test.
- /** The known resource id. */
- private String knownResourceId = null;
-
private final String OBJECT_NAME_VALUE = "an object name";
private final BigInteger AGE_VALUE = new BigInteger("55");
private final String MEASURED_PART = "light box frame";
protected CollectionSpaceClient getClientInstance() {
return new CollectionObjectClient();
}
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
- }
-
+
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
+ // Expected success outcomes
+
+ /*
+ * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
+ * refer to this method in their @Test annotation declarations.
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // 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();
-
- // Submit the request to the service and store the response.
- CollectionObjectClient client = new CollectionObjectClient();
- String identifier = createIdentifier();
- PoxPayloadOut multipart =
- createCollectionObjectInstance(client.getCommonPartName(), identifier);
- ClientResponse<Response> res = client.create(multipart);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Store the ID returned from the first resource created
- // for additional tests below.
- if (knownResourceId == null) {
- knownResourceId = extractId(res);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
- }
-
- // Store the IDs from every resource created by tests,
- // so they can be deleted after tests have been run.
- allResourceIdsCreated.add(extractId(res));
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {
+ "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
+ public void CRUDTests(String testName) {
+ // Do nothing. Simply here to for a TestNG execution order for our tests
}
-
-
+
/*
* Tests to diagnose and verify the fixed status of CSPACE-1026,
* "Whitespace at certain points in payload cause failure"
*/
+
/**
* Creates the from xml cambridge.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void createFromXmlCambridge(String testName) throws Exception {
String newId =
createFromXmlFile(testName, "./test-data/testCambridge.xml", true);
// Verify that record creation occurs successfully when the first value instance
// of a single, repeatable String scalar field is non-blank.
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "testSubmitRequest"}, groups = {"cspace2242group"})
+ dependsOnMethods = {"CRUDTests"}, groups = {"cspace2242group"})
public void createFromXmlNonBlankFirstValueInstance(String testName) throws Exception {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
String newId =
createFromXmlFile(testName, "./test-data/cspace-2242-first-value-instance-nonblank.xml", true);
CollectionobjectsCommon collectionObject = readCollectionObjectCommonPart(newId);
// Verify that record creation occurs successfully when the first value instance
// of a single, repeatable String scalar field is blank.
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "testSubmitRequest"}, groups = {"cspace2242group"})
+ dependsOnMethods = {"CRUDTests"}, groups = {"cspace2242group"})
public void createFromXmlBlankFirstValueInstance(String testName) throws Exception {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
String newId =
createFromXmlFile(testName, "./test-data/cspace-2242-first-value-instance-blank.xml", true);
CollectionobjectsCommon collectionObject = readCollectionObjectCommonPart(newId);
// Verify that values are preserved when enclosed in double quote marks.
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "testSubmitRequest"}, groups = {"cspace3237group"})
+ dependsOnMethods = {"CRUDTests"}, groups = {"cspace3237group"})
public void doubleQuotesEnclosingFieldContents(String testName) throws Exception {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
String newId =
createFromXmlFile(testName, "./test-data/cspace-3237-double-quotes.xml", true);
CollectionobjectsCommon collectionObject = readCollectionObjectCommonPart(newId);
* @throws Exception the exception
*/
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
+ dependsOnMethods = {"CRUDTests"})
public void createFromXmlRFWS1(String testName) throws Exception {
String testDataDir = System.getProperty("test-data.fileName");
String newId =
* @throws Exception the exception
*/
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
+ dependsOnMethods = {"CRUDTests"})
public void createFromXmlRFWS2(String testName) throws Exception {
String testDataDir = System.getProperty("test-data.fileName");
String newId =
* @throws Exception the exception
*/
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
+ dependsOnMethods = {"CRUDTests"})
public void createFromXmlRFWS3(String testName) throws Exception {
String testDataDir = System.getProperty("test-data.fileName");
String newId =
* @throws Exception the exception
*/
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
+ dependsOnMethods = {"CRUDTests"})
public void createFromXmlRFWS4(String testName) throws Exception {
String testDataDir = System.getProperty("test-data.fileName");
String newId =
* @throws Exception the exception
*/
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
+ dependsOnMethods = {"CRUDTests"})
public void createWithNullValueRepeatableField(String testName) throws Exception {
String testDataDir = System.getProperty("test-data.fileName");
String newId =
* @throws Exception the exception
*/
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "testSubmitRequest"}, groups={"utf8-create"})
+ dependsOnMethods = {"CRUDTests"}, groups={"utf8-create"})
public void createWithUTF8Data(String testName) throws Exception {
String testDataDir = System.getProperty("test-data.fileName");
String newId =
Assert.assertTrue(distinguishingFeatures.equals(UTF8_DATA_SAMPLE));
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#createList()
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void createList(String testName) throws Exception {
- this.createPaginatedList(testName, DEFAULT_LIST_SIZE);
- }
-
// Failure outcomes
// Placeholders until the three tests below can be uncommented.
// See Issue CSPACE-401.
@Override
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void createWithMalformedXml(String testName) throws Exception {
+ //FIXME: Should this test really be empty?
}
/* (non-Javadoc)
*/
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void createWithRequiredValuesNullOrEmpty(String testName) throws Exception {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
// Build a payload with invalid content, by omitting a
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
// FIXME: Consider splitting off the following into its own test method.
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
-
}
-
-
- // ---------------------------------------------------------------
- // CRUD tests : READ tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- CollectionObjectClient client = new CollectionObjectClient();
- ClientResponse<String> res = client.read(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Extract the common part.
- CollectionobjectsCommon collectionobjectCommon = extractCommonPartValue(testName, res);
-
- // Verify the number and contents of values in repeatable fields,
- // as created in the instance record used for testing.
- MeasuredPartGroupList measuredPartGroupList = collectionobjectCommon.getMeasuredPartGroupList();
- Assert.assertNotNull(measuredPartGroupList, "Measured part group list was null");
- List<MeasuredPartGroup> measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
- Assert.assertNotNull(measuredPartGroups, "Measured part groups were null");
- Assert.assertTrue(measuredPartGroups.size() > 0, "No measured part groups were returned");
- MeasuredPartGroup mpGroup = measuredPartGroups.get(0);
- Assert.assertNotNull(mpGroup.getMeasuredPart(), "Measured part was null");
- Assert.assertEquals(mpGroup.getMeasuredPart(), MEASURED_PART,
- "Measured part value returned didn't match expected value");
-
- DimensionSubGroupList dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
- Assert.assertNotNull(dimensionSubGroupList, "Dimension subgroup list was null");
- List<DimensionSubGroup> dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
- Assert.assertNotNull(dimensionSubGroups, "Dimension subgroups were null");
- Assert.assertTrue(dimensionSubGroups.size() > 0, "No dimension subgroups were returned");
- DimensionSubGroup lengthDimension = dimensionSubGroups.get(0);
- Assert.assertNotNull(lengthDimension, "Length dimension was null");
- Assert.assertTrue(lengthDimension.getValue().compareTo(DIMENSION_VALUE_LENGTH) == 0,
- "Dimension length value returned didn't match expected value");
-
- /* No longer part of the "default" domain service tests for the CollectionObject record.
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": Reading Natural History part ...");
- }
-
- // Currently checking only that the natural history part is non-null;
- // can add specific field-level checks as warranted.
- Object conh = extractPartValue(testName, res, getNHPartName());
- Assert.assertNotNull(conh);
- */
- }
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void readNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- CollectionObjectClient client = new CollectionObjectClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : READ_LIST tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
- public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadList();
-
- // Submit the request to the service and store the response.
- CollectionObjectClient client = new CollectionObjectClient();
- ClientResponse<AbstractCommonList> res = client.readList();
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
-
- // Optionally output additional data about list members for debugging.
- // the expected response(s)?
- if(logger.isTraceEnabled()){
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
-
- }
-
- // Failure outcomes
- // None at present.
- // ---------------------------------------------------------------
- // CRUD tests : UPDATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void update(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
- // Read an existing resource that will be updated.
- ClientResponse<String> res = updateRetrieve(testName, knownResourceId);
-
- // Extract its common part.
- CollectionobjectsCommon collectionObjectCommon = extractCommonPartValue(testName, res);
-
- // Change the content of one or more fields in the common part.
-
- collectionObjectCommon.setObjectNumber("updated-" + collectionObjectCommon.getObjectNumber());
-
- // Change the object name in the first value instance in the
- // object name repeatable group.
- ObjectNameList objNameList = collectionObjectCommon.getObjectNameList();
- List<ObjectNameGroup> objNameGroups = objNameList.getObjectNameGroup();
- Assert.assertNotNull(objNameGroups);
- Assert.assertTrue(objNameGroups.size() >= 1);
- String objectName = objNameGroups.get(0).getObjectName();
- Assert.assertEquals(objectName, OBJECT_NAME_VALUE);
- String updatedObjectName = "updated-" + objectName;
- objNameGroups.get(0).setObjectName(updatedObjectName);
- collectionObjectCommon.setObjectNameList(objNameList);
-
- // Replace the existing value instances in the dimensions repeatable group
- // with entirely new value instances, also changing the number of such instances.
- MeasuredPartGroupList measuredPartGroupList = collectionObjectCommon.getMeasuredPartGroupList();
- Assert.assertNotNull(measuredPartGroupList);
- List<MeasuredPartGroup> measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
- Assert.assertNotNull(measuredPartGroups);
- Assert.assertTrue(measuredPartGroups.size() > 0);
- MeasuredPartGroup mpGroup = measuredPartGroups.get(0);
- Assert.assertNotNull(mpGroup.getMeasuredPart());
-
- DimensionSubGroupList dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
- Assert.assertNotNull(dimensionSubGroupList);
- List<DimensionSubGroup> dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
- Assert.assertNotNull(dimensionSubGroups);
- int originalDimensionSubGroupSize = dimensionSubGroups.size();
- Assert.assertTrue(dimensionSubGroups.size() > 0);
- dimensionSubGroups.clear();
-
- DimensionSubGroup heightDimension = new DimensionSubGroup();
- heightDimension.setDimension("height");
- heightDimension.setMeasurementUnit(UPDATED_MEASUREMENT_UNIT);
- dimensionSubGroups.add(heightDimension);
-
- int updatedDimensionGroupSize = dimensionSubGroups.size();
- Assert.assertTrue(updatedDimensionGroupSize > 0);
- Assert.assertTrue(updatedDimensionGroupSize != originalDimensionSubGroupSize);
-
- collectionObjectCommon.setMeasuredPartGroupList(measuredPartGroupList);
-
- if (logger.isDebugEnabled()) {
- logger.debug("sparse update that will be sent in update request:");
- logger.debug(objectAsXmlString(collectionObjectCommon,
- CollectionobjectsCommon.class));
- }
-
- // Send the changed resource to be updated and read the updated resource
- // from the response.
- res = updateSend(testName, knownResourceId, collectionObjectCommon);
-
- // Extract its common part.
- CollectionobjectsCommon updatedCollectionobjectCommon = extractCommonPartValue(testName, res);
-
- // Read the updated common part and verify that the resource was correctly updated.
- objNameList = updatedCollectionobjectCommon.getObjectNameList();
- Assert.assertNotNull(objNameList);
- objNameGroups = objNameList.getObjectNameGroup();
- Assert.assertNotNull(objNameGroups);
- Assert.assertTrue(objNameGroups.size() >= 1);
- Assert.assertEquals(updatedObjectName,
- objNameGroups.get(0).getObjectName(),
- "Data in updated object did not match submitted data.");
-
- measuredPartGroupList = collectionObjectCommon.getMeasuredPartGroupList();
- Assert.assertNotNull(measuredPartGroupList);
- measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
- Assert.assertNotNull(measuredPartGroups);
- Assert.assertTrue(measuredPartGroups.size() > 0);
- mpGroup = measuredPartGroups.get(0);
- Assert.assertNotNull(mpGroup.getMeasuredPart());
-
- dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
- Assert.assertNotNull(dimensionSubGroupList);
- dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
- Assert.assertNotNull(dimensionSubGroups);
- Assert.assertTrue(dimensionSubGroups.size() > 0);
- Assert.assertTrue(dimensionSubGroups.size() == updatedDimensionGroupSize);
- Assert.assertEquals(UPDATED_MEASUREMENT_UNIT,
- dimensionSubGroups.get(0).getMeasurementUnit(),
- "Data in updated object did not match submitted data.");
-
- }
-
/**
* Update retrieve.
*
if (logger.isDebugEnabled()) {
logger.debug(testName + ": read status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
if(logger.isDebugEnabled()){
logger.debug("got object to update with ID: " + knownResourceId);
}
if (logger.isDebugEnabled()) {
logger.debug(testName + ": read status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
return res;
}
*/
@Override
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+ dependsOnMethods = {"CRUDTests"})
public void updateWithEmptyEntityBody(String testName) throws Exception {
//FIXME: Should this test really be empty?
}
*/
@Override
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+ dependsOnMethods = {"CRUDTests"})
public void updateWithMalformedXml(String testName) throws Exception {
//FIXME: Should this test really be empty?
}
*/
@Override
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+ dependsOnMethods = {"CRUDTests"})
public void updateWithWrongXmlSchema(String testName) throws Exception {
//FIXME: Should this test really be empty?
}
}
*/
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
- */
-@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"update", "testSubmitRequest"})
+ @Override
public void updateNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupUpdateNonExistent();
// The only relevant ID may be the one used in updateCollectionObject(), below.
CollectionObjectClient client = new CollectionObjectClient();
PoxPayloadOut multipart =
- createCollectionObjectInstance(client.getCommonPartName(), NON_EXISTENT_ID);
+ createInstance(client.getCommonPartName(), NON_EXISTENT_ID);
ClientResponse<String> res = client.update(NON_EXISTENT_ID, multipart);
int statusCode = res.getStatus();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
/**
* @param testName The name of this test method. This name is supplied
* automatically, via reflection, by a TestNG 'data provider' in
* a base class.
- * @throws Exception
+ * @throws Exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void updateWithRequiredValuesNullOrEmpty(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Read an existing record for updating.
ClientResponse<String> res = updateRetrieve(testName, knownResourceId);
-
- // Extract its common part.
- CollectionobjectsCommon collectionObjectCommon = extractCommonPartValue(testName, res);
+ CollectionobjectsCommon collectionObjectCommon = null;
+ try {
+ // Extract its common part.
+ collectionObjectCommon = extractCommonPartValue(res);
+ } finally {
+ res.releaseConnection();
+ }
// Update the common part with invalid content, by setting a value to
// the empty String, in a field that requires a non-empty value,
// Submit the request to the service and store the response.
setupUpdate();
PoxPayloadOut output = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(collectionObjectCommon, MediaType.APPLICATION_XML_TYPE);
CollectionObjectClient client = new CollectionObjectClient();
- commonPart.setLabel(client.getCommonPartName());
+ output.addPart(client.getCommonPartName(), collectionObjectCommon);
res = client.update(knownResourceId, output);
- int statusCode = res.getStatus();
-
- // Read the response and verify that the update attempt failed.
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
-
+
+ try {
+ int statusCode = res.getStatus();
+ // Read the response and verify that the update attempt failed.
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+ } finally {
+ res.releaseConnection();
+ }
}
// ---------------------------------------------------------------
// CRUD tests : DELETE tests
// ---------------------------------------------------------------
// Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
- */
+
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- // Submit the request to the service and store the response.
- CollectionObjectClient client = new CollectionObjectClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ //
+ // Create an object to delete, save the current 'knownResourceId' since we don't want to delete it yet
+ // and temporarily set it to the csid of the resource we just created.
+ //
+ String tempCsid = knownResourceId;
+ // the super.delete() method uses the knownResourceId member
+ knownResourceId = newCollectionObject(true);
+
+ try {
+ super.delete(testName);
+ } finally {
+ // reset the 'knownResourceId'
+ knownResourceId = tempCsid;
+ }
}
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
- */
+ //
+ // Expected failure outcome tests
+ //
+
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"delete"})
public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupDeleteNonExistent();
// Submit the request to the service and store the response.
CollectionObjectClient client = new CollectionObjectClient();
ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ } finally {
+ res.releaseConnection();
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
}
// ---------------------------------------------------------------
// Utility tests : tests of code used in tests above
// ---------------------------------------------------------------
+
/**
* Tests the code for manually submitting data that is used by several
* of the methods above.
* @throws Exception
*/
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() throws Exception {
- testSubmitRequest(knownResourceId);
- }
-
- /**
- * Test submit request.
- *
- * @param resourceId the resource id
- * @throws Exception the exception
- */
- private void testSubmitRequest(String resourceId) throws Exception {
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(resourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testSubmitRequest: url=" + url
- + " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
- }
-
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
+
+ private ClientResponse<Response> newCollectionObject() {
+ ClientResponse<Response> result = null;
+
+ CollectionObjectClient client = new CollectionObjectClient();
+ String identifier = createIdentifier();
+ PoxPayloadOut multipart =
+ createInstance(client.getCommonPartName(), identifier);
+ result = client.create(multipart);
+
+ return result;
+ }
+
+ private String newCollectionObject(boolean assertStatus) {
+ String result = null;
+
+ ClientResponse<Response> res = newCollectionObject();
+ try {
+ int statusCode = res.getStatus();
+ Assert.assertEquals(statusCode, STATUS_CREATED);
+ result = extractId(res);
+ } finally {
+ res.releaseConnection();
+ }
+
+ return result;
+ }
+
+ @Override
+ protected PoxPayloadOut createInstance(String identifier) {
+ String commonPartName = CollectionObjectClient.SERVICE_COMMON_PART_NAME;
+ return createInstance(commonPartName, identifier);
+ }
+
/**
* Creates the collection object instance.
*
* @param identifier the identifier
* @return the multipart output
*/
- private PoxPayloadOut createCollectionObjectInstance(String commonPartName,
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
String identifier) {
return createCollectionObjectInstance(commonPartName,
"objectNumber-" + identifier,
"objectName-" + identifier);
}
-
- @Override
- protected PoxPayloadOut createInstance(String identifier) {
- String commonPartName = CollectionObjectClient.SERVICE_COMMON_PART_NAME;
- return createCollectionObjectInstance(commonPartName, identifier);
- }
/**
* Creates the collection object instance.
private PoxPayloadOut createCollectionObjectInstance(String commonPartName,
String objectNumber, String objectName) {
CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
-
+
// Scalar fields
collectionObject.setObjectNumber(objectNumber);
collectionObject.setAge(AGE_VALUE); //test for null string
-
+
// Repeatable structured groups
TitleGroupList titleGroupList = new TitleGroupList();
CollectionobjectsNaturalhistory.class));
}
}
+
return multipart;
-
}
/**
logger.debug(objectAsXmlString(collectionObject,
CollectionobjectsCommon.class));
}
+
return multipart;
-
}
/**
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
String newId = extractId(res);
allResourceIdsCreated.add(newId);
return newId;
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Extract the common part.
- CollectionobjectsCommon collectionObject = extractCommonPartValue(testName, res);
+ CollectionobjectsCommon collectionObject = extractCommonPartValue(res);
Assert.assertNotNull(collectionObject);
return collectionObject;
}
- private CollectionobjectsCommon extractCommonPartValue(String testName, ClientResponse<String> res)
- throws Exception {
- CollectionObjectClient client = new CollectionObjectClient();
- PayloadInputPart payloadInputPart = extractPart(testName, res, client.getCommonPartName());
- Object obj = null;
- if (payloadInputPart != null) {
- obj = payloadInputPart.getBody();
- }
- Assert.assertNotNull(obj,
- testName + ": body of " + client.getCommonPartName() + " part was unexpectedly null.");
- CollectionobjectsCommon collectionobjectCommon = (CollectionobjectsCommon) obj;
- Assert.assertNotNull(collectionobjectCommon,
- testName + ": " + client.getCommonPartName() + " part was unexpectedly null.");
- return collectionobjectCommon;
- }
-
-// private Object extractPartValue(String testName, ClientResponse<String> res, String partLabel)
-// throws Exception {
-// Object obj = null;
-// PayloadInputPart payloadInputPart = extractPart(testName, res, partLabel);
-// if (payloadInputPart != null) {
-// obj = payloadInputPart.getElementBody();
-// }
-// Assert.assertNotNull(obj,
-// testName + ": value of part " + partLabel + " was unexpectedly null.");
-// return obj;
-// }
-
- private PayloadInputPart extractPart(String testName, ClientResponse<String> res, String partLabel)
- throws Exception {
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": Reading part " + partLabel + " ...");
- }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PayloadInputPart payloadInputPart = input.getPart(partLabel);
- Assert.assertNotNull(payloadInputPart,
- testName + ": part " + partLabel + " was unexpectedly null.");
- return payloadInputPart;
- }
-
@Override
protected String getServicePathComponent() {
// TODO Auto-generated method stub
return CollectionObjectClient.SERVICE_PATH_COMPONENT;
}
+ @Override
+ protected CollectionobjectsCommon updateInstance(CollectionobjectsCommon collectionObjectCommon) {
+ collectionObjectCommon.setObjectNumber("updated-" + collectionObjectCommon.getObjectNumber());
+
+ // Change the object name in the first value instance in the
+ // object name repeatable group.
+ ObjectNameList objNameList = collectionObjectCommon.getObjectNameList();
+ List<ObjectNameGroup> objNameGroups = objNameList.getObjectNameGroup();
+ Assert.assertNotNull(objNameGroups);
+ Assert.assertTrue(objNameGroups.size() >= 1);
+ String objectName = objNameGroups.get(0).getObjectName();
+ Assert.assertEquals(objectName, OBJECT_NAME_VALUE);
+ String updatedObjectName = "updated-" + objectName;
+ objNameGroups.get(0).setObjectName(updatedObjectName);
+ collectionObjectCommon.setObjectNameList(objNameList);
+
+ // Replace the existing value instances in the dimensions repeatable group
+ // with entirely new value instances, also changing the number of such instances.
+ MeasuredPartGroupList measuredPartGroupList = collectionObjectCommon.getMeasuredPartGroupList();
+ Assert.assertNotNull(measuredPartGroupList);
+ List<MeasuredPartGroup> measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
+ Assert.assertNotNull(measuredPartGroups);
+ Assert.assertTrue(measuredPartGroups.size() > 0);
+ MeasuredPartGroup mpGroup = measuredPartGroups.get(0);
+ Assert.assertNotNull(mpGroup.getMeasuredPart());
+
+ DimensionSubGroupList dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
+ Assert.assertNotNull(dimensionSubGroupList);
+ List<DimensionSubGroup> dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
+ Assert.assertNotNull(dimensionSubGroups);
+ int originalDimensionSubGroupSize = dimensionSubGroups.size();
+ Assert.assertTrue(dimensionSubGroups.size() > 0);
+ dimensionSubGroups.clear();
+
+ DimensionSubGroup heightDimension = new DimensionSubGroup();
+ heightDimension.setDimension("height");
+ heightDimension.setMeasurementUnit(UPDATED_MEASUREMENT_UNIT);
+ dimensionSubGroups.add(heightDimension);
+
+ int updatedDimensionGroupSize = dimensionSubGroups.size();
+ Assert.assertTrue(updatedDimensionGroupSize > 0);
+ Assert.assertTrue(updatedDimensionGroupSize != originalDimensionSubGroupSize);
+
+ collectionObjectCommon.setMeasuredPartGroupList(measuredPartGroupList);
+
+ return collectionObjectCommon;
+ }
+
+ @Override
+ protected void compareReadInstances(CollectionobjectsCommon original,
+ CollectionobjectsCommon fromRead) throws Exception {
+ // Verify the number and contents of values in repeatable fields,
+ // as created in the instance record used for testing.
+ MeasuredPartGroupList measuredPartGroupList = fromRead.getMeasuredPartGroupList();
+ Assert.assertNotNull(measuredPartGroupList, "Measured part group list was null");
+ List<MeasuredPartGroup> measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
+ Assert.assertNotNull(measuredPartGroups, "Measured part groups were null");
+ Assert.assertTrue(measuredPartGroups.size() > 0, "No measured part groups were returned");
+ MeasuredPartGroup mpGroup = measuredPartGroups.get(0);
+ Assert.assertNotNull(mpGroup.getMeasuredPart(), "Measured part was null");
+ Assert.assertEquals(mpGroup.getMeasuredPart(), MEASURED_PART,
+ "Measured part value returned didn't match expected value");
+
+ DimensionSubGroupList dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
+ Assert.assertNotNull(dimensionSubGroupList, "Dimension subgroup list was null");
+ List<DimensionSubGroup> dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
+ Assert.assertNotNull(dimensionSubGroups, "Dimension subgroups were null");
+ Assert.assertTrue(dimensionSubGroups.size() > 0, "No dimension subgroups were returned");
+ DimensionSubGroup lengthDimension = dimensionSubGroups.get(0);
+ Assert.assertNotNull(lengthDimension, "Length dimension was null");
+ Assert.assertTrue(lengthDimension.getValue().compareTo(DIMENSION_VALUE_LENGTH) == 0,
+ "Dimension length value returned didn't match expected value");
+ }
+
+ @Override
+ protected void compareUpdatedInstances(CollectionobjectsCommon original,
+ CollectionobjectsCommon updated) throws Exception {
+
+ ObjectNameList objNameList = updated.getObjectNameList();
+ Assert.assertNotNull(objNameList);
+ List<ObjectNameGroup> objNameGroups = objNameList.getObjectNameGroup();
+ Assert.assertNotNull(objNameGroups);
+ Assert.assertTrue(objNameGroups.size() >= 1);
+ Assert.assertEquals(original.getObjectNameList().getObjectNameGroup().get(0).getObjectName(),
+ objNameGroups.get(0).getObjectName(),
+ "Data in updated object did not match submitted data.");
+ //
+ // Get the dimension group size of the original
+ //
+ MeasuredPartGroupList measuredPartGroupList = original.getMeasuredPartGroupList();
+ List<MeasuredPartGroup> measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
+ MeasuredPartGroup mpGroup = measuredPartGroups.get(0);
+ DimensionSubGroupList dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
+ List<DimensionSubGroup> dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
+ int updatedDimensionGroupSize = dimensionSubGroups.size();
+ //
+ // Now get the dimension group size of the updated
+ //
+ measuredPartGroupList = updated.getMeasuredPartGroupList();
+ Assert.assertNotNull(measuredPartGroupList);
+ measuredPartGroups = measuredPartGroupList.getMeasuredPartGroup();
+ Assert.assertNotNull(measuredPartGroups);
+ Assert.assertTrue(measuredPartGroups.size() > 0);
+ mpGroup = measuredPartGroups.get(0);
+ Assert.assertNotNull(mpGroup.getMeasuredPart());
+ dimensionSubGroupList = mpGroup.getDimensionSubGroupList();
+ Assert.assertNotNull(dimensionSubGroupList);
+ dimensionSubGroups = dimensionSubGroupList.getDimensionSubGroup();
+ Assert.assertNotNull(dimensionSubGroups);
+ Assert.assertTrue(dimensionSubGroups.size() == updatedDimensionGroupSize);
+
+ Assert.assertEquals(UPDATED_MEASUREMENT_UNIT,
+ dimensionSubGroups.get(0).getMeasurementUnit(),
+ "Data in updated object did not match submitted data.");
+ }
}
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
\r
<!-- apache -->\r
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
<scope>provided</scope>\r
</dependency>\r
</dependencies>\r
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
</dependencies>
import org.apache.commons.httpclient.methods.HeadMethod;
import org.apache.commons.httpclient.methods.OptionsMethod;
import org.apache.commons.httpclient.methods.TraceMethod;
+import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.TestServiceClient;
import org.slf4j.Logger;
logger.debug("Client properties read from the properties path;\n"
+ "possibly from the command line or a properties file:");
logger.debug("url = "
- + serviceClient.getProperty(serviceClient.URL_PROPERTY));
+ + serviceClient.getProperty(CollectionSpaceClient.URL_PROPERTY));
logger.debug("secure (SSL) = "
- + serviceClient.getProperty(serviceClient.SSL_PROPERTY));
+ + serviceClient.getProperty(CollectionSpaceClient.SSL_PROPERTY));
logger.debug("useAuth = "
- + serviceClient.getProperty(serviceClient.AUTH_PROPERTY));
+ + serviceClient.getProperty(CollectionSpaceClient.AUTH_PROPERTY));
logger.debug("user = "
- + serviceClient.getProperty(serviceClient.USER_PROPERTY));
+ + serviceClient.getProperty(CollectionSpaceClient.USER_PROPERTY));
logger.debug("password = "
- + serviceClient.getProperty(serviceClient.PASSWORD_PROPERTY));
+ + serviceClient.getProperty(CollectionSpaceClient.PASSWORD_PROPERTY));
}
}
public void servicesExist() {
if (logger.isDebugEnabled()) {
- logger.debug(BaseServiceTest.testBanner("servicesExist", CLASS_NAME));
+ logger.debug(BaseServiceTest.getTestBanner("servicesExist", CLASS_NAME));
}
//use ID service that should always be present in a working service layer
String url = serviceClient.getBaseURL() + "idgenerators";
@Test
public void methodNotAllowed() {
if (logger.isDebugEnabled()) {
- logger.debug(BaseServiceTest.testBanner("methodNotAllowed", CLASS_NAME));
+ logger.debug(BaseServiceTest.getTestBanner("methodNotAllowed", CLASS_NAME));
}
// Delete is not allowed on the root URL of the id service
String url = serviceClient.getBaseURL() + "idgenerators";
@Test
public void nonexistentService() {
if (logger.isDebugEnabled()) {
- logger.debug(BaseServiceTest.testBanner("nonexistentService", CLASS_NAME));
+ logger.debug(BaseServiceTest.getTestBanner("nonexistentService", CLASS_NAME));
}
String url = serviceClient.getBaseURL() + "nonexistent-service";
GetMethod method = new GetMethod(url);
// @Test
public void serviceSecure() {
if (logger.isDebugEnabled()) {
- logger.debug(BaseServiceTest.testBanner("serviceSecure", CLASS_NAME));
+ logger.debug(BaseServiceTest.getTestBanner("serviceSecure", CLASS_NAME));
}
String url = serviceClient.getBaseURL() + "collectionobjects";
GetMethod method = new GetMethod(url);
@Test
public void traceSupported() {
if (logger.isDebugEnabled()) {
- logger.debug(BaseServiceTest.testBanner("traceSupported", CLASS_NAME));
+ logger.debug(BaseServiceTest.getTestBanner("traceSupported", CLASS_NAME));
}
String url = serviceClient.getBaseURL() + "collectionobjects";
TraceMethod method = new TraceMethod(url);
@Test
public void headSupported() {
if (logger.isDebugEnabled()) {
- logger.debug(BaseServiceTest.testBanner("headSupported", CLASS_NAME));
+ logger.debug(BaseServiceTest.getTestBanner("headSupported", CLASS_NAME));
}
String url = serviceClient.getBaseURL() + "intakes";
HeadMethod method = new HeadMethod(url);
<tenant:TenantBindingConfig xmlns:tenant="http://collectionspace.org/services/common/tenant" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://collectionspace.org/services/common/tenant http://collectionspace.org/services/common/tenant.xsd">
<!-- begin prototype collectionspace.org tenant meta-data -->
- <tenant:tenantBinding id="-1" name="prototype.collectionspace.org" displayName="CollectionSpace Services Bindings Prototype" version="0.1">
- <tenant:repositoryDomain name="default-domain" storageName="prototype-domain" repositoryClient="nuxeo-java" />
- <tenant:properties>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>datePattern</types:key>
- <types:value>MM/dd/yyyy</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>datePattern</types:key>
- <types:value>MMM dd, yyyy</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>datePattern</types:key>
- <types:value>dd.MM.yyyy</types:value>
- </types:item>
+ <tenant:tenantBinding id="-1" name="prototype.collectionspace.org" displayName="CollectionSpace Services Bindings Prototype" version="0.1">
+ <tenant:repositoryDomain name="default-domain" storageName="prototype-domain" repositoryClient="nuxeo-java" />
+ <tenant:properties>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>datePattern</types:key>
+ <types:value>MM/dd/yyyy</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>datePattern</types:key>
+ <types:value>MMM dd, yyyy</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>datePattern</types:key>
+ <types:value>dd.MM.yyyy</types:value>
+ </types:item>
<!--
<types:item>
<types:key>datePattern</types:key>
<types:value>dd/MM/yyyy</types:value>
</types:item>
-->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>localeLanguage</types:key>
- <types:value>en</types:value>
- </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>localeLanguage</types:key>
+ <types:value>en</types:value>
+ </types:item>
<!--
<types:item>
<types:key>localeLanguage</types:key>
<types:value>da</types:value>
</types:item>
-->
- </tenant:properties>
+ </tenant:properties>
<!-- begin idgenerator service meta-data -->
- <tenant:serviceBindings id="idgenerators" name="idgenerators" type="utility" version="0.1">
+ <tenant:serviceBindings id="idgenerators" name="idgenerators" type="utility" version="0.1">
<!-- other URI paths through which this service could be accessed -->
- </tenant:serviceBindings>
- <!-- end idgenerator service meta-data -->
+ </tenant:serviceBindings>
+ <!-- end idgenerator service meta-data -->
- <!-- begin id service meta-data -->
- <tenant:serviceBindings id="id" name="id" type="utility" version="0.1">
+ <!-- begin id service meta-data -->
+ <tenant:serviceBindings id="id" name="id" type="utility" version="0.1">
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/idgenerators/*/ids
</service:uriPath>
-->
- </tenant:serviceBindings>
- <!-- end id service meta-data -->
+ </tenant:serviceBindings>
+ <!-- end id service meta-data -->
- <!-- begin collectionobject service meta-data -->
- <tenant:serviceBindings id="CollectionObjects" name="CollectionObjects" type="object" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/collectionobjects/*/workflow/</service:uriPath>
+ <!-- begin collectionobject service meta-data -->
+ <tenant:serviceBindings id="CollectionObjects" name="CollectionObjects" type="object" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/collectionobjects/*/workflow/</service:uriPath>
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
- /collectionobjects/*/authorityrefs/
+ /collectionobjects/*/authorityrefs/
</service:uriPath>
-->
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.collectionobject.nuxeo.CollectionObjectDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.blob.nuxeo.BlobDocumentModelHandler</service:classname>
- <service:params>
- <service:DublinCoreTitle>collectionobjects</service:DublinCoreTitle>
- <service:ListResultsItemMethodName>getCollectionObjectListItem</service:ListResultsItemMethodName>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>objectNumber</service:element>
- <service:xpath>objectNumber</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>objectName</service:element>
- <service:xpath>objectNameList/[0]/objectName</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>title</service:element>
- <service:xpath>titleGroupList/[0]/title</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>responsibleDepartment</service:element>
- <service:xpath>responsibleDepartments/[0]</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.collectionobject.nuxeo.CollectionObjectValidatorHandler</service:validatorHandler>
- <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.common.init.ModifyFieldDatatypes</service:classname>
- <service:params>
- <service:field>
- <service:table>collectionobjects_common_briefdescriptions</service:table>
- <service:col>item</service:col>
- <service:type>LARGETEXT</service:type>
- <service:param />
- </service:field>
- <service:field>
- <service:table>collectionobjects_common_comments</service:table>
- <service:col>item</service:col>
- <service:type>LARGETEXT</service:type>
- <service:param />
- </service:field>
- <service:field>
- <service:table>collectionobjects_common_objectproductionreasons</service:table>
- <service:col>item</service:col>
- <service:type>LARGETEXT</service:type>
- <service:param />
- </service:field>
- <service:field>
- <service:table>collectionobjects_common_ownersreferences</service:table>
- <service:col>item</service:col>
- <service:type>LARGETEXT</service:type>
- <service:param />
- </service:field>
- <service:field>
- <service:table>collectionobjects_common_viewersreferences</service:table>
- <service:col>item</service:col>
- <service:type>LARGETEXT</service:type>
- <service:param />
- </service:field>
- </service:params>
- </service:initHandler>
- <service:properties xmlns:service="http://collectionspace.org/services/common/service">
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNameProperty</types:key>
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.collectionobject.nuxeo.CollectionObjectDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.blob.nuxeo.BlobDocumentModelHandler</service:classname>
+ <service:params>
+ <service:DublinCoreTitle>collectionobjects</service:DublinCoreTitle>
+ <service:ListResultsItemMethodName>getCollectionObjectListItem</service:ListResultsItemMethodName>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>objectNumber</service:element>
+ <service:xpath>objectNumber</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>objectName</service:element>
+ <service:xpath>objectNameList/[0]/objectName</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>title</service:element>
+ <service:xpath>titleGroupList/[0]/title</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>responsibleDepartment</service:element>
+ <service:xpath>responsibleDepartments/[0]</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.collectionobject.nuxeo.CollectionObjectValidatorHandler</service:validatorHandler>
+ <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.common.init.ModifyFieldDatatypes</service:classname>
+ <service:params>
+ <service:field>
+ <service:table>collectionobjects_common_briefdescriptions</service:table>
+ <service:col>item</service:col>
+ <service:type>LARGETEXT</service:type>
+ <service:param />
+ </service:field>
+ <service:field>
+ <service:table>collectionobjects_common_comments</service:table>
+ <service:col>item</service:col>
+ <service:type>LARGETEXT</service:type>
+ <service:param />
+ </service:field>
+ <service:field>
+ <service:table>collectionobjects_common_objectproductionreasons</service:table>
+ <service:col>item</service:col>
+ <service:type>LARGETEXT</service:type>
+ <service:param />
+ </service:field>
+ <service:field>
+ <service:table>collectionobjects_common_ownersreferences</service:table>
+ <service:col>item</service:col>
+ <service:type>LARGETEXT</service:type>
+ <service:param />
+ </service:field>
+ <service:field>
+ <service:table>collectionobjects_common_viewersreferences</service:table>
+ <service:col>item</service:col>
+ <service:type>LARGETEXT</service:type>
+ <service:param />
+ </service:field>
+ </service:params>
+ </service:initHandler>
+ <service:properties xmlns:service="http://collectionspace.org/services/common/service">
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>objectNameProperty</types:key>
<types:value>objectNameList/[0]/objectName</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNumberProperty</types:key>
- <types:value>objectNumber</types:value>
- </types:item>
- </service:properties>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="CollectionObject" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="collectionobjects-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="collectionobjects_common" updated="" order="1">
- <service:properties>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>objectNumberProperty</types:key>
+ <types:value>objectNumber</types:value>
+ </types:item>
+ </service:properties>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="CollectionObject" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="collectionobjects-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="collectionobjects_common" updated="" order="1">
+ <service:properties>
<!-- Fields containing authority term references -->
<!-- Object Identification Information group -->
<!-- There are currently no authority term references in this group -->
<!-- Object Description Information group -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>contentActivities|contentActivity</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>contentConcepts|contentConcept</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>contentActivities|contentActivity</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>contentConcepts|contentConcept</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>contentEventNameGroupList/*/contentEventName</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>contentEventNameGroupList/*/contentEventNameType</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>contentOrganizations|contentOrganization</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>contentOtherGroupList/*/contentOther</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>contentOtherGroupList/*/contentOtherType</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>contentPeoples|contentPeople</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>contentPersons|contentPerson</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>contentPlaces|contentPlace</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>measuredPartGroupList/*/dimensionSubGroupList/*/measuredBy</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>textualInscriptionGroupList/*/inscriptionContentInscriber</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>textualInscriptionGroupList/*/inscriptionContentMethod</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>nonTextualInscriptionGroupList/*/inscriptionDescriptionInscriber</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>nonTextualInscriptionGroupList/*/inscriptionDescriptionMethod</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>materialGroupList/*/material</types:value>
- </types:item>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>materialGroupList/*/material</types:value>
+ </types:item>
<!-- The following field may become part of a repeatable sub-group -->
<!-- for materialComponent, per CSPACE-4563. -->
<!-- Names of ancestor elements below are placeholders and subject to change. -->
<!--
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>materialGroupList/*/materialComponentSubGroupList/*/materialComponent</types:value>
- </types:item>
+ </types:item>
-->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>materialGroupList/*/materialSource</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>materialGroupList/*/materialSource</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>styles|style</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>objectComponentGroupList/*/objectComponentName</types:value>
- </types:item>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>objectComponentGroupList/*/objectComponentName</types:value>
+ </types:item>
<!-- Object Production Information group -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>objectProductionOrganizationGroupList/*/objectProductionOrganization</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>objectProductionPeopleGroupList/*/objectProductionPeople</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>objectProductionPersonGroupList/*/objectProductionPerson</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>objectProductionOrganizationGroupList/*/objectProductionOrganization</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>objectProductionPeopleGroupList/*/objectProductionPeople</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>objectProductionPersonGroupList/*/objectProductionPerson</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>objectProductionPlaceGroupList/*/objectProductionPlace</types:value>
</types:item>
<types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>authRef</types:key>
- <types:value>techniqueGroupList/*/technique</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>techniqueGroupList/*/techniqueType</types:value>
- </types:item>
+ <types:value>techniqueGroupList/*/technique</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>techniqueGroupList/*/techniqueType</types:value>
+ </types:item>
<!-- Object History and Association Information group -->
<!-- The following fields may become part of a repeatable group -->
<!-- for associatedEvent, per CSPACE-3229. -->
<!-- Names of ancestor elements below are placeholders and subject to change. -->
<!--
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>assocEventGroupList/*/assocEventOrganization</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>assocEventGroupList/*/assocEventPeople</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>assocEventGroupList/*/assocEventPerson</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>assocEventGroupList/*/assocEventPlace</types:value>
- </types:item>
+ </types:item>
-->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>assocOrganizationGroupList/*/assocOrganization</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>assocPeopleGroupList/*/assocPeople</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>assocPersonGroupList/*/assocPerson</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>assocPlaceGroupList/*/assocPlace</types:value>
- </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>assocOrganizationGroupList/*/assocOrganization</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>assocPeopleGroupList/*/assocPeople</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>assocPersonGroupList/*/assocPerson</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>assocPlaceGroupList/*/assocPlace</types:value>
+ </types:item>
<!-- The following fields may become part of a repeatable group -->
<!-- for 'owner', per CSPACE-3229. -->
<!-- Names of ancestor elements below are placeholders and subject to change. -->
<!--
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>ownerGroupList/*/owner</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>ownerGroupList/*/ownershipPlace</types:value>
- </types:item>
+ </types:item>
-->
<!-- Object Owner's Contribution Information group -->
<!-- There are currently no authority term references in this group -->
<!-- Object Viewer's Contribution Information group -->
<!-- There are currently no authority term references in this group -->
<!-- Reference Information group -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>referenceGroupList/*/reference</types:value>
- </types:item>
+ </types:item>
<!-- Object Collection Information group -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>fieldCollectionPlace</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>fieldCollectionSources|fieldCollectionSource</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>fieldCollectors|fieldCollector</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>fieldColEventNames|fieldColEventName</types:value>
- </types:item>
+ </types:item>
<!-- ### -->
<!-- Fields containing term list / controlled vocabulary references -->
<!-- ### -->
<!-- Object Identification Information group -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>termRef</types:key>
<types:value>otherNumberList/*/numberType</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>objectNameList/*/objectNameCurrency</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>objectNameList/*/objectNameLevel</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>objectNameList/*/objectNameSystem</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>objectNameList/*/objectNameType</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>objectNameList/*/objectNameLanguage</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>responsibleDepartments|responsibleDepartment</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>responsibleDepartments|responsibleDepartment</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>collection</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>titleGroupList/*/titleLanguage</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>titleGroupList/*/titleTranslationSubGroupList/*/titleTranslationLanguage</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>titleGroupList/*/titleType</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>recordStatus</types:value>
- </types:item>
+ </types:item>
<!-- Object Description Information group -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>ageUnit</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>contentLanguages|contentLanguage</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>contentObjectGroupList/*/contentObjectType</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>contentPositions|contentPosition</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>contentScripts|contentScript</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>measuredPartGroupList/*/measuredPart</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>measuredPartGroupList/*/dimensionSubGroupList/*/dimension</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>measuredPartGroupList/*/dimensionSubGroupList/*/measurementUnit</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>measuredPartGroupList/*/dimensionSubGroupList/*/measurementMethod</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>forms|form</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>textualInscriptionGroupList/*/inscriptionContentLanguage</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>textualInscriptionGroupList/*/inscriptionContentPosition</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>textualInscriptionGroupList/*/inscriptionContentScript</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>textualInscriptionGroupList/*/inscriptionContentType</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>nonTextualInscriptionGroupList/*/inscriptionDescriptionPosition</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>nonTextualInscriptionGroupList/*/inscriptionDescriptionType</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>objectStatusList|objectStatus</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>phase</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>sex</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>technicalAttributeGroupList/*/technicalAttribute</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>technicalAttributeGroupList/*/technicalAttributeMeasurement</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>technicalAttributeGroupList/*/technicalAttributeMeasurementUnit</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>technicalAttributeGroupList/*/technicalAttribute</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>technicalAttributeGroupList/*/technicalAttributeMeasurement</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>technicalAttributeGroupList/*/technicalAttributeMeasurementUnit</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>objectComponentGroupList/*/objectComponentInformation</types:value>
- </types:item>
+ </types:item>
<!-- Object Production Information group -->
<!-- There are currently no term references in this group -->
<!-- Object History and Association Information group -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>assocActivityGroupList/*/assocActivity</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>assocConceptGroupList/*/assocConcept</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>assocCulturalContextGroupList/*/assocCulturalContext</types:value>
- </types:item>
+ </types:item>
<!-- The following fields may become part of a repeatable group -->
<!-- for associatedEvent, per CSPACE-3229. -->
<!-- Names of ancestor elements below are placeholders and subject to change. -->
<!--
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>assocEventGroupList/*/assocEventName</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>assocEventGroupList/*/assocEventNameType</types:value>
- </types:item>
- -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ -->
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>assocObjectGroupList/*/assocObject</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>assocObjectGroupList/*/assocObjectType</types:value>
- </types:item>
+ </types:item>
<!-- The following fields may become part of a repeatable group -->
<!-- for 'owner', per CSPACE-3229. -->
<!-- Names of ancestor elements below are placeholders and subject to change. -->
<!--
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>ownerGroupList/*/ownershipAccess</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>ownerGroupList/*/ownershipCategory</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>ownerGroupList/*/ownershipExchangeMethod</types:value>
- </types:item>
- -->
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>ownerGroupList/*/ownershipAccess</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>ownerGroupList/*/ownershipCategory</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>ownerGroupList/*/ownershipExchangeMethod</types:value>
+ </types:item>
+ -->
<types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>termRef</types:key>
<types:value>usageGroupList/*/usage</types:value>
<types:key>termRef</types:key>
<types:value>fieldCollectionMethods|fieldCollectionMethod</types:value>
</types:item>
- </service:properties>
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/collectionobject" schemaLocation="http://collectionspace.org/services/collectionobject http://services.collectionspace.org/collectionobject/collectionobjects_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!--end collectionobject service meta-data -->
+ </service:properties>
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/collectionobject" schemaLocation="http://collectionspace.org/services/collectionobject http://services.collectionspace.org/collectionobject/collectionobjects_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!--end collectionobject service meta-data -->
- <!-- begin blob service meta-data -->
- <!-- This should likely be type="object" -->
- <tenant:serviceBindings id="Blobs" name="Blobs" type="procedure" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/blobs/*/workflow/</service:uriPath>
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.blob.nuxeo.BlobDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>name</service:element>
- <service:xpath>name</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>mimeType</service:element>
- <service:xpath>mimeType</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>encoding</service:element>
- <service:xpath>encoding</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>length</service:element>
- <service:xpath>length</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.blob.nuxeo.BlobValidatorHandler</service:validatorHandler>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Blob" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="blob-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="blobs_common" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/blob" schemaLocation="http://collectionspace.org/services/blob http://services.collectionspace.org/blob/blobs_common.xsd" />
+ <!-- begin blob service meta-data -->
+ <!-- This should likely be type="object" -->
+ <tenant:serviceBindings id="Blobs" name="Blobs" type="procedure" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/blobs/*/workflow/</service:uriPath>
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.blob.nuxeo.BlobDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>name</service:element>
+ <service:xpath>name</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>mimeType</service:element>
+ <service:xpath>mimeType</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>encoding</service:element>
+ <service:xpath>encoding</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>length</service:element>
+ <service:xpath>length</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.blob.nuxeo.BlobValidatorHandler</service:validatorHandler>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Blob" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="blob-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="blobs_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/blob" schemaLocation="http://collectionspace.org/services/blob http://services.collectionspace.org/blob/blobs_common.xsd" />
<!-- The Blob service has at least one authRef field and two or more termRef fields -->
<!-- in its multivalued dimensionGroup. -->
<!-- If these require enumeration here, please see authRef and termRef declarations -->
<!-- in Media for relevant entries. -->
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- <service:part id="3" control_group="Managed" versionable="true" auditable="false" label="image_metadata" updated="" order="3">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/image_metadata/" schemaLocation="http://collectionspace.org/image_metadata/ http://services.collectionspace.org/image_metadata.xsd" />
- </service:content>
- </service:part>
- <service:part id="4" control_group="Managed" versionable="true" auditable="false" label="iptc" updated="" order="4">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/iptc/" schemaLocation="http://collectionspace.org/iptc/ http://services.collectionspace.org/iptc.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end blob service meta-data -->
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="3" control_group="Managed" versionable="true" auditable="false" label="image_metadata" updated="" order="3">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/image_metadata/" schemaLocation="http://collectionspace.org/image_metadata/ http://services.collectionspace.org/image_metadata.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="4" control_group="Managed" versionable="true" auditable="false" label="iptc" updated="" order="4">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/iptc/" schemaLocation="http://collectionspace.org/iptc/ http://services.collectionspace.org/iptc.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end blob service meta-data -->
- <!-- begin intake service meta-data -->
- <tenant:serviceBindings id="Intakes" name="Intakes" type="procedure" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/intakes/*/workflow/</service:uriPath>
+ <!-- begin intake service meta-data -->
+ <tenant:serviceBindings id="Intakes" name="Intakes" type="procedure" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/intakes/*/workflow/</service:uriPath>
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/intakes/*/authorityrefs/
</service:uriPath>
-->
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.intake.nuxeo.IntakeDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.group.nuxeo.IntakeDocumentModelHandler</service:classname>
- <service:params>
- <service:SchemaName>intakes</service:SchemaName>
- <service:DublinCoreTitle>intakes</service:DublinCoreTitle>
- <service:SummaryFields>entryNumber|depositor|currentOwner|uri|csid</service:SummaryFields>
- <service:AbstractCommonListClassname />
- <service:CommonListItemClassname />
- <service:ListResultsItemMethodName>getIntakeListItem</service:ListResultsItemMethodName>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>entryNumber</service:element>
- <service:xpath>entryNumber</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>depositor</service:element>
- <service:xpath>depositor</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>currentOwner</service:element>
- <service:xpath>currentOwner</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.intake.nuxeo.IntakeValidatorHandler</service:validatorHandler>
- <service:properties xmlns:service="http://collectionspace.org/services/common/service">
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.intake.nuxeo.IntakeDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.group.nuxeo.IntakeDocumentModelHandler</service:classname>
+ <service:params>
+ <service:SchemaName>intakes</service:SchemaName>
+ <service:DublinCoreTitle>intakes</service:DublinCoreTitle>
+ <service:SummaryFields> entryNumber|depositor|currentOwner|uri|csid</service:SummaryFields>
+ <service:AbstractCommonListClassname />
+ <service:CommonListItemClassname />
+ <service:ListResultsItemMethodName>getIntakeListItem</service:ListResultsItemMethodName>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>entryNumber</service:element>
+ <service:xpath>entryNumber</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>depositor</service:element>
+ <service:xpath>depositor</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>currentOwner</service:element>
+ <service:xpath>currentOwner</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.intake.nuxeo.IntakeValidatorHandler</service:validatorHandler>
+ <service:properties xmlns:service="http://collectionspace.org/services/common/service">
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>objectNameProperty</types:key>
<types:value>currentOwner</types:value>
</types:item>
<types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNumberProperty</types:key>
- <types:value>entryNumber</types:value>
- </types:item>
- </service:properties>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Intake" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="intakes-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="intakes_common" updated="" order="1">
- <service:properties>
+ <types:key>objectNumberProperty</types:key>
+ <types:value>entryNumber</types:value>
+ </types:item>
+ </service:properties>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Intake" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="intakes-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="intakes_common" updated="" order="1">
+ <service:properties>
<!-- Fields containing authority term references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>currentOwner</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>depositor</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>currentOwner</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>depositor</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>fieldCollectionPlace</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>fieldCollectionSources|fieldCollectionSource</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>fieldCollectors|fieldCollector</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>fieldCollectors|fieldCollector</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>fieldCollectionEventNames|fieldCollectionEventName</types:value>
</types:item>
<types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>authRef</types:key>
- <types:value>valuer</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>insurers|insurer</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ <types:value>valuer</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>insurers|insurer</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>currentLocationGroupList/*/currentLocation</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>normalLocation</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>conditionCheckersOrAssessors|conditionCheckerOrAssessor</types:value>
- </types:item>
+ </types:item>
<!-- Fields containing term list / controlled vocabulary references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>entryMethods|entryMethod</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>entryReason</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>fieldCollectionMethods|fieldCollectionMethod</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>entryMethods|entryMethod</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>entryReason</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>fieldCollectionMethods|fieldCollectionMethod</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>currentLocationGroupList/*/currentLocationFitness</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>conditionCheckMethods|conditionCheckMethod</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>conditionCheckReasons|conditionCheckReason</types:value>
- </types:item>
- </service:properties>
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/intake" schemaLocation="http://collectionspace.org/services/intake http://services.collectionspace.org/intake/intakes_common.xsd" />
- </service:content>
- </service:part>
- <!-- BEGIN Laramie for new collectionspace_core -->
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- <!-- END Laramie for new collectionspace_core -->
- </service:object>
- </tenant:serviceBindings>
- <!-- end intake service meta-data -->
+ </types:item>
+ </service:properties>
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/intake" schemaLocation="http://collectionspace.org/services/intake http://services.collectionspace.org/intake/intakes_common.xsd" />
+ </service:content>
+ </service:part>
+ <!-- BEGIN Laramie for new collectionspace_core -->
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ <!-- END Laramie for new collectionspace_core -->
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end intake service meta-data -->
- <!-- begin loanin service meta-data -->
- <tenant:serviceBindings id="Loansin" name="Loansin" type="procedure" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/loansin/*/workflow/</service:uriPath>
+ <!-- begin loanin service meta-data -->
+ <tenant:serviceBindings id="Loansin" name="Loansin" type="procedure" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/loansin/*/workflow/</service:uriPath>
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/loansin/*/authorityrefs/
</service:uriPath>
-->
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.loanin.nuxeo.LoaninDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.loanin.nuxeo.LoaninDocumentModelHandler</service:classname>
- <service:params>
- <service:SchemaName>loansin</service:SchemaName>
- <service:DublinCoreTitle>loansin</service:DublinCoreTitle>
- <service:SummaryFields>loanInNumber|lenderList|loanReturnDate|uri|csid</service:SummaryFields>
- <service:AbstractCommonListClassname />
- <service:CommonListItemClassname />
- <service:ListResultsItemMethodName>getLoaninListItem</service:ListResultsItemMethodName>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>loanInNumber</service:element>
- <service:xpath>loanInNumber</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>lender</service:element>
- <service:xpath>lenderGroupList/[0]/lender</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>loanReturnDate</service:element>
- <service:xpath>loanReturnDate</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.loanin.nuxeo.LoaninValidatorHandler</service:validatorHandler>
- <!-- This block is likely cruft; see CSPACE-4475 -->
- <s:initHandler xmlns:s="http://collectionspace.org/services/common/service">
- <s:classname>org.collectionspace.services.common.init.InitHandler</s:classname>
- <s:params>
- <s:field>
- <s:table>mytable</s:table>
- <s:col>mycol</s:col>
- <s:type>mytpe</s:type>
- <s:param>myparam, myparamB</s:param>
- </s:field>
- <s:field>
- <s:table>mytable2</s:table>
- <s:col>mycol2</s:col>
- <s:type>mytpe2</s:type>
- <s:param>myparam, myparam2B</s:param>
- </s:field>
- <s:property>
- <s:key>my key</s:key>
- <s:value>my value</s:value>
- </s:property>
- <s:property>
- <s:key>my key 2</s:key>
- <s:value>my value 2</s:value>
- </s:property>
- </s:params>
- </s:initHandler>
- <!-- This tenant:properties block is likely cruft; see CSPACE-4475 -->
- <tenant:properties>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>datePattern</types:key>
- <types:value>MMM dd, yyyy</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>datePattern</types:key>
- <types:value>dd.MM.yyyy</types:value>
- </types:item>
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.loanin.nuxeo.LoaninDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.loanin.nuxeo.LoaninDocumentModelHandler</service:classname>
+ <service:params>
+ <service:SchemaName>loansin</service:SchemaName>
+ <service:DublinCoreTitle>loansin</service:DublinCoreTitle>
+ <service:SummaryFields>loanInNumber|lenderList|loanReturnDate|uri|csid</service:SummaryFields>
+ <service:AbstractCommonListClassname />
+ <service:CommonListItemClassname />
+ <service:ListResultsItemMethodName>getLoaninListItem</service:ListResultsItemMethodName>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>loanInNumber</service:element>
+ <service:xpath>loanInNumber</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>lender</service:element>
+ <service:xpath>lenderGroupList/[0]/lender</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>loanReturnDate</service:element>
+ <service:xpath>loanReturnDate</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.loanin.nuxeo.LoaninValidatorHandler</service:validatorHandler>
+ <!-- This block is likely cruft; see CSPACE-4475 -->
+ <s:initHandler xmlns:s="http://collectionspace.org/services/common/service">
+ <s:classname>org.collectionspace.services.common.init.InitHandler</s:classname>
+ <s:params>
+ <s:field>
+ <s:table>mytable</s:table>
+ <s:col>mycol</s:col>
+ <s:type>mytpe</s:type>
+ <s:param>myparam, myparamB</s:param>
+ </s:field>
+ <s:field>
+ <s:table>mytable2</s:table>
+ <s:col>mycol2</s:col>
+ <s:type>mytpe2</s:type>
+ <s:param>myparam, myparam2B</s:param>
+ </s:field>
+ <s:property>
+ <s:key>my key</s:key>
+ <s:value>my value</s:value>
+ </s:property>
+ <s:property>
+ <s:key>my key 2</s:key>
+ <s:value>my value 2</s:value>
+ </s:property>
+ </s:params>
+ </s:initHandler>
+ <!-- This tenant:properties block is likely cruft; see CSPACE-4475 -->
+ <tenant:properties>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>datePattern</types:key>
+ <types:value>MMM dd, yyyy</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>datePattern</types:key>
+ <types:value>dd.MM.yyyy</types:value>
+ </types:item>
<!--
<types:item>
<types:key>datePattern</types:key>
<types:value>dd/MM/yyyy</types:value>
</types:item>
-->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>localeLanguage</types:key>
- <types:value>en</types:value>
- </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>localeLanguage</types:key>
+ <types:value>en</types:value>
+ </types:item>
<!--
<types:item>
<types:key>localeLanguage</types:key>
<types:value>da</types:value>
</types:item>
-->
- </tenant:properties>
- <service:properties xmlns:service="http://collectionspace.org/services/common/service">
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ </tenant:properties>
+ <service:properties xmlns:service="http://collectionspace.org/services/common/service">
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>objectNameProperty</types:key>
<types:value>lenderGroupList/[0]/lender</types:value>
</types:item>
<types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNumberProperty</types:key>
- <types:value>loanInNumber</types:value>
- </types:item>
- </service:properties>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Loanin" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="loansin-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="loansin_common" updated="" order="1">
- <service:properties>
+ <types:key>objectNumberProperty</types:key>
+ <types:value>loanInNumber</types:value>
+ </types:item>
+ </service:properties>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Loanin" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="loansin-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="loansin_common" updated="" order="1">
+ <service:properties>
<!-- Fields containing authority term references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>lenderGroupList/*/lender</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>lenderGroupList/*/lendersAuthorizer</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>lenderGroupList/*/lendersContact</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>borrowersAuthorizer</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>borrowersContact</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>loanInContact</types:value>
- </types:item>
+ </types:item>
<!-- Fields containing term list / controlled vocabulary references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>termRef</types:key>
<types:value>loanPurpose</types:value>
</types:item>
<types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>termRef</types:key>
- <types:value>loanStatusGroupList/*/loanStatus</types:value>
- </types:item>
- </service:properties>
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/loanin" schemaLocation="http://collectionspace.org/services/loanin http://services.collectionspace.org/loanin/loansin_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end loanin service meta-data -->
+ <types:value>loanStatusGroupList/*/loanStatus</types:value>
+ </types:item>
+ </service:properties>
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/loanin" schemaLocation="http://collectionspace.org/services/loanin http://services.collectionspace.org/loanin/loansin_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end loanin service meta-data -->
- <!-- begin loanout service meta-data -->
- <tenant:serviceBindings id="Loansout" name="Loansout" type="procedure" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/loansout/*/workflow/</service:uriPath>
+ <!-- begin loanout service meta-data -->
+ <tenant:serviceBindings id="Loansout" name="Loansout" type="procedure" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/loansout/*/workflow/</service:uriPath>
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/loansout/*/authorityrefs/
</service:uriPath>
-->
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.loanout.nuxeo.LoanoutDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>loanOutNumber</service:element>
- <service:xpath>loanOutNumber</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>borrower</service:element>
- <service:xpath>borrower</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>loanReturnDate</service:element>
- <service:xpath>loanReturnDate</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.loanout.nuxeo.LoanoutValidatorHandler</service:validatorHandler>
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.loanout.nuxeo.LoanoutDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>loanOutNumber</service:element>
+ <service:xpath>loanOutNumber</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>borrower</service:element>
+ <service:xpath>borrower</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>loanReturnDate</service:element>
+ <service:xpath>loanReturnDate</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.loanout.nuxeo.LoanoutValidatorHandler</service:validatorHandler>
<service:properties xmlns:service="http://collectionspace.org/services/common/service">
<types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>objectNameProperty</types:key>
<types:value>loanOutNumber</types:value>
</types:item>
</service:properties>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Loanout" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="loansout-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="loansout_common" updated="" order="1">
- <service:properties>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Loanout" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="loansout-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="loansout_common" updated="" order="1">
+ <service:properties>
<!-- Fields containing authority term references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>borrower</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>borrowersContact</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>lendersAuthorizer</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>lendersContact</types:value>
- </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>borrower</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>borrowersContact</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>lendersAuthorizer</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>lendersContact</types:value>
+ </types:item>
<!-- Fields containing term list / controlled vocabulary references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>loanPurpose</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>loanStatusGroupList/*/loanStatus</types:value>
- </types:item>
- </service:properties>
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/loanout" schemaLocation="http://collectionspace.org/services/loanout http://services.collectionspace.org/loanout/loansout_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end loanout service meta-data -->
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>loanPurpose</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>loanStatusGroupList/*/loanStatus</types:value>
+ </types:item>
+ </service:properties>
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/loanout" schemaLocation="http://collectionspace.org/services/loanout http://services.collectionspace.org/loanout/loansout_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end loanout service meta-data -->
- <!-- begin objectexit service meta-data -->
- <tenant:serviceBindings id="ObjectExit" name="ObjectExit" type="procedure" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/objectexit/*/workflow/</service:uriPath>
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.objectexit.nuxeo.ObjectExitDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.objectexit.nuxeo.ObjectExitDocumentModelHandler</service:classname>
- <service:params>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>exitNumber</service:element>
- <service:xpath>exitNumber</service:xpath>
- <service:setter>setExitNumber</service:setter>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>currentOwner</service:element>
- <service:xpath>currentOwner</service:xpath>
- <service:setter>setCurrentOwner</service:setter>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.objectexit.nuxeo.ObjectExitValidatorHandler</service:validatorHandler>
- <service:properties xmlns:service="http://collectionspace.org/services/common/service">
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNameProperty</types:key>
- <types:value>currentOwner</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNumberProperty</types:key>
- <types:value>exitNumber</types:value>
- </types:item>
- </service:properties>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="ObjectExit" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="objectexit-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="objectexit_common" updated="" order="1">
- <service:properties>
+ <!-- begin objectexit service meta-data -->
+ <tenant:serviceBindings id="ObjectExit" name="ObjectExit" type="procedure" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/objectexit/*/workflow/</service:uriPath>
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.objectexit.nuxeo.ObjectExitDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.objectexit.nuxeo.ObjectExitDocumentModelHandler</service:classname>
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>exitNumber</service:element>
+ <service:xpath>exitNumber</service:xpath>
+ <service:setter>setExitNumber</service:setter>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>currentOwner</service:element>
+ <service:xpath>currentOwner</service:xpath>
+ <service:setter>setCurrentOwner</service:setter>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.objectexit.nuxeo.ObjectExitValidatorHandler</service:validatorHandler>
+ <service:properties xmlns:service="http://collectionspace.org/services/common/service">
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>objectNameProperty</types:key>
+ <types:value>currentOwner</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>objectNumberProperty</types:key>
+ <types:value>exitNumber</types:value>
+ </types:item>
+ </service:properties>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="ObjectExit" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="objectexit-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="objectexit_common" updated="" order="1">
+ <service:properties>
<!-- Fields containing authority term references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>currentOwner</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>depositor</types:value>
- </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>currentOwner</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>depositor</types:value>
+ </types:item>
<!-- Fields containing term list / controlled vocabulary references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>exitMethods|exitMethod</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>exitReason</types:value>
- </types:item>
- </service:properties>
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/objectexit" schemaLocation="http://collectionspace.org/services/objectexit http://services.collectionspace.org/objectexit/objectexit_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end objectexit service meta-data -->
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>exitMethods|exitMethod</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>exitReason</types:value>
+ </types:item>
+ </service:properties>
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/objectexit" schemaLocation="http://collectionspace.org/services/objectexit http://services.collectionspace.org/objectexit/objectexit_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end objectexit service meta-data -->
- <!-- begin batch service meta-data -->
- <tenant:serviceBindings id="Batch" name="Batch" type="procedure" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/batch/*/workflow/</service:uriPath>
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.batch.nuxeo.BatchDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>name</service:element>
- <service:xpath>name</service:xpath>
- <service:setter>setName</service:setter>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.batch.nuxeo.BatchValidatorHandler</service:validatorHandler>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Batch" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="batch-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="batch_common" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/batch" schemaLocation="http://collectionspace.org/services/batch http://services.collectionspace.org/batch/batch_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end batch service meta-data -->
+ <!-- begin batch service meta-data -->
+ <tenant:serviceBindings id="Batch" name="Batch" type="procedure" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/batch/*/workflow/</service:uriPath>
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.batch.nuxeo.BatchDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>name</service:element>
+ <service:xpath>name</service:xpath>
+ <service:setter>setName</service:setter>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.batch.nuxeo.BatchValidatorHandler</service:validatorHandler>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Batch" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="batch-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="batch_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/batch" schemaLocation="http://collectionspace.org/services/batch http://services.collectionspace.org/batch/batch_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end batch service meta-data -->
- <!-- begin group service meta-data -->
- <tenant:serviceBindings id="Groups" name="Groups" type="procedure" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/groups/*/workflow/</service:uriPath>
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.group.nuxeo.GroupDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>title</service:element>
- <service:xpath>title</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.group.nuxeo.GroupValidatorHandler</service:validatorHandler>
- <service:properties xmlns:service="http://collectionspace.org/services/common/service">
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNameProperty</types:key>
- <types:value>title</types:value>
- </types:item>
- </service:properties>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Group" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="group-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="groups_common" updated="" order="1">
- <service:properties>
+ <!-- begin group service meta-data -->
+ <tenant:serviceBindings id="Groups" name="Groups" type="procedure" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/groups/*/workflow/</service:uriPath>
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.group.nuxeo.GroupDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>title</service:element>
+ <service:xpath>title</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.group.nuxeo.GroupValidatorHandler</service:validatorHandler>
+ <service:properties xmlns:service="http://collectionspace.org/services/common/service">
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>objectNameProperty</types:key>
+ <types:value>title</types:value>
+ </types:item>
+ </service:properties>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Group" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="group-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="groups_common" updated="" order="1">
+ <service:properties>
<!-- Fields containing authority term references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>owner</types:value>
- </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>owner</types:value>
+ </types:item>
<!-- Fields containing term list / controlled vocabulary references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>responsibleDepartment</types:value>
- </types:item>
- </service:properties>
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/group" schemaLocation="http://collectionspace.org/services/group http://services.collectionspace.org/group/groups_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end group service meta-data -->
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>responsibleDepartment</types:value>
+ </types:item>
+ </service:properties>
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/group" schemaLocation="http://collectionspace.org/services/group http://services.collectionspace.org/group/groups_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end group service meta-data -->
- <!-- begin imports service meta-data -->
- <tenant:serviceBindings id="Imports" name="Imports" type="procedure" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/imports/*/workflow/</service:uriPath>
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.imports.nuxeo.ImportsDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.imports.nuxeo.ImportsDocumentModelHandler</service:classname>
- <service:params>
- <service:SchemaName>imports</service:SchemaName>
- <service:DublinCoreTitle>imports</service:DublinCoreTitle>
- <service:SummaryFields>importsField|uri|csid</service:SummaryFields>
- <service:AbstractCommonListClassname>org.collectionspace.services.imports.ImportsCommonList</service:AbstractCommonListClassname>
- <service:CommonListItemClassname>org.collectionspace.services.imports.ImportsCommonList$ImportsListItem</service:CommonListItemClassname>
- <service:ListResultsItemMethodName>getImportsListItem</service:ListResultsItemMethodName>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>importsField</service:element>
- <service:xpath>importsField</service:xpath>
- <service:setter>setImportsField</service:setter>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Imports" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="imports-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="imports_common" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/imports" schemaLocation="http://collectionspace.org/services/imports http://services.collectionspace.org/imports/imports_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end imports service meta-data -->
+ <!-- begin imports service meta-data -->
+ <tenant:serviceBindings id="Imports" name="Imports" type="procedure" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/imports/*/workflow/</service:uriPath>
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.imports.nuxeo.ImportsDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.imports.nuxeo.ImportsDocumentModelHandler</service:classname>
+ <service:params>
+ <service:SchemaName>imports</service:SchemaName>
+ <service:DublinCoreTitle>imports</service:DublinCoreTitle>
+ <service:SummaryFields>importsField|uri|csid</service:SummaryFields>
+ <service:AbstractCommonListClassname>org.collectionspace.services.imports.ImportsCommonList</service:AbstractCommonListClassname>
+ <service:CommonListItemClassname>org.collectionspace.services.imports.ImportsCommonList$ImportsListItem</service:CommonListItemClassname>
+ <service:ListResultsItemMethodName>getImportsListItem</service:ListResultsItemMethodName>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>importsField</service:element>
+ <service:xpath>importsField</service:xpath>
+ <service:setter>setImportsField</service:setter>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Imports" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="imports-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="imports_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/imports" schemaLocation="http://collectionspace.org/services/imports http://services.collectionspace.org/imports/imports_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end imports service meta-data -->
- <!-- begin media service meta-data -->
- <!-- This should likely be type="object" -->
- <tenant:serviceBindings id="Media" name="Media" type="procedure" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/media/*/workflow/</service:uriPath>
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.media.nuxeo.MediaDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>title</service:element>
- <service:xpath>title</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>source</service:element>
- <service:xpath>source</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>filename</service:element>
- <service:xpath>filename</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>identificationNumber</service:element>
- <service:xpath>identificationNumber</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>blobCsid</service:element>
- <service:xpath>blobCsid</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.media.nuxeo.MediaValidatorHandler</service:validatorHandler>
+ <!-- begin media service meta-data -->
+ <!-- This should likely be type="object" -->
+ <tenant:serviceBindings id="Media" name="Media" type="procedure" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/media/*/workflow/</service:uriPath>
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.media.nuxeo.MediaDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>title</service:element>
+ <service:xpath>title</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>source</service:element>
+ <service:xpath>source</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>filename</service:element>
+ <service:xpath>filename</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>identificationNumber</service:element>
+ <service:xpath>identificationNumber</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>blobCsid</service:element>
+ <service:xpath>blobCsid</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.media.nuxeo.MediaValidatorHandler</service:validatorHandler>
<service:properties xmlns:service="http://collectionspace.org/services/common/service">
<types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>objectNameProperty</types:key>
<types:value>identificationNumber</types:value>
</types:item>
</service:properties>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Media" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="media-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="media_common" updated="" order="1">
- <service:properties>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Media" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="media-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="media_common" updated="" order="1">
+ <service:properties>
<!-- Fields containing authority term references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>contributor</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>coverage</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>creator</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>publisher</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>rightsHolder</types:value>
- </types:item>
- <!-- Subject Authority field -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>subjectList|subject</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>measuredPartGroupList/*/dimensionSubGroupList/*/measuredBy</types:value>
- </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>contributor</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>coverage</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>creator</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>publisher</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>rightsHolder</types:value>
+ </types:item>
+ <!-- Subject Authority field -->
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>subjectList|subject</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>measuredPartGroupList/*/dimensionSubGroupList/*/measuredBy</types:value>
+ </types:item>
<!-- Fields containing term list / controlled vocabulary references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>languageList|language</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>typeList|type</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>languageList|language</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>typeList|type</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>measuredPartGroupList/*/dimensionSubGroupList/*/dimension</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>measuredPartGroupList/*/dimensionSubGroupList/*/measurementUnit</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>measuredPartGroupList/*/dimensionSubGroupList/*/measurementMethod</types:value>
- </types:item>
- </service:properties>
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/media" schemaLocation="http://collectionspace.org/services/media http://services.collectionspace.org/media/media_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end media service meta-data -->
+ </types:item>
+ </service:properties>
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/media" schemaLocation="http://collectionspace.org/services/media http://services.collectionspace.org/media/media_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end media service meta-data -->
- <!-- begin movement service meta-data -->
- <tenant:serviceBindings id="Movements" name="Movements" type="procedure" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/movements/*/workflow/</service:uriPath>
+ <!-- begin movement service meta-data -->
+ <tenant:serviceBindings id="Movements" name="Movements" type="procedure" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/movements/*/workflow/</service:uriPath>
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/movements/*/authorityrefs/
</service:uriPath>
-->
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.movement.nuxeo.MovementDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>movementReferenceNumber</service:element>
- <service:xpath>movementReferenceNumber</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>currentLocation</service:element>
- <service:xpath>currentLocation</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>locationDate</service:element>
- <service:xpath>locationDate</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.movement.nuxeo.MovementValidatorHandler</service:validatorHandler>
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.movement.nuxeo.MovementDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>movementReferenceNumber</service:element>
+ <service:xpath>movementReferenceNumber</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>currentLocation</service:element>
+ <service:xpath>currentLocation</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>locationDate</service:element>
+ <service:xpath>locationDate</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.movement.nuxeo.MovementValidatorHandler</service:validatorHandler>
<service:properties xmlns:service="http://collectionspace.org/services/common/service">
<types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>objectNameProperty</types:key>
<types:value>movementReferenceNumber</types:value>
</types:item>
</service:properties>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Movement" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="movements-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="movements_common" updated="" order="1">
- <service:properties>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Movement" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="movements-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="movements_common" updated="" order="1">
+ <service:properties>
<!-- See CSPACE-4474 for possible additional authRef and termRef entries -->
<!-- Fields containing authority term references -->
<!-- Object Location Information group -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>currentLocation</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>normalLocation</types:value>
- </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>currentLocation</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>normalLocation</types:value>
+ </types:item>
<!-- Movement Information group -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>movementContact</types:value>
- </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>movementContact</types:value>
+ </types:item>
<!-- Fields containing term list / controlled vocabulary references -->
<!-- Object Location Information group -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>currentLocationFitness</types:value>
- </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>currentLocationFitness</types:value>
+ </types:item>
<!-- Movement Information group -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>movementMethods|movementMethod</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>reasonForMove</types:value>
- </types:item>
- </service:properties>
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/movement" schemaLocation="http://collectionspace.org/services/movement http://services.collectionspace.org/movement/movements_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end movement service meta-data -->
+ </types:item>
+ </service:properties>
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/movement" schemaLocation="http://collectionspace.org/services/movement http://services.collectionspace.org/movement/movements_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end movement service meta-data -->
- <!-- begin Workflow service meta-data -->
- <tenant:serviceBindings id="Workflow" name="Workflow" type="procedure" version="0.1">
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.common.workflow.service.nuxeo.WorkflowDocumentModelHandler</service:documentHandler>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.workflow.nuxeo.WorkflowValidatorHandler</service:validatorHandler>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Workflow" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="workflow-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="workflow_common" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/workflow" schemaLocation="http://collectionspace.org/services/workflow http://services.collectionspace.org/movement/workflow_common.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end Workflow service meta-data -->
+ <!-- begin Workflow service meta-data -->
+ <tenant:serviceBindings id="Workflow" name="Workflow" type="procedure" version="0.1">
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.common.workflow.service.nuxeo.WorkflowDocumentModelHandler</service:documentHandler>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.workflow.nuxeo.WorkflowValidatorHandler</service:validatorHandler>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Workflow" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="workflow-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="workflow_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/workflow" schemaLocation="http://collectionspace.org/services/workflow http://services.collectionspace.org/movement/workflow_common.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end Workflow service meta-data -->
- <!-- begin report service meta-data -->
- <tenant:serviceBindings id="Reports" name="Reports" type="procedure" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/reports/*/workflow/</service:uriPath>
+ <!-- begin report service meta-data -->
+ <tenant:serviceBindings id="Reports" name="Reports" type="procedure" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/reports/*/workflow/</service:uriPath>
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/reports/*/output/
</service:uriPath>-->
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.report.nuxeo.ReportDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>name</service:element>
- <service:xpath>name</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.report.nuxeo.ReportValidatorHandler</service:validatorHandler>
- <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.report.nuxeo.ReportPostInitHandler</service:classname>
- <service:params>
- <service:property>
- <service:key>readerRoleName</service:key>
- <service:value>reader</service:value>
- </service:property>
- </service:params>
- </service:initHandler>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Report" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="reports-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="reports_common" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/report" schemaLocation="http://collectionspace.org/services/report http://services.collectionspace.org/report/reports_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end report service meta-data -->
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.report.nuxeo.ReportDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>name</service:element>
+ <service:xpath>name</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.report.nuxeo.ReportValidatorHandler</service:validatorHandler>
+ <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.report.nuxeo.ReportPostInitHandler</service:classname>
+ <service:params>
+ <service:property>
+ <service:key>readerRoleName</service:key>
+ <service:value>reader</service:value>
+ </service:property>
+ </service:params>
+ </service:initHandler>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Report" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="reports-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="reports_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/report" schemaLocation="http://collectionspace.org/services/report http://services.collectionspace.org/report/reports_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end report service meta-data -->
- <!-- begin vocabulary service meta-data -->
- <tenant:serviceBindings id="Vocabularies" name="Vocabularies" type="utility" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/vocabularies/*/workflow/</service:uriPath>
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/vocabularies/*/items/*/workflow/</service:uriPath>
+ <!-- begin vocabulary service meta-data -->
+ <tenant:serviceBindings id="Vocabularies" name="Vocabularies" type="utility" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/vocabularies/*/workflow/</service:uriPath>
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/vocabularies/*/items/*/workflow/</service:uriPath>
<!-- other URI paths through which this service could be accessed -->
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.vocabulary.nuxeo.VocabularyDocumentModelHandler</service:documentHandler>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.vocabulary.nuxeo.VocabularyValidatorHandler</service:validatorHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>displayName</service:element>
- <service:xpath>displayName</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>refName</service:element>
- <service:xpath>refName</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>shortIdentifier</service:element>
- <service:xpath>shortIdentifier</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>vocabType</service:element>
- <service:xpath>vocabType</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
- <service:params>
- <service:field>
- <service:table>vocabularies_common</service:table>
- <service:col>displayname</service:col>
- </service:field>
- <service:field>
- <service:table>vocabularies_common</service:table>
- <service:col>shortidentifier</service:col>
- </service:field>
- </service:params>
- </service:initHandler>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Vocabulary" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="vocabularies-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="vocabularies_common" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/vocabulary" schemaLocation="http://collectionspace.org/services/vocabulary http://services.collectionspace.org/vocabulary/vocabularies_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end vocabulary service meta-data -->
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.vocabulary.nuxeo.VocabularyDocumentModelHandler</service:documentHandler>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.vocabulary.nuxeo.VocabularyValidatorHandler</service:validatorHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>displayName</service:element>
+ <service:xpath>displayName</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>refName</service:element>
+ <service:xpath>refName</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>shortIdentifier</service:element>
+ <service:xpath>shortIdentifier</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>vocabType</service:element>
+ <service:xpath>vocabType</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
+ <service:params>
+ <service:field>
+ <service:table>vocabularies_common</service:table>
+ <service:col>displayname</service:col>
+ </service:field>
+ <service:field>
+ <service:table>vocabularies_common</service:table>
+ <service:col>shortidentifier</service:col>
+ </service:field>
+ </service:params>
+ </service:initHandler>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Vocabulary" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="vocabularies-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="vocabularies_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/vocabulary" schemaLocation="http://collectionspace.org/services/vocabulary http://services.collectionspace.org/vocabulary/vocabularies_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end vocabulary service meta-data -->
- <!-- begin vocabularyitem service meta-data.
+ <!-- begin vocabularyitem service meta-data.
Note there is no Vocabularyitem service, but there is a
Repository workspace so we have to configure that.
-->
- <tenant:serviceBindings id="Vocabularyitems" name="Vocabularyitems" type="authority" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/vocabularyitems/*/workflow/</service:uriPath>
+ <tenant:serviceBindings id="Vocabularyitems" name="Vocabularyitems" type="authority" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/vocabularyitems/*/workflow/</service:uriPath>
<!-- other URI paths through which this service could be accessed -->
- <!--
- <service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
+ <!--
+ <service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/vocabularies/*/items/
</service:uriPath>
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/vocabularies/*/items/*/refObjs
</service:uriPath>
- -->
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.vocabulary.nuxeo.VocabularyItemDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <!-- Omit the standard AuthorityItem items (they are handled by the code) -->
- <service:ListResultField>
- <service:element>order</service:element>
- <service:xpath>order</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.vocabulary.nuxeo.VocabularyItemValidatorHandler</service:validatorHandler>
- <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
- <service:params>
- <service:field>
- <service:table>vocabularyitems_common</service:table>
- <service:col>inauthority</service:col>
- </service:field>
- <service:field>
- <service:table>vocabularyitems_common</service:table>
- <service:col>displayname</service:col>
- </service:field>
- <service:field>
- <service:table>vocabularyitems_common</service:table>
- <service:col>shortidentifier</service:col>
- </service:field>
- </service:params>
- </service:initHandler>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Vocabularyitem" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="vocabularyitems-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="vocabularyitems_common" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/vocabulary" schemaLocation="http://collectionspace.org/services/vocabulary http://services.collectionspace.org/vocabulary/vocabularyitems_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end vocabulary service meta-data -->
+ -->
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.vocabulary.nuxeo.VocabularyItemDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <!-- Omit the standard AuthorityItem items (they are handled by the code) -->
+ <service:ListResultField>
+ <service:element>order</service:element>
+ <service:xpath>order</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.vocabulary.nuxeo.VocabularyItemValidatorHandler</service:validatorHandler>
+ <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
+ <service:params>
+ <service:field>
+ <service:table>vocabularyitems_common</service:table>
+ <service:col>inauthority</service:col>
+ </service:field>
+ <service:field>
+ <service:table>vocabularyitems_common</service:table>
+ <service:col>displayname</service:col>
+ </service:field>
+ <service:field>
+ <service:table>vocabularyitems_common</service:table>
+ <service:col>shortidentifier</service:col>
+ </service:field>
+ </service:params>
+ </service:initHandler>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Vocabularyitem" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="vocabularyitems-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="vocabularyitems_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/vocabulary" schemaLocation="http://collectionspace.org/services/vocabulary http://services.collectionspace.org/vocabulary/vocabularyitems_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end vocabulary service meta-data -->
- <!-- begin orgauthority service meta-data -->
- <tenant:serviceBindings id="Orgauthorities" name="Orgauthorities" type="utility" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/orgauthorities/*/workflow/</service:uriPath>
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/orgauthorities/*/items/*/workflow/</service:uriPath>
+ <!-- begin orgauthority service meta-data -->
+ <tenant:serviceBindings id="Orgauthorities" name="Orgauthorities" type="utility" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/orgauthorities/*/workflow/</service:uriPath>
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/orgauthorities/*/items/*/workflow/</service:uriPath>
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/orgauthorities/*/items/*/authorityrefs/
</service:uriPath>
-->
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.organization.nuxeo.OrgAuthorityDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>displayName</service:element>
- <service:xpath>displayName</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>refName</service:element>
- <service:xpath>refName</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>shortIdentifier</service:element>
- <service:xpath>shortIdentifier</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>vocabType</service:element>
- <service:xpath>vocabType</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.organization.nuxeo.OrgAuthorityValidatorHandler</service:validatorHandler>
- <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
- <service:params>
- <service:field>
- <service:table>orgauthorities_common</service:table>
- <service:col>displayname</service:col>
- </service:field>
- <service:field>
- <service:table>orgauthorities_common</service:table>
- <service:col>shortidentifier</service:col>
- </service:field>
- </service:params>
- </service:initHandler>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" id="1" name="Orgauthority" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="orgauthorities-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="orgauthorities_common" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/organization" schemaLocation="http://collectionspace.org/services/organization http://services.collectionspace.org/organization/orgauthorities_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end orgauthority service meta-data -->
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.organization.nuxeo.OrgAuthorityDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>displayName</service:element>
+ <service:xpath>displayName</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>refName</service:element>
+ <service:xpath>refName</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>shortIdentifier</service:element>
+ <service:xpath>shortIdentifier</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>vocabType</service:element>
+ <service:xpath>vocabType</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.organization.nuxeo.OrgAuthorityValidatorHandler</service:validatorHandler>
+ <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
+ <service:params>
+ <service:field>
+ <service:table>orgauthorities_common</service:table>
+ <service:col>displayname</service:col>
+ </service:field>
+ <service:field>
+ <service:table>orgauthorities_common</service:table>
+ <service:col>shortidentifier</service:col>
+ </service:field>
+ </service:params>
+ </service:initHandler>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" id="1" name="Orgauthority" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="orgauthorities-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="orgauthorities_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/organization" schemaLocation="http://collectionspace.org/services/organization http://services.collectionspace.org/organization/orgauthorities_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end orgauthority service meta-data -->
- <!-- begin organization service meta-data.
+ <!-- begin organization service meta-data.
Note there is no Organization service, but there is a
Repository workspace so we have to configure that.
-->
- <tenant:serviceBindings id="Organizations" name="Organizations" type="authority" version="0.1">
+ <tenant:serviceBindings id="Organizations" name="Organizations" type="authority" version="0.1">
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/orgauthorities/*/items/*/refObjs
</service:uriPath>
-->
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.organization.nuxeo.OrganizationDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <!-- Omit the standard AuthorityItem items (they are handled by the code) -->
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.organization.nuxeo.OrganizationValidatorHandler</service:validatorHandler>
- <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
- <service:params>
- <service:field>
- <service:table>organizations_common</service:table>
- <service:col>inauthority</service:col>
- </service:field>
- <service:field>
- <service:table>organizations_common</service:table>
- <service:col>displayname</service:col>
- </service:field>
- <service:field>
- <service:table>organizations_common</service:table>
- <service:col>shortidentifier</service:col>
- </service:field>
- </service:params>
- </service:initHandler>
- <service:properties xmlns:service="http://collectionspace.org/services/common/service">
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNameProperty</types:key>
- <types:value>displayName</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNumberProperty</types:key>
- <types:value>shortIdentifier</types:value>
- </types:item>
- </service:properties>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" id="1" name="Organization" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="organizations-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="organizations_common" updated="" order="1">
- <service:properties>
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.organization.nuxeo.OrganizationDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <!-- Omit the standard AuthorityItem items (they are handled by the code) -->
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.organization.nuxeo.OrganizationValidatorHandler</service:validatorHandler>
+ <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
+ <service:params>
+ <service:field>
+ <service:table>organizations_common</service:table>
+ <service:col>inauthority</service:col>
+ </service:field>
+ <service:field>
+ <service:table>organizations_common</service:table>
+ <service:col>displayname</service:col>
+ </service:field>
+ <service:field>
+ <service:table>organizations_common</service:table>
+ <service:col>shortidentifier</service:col>
+ </service:field>
+ </service:params>
+ </service:initHandler>
+ <service:properties xmlns:service="http://collectionspace.org/services/common/service">
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>objectNameProperty</types:key>
+ <types:value>displayName</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>objectNumberProperty</types:key>
+ <types:value>shortIdentifier</types:value>
+ </types:item>
+ </service:properties>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" id="1" name="Organization" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="organizations-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="organizations_common" updated="" order="1">
+ <service:properties>
<!-- See CSPACE-3939 for potential additional authRef and termRef entries -->
<!-- Fields containing authority term references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>contactNames|contactName</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>foundingPlace</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>groups|group</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>functions|function</types:value>
- </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>contactNames|contactName</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>foundingPlace</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>groups|group</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>functions|function</types:value>
+ </types:item>
<!-- Organization's subBody field was removed here from the authRef list -->
<!-- per anticipated work on CSPACE-4685.-->
<!-- Fields containing term list / controlled vocabulary references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>termStatus</types:value>
- </types:item>
- </service:properties>
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/organization" schemaLocation="http://collectionspace.org/services/organization http://services.collectionspace.org/organization/organizations_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end organization service meta-data -->
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>termStatus</types:value>
+ </types:item>
+ </service:properties>
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/organization" schemaLocation="http://collectionspace.org/services/organization http://services.collectionspace.org/organization/organizations_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end organization service meta-data -->
- <!-- begin personauthority service meta-data -->
- <tenant:serviceBindings id="Personauthorities" name="Personauthorities" type="utility" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/personauthorities/*/workflow/</service:uriPath>
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/personauthorities/*/items/*/workflow/</service:uriPath>
+ <!-- begin personauthority service meta-data -->
+ <tenant:serviceBindings id="Personauthorities" name="Personauthorities" type="utility" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/personauthorities/*/workflow/</service:uriPath>
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/personauthorities/*/items/*/workflow/</service:uriPath>
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/personauthorities/*/items/*/refObjs
</service:uriPath>
-->
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.person.nuxeo.PersonAuthorityDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>displayName</service:element>
- <service:xpath>displayName</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>refName</service:element>
- <service:xpath>refName</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>shortIdentifier</service:element>
- <service:xpath>shortIdentifier</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>vocabType</service:element>
- <service:xpath>vocabType</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.person.nuxeo.PersonAuthorityValidatorHandler</service:validatorHandler>
- <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
- <service:params>
- <service:field>
- <service:table>personauthorities_common</service:table>
- <service:col>displayname</service:col>
- </service:field>
- <service:field>
- <service:table>personauthorities_common</service:table>
- <service:col>shortidentifier</service:col>
- </service:field>
- </service:params>
- </service:initHandler>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" id="1" name="Personauthority" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="personauthorities-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="personauthorities_common" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/person" schemaLocation="http://collectionspace.org/services/person http://services.collectionspace.org/person/personauthorities_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end personauthority service meta-data -->
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.person.nuxeo.PersonAuthorityDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>displayName</service:element>
+ <service:xpath>displayName</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>refName</service:element>
+ <service:xpath>refName</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>shortIdentifier</service:element>
+ <service:xpath>shortIdentifier</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>vocabType</service:element>
+ <service:xpath>vocabType</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.person.nuxeo.PersonAuthorityValidatorHandler</service:validatorHandler>
+ <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
+ <service:params>
+ <service:field>
+ <service:table>personauthorities_common</service:table>
+ <service:col>displayname</service:col>
+ </service:field>
+ <service:field>
+ <service:table>personauthorities_common</service:table>
+ <service:col>shortidentifier</service:col>
+ </service:field>
+ </service:params>
+ </service:initHandler>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" id="1" name="Personauthority" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="personauthorities-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="personauthorities_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/person" schemaLocation="http://collectionspace.org/services/person http://services.collectionspace.org/person/personauthorities_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end personauthority service meta-data -->
- <!-- begin person service meta-data.
+ <!-- begin person service meta-data.
Note there is no Person service, but there is a
Repository workspace so we have to configure that.
-->
- <tenant:serviceBindings id="Persons" name="Persons" type="authority" version="0.1">
+ <tenant:serviceBindings id="Persons" name="Persons" type="authority" version="0.1">
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/personauthorities/*/items/
</service:uriPath>
-->
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.person.nuxeo.PersonDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <!-- Omit the standard AuthorityItem items (they are handled by the code) -->
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.person.nuxeo.PersonValidatorHandler</service:validatorHandler>
- <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
- <service:params>
- <service:field>
- <service:table>persons_common</service:table>
- <service:col>inauthority</service:col>
- </service:field>
- <service:field>
- <service:table>persons_common</service:table>
- <service:col>displayname</service:col>
- </service:field>
- <service:field>
- <service:table>persons_common</service:table>
- <service:col>shortidentifier</service:col>
- </service:field>
- </service:params>
- </service:initHandler>
- <service:properties xmlns:service="http://collectionspace.org/services/common/service">
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNameProperty</types:key>
- <types:value>displayName</types:value>
- </types:item>
- <!-- there is no objectNumberProperty for persons -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNumberProperty</types:key>
- <types:value>shortIdentifier</types:value>
- </types:item>
- </service:properties>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" id="1" name="Person" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="persons-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="persons_common" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/person" schemaLocation="http://collectionspace.org/services/person http://services.collectionspace.org/person/persons_common.xsd" />
- </service:content>
- <service:properties>
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.person.nuxeo.PersonDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <!-- Omit the standard AuthorityItem items (they are handled by the code) -->
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.person.nuxeo.PersonValidatorHandler</service:validatorHandler>
+ <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
+ <service:params>
+ <service:field>
+ <service:table>persons_common</service:table>
+ <service:col>inauthority</service:col>
+ </service:field>
+ <service:field>
+ <service:table>persons_common</service:table>
+ <service:col>displayname</service:col>
+ </service:field>
+ <service:field>
+ <service:table>persons_common</service:table>
+ <service:col>shortidentifier</service:col>
+ </service:field>
+ </service:params>
+ </service:initHandler>
+ <service:properties xmlns:service="http://collectionspace.org/services/common/service">
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>objectNameProperty</types:key>
+ <types:value>displayName</types:value>
+ </types:item>
+ <!-- there is no objectNumberProperty for persons -->
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>objectNumberProperty</types:key>
+ <types:value>shortIdentifier</types:value>
+ </types:item>
+ </service:properties>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" id="1" name="Person" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="persons-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="persons_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/person" schemaLocation="http://collectionspace.org/services/person http://services.collectionspace.org/person/persons_common.xsd" />
+ </service:content>
+ <service:properties>
<!-- See CSPACE-3938 for potential additional authRef and termRef entries -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>birthPlace</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>deathPlace</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>groups|group</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>nationalities|nationality</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>occupations|occupation</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>schoolsOrStyles|schoolOrStyle</types:value>
- </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>birthPlace</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>deathPlace</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>groups|group</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>nationalities|nationality</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>occupations|occupation</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>schoolsOrStyles|schoolOrStyle</types:value>
+ </types:item>
<!-- Fields containing term list / controlled vocabulary references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>termRef</types:key>
- <types:value>salutation</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:value>salutation</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>termRef</types:key>
- <types:value>title</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:value>title</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>termRef</types:key>
- <types:value>gender</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:value>gender</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>termRef</types:key>
<types:value>termStatus</types:value>
- </types:item>
- </service:properties>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end person service meta-data -->
+ </types:item>
+ </service:properties>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end person service meta-data -->
- <!-- begin locationauthority service meta-data -->
- <tenant:serviceBindings id="Locationauthorities" name="Locationauthorities" type="utility" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/locationauthorities/*/workflow/</service:uriPath>
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/locationauthorities/*/items/*/workflow/</service:uriPath>
+ <!-- begin locationauthority service meta-data -->
+ <tenant:serviceBindings id="Locationauthorities" name="Locationauthorities" type="utility" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/locationauthorities/*/workflow/</service:uriPath>
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/locationauthorities/*/items/*/workflow/</service:uriPath>
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/locationauthorities/*/items/
</service:uriPath>
-->
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.location.nuxeo.LocationAuthorityDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>displayName</service:element>
- <service:xpath>displayName</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>refName</service:element>
- <service:xpath>refName</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>shortIdentifier</service:element>
- <service:xpath>shortIdentifier</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>vocabType</service:element>
- <service:xpath>vocabType</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
- <service:params>
- <service:field>
- <service:table>locationauthorities_common</service:table>
- <service:col>displayname</service:col>
- </service:field>
- <service:field>
- <service:table>locationauthorities_common</service:table>
- <service:col>shortidentifier</service:col>
- </service:field>
- </service:params>
- </service:initHandler>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" id="1" name="Locationauthority" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="locationauthorities-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="locationauthorities_common" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/location" schemaLocation="http://collectionspace.org/services/location http://services.collectionspace.org/location/locationauthorities_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end locationauthority service meta-data -->
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.location.nuxeo.LocationAuthorityDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>displayName</service:element>
+ <service:xpath>displayName</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>refName</service:element>
+ <service:xpath>refName</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>shortIdentifier</service:element>
+ <service:xpath>shortIdentifier</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>vocabType</service:element>
+ <service:xpath>vocabType</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
+ <service:params>
+ <service:field>
+ <service:table>locationauthorities_common</service:table>
+ <service:col>displayname</service:col>
+ </service:field>
+ <service:field>
+ <service:table>locationauthorities_common</service:table>
+ <service:col>shortidentifier</service:col>
+ </service:field>
+ </service:params>
+ </service:initHandler>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" id="1" name="Locationauthority" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="locationauthorities-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="locationauthorities_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/location" schemaLocation="http://collectionspace.org/services/location http://services.collectionspace.org/location/locationauthorities_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end locationauthority service meta-data -->
- <!-- begin location service meta-data.
+ <!-- begin location service meta-data.
Note there is no Location service, but there is a
Repository workspace so we have to configure that.
-->
- <tenant:serviceBindings id="Locations" name="Locations" type="authority" version="0.1">
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.location.nuxeo.LocationDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <!-- Omit the standard AuthorityItem items (they are handled by the code) -->
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.location.nuxeo.LocationValidatorHandler</service:validatorHandler>
- <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
- <service:params>
- <service:field>
- <service:table>locations_common</service:table>
- <service:col>inauthority</service:col>
- </service:field>
- <service:field>
- <service:table>locations_common</service:table>
- <service:col>displayname</service:col>
- </service:field>
- <service:field>
- <service:table>locations_common</service:table>
- <service:col>shortidentifier</service:col>
- </service:field>
- </service:params>
- </service:initHandler>
- <service:properties xmlns:service="http://collectionspace.org/services/common/service">
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNameProperty</types:key>
- <types:value>displayName</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNumberProperty</types:key>
- <types:value>shortIdentifier</types:value>
- </types:item>
- </service:properties>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" id="1" name="Locationitem" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="locations-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="locations_common" updated="" order="1">
- <service:properties xmlns:service="http://collectionspace.org/services/common/service">
+ <tenant:serviceBindings id="Locations" name="Locations" type="authority" version="0.1">
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.location.nuxeo.LocationDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <!-- Omit the standard AuthorityItem items (they are handled by the code) -->
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.location.nuxeo.LocationValidatorHandler</service:validatorHandler>
+ <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
+ <service:params>
+ <service:field>
+ <service:table>locations_common</service:table>
+ <service:col>inauthority</service:col>
+ </service:field>
+ <service:field>
+ <service:table>locations_common</service:table>
+ <service:col>displayname</service:col>
+ </service:field>
+ <service:field>
+ <service:table>locations_common</service:table>
+ <service:col>shortidentifier</service:col>
+ </service:field>
+ </service:params>
+ </service:initHandler>
+ <service:properties xmlns:service="http://collectionspace.org/services/common/service">
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>objectNameProperty</types:key>
+ <types:value>displayName</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>objectNumberProperty</types:key>
+ <types:value>shortIdentifier</types:value>
+ </types:item>
+ </service:properties>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" id="1" name="Locationitem" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="locations-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="locations_common" updated="" order="1">
+ <service:properties xmlns:service="http://collectionspace.org/services/common/service">
<!-- Fields containing term list / controlled vocabulary references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>locationType</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>termStatus</types:value>
- </types:item>
+ </types:item>
</service:properties>
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/location" schemaLocation="http://collectionspace.org/services/location http://services.collectionspace.org/location/locations_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end location service meta-data -->
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/location" schemaLocation="http://collectionspace.org/services/location http://services.collectionspace.org/location/locations_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end location service meta-data -->
- <!-- begin taxonomyauthority service meta-data -->
- <tenant:serviceBindings id="Taxonomyauthority" name="Taxonomyauthority" type="utility" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/taxonomyauthority/*/workflow/</service:uriPath>
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/taxonomyauthority/*/items/*/workflow/</service:uriPath>
+ <!-- begin taxonomyauthority service meta-data -->
+ <tenant:serviceBindings id="Taxonomyauthority" name="Taxonomyauthority" type="utility" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/taxonomyauthority/*/workflow/</service:uriPath>
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/taxonomyauthority/*/items/*/workflow/</service:uriPath>
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/taxonomyauthority/*/items/
</service:uriPath>
-->
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.taxonomy.nuxeo.TaxonomyAuthorityDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>displayName</service:element>
- <service:xpath>displayName</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>refName</service:element>
- <service:xpath>refName</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>shortIdentifier</service:element>
- <service:xpath>shortIdentifier</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>vocabType</service:element>
- <service:xpath>vocabType</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
- <service:params>
- <service:field>
- <service:table>taxonomyauthority_common</service:table>
- <service:col>displayname</service:col>
- </service:field>
- <service:field>
- <service:table>taxonomyauthority_common</service:table>
- <service:col>shortidentifier</service:col>
- </service:field>
- </service:params>
- </service:initHandler>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" id="1" name="Taxonomyauthority" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="taxonomyauthority-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="taxonomyauthority_common" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/taxonomy" schemaLocation="http://collectionspace.org/services/taxonomy http://services.collectionspace.org/location/taxonomyauthority_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end taxonomyauthority service meta-data -->
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.taxonomy.nuxeo.TaxonomyAuthorityDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>displayName</service:element>
+ <service:xpath>displayName</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>refName</service:element>
+ <service:xpath>refName</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>shortIdentifier</service:element>
+ <service:xpath>shortIdentifier</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>vocabType</service:element>
+ <service:xpath>vocabType</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
+ <service:params>
+ <service:field>
+ <service:table>taxonomyauthority_common</service:table>
+ <service:col>displayname</service:col>
+ </service:field>
+ <service:field>
+ <service:table>taxonomyauthority_common</service:table>
+ <service:col>shortidentifier</service:col>
+ </service:field>
+ </service:params>
+ </service:initHandler>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" id="1" name="Taxonomyauthority" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="taxonomyauthority-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="taxonomyauthority_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/taxonomy" schemaLocation="http://collectionspace.org/services/taxonomy http://services.collectionspace.org/location/taxonomyauthority_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end taxonomyauthority service meta-data -->
- <!-- begin Taxon (the 'item' child of TaxonomyAuthority) service meta-data.
+ <!-- begin Taxon (the 'item' child of TaxonomyAuthority) service meta-data.
Note there is no Taxon service, but there is a
Repository workspace so we have to configure that.
-->
- <tenant:serviceBindings id="Taxon" name="Taxon" type="authority" version="0.1">
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.taxonomy.nuxeo.TaxonDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <!-- Omit the standard AuthorityItem items (they are handled by the code) -->
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.taxonomy.nuxeo.TaxonValidatorHandler</service:validatorHandler>
- <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
- <service:params>
- <service:field>
- <service:table>taxon_common</service:table>
- <service:col>inauthority</service:col>
- </service:field>
- <service:field>
- <service:table>taxon_common</service:table>
- <service:col>displayname</service:col>
- </service:field>
- <service:field>
- <service:table>taxon_common</service:table>
- <service:col>shortidentifier</service:col>
- </service:field>
- </service:params>
- </service:initHandler>
- <service:properties xmlns:service="http://collectionspace.org/services/common/service">
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNameProperty</types:key>
- <types:value>displayName</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNumberProperty</types:key>
- <types:value>shortIdentifier</types:value>
- </types:item>
- </service:properties>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" id="1" name="Taxon" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="taxon-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="taxon_common" updated="" order="1">
- <service:properties xmlns:service="http://collectionspace.org/services/common/service">
+ <tenant:serviceBindings id="Taxon" name="Taxon" type="authority" version="0.1">
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.taxonomy.nuxeo.TaxonDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <!-- Omit the standard AuthorityItem items (they are handled by the code) -->
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.taxonomy.nuxeo.TaxonValidatorHandler</service:validatorHandler>
+ <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
+ <service:params>
+ <service:field>
+ <service:table>taxon_common</service:table>
+ <service:col>inauthority</service:col>
+ </service:field>
+ <service:field>
+ <service:table>taxon_common</service:table>
+ <service:col>displayname</service:col>
+ </service:field>
+ <service:field>
+ <service:table>taxon_common</service:table>
+ <service:col>shortidentifier</service:col>
+ </service:field>
+ </service:params>
+ </service:initHandler>
+ <service:properties xmlns:service="http://collectionspace.org/services/common/service">
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>objectNameProperty</types:key>
+ <types:value>displayName</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>objectNumberProperty</types:key>
+ <types:value>shortIdentifier</types:value>
+ </types:item>
+ </service:properties>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" id="1" name="Taxon" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="taxon-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="taxon_common" updated="" order="1">
+ <service:properties xmlns:service="http://collectionspace.org/services/common/service">
<!-- Fields containing authority term references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>taxonAuthorGroupList/*/taxonAuthor</types:value>
- </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>taxonAuthorGroupList/*/taxonAuthor</types:value>
+ </types:item>
<!-- Fields containing term list / controlled vocabulary references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>taxonRank</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>taxonCurrency</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>taxonAuthorGroupList/*/taxonAuthorType</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>taxonomicStatus</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>taxonNameSource</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>taxonomicStatus</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>taxonNameSource</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>termStatus</types:value>
- </types:item>
- </service:properties>
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/taxonomy" schemaLocation="http://collectionspace.org/services/taxonomy http://services.collectionspace.org/taxonomy/taxon_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end taxon service meta-data -->
+ </types:item>
+ </service:properties>
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/taxonomy" schemaLocation="http://collectionspace.org/services/taxonomy http://services.collectionspace.org/taxonomy/taxon_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end taxon service meta-data -->
- <!-- begin acquisition service meta-data -->
- <tenant:serviceBindings id="Acquisitions" name="Acquisitions" type="procedure" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/acquisitions/*/workflow/</service:uriPath>
+ <!-- begin acquisition service meta-data -->
+ <tenant:serviceBindings id="Acquisitions" name="Acquisitions" type="procedure" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/acquisitions/*/workflow/</service:uriPath>
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/acquisitions/*/authorityrefs/
</service:uriPath>
-->
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.acquisition.nuxeo.AcquisitionDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>acquisitionReferenceNumber</service:element>
- <service:xpath>acquisitionReferenceNumber</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>acquisitionSource</service:element>
- <service:xpath>acquisitionSources/[0]</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>owner</service:element>
- <service:xpath>owners/[0]</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.acquisition.nuxeo.AcquisitionValidatorHandler</service:validatorHandler>
- <service:properties xmlns:service="http://collectionspace.org/services/common/service">
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.acquisition.nuxeo.AcquisitionDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>acquisitionReferenceNumber</service:element>
+ <service:xpath>acquisitionReferenceNumber</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>acquisitionSource</service:element>
+ <service:xpath>acquisitionSources/[0]</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>owner</service:element>
+ <service:xpath>owners/[0]</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.acquisition.nuxeo.AcquisitionValidatorHandler</service:validatorHandler>
+ <service:properties xmlns:service="http://collectionspace.org/services/common/service">
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>objectNameProperty</types:key>
<types:value>acquisitionSources/[0]</types:value>
</types:item>
<types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNumberProperty</types:key>
- <types:value>acquisitionReferenceNumber</types:value>
- </types:item>
- </service:properties>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Acquisition" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="acquisitions-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="acquisitions_common" updated="" order="1">
- <service:properties>
+ <types:key>objectNumberProperty</types:key>
+ <types:value>acquisitionReferenceNumber</types:value>
+ </types:item>
+ </service:properties>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Acquisition" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="acquisitions-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="acquisitions_common" updated="" order="1">
+ <service:properties>
<!-- Fields containing authority term references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>acquisitionAuthorizer</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>acquisitionAuthorizer</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
<types:value>acquisitionFundingList/*/acquisitionFundingSource</types:value>
</types:item>
<types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>authRef</types:key>
- <types:value>owners|owner</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>acquisitionSources|acquisitionSource</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>fieldCollectionEventNames|fieldCollectionEventName</types:value>
- </types:item>
+ <types:value>owners|owner</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>acquisitionSources|acquisitionSource</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>fieldCollectionEventNames|fieldCollectionEventName</types:value>
+ </types:item>
<!-- Fields containing term list / controlled vocabulary references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>termRef</types:key>
<types:value>acquisitionFundingList/*/acquisitionFundingCurrency</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>acquisitionMethod</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>groupPurchasePriceCurrency</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>objectOfferPriceCurrency</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>objectPurchaseOfferPriceCurrency</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>objectPurchasePriceCurrency</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>acquisitionMethod</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>groupPurchasePriceCurrency</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>objectOfferPriceCurrency</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>objectPurchaseOfferPriceCurrency</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>objectPurchasePriceCurrency</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>originalObjectPurchasePriceCurrency</types:value>
- </types:item>
- </service:properties>
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/acquisition" schemaLocation="http://collectionspace.org/services/acquisition http://services.collectionspace.org/acquisition/acquisitions_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end acquisition service meta-data -->
+ </types:item>
+ </service:properties>
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/acquisition" schemaLocation="http://collectionspace.org/services/acquisition http://services.collectionspace.org/acquisition/acquisitions_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end acquisition service meta-data -->
- <!-- begin relation service meta-data -->
- <tenant:serviceBindings id="Relations" name="Relations" type="utility" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/relations/*/workflow/</service:uriPath>
+ <!-- begin relation service meta-data -->
+ <tenant:serviceBindings id="Relations" name="Relations" type="utility" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/relations/*/workflow/</service:uriPath>
<!-- other URI paths through which this service could be accessed -->
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.relation.nuxeo.RelationDocumentModelHandler</service:documentHandler>
- <!-- Configuration of list results fields for relation items is commented out for now, -->
- <!-- pending resolution of how to specify nested elements in list results. -->
- <!--
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>subjectCsid</service:element>
- <service:xpath>subjectCsid</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>subjectRefName</service:element>
- <service:xpath>subjectRefName</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>relationshipType</service:element>
- <service:xpath>relationshipType</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>predicate</service:element>
- <service:xpath>predicate</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>predicateDisplayName</service:element>
- <service:xpath>predicateDisplayName</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>objectCsid</service:element>
- <service:xpath>objectCsid</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>objectRefName</service:element>
- <service:xpath>objectRefName</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>relationshipType</service:element>
- <service:xpath>relationshipType</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- -->
- <!--
- Relation list items can include two additional fields,
- 'subject' and 'object', each of which are parent elements of,
- and hence containers for, as many as eight child fields. See
- services/jaxb/src/main/resources/relations_common.xsd
- -->
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.relation.nuxeo.RelationValidatorHandler</service:validatorHandler>
- <service:properties xmlns:service="http://collectionspace.org/services/common/service">
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNameProperty</types:key>
- <types:value>subjectCsid</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>objectNumberProperty</types:key>
- <types:value>predicateDisplayName</types:value>
- </types:item>
- </service:properties>
- <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
- <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
- <service:params>
- <!-- The database index that is to be created for the ubiquitious updatedAt field -->
- <!-- in collectionspace_core is configured here in the Relation -->
- <!-- service, as it is a core service that will be reliably present. -->
- <service:field>
- <service:table>collectionspace_core</service:table>
- <service:col>updatedat</service:col>
- </service:field>
- <service:field>
- <service:table>relations_common</service:table>
- <service:param>subjectcsid,objectcsid</service:param>
- </service:field>
- </service:params>
- </service:initHandler>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Relation" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="relations-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="relations_common" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/relation" schemaLocation="http://collectionspace.org/services/relation http://services.collectionspace.org/relation/relations_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end relation service meta-data -->
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.relation.nuxeo.RelationDocumentModelHandler</service:documentHandler>
+ <!-- Configuration of list results fields for relation items is commented out for now, -->
+ <!-- pending resolution of how to specify nested elements in list results. -->
+ <!--
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>subjectCsid</service:element>
+ <service:xpath>subjectCsid</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>subjectRefName</service:element>
+ <service:xpath>subjectRefName</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>relationshipType</service:element>
+ <service:xpath>relationshipType</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>predicate</service:element>
+ <service:xpath>predicate</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>predicateDisplayName</service:element>
+ <service:xpath>predicateDisplayName</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>objectCsid</service:element>
+ <service:xpath>objectCsid</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>objectRefName</service:element>
+ <service:xpath>objectRefName</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>relationshipType</service:element>
+ <service:xpath>relationshipType</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ -->
+ <!--
+ Relation list items can include two additional fields,
+ 'subject' and 'object', each of which are parent elements of,
+ and hence containers for, as many as eight child fields. See
+ services/jaxb/src/main/resources/relations_common.xsd
+ -->
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.relation.nuxeo.RelationValidatorHandler</service:validatorHandler>
+ <service:properties xmlns:service="http://collectionspace.org/services/common/service">
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>objectNameProperty</types:key>
+ <types:value>subjectCsid</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>objectNumberProperty</types:key>
+ <types:value>predicateDisplayName</types:value>
+ </types:item>
+ </service:properties>
+ <service:initHandler xmlns:service="http://collectionspace.org/services/common/service">
+ <service:classname>org.collectionspace.services.common.init.AddIndices</service:classname>
+ <service:params>
+ <!-- The database index that is to be created for the ubiquitious updatedAt field -->
+ <!-- in collectionspace_core is configured here in the Relation -->
+ <!-- service, as it is a core service that will be reliably present. -->
+ <service:field>
+ <service:table>collectionspace_core</service:table>
+ <service:col>updatedat</service:col>
+ </service:field>
+ <service:field>
+ <service:table>relations_common</service:table>
+ <service:param>subjectcsid,objectcsid</service:param>
+ </service:field>
+ </service:params>
+ </service:initHandler>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Relation" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="relations-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="relations_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/relation" schemaLocation="http://collectionspace.org/services/relation http://services.collectionspace.org/relation/relations_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end relation service meta-data -->
- <!-- begin account service meta-data -->
- <tenant:serviceBindings id="Accounts" name="Accounts" type="security" version="0.1">
+ <!-- begin account service meta-data -->
+ <tenant:serviceBindings id="Accounts" name="Accounts" type="security" version="0.1">
<!-- other URI paths through which this service could be accessed -->
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.account.storage.AccountDocumentHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>screenName</service:element>
- <service:xpath>screenName</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>personRefName</service:element>
- <service:xpath>personRefName</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>email</service:element>
- <service:xpath>email</service:xpath>
- </service:ListResultField>
- <service:ListResultField>
- <service:element>status</service:element>
- <service:xpath>status</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.account.storage.AccountValidatorHandler</service:validatorHandler>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Acccount" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="accounts_system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="accounts_common" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/account" schemaLocation="http://collectionspace.org/services/account http://collectionspace.org/services/account/accounts_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end account service meta-data -->
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.account.storage.AccountDocumentHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>screenName</service:element>
+ <service:xpath>screenName</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>personRefName</service:element>
+ <service:xpath>personRefName</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>email</service:element>
+ <service:xpath>email</service:xpath>
+ </service:ListResultField>
+ <service:ListResultField>
+ <service:element>status</service:element>
+ <service:xpath>status</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.account.storage.AccountValidatorHandler</service:validatorHandler>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Acccount" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="accounts_system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="accounts_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/account" schemaLocation="http://collectionspace.org/services/account http://collectionspace.org/services/account/accounts_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end account service meta-data -->
- <!-- begin dimension service meta-data -->
- <tenant:serviceBindings id="Dimensions" name="Dimensions" type="utility" version="0.1">
+ <!-- begin dimension service meta-data -->
+ <tenant:serviceBindings id="Dimensions" name="Dimensions" type="utility" version="0.1">
<!-- other URI paths through which this service could be accessed -->
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/dimensions/*/workflow/</service:uriPath>
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.dimension.nuxeo.DimensionDocumentModelHandler</service:documentHandler>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Dimension" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="dimensions-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="dimensions_common" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/dimension" schemaLocation="http://collectionspace.org/services/dimension http://services.collectionspace.org/dimension/dimensions_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end dimension service meta-data -->
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/dimensions/*/workflow/</service:uriPath>
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.dimension.nuxeo.DimensionDocumentModelHandler</service:documentHandler>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Dimension" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="dimensions-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="dimensions_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/dimension" schemaLocation="http://collectionspace.org/services/dimension http://services.collectionspace.org/dimension/dimensions_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end dimension service meta-data -->
- <!-- begin contact service meta-data -->
- <tenant:serviceBindings id="Contacts" name="Contacts" type="utility" version="0.1">
+ <!-- begin contact service meta-data -->
+ <tenant:serviceBindings id="Contacts" name="Contacts" type="utility" version="0.1">
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/orgauthorities/*/items/*/contacts
</service:uriPath>
-->
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.contact.nuxeo.ContactDocumentModelHandler</service:documentHandler>
- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
- <service:params>
- <service:ListResultsFields>
- <service:ListResultField>
- <service:element>displayName</service:element>
- <service:xpath>displayName</service:xpath>
- </service:ListResultField>
- </service:ListResultsFields>
- </service:params>
- </service:DocHandlerParams>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Contact" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="contacts-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="contacts_common" updated="" order="1">
- <service:properties>
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.contact.nuxeo.ContactDocumentModelHandler</service:documentHandler>
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/common/service">
+ <service:params>
+ <service:ListResultsFields>
+ <service:ListResultField>
+ <service:element>displayName</service:element>
+ <service:xpath>displayName</service:xpath>
+ </service:ListResultField>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Contact" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="contacts-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="contacts_common" updated="" order="1">
+ <service:properties>
<!-- Fields containing authority term references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>addressGroupList/*/addressMunicipality</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>addressGroupList/*/addressStateOrProvince</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>authRef</types:key>
- <types:value>addressGroupList/*/addressCountry</types:value>
- </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>addressGroupList/*/addressMunicipality</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>addressGroupList/*/addressStateOrProvince</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>authRef</types:key>
+ <types:value>addressGroupList/*/addressCountry</types:value>
+ </types:item>
<!-- Fields containing term list / controlled vocabulary references -->
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>emailGroupList/*/emailType</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>emailGroupList/*/emailType</types:value>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>telephoneNumberGroupList/*/telephoneNumberType</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>faxNumberGroupList/*/faxNumberType</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
<types:value>webAddressGroupList/*/webAddressType</types:value>
- </types:item>
- <types:item xmlns:types="http://collectionspace.org/services/common/types">
- <types:key>termRef</types:key>
- <types:value>addressGroupList/*/addressType</types:value>
- </types:item>
- </service:properties>
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/contact" schemaLocation="http://collectionspace.org/services/contact http://services.collectionspace.org/contact/contacts_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end contact service meta-data -->
+ </types:item>
+ <types:item xmlns:types="http://collectionspace.org/services/common/types">
+ <types:key>termRef</types:key>
+ <types:value>addressGroupList/*/addressType</types:value>
+ </types:item>
+ </service:properties>
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/contact" schemaLocation="http://collectionspace.org/services/contact http://services.collectionspace.org/contact/contacts_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end contact service meta-data -->
- <!-- begin note service meta-data -->
- <tenant:serviceBindings id="Notes" name="Notes" type="utility" version="0.1">
- <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.note.nuxeo.NoteDocumentModelHandler</service:documentHandler>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="CSNote" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="notes-system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="notes_common" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/note" schemaLocation="http://collectionspace.org/services/note http://services.collectionspace.org/note/notes_common.xsd" />
- </service:content>
- </service:part>
- <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
+ <!-- begin note service meta-data -->
+ <tenant:serviceBindings id="Notes" name="Notes" type="utility" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/notes/*/workflow/</service:uriPath>
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.note.nuxeo.NoteDocumentModelHandler</service:documentHandler>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="CSNote" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="notes-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="notes_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/note" schemaLocation="http://collectionspace.org/services/note http://services.collectionspace.org/note/notes_common.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="2" control_group="Managed" versionable="true" auditable="false" label="collectionspace_core" updated="" order="2">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/collectionspace_core/" schemaLocation="http://collectionspace.org/collectionspace_core/ http://services.collectionspace.org/collectionspace_core.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
<!-- end note service meta-data -->
<!-- begin role service meta-data -->
- <tenant:serviceBindings id="authorization/roles" name="authorization/roles" type="security" version="0.1">
+ <tenant:serviceBindings id="authorization/roles" name="authorization/roles" type="security" version="0.1">
<!-- other URI paths through which this service could be accessed -->
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.authorization.storage.RoleDocumentHandler</service:documentHandler>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.authorization.storage.RoleValidatorHandler</service:validatorHandler>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Role" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="roles_system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="roles" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/authorization" schemaLocation="http://collectionspace.org/services/authorization http://services.collectionspace.org/authorization/roles.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end role service meta-data -->
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.authorization.storage.RoleDocumentHandler</service:documentHandler>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.authorization.storage.RoleValidatorHandler</service:validatorHandler>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Role" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="roles_system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="roles" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/authorization" schemaLocation="http://collectionspace.org/services/authorization http://services.collectionspace.org/authorization/roles.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end role service meta-data -->
- <!-- begin permission service meta-data -->
- <tenant:serviceBindings id="authorization/permissions" name="authorization/permissions" type="security" version="0.1">
+ <!-- begin permission service meta-data -->
+ <tenant:serviceBindings id="authorization/permissions" name="authorization/permissions" type="security" version="0.1">
<!-- other URI paths through which this service could be accessed -->
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.authorization.storage.PermissionDocumentHandler</service:documentHandler>
- <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.authorization.storage.PermissionValidatorHandler</service:validatorHandler>
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Permission" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="permissions_system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="permissions" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/authorization" schemaLocation="http://collectionspace.org/services/authorization http://services.collectionspace.org/authorization/permissions.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end permission service meta-data -->
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.authorization.storage.PermissionDocumentHandler</service:documentHandler>
+ <service:validatorHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.authorization.storage.PermissionValidatorHandler</service:validatorHandler>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="Permission" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="permissions_system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="permissions" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/authorization" schemaLocation="http://collectionspace.org/services/authorization http://services.collectionspace.org/authorization/permissions.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end permission service meta-data -->
- <!-- begin permission-role service meta-data -->
- <!-- the following service is same as authorization/roles/permroles service -->
- <!-- except that it is available as a sub resource of the permission service -->
- <tenant:serviceBindings id="authorization/permissions/permroles" name="authorization/permissions/permroles" type="security" version="0.1">
+ <!-- begin permission-role service meta-data -->
+ <!-- the following service is same as authorization/roles/permroles service -->
+ <!-- except that it is available as a sub resource of the permission service -->
+ <tenant:serviceBindings id="authorization/permissions/permroles" name="authorization/permissions/permroles" type="security" version="0.1">
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/authorization/permissions/*/permroles/
</service:uriPath>
-->
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.authorization.storage.PermissionRoleDocumentHandler</service:documentHandler>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.authorization.storage.PermissionRoleDocumentHandler</service:documentHandler>
<!--
<service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
org.collectionspace.services.authorization.storage.PermissionRoleValidatorHandler
</service:validatorHandler>
-->
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="PermissionRole" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="permroles_system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="permroles" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/authorization" schemaLocation="http://collectionspace.org/services/authorization http://services.collectionspace.org/authorization/permissions_roles.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end permission-role service meta-data -->
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="PermissionRole" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="permroles_system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="permroles" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/authorization" schemaLocation="http://collectionspace.org/services/authorization http://services.collectionspace.org/authorization/permissions_roles.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end permission-role service meta-data -->
- <!-- begin account-role service meta-data -->
- <tenant:serviceBindings id="accounts/accountroles" name="accounts/accountroles" type="security" version="0.1">
+ <!-- begin account-role service meta-data -->
+ <tenant:serviceBindings id="accounts/accountroles" name="accounts/accountroles" type="security" version="0.1">
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/accounts/*/accountroles/
</service:uriPath>
-->
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.account.storage.AccountRoleDocumentHandler</service:documentHandler>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.account.storage.AccountRoleDocumentHandler</service:documentHandler>
<!--
<service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
org.collectionspace.services.account.storage.AccountRoleDocumentHandler
</service:validatorHandler>
-->
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="AccountRole" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="accountroles_system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="accountroles" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/authorization" schemaLocation="http://collectionspace.org/services/authorization http://services.collectionspace.org/authorization/accounts_roles.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end account-role service meta-data -->
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="AccountRole" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="accountroles_system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="accountroles" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/authorization" schemaLocation="http://collectionspace.org/services/authorization http://services.collectionspace.org/authorization/accounts_roles.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end account-role service meta-data -->
- <!-- begin role-permission service meta-data -->
- <!-- the following service is same as authorization/permissions/permroles service -->
- <!-- except that it is available as a sub resource of the role service -->
- <tenant:serviceBindings id="authorization/roles/permroles" name="authorization/roles/permroles" type="security" version="0.1">
+ <!-- begin role-permission service meta-data -->
+ <!-- the following service is same as authorization/permissions/permroles service -->
+ <!-- except that it is available as a sub resource of the role service -->
+ <tenant:serviceBindings id="authorization/roles/permroles" name="authorization/roles/permroles" type="security" version="0.1">
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/authorization/roles/*/permroles/
</service:uriPath>
-->
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.authorization.storage.PermissionRoleDocumentHandler</service:documentHandler>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.authorization.storage.PermissionRoleDocumentHandler</service:documentHandler>
<!--
<service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
org.collectionspace.services.authorization.storage.PermissionRoleValidatorHandler
</service:validatorHandler>
-->
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="PermissionRole" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="permroles_system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="permroles" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/authorization" schemaLocation="http://collectionspace.org/services/authorization http://services.collectionspace.org/authorization/permissions_roles.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- <!-- end role-permission service meta-data -->
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="PermissionRole" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="permroles_system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="permroles" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/authorization" schemaLocation="http://collectionspace.org/services/authorization http://services.collectionspace.org/authorization/permissions_roles.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end role-permission service meta-data -->
- <!-- begin role-account service meta-data -->
- <!-- the following service is same as account/accountroles service -->
- <!-- except that it is available as a sub resource of the role service -->
- <tenant:serviceBindings id="authorization/roles/accountroles" name="authorization/roles/accountroles" type="security" version="0.1">
+ <!-- begin role-account service meta-data -->
+ <!-- the following service is same as account/accountroles service -->
+ <!-- except that it is available as a sub resource of the role service -->
+ <tenant:serviceBindings id="authorization/roles/accountroles" name="authorization/roles/accountroles" type="security" version="0.1">
<!-- other URI paths through which this service could be accessed -->
<!--
<service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
/authorization/roles/*/accountroles/
</service:uriPath>
-->
- <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.account.storage.AccountRoleDocumentHandler</service:documentHandler>
+ <service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.account.storage.AccountRoleDocumentHandler</service:documentHandler>
<!--
<service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
org.collectionspace.services.authorization.storage.PermissionRoleValidatorHandler
</service:validatorHandler>
-->
- <service:object xmlns:service="http://collectionspace.org/services/common/service" name="AccountRole" version="0.1">
- <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="accountroles_system" updated="" order="0">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
- </service:content>
- </service:part>
- <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="accountroles" updated="" order="1">
- <service:content contentType="application/xml">
- <service:xmlContent namespaceURI="http://collectionspace.org/services/authorization" schemaLocation="http://collectionspace.org/services/authorization http://services.collectionspace.org/authorization/accounts_roles.xsd" />
- </service:content>
- </service:part>
- </service:object>
- </tenant:serviceBindings>
- </tenant:tenantBinding>
+ <service:object xmlns:service="http://collectionspace.org/services/common/service" name="AccountRole" version="0.1">
+ <service:part id="0" control_group="Managed" versionable="true" auditable="false" label="accountroles_system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/common/system" schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd" />
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed" versionable="true" auditable="false" label="accountroles" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent namespaceURI="http://collectionspace.org/services/authorization" schemaLocation="http://collectionspace.org/services/authorization http://services.collectionspace.org/authorization/accounts_roles.xsd" />
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ </tenant:tenantBinding>
<!-- end prototype collectionspace.org tenant meta-data -->
</tenant:TenantBindingConfig>
String digestAlgorithm = getFileManagerService()\r
.getDigestAlgorithm(); // Need some way on initializing the\r
// FileManager with a call.\r
+ \r
+ logger.debug("Start --> Calling Nuxeo to create an image blob.");\r
DocumentModel documentModel = getFileManagerService()\r
.createDocumentFromBlob(nuxeoSession, fileBlob,\r
blobLocation.getPathAsString(), true,\r
file.getName());\r
+ logger.debug("Stop --> Calling Nuxeo to create an image blob.");\r
+ \r
result = createBlobsCommon(documentModel, fileBlob);\r
} catch (Exception e) {\r
result = null;\r
setStartTime(currentTime());\r
}\r
\r
+ private void stopTimer() {\r
+ setStopTime(currentTime());\r
+ setElapsedTime(getStopTime() - getStartTime());\r
+ addToCumulativeTime(getElapsedTime());\r
+ }\r
+ \r
/**\r
* Stores and logs the stop time, and the elapsed and cumulative timings\r
* from one or more cycles of start and stop.\r
* Logs using a default message.\r
*/\r
public void stop() {\r
- // FIXME: Need to store values before constructing default stop message,\r
- // hence has some redundant code with stop(msg) below. Perhaps can be consolidated.\r
- setStopTime(currentTime());\r
- setElapsedTime(elapsedTime());\r
- addToCumulativeTime(elapsedTime());\r
- stop(defaultStopMessage());\r
+ stopTimer();\r
+ log(defaultStopMessage());\r
}\r
\r
/**\r
* @param msg the message to log.\r
*/\r
public void stop(String msg) {\r
- setStopTime(currentTime());\r
- setElapsedTime(elapsedTime());\r
- addToCumulativeTime(elapsedTime());\r
+ stopTimer();\r
log(msg);\r
}\r
\r
import org.collectionspace.services.common.document.AbstractDocumentHandlerImpl;\r
import org.collectionspace.services.common.document.DocumentFilter;\r
import org.collectionspace.services.common.document.DocumentWrapper;\r
-import org.collectionspace.services.hyperjaxb.AbstractCommonList;\r
+import org.collectionspace.services.jaxb.AbstractCommonList;\r
\r
public abstract class JpaDocumentHandler<T, TL, WT, WLT>\r
extends AbstractDocumentHandlerImpl<T, TL, WT, WLT>{\r
result = TRANSITION_APPROVE;
} else if (state.equalsIgnoreCase(WorkflowClient.WORKFLOWSTATE_PROJECT)) {
result = TRANSITION_UNDELETE;
- }
+ } else {
+ logger.warn("An attempt was made to transition a document to an unknown workflow state = "
+ + state);
+ }
+
return result;
}
+
/*
* Handle Update (PUT)
*/
ObjectPartType partMeta, Action action,
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx)
throws Exception {
- WorkflowCommon workflowsCommon = (WorkflowCommon) part.getBody();
- docModel.followTransition(getTransitionFromState(workflowsCommon.getCurrentLifeCycleState()));
+ String toState = null;
+
+ try {
+ WorkflowCommon workflowsCommon = (WorkflowCommon) part.getBody();
+ toState = getTransitionFromState(workflowsCommon.getCurrentLifeCycleState());
+ docModel.followTransition(toState);
+ } catch (Exception e) {
+ String msg = "Unable to follow workflow transition to state = "
+ + toState;
+ if (logger.isDebugEnabled() == true) {
+ logger.debug(msg, e);
+ }
+ ClientException ce = new ClientException("Unable to follow workflow transition to state = "
+ + toState);
+ throw ce;
+ }
}
}
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
* ILT - Authority item list type\r
* P - Proxy type\r
*/\r
-public interface AuthorityWithContactsClient<P extends AuthorityProxy>\r
- extends AuthorityClient<P> {\r
+public interface AuthorityWithContactsClient<AUTHORITY_ITEM_TYPE, P extends AuthorityProxy>\r
+ extends AuthorityClient<AUTHORITY_ITEM_TYPE, P> {\r
/**\r
* Creates the contact.\r
*\r
* ILT - Authority item list type\r
* P - Proxy type\r
*/\r
-public abstract class AuthorityWithContactsClientImpl<P extends AuthorityWithContactsProxy>\r
- extends AuthorityClientImpl<P>\r
- implements AuthorityWithContactsClient<P> {\r
+public abstract class AuthorityWithContactsClientImpl<AUTHORITY_ITEM_TYPE, P extends AuthorityWithContactsProxy>\r
+ extends AuthorityClientImpl<AUTHORITY_ITEM_TYPE, P>\r
+ implements AuthorityWithContactsClient<AUTHORITY_ITEM_TYPE, P> {\r
\r
@Override\r
public ClientResponse<Response> createContact(String parentcsid,\r
*
* $LastChangedRevision: $
* $LastChangedDate: $
+ *
*/
public class ContactClient extends AbstractCommonListPoxServiceClientImpl<ContactProxy> {
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.ContactClient;
import org.collectionspace.services.client.ContactClientUtils;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.contact.AddressGroup;
import org.collectionspace.services.contact.AddressGroupList;
import org.collectionspace.services.contact.ContactsCommon;
import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
-import org.testng.annotations.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* $LastChangedRevision: 917 $
* $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
*/
-public class ContactServiceTest extends AbstractServiceTestImpl {
+public class ContactServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, ContactsCommon> {
private final String CLASS_NAME = ContactServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(ContactServiceTest.class);
// Instance variables specific to this test.
// final String SERVICE_PATH_COMPONENT = "contacts";
- private String knownResourceId = null;
@Override
public String getServicePathComponent() {
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
+ protected AbstractCommonList getCommonList(
ClientResponse<AbstractCommonList> response) {
return response.getEntity(AbstractCommonList.class);
}
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
// Success outcomes
+
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// 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).
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Store the ID returned from the first resource created
// for additional tests below.
}
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"create"})
public void createList(String testName) throws Exception {
for (int i = 0; i < 3; i++) {
create(testName);
// ---------------------------------------------------------------
// Success outcomes
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"create"})
public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupRead();
// Submit the request to the service and store the response.
ContactClient client = new ContactClient();
ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
-
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- ContactsCommon contact = (ContactsCommon) extractPart(input,
- client.getCommonPartName(), ContactsCommon.class);
- Assert.assertNotNull(contact);
- }
-
- // Failure outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void readNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- ContactClient client = new ContactClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ assertStatusCode(res, testName);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ ContactsCommon contact = (ContactsCommon) extractPart(input,
+ client.getCommonPartName(), ContactsCommon.class);
+ Assert.assertNotNull(contact);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
}
// ---------------------------------------------------------------
// ---------------------------------------------------------------
// Success outcomes
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"read"})
public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupReadList();
// Submit the request to the service and store the response.
ContactClient client = new ContactClient();
ClientResponse<AbstractCommonList> res = client.readList();
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
-
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = false;
- if (iterateThroughList && logger.isDebugEnabled()) {
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
+ try {
+ assertStatusCode(res, testName);
+ AbstractCommonList list = res.getEntity();
+
+ // Optionally output additional data about list members for debugging.
+ boolean iterateThroughList = false;
+ if (iterateThroughList && logger.isDebugEnabled()) {
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
-
}
// Failure outcomes
// ---------------------------------------------------------------
// Success outcomes
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"read"})
public void update(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupUpdate();
-
- // Submit the request to the service and store the response.
+ //
+ // First read the object that will be updated
+ //
ContactClient client = new ContactClient();
ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
-
- if (logger.isDebugEnabled()) {
- logger.debug("got object to update with ID: " + knownResourceId);
+ ContactsCommon contact = null;
+ try {
+ assertStatusCode(res, testName);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("got object to update with ID: " + knownResourceId);
+ }
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ contact = (ContactsCommon) extractPart(input,
+ client.getCommonPartName(), ContactsCommon.class);
+ Assert.assertNotNull(contact);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- ContactsCommon contact = (ContactsCommon) extractPart(input,
- client.getCommonPartName(), ContactsCommon.class);
- Assert.assertNotNull(contact);
if(logger.isDebugEnabled()){
logger.debug("contact common before updating");
logger.debug("to be updated object");
logger.debug(BaseServiceTest.objectAsXmlString(contact, ContactsCommon.class));
}
-
- // Submit the request to the service and store the response.
+ //
+ // Next, send the update to the server
+ //
PoxPayloadOut output = new PoxPayloadOut(ContactClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
+ PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), contact);
res = client.update(knownResourceId, output);
- assertStatusCode(res, testName);
-
- input = new PoxPayloadIn(res.getEntity());
- ContactsCommon updatedContact =
- (ContactsCommon) extractPart(input,
- client.getCommonPartName(), ContactsCommon.class);
- Assert.assertNotNull(updatedContact);
+ ContactsCommon updatedContact = null;
+ try {
+ assertStatusCode(res, testName);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ updatedContact = (ContactsCommon) extractPart(input,
+ client.getCommonPartName(), ContactsCommon.class);
+ Assert.assertNotNull(updatedContact);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
if (logger.isDebugEnabled()) {
logger.debug("object after update");
}
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"update", "testSubmitRequest"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"update", "testSubmitRequest"})
public void updateNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupUpdateNonExistent();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
// ---------------------------------------------------------------
// Success outcomes
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupDelete();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// Failure outcomes
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"delete"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"delete"})
public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupDeleteNonExistent();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
* Tests the code for manually submitting data that is used by several
* of the methods above.
*/
- @Test(dependsOnMethods = {"create", "read"})
+// @Test(dependsOnMethods = {"create", "read"})
public void testSubmitRequest() {
// Expected status code: 200 OK
+ " status=" + statusCode);
}
Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
}
+
+ @Override
+ public void readWorkflow(String testName) throws Exception {
+ // Not applicable for the Contact service
+ }
+
+ @Override
+ public void searchWorkflowDeleted(String testName) throws Exception {
+ // Not applicable for the Contact service
+ }
+
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ return ContactClientUtils.createContactInstance(identifier, commonPartName);
+ }
+
+ @Override
+ protected ContactsCommon updateInstance(ContactsCommon commonPartObject) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(ContactsCommon original,
+ ContactsCommon updated) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void CRUDTests(String testName) {
+ // TODO Auto-generated method stub
+ }
}
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<!-- javax -->
</parent>\r
\r
<modelVersion>4.0.0</modelVersion>\r
- <groupId>org.collectionspace.services</groupId>\r
<artifactId>org.collectionspace.services.dimension.client</artifactId>\r
<name>services.dimension.client</name>\r
\r
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
+ <scope>test</scope>\r
</dependency>\r
<dependency>\r
<groupId>org.jboss.resteasy</groupId>\r
*/
public class DimensionClient extends AbstractPoxServiceClientImpl<DimensionsCommonList, DimensionProxy> {
public static final String SERVICE_NAME = "dimensions";
- public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
+ public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
@GET
@Produces({"application/xml"})
ClientResponse<DimensionsCommonList> readList();
-
- @Override
+
+ @Override
@GET
@Produces({"application/xml"})
ClientResponse<DimensionsCommonList> readIncludeDeleted(
//import java.util.ArrayList;
import java.math.BigDecimal;
import java.util.List;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.DimensionClient;
import org.collectionspace.services.client.DimensionFactory;
-import org.collectionspace.services.client.PayloadInputPart;
-import org.collectionspace.services.client.PayloadOutputPart;
-import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.client.workflow.WorkflowClient;
import org.collectionspace.services.dimension.DimensionsCommon;
import org.collectionspace.services.dimension.DimensionsCommonList;
-import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.collectionspace.services.workflow.WorkflowCommon;
-
-import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
//import org.testng.annotations.AfterClass;
* $LastChangedRevision: 917 $
* $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
*/
-public class DimensionServiceTest extends AbstractServiceTestImpl {
+public class DimensionServiceTest extends AbstractPoxServiceTestImpl<DimensionsCommonList, DimensionsCommon> {
/** The logger. */
private final String CLASS_NAME = DimensionServiceTest.class.getName();
// Instance variables specific to this test.
/** The SERVIC e_ pat h_ component. */
- /** The known resource id. */
- private String knownResourceId = null;
private final String DIMENSION_VALUE = "78.306";
+ @Override
+ protected Logger getLogger() {
+ return this.logger;
+ }
+
@Override
protected String getServiceName() {
return DimensionClient.SERVICE_NAME;
return new DimensionClient();
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
@Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(DimensionsCommonList.class);
+ protected Class<DimensionsCommonList> getCommonListType() {
+ return DimensionsCommonList.class;
}
+ /*
+ * This method gets called by the parent's method public void readList(String testName)
+ */
+ protected void printList(String testName, DimensionsCommonList list) {
+ // Optionally output additional data about list members for debugging.
+ boolean iterateThroughList = false;
+ if (iterateThroughList && logger.isDebugEnabled()) {
+ List<DimensionsCommonList.DimensionListItem> items =
+ list.getDimensionListItem();
+ int i = 0;
+ for (DimensionsCommonList.DimensionListItem item : items) {
+ logger.debug(testName + ": list-item[" + i + "] csid="
+ + item.getCsid());
+ logger.debug(testName + ": list-item[" + i + "] objectNumber="
+ + item.getDimension());
+ logger.debug(testName + ": list-item[" + i + "] URI="
+ + item.getUri());
+ i++;
+ }
+ }
+ }
+
+ protected void compareInstances(DimensionsCommon original, DimensionsCommon updated) throws Exception {
+ Assert.assertEquals(original.getValueDate(),
+ updated.getValueDate(),
+ "Data in updated object did not match submitted data.");
+ }
+
+ @Override
+ protected DimensionsCommon updateInstance(DimensionsCommon dimensionsCommon) {
+ DimensionsCommon result = new DimensionsCommon();
+
+ // Update the content of this resource.
+ result.setValue(dimensionsCommon.getValue().multiply(new BigDecimal("2.0")));
+ result.setValueDate("updated-" + dimensionsCommon.getValueDate());
+
+ return result;
+ }
+
// ---------------------------------------------------------------
- // CRUD tests : CREATE tests
+ // Utility methods used by tests above
// ---------------------------------------------------------------
- // Success outcomes
/* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
+ * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // 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();
+ public String getServicePathComponent() {
+ return DimensionClient.SERVICE_PATH_COMPONENT;
+ }
- // Submit the request to the service and store the response.
- DimensionClient client = new DimensionClient();
- String identifier = createIdentifier();
- PoxPayloadOut multipart = createDimensionInstance(client.getCommonPartName(),
- identifier);
- ClientResponse<Response> res = client.create(multipart);
+ @Override
+ protected PoxPayloadOut createInstance(String identifier) {
+ DimensionClient client = new DimensionClient();
+ return createInstance(client.getCommonPartName(), identifier);
+ }
+
+ /**
+ * Creates the dimension instance.
+ *
+ * @param identifier the identifier
+ * @return the multipart output
+ */
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName, String identifier) {
+ return createDimensionInstance(commonPartName,
+ "dimensionType-" + identifier,
+ DIMENSION_VALUE,
+ "entryDate-" + identifier);
+ }
- int statusCode = res.getStatus();
+ /**
+ * Creates the dimension instance.
+ *
+ * @param dimensionType the dimension type
+ * @param entryNumber the entry number
+ * @param entryDate the entry date
+ * @return the multipart output
+ */
+ private PoxPayloadOut createDimensionInstance(String commonPartName, String dimensionType, String dimensionValue, String entryDate) {
+ DimensionsCommon dimensionsCommon = new DimensionsCommon();
+ dimensionsCommon.setDimension(dimensionType);
+ dimensionsCommon.setValue(new BigDecimal(dimensionValue));
+ dimensionsCommon.setValueDate(entryDate);
+ PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(
+ commonPartName, dimensionsCommon);
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Store the ID returned from the first resource created
- // for additional tests below.
- if (knownResourceId == null) {
- knownResourceId = extractId(res);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
+ logger.debug("to be created, dimension common");
+ logger.debug(objectAsXmlString(dimensionsCommon,
+ DimensionsCommon.class));
}
- // Store the IDs from every resource created by tests,
- // so they can be deleted after tests have been run.
- allResourceIdsCreated.add(extractId(res));
+ return multipart;
}
+
+ // Placeholders until the three tests below can be uncommented.
+ // See Issue CSPACE-401.
/* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void createList(String testName) throws Exception {
- for (int i = 0; i < 3; i++) {
- create(testName);
- }
+ public void createWithMalformedXml(String testName) throws Exception {
+ //Should this really be empty?
}
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
/* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
*/
@Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
+ public void createWithWrongXmlSchema(String testName) throws Exception {
+ //Should this really be empty?
+ }
+
+ @Override
+ public void createWithEmptyEntityBody(String testName) throws Exception {
+ //FIXME: Should this test really be empty?
+ }
+ @Override
+ public void updateWithEmptyEntityBody(String testName) throws Exception {
//Should this really be empty?
}
/* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
*/
@Override
- public void createWithMalformedXml(String testName) throws Exception {
+ public void updateWithMalformedXml(String testName) throws Exception {
//Should this really be empty?
}
/* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
*/
@Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
+ public void updateWithWrongXmlSchema(String testName) throws Exception {
//Should this really be empty?
}
+ @Override
+ protected void compareUpdatedInstances(DimensionsCommon original,
+ DimensionsCommon updated) throws Exception {
+ //Check the dimension value to see if the update happened correctly
+ BigDecimal expectedValue = original.getValue();
+ BigDecimal actualValue = updated.getValue();
+ Assert.assertTrue(actualValue.compareTo(expectedValue) == 0);
+
+ //Next, check the date value to see if it was updated
+ String expectedDate = original.getValueDate();
+ String actualDate = updated.getValueDate();
+ Assert.assertEquals(actualDate, expectedDate);
+ }
+
+ /*
+ * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
+ * refer to this method in their @Test annotation declarations.
+ */
+ @Override
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {
+ "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
+ public void CRUDTests(String testName) {
+ // Do nothing. Simply here to for a TestNG execution order for our tests
+ }
+
/*
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
}
- */
- // ---------------------------------------------------------------
- // CRUD tests : READ tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- DimensionClient client = new DimensionClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
- DimensionsCommon dimensionsCommon = null;
- if (payloadInputPart != null) {
- dimensionsCommon = (DimensionsCommon) payloadInputPart.getBody();
- }
- Assert.assertNotNull(dimensionsCommon);
- }
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void readNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- DimensionClient client = new DimensionClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : READ_LIST tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadList();
-
- // Submit the request to the service and store the response.
- DimensionClient client = new DimensionClient();
- ClientResponse<DimensionsCommonList> res = client.readList();
- assertStatusCode(res, testName);
- DimensionsCommonList list = res.getEntity();
-
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = false;
- if (iterateThroughList && logger.isDebugEnabled()) {
- List<DimensionsCommonList.DimensionListItem> items =
- list.getDimensionListItem();
- int i = 0;
- for (DimensionsCommonList.DimensionListItem item : items) {
- logger.debug(testName + ": list-item[" + i + "] csid="
- + item.getCsid());
- logger.debug(testName + ": list-item[" + i + "] objectNumber="
- + item.getDimension());
- logger.debug(testName + ": list-item[" + i + "] URI="
- + item.getUri());
- i++;
- }
- }
-
- }
-
- // Failure outcomes
- // None at present.
- // ---------------------------------------------------------------
- // CRUD tests : UPDATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void update(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
-
- // Retrieve the contents of a resource to update.
- DimensionClient client = new DimensionClient();
- ClientResponse<String> res =
- client.read(knownResourceId);
- assertStatusCode(res, testName);
- if (logger.isDebugEnabled()) {
- logger.debug("got object to update with ID: " + knownResourceId);
- }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
- DimensionsCommon dimensionsCommon = null;
- if (payloadInputPart != null) {
- dimensionsCommon = (DimensionsCommon) payloadInputPart.getBody();
- }
- Assert.assertNotNull(dimensionsCommon);
-
- // Update the content of this resource.
- dimensionsCommon.setValue(dimensionsCommon.getValue().multiply(new BigDecimal("2.0")));
- dimensionsCommon.setValueDate("updated-" + dimensionsCommon.getValueDate());
- if (logger.isDebugEnabled()) {
- logger.debug("to be updated object");
- logger.debug(objectAsXmlString(dimensionsCommon, DimensionsCommon.class));
- }
- // Submit the request to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());
- PayloadOutputPart commonPart = output.addPart(dimensionsCommon, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
-
- res = client.update(knownResourceId, output);
- int statusCode = res.getStatus();
- assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
- DimensionsCommon updatedDimensionsCommon =
- (DimensionsCommon) extractPart(input,
- client.getCommonPartName(), DimensionsCommon.class);
- Assert.assertNotNull(updatedDimensionsCommon);
-
- Assert.assertEquals(updatedDimensionsCommon.getValueDate(),
- dimensionsCommon.getValueDate(),
- "Data in updated object did not match submitted data.");
-
- }
-
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
- */
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty?
- }
-
+*/
/*
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
}
- */
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateNonExistent();
-
- // 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 update(), below.
- DimensionClient client = new DimensionClient();
- PoxPayloadOut multipart = createDimensionInstance(client.getCommonPartName(),
- NON_EXISTENT_ID);
- ClientResponse<String> 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(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : DELETE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "readList", "testSubmitRequest", "update", "readWorkflow"})
- public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- // Submit the request to the service and store the response.
- DimensionClient client = new DimensionClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDeleteNonExistent();
-
- // Submit the request to the service and store the response.
- DimensionClient client = new DimensionClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // Search tests
- // ---------------------------------------------------------------
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void searchWorkflowDeleted(String testName) throws Exception {
- // Fixme: null test for now, overriding test in base class
- }
-
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
- /**
- * Tests the code for manually submitting data that is used by several
- * of the methods above.
- */
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() {
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testSubmitRequest: url=" + url
- + " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
- }
-
- // ---------------------------------------------------------------
- // Utility methods used by tests above
- // ---------------------------------------------------------------
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
- */
- @Override
- public String getServicePathComponent() {
- return DimensionClient.SERVICE_PATH_COMPONENT;
- }
-
- @Override
- protected PoxPayloadOut createInstance(String identifier) {
- DimensionClient client = new DimensionClient();
- return createDimensionInstance(client.getCommonPartName(), identifier);
- }
-
- /**
- * Creates the dimension instance.
- *
- * @param identifier the identifier
- * @return the multipart output
- */
- private PoxPayloadOut createDimensionInstance(String commonPartName, String identifier) {
- return createDimensionInstance(commonPartName,
- "dimensionType-" + identifier,
- DIMENSION_VALUE,
- "entryDate-" + identifier);
- }
-
- /**
- * Creates the dimension instance.
- *
- * @param dimensionType the dimension type
- * @param entryNumber the entry number
- * @param entryDate the entry date
- * @return the multipart output
- */
- private PoxPayloadOut createDimensionInstance(String commonPartName, String dimensionType, String dimensionValue, String entryDate) {
- DimensionsCommon dimensionsCommon = new DimensionsCommon();
- dimensionsCommon.setDimension(dimensionType);
- dimensionsCommon.setValue(new BigDecimal(dimensionValue));
- dimensionsCommon.setValueDate(entryDate);
- PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(
- commonPartName, dimensionsCommon);
-
- if (logger.isDebugEnabled()) {
- logger.debug("to be created, dimension common");
- logger.debug(objectAsXmlString(dimensionsCommon,
- DimensionsCommon.class));
- }
-
- return multipart;
- }
-
-// @Override
-// protected String createTestObject(String testName) throws Exception {
-// String result = null;
-//
-// DimensionClient client = new DimensionClient();
-// String identifier = createIdentifier();
-// PoxPayloadOut multipart = createDimensionInstance(client.getCommonPartName(),
-// identifier);
-// ClientResponse<Response> res = client.create(multipart);
-//
-// int statusCode = res.getStatus();
-// Assert.assertEquals(statusCode, STATUS_CREATED);
-//
-// result = extractId(res);
-// allResourceIdsCreated.add(result);
-//
-// return result;
-// }
-
-// /*
-// * This test assumes that no objects exist yet.
-// *
-// * http://localhost:8180/cspace-services/intakes?wf_deleted=false
-// */
-// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"update"})
-// public void readWorkflowList(String testName) throws Exception {
-// //
-// // Create 3 new objects
-// //
-// final int OBJECTS_TOTAL = 3;
-// for (int i = 0; i < OBJECTS_TOTAL; i++) {
-// this.createWorkflowTarget(testName);
-// }
-// //
-// // Mark one as soft deleted
-// //
-// int currentTotal = allResourceIdsCreated.size();
-// String csid = allResourceIdsCreated.get(currentTotal - 1); //0-based index to get the last one added
-// this.setupUpdate();
-// this.updateLifeCycleState(testName, csid, WorkflowClient.WORKFLOWSTATE_DELETED);
-// //
-// // Read the list back. The deleted item should not be in the list
-// //
-//// int updatedTotal = readIncludeDeleted(testName, Boolean.FALSE);
-//// Assert.assertEquals(updatedTotal, currentTotal - 1, "Deleted items seem to be returned in list results.");
-// }
-
- protected void updateLifeCycleState(String testName, String resourceId, String lifeCycleState) throws Exception {
- //
- // Read the existing object
- //
- DimensionClient client = new DimensionClient();
- ClientResponse<String> res = client.getWorkflow(resourceId);
- assertStatusCode(res, testName);
- logger.debug("Got object to update life cycle state with ID: " + resourceId);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- WorkflowCommon workflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
- Assert.assertNotNull(workflowCommons);
- //
- // Mark it for a soft delete.
- //
- logger.debug("Current workflow state:" + objectAsXmlString(workflowCommons, WorkflowCommon.class));
- workflowCommons.setCurrentLifeCycleState(lifeCycleState);
- PoxPayloadOut output = new PoxPayloadOut(WorkflowClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(workflowCommons, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(WorkflowClient.SERVICE_COMMONPART_NAME);
- //
- // Perform the update
- //
- res = client.updateWorkflow(resourceId, output);
- assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
- WorkflowCommon updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
- Assert.assertNotNull(updatedWorkflowCommons);
- //
- // Read the updated object and make sure it was updated correctly.
- //
- res = client.getWorkflow(resourceId);
- assertStatusCode(res, testName);
- logger.debug("Got workflow state of updated object with ID: " + resourceId);
- input = new PoxPayloadIn(res.getEntity());
- updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
- Assert.assertNotNull(workflowCommons);
- Assert.assertEquals(updatedWorkflowCommons.getCurrentLifeCycleState(), lifeCycleState);
- }
-
+*/
}
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.dimension.jaxb</artifactId>
<name>services.dimension.jaxb</name>
<artifactId>org.collectionspace.services.jaxb</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.hyperjaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
- jaxb:version="1.0" elementFormDefault="unqualified"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"
+ elementFormDefault="unqualified"
xmlns:ns="http://collectionspace.org/services/dimension"
xmlns="http://collectionspace.org/services/dimension"
targetNamespace="http://collectionspace.org/services/dimension"
<xs:element name="dimension" type="xs:string"
minOccurs="1" />
<!-- uri to retrive dimension details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
+ <xs:element name="uri" type="xs:anyURI" minOccurs="1" />
+ <xs:element name="csid" type="xs:string" minOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
</parent>\r
\r
<modelVersion>4.0.0</modelVersion>\r
- <groupId>org.collectionspace.services</groupId>\r
<artifactId>org.collectionspace.services.dimension</artifactId>\r
<name>services.dimension</name>\r
<packaging>pom</packaging>\r
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
\r
<!-- javax -->\r
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
*
*/
public class GroupClient extends AbstractCommonListPoxServiceClientImpl<GroupProxy> {
+
public static final String SERVICE_NAME = "groups";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
@Override
public Class<GroupProxy> getProxyClass() {
- // TODO Auto-generated method stub
return GroupProxy.class;
}
-
}
*/
package org.collectionspace.services.client.test;
-import java.util.List;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.GroupClient;
import org.collectionspace.services.client.GroupProxy;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.group.GroupsCommon;
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-public class GroupServiceTest extends AbstractServiceTestImpl {
+public class GroupServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, GroupsCommon> {
private final String CLASS_NAME = GroupServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
}
@Override
- protected CollectionSpaceClient<AbstractCommonList, GroupProxy> getClientInstance() {
+ protected CollectionSpaceClient<AbstractCommonList, PoxPayloadOut, String, GroupProxy> getClientInstance() {
return new GroupClient();
}
@Override
- protected AbstractCommonList getAbstractCommonList(ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
return response.getEntity(AbstractCommonList.class);
}
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void create(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupCreate();
- GroupClient client = new GroupClient();
- PoxPayloadOut multipart = createGroupInstance(createIdentifier());
- ClientResponse<Response> res = client.create(multipart);
- assertStatusCode(res, testName);
- if (knownResourceId == null) {
- knownResourceId = extractId(res); // Store the ID returned from the first resource created for additional tests below.
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
- allResourceIdsCreated.add(extractId(res)); // Store the IDs from every resource created by tests so they can be deleted after tests have been run.
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
- public void createList(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- for (int i = 0; i < 3; i++) {
- create(testName);
- }
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
- public void read(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupRead();
- GroupClient client = new GroupClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- GroupsCommon group = (GroupsCommon) extractPart(input, client.getCommonPartName(), GroupsCommon.class);
- Assert.assertNotNull(group);
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"createList", "read"})
- public void readList(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupReadList();
- GroupClient client = new GroupClient();
- ClientResponse<AbstractCommonList> res = client.readList();
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
- if(logger.isTraceEnabled()){
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"read"})
- public void update(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupUpdate();
- GroupClient client = new GroupClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
- logger.debug("got object to update with ID: " + knownResourceId);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- GroupsCommon group = (GroupsCommon) extractPart(input, client.getCommonPartName(), GroupsCommon.class);
- Assert.assertNotNull(group);
-
- group.setTitle("updated-" + group.getTitle());
- logger.debug("Object to be updated:"+objectAsXmlString(group, GroupsCommon.class));
- PoxPayloadOut output = new PoxPayloadOut(GroupClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(group, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
- res = client.update(knownResourceId, output);
- assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
- GroupsCommon updatedGroup = (GroupsCommon) extractPart(input, client.getCommonPartName(), GroupsCommon.class);
- Assert.assertNotNull(updatedGroup);
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupUpdateNonExistent();
- // 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 update(), below.
- GroupClient client = new GroupClient();
- PoxPayloadOut multipart = createGroupInstance(NON_EXISTENT_ID);
- ClientResponse<String> res = client.update(NON_EXISTENT_ID, multipart);
- assertStatusCode(res, testName);
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
- public void delete(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupDelete();
- GroupClient client = new GroupClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- assertStatusCode(res, testName);
- }
-
- // ---------------------------------------------------------------
- // Failure outcome tests : means we expect response to fail, but test to succeed
- // ---------------------------------------------------------------
-
- // Failure outcome
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"read"})
- public void readNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupReadNonExistent();
- GroupClient client = new GroupClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
- assertStatusCode(res, testName);
- }
-
- // Failure outcome
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupDeleteNonExistent();
- GroupClient client = new GroupClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- assertStatusCode(res, testName);
- }
-
- // Failure outcomes
- // Placeholders until the tests below can be implemented. See Issue CSPACE-401.
-
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- }
-
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- }
-
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- }
-
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- }
-
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- }
-
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- }
-
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
-
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() {
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode(); // Expected status code: 200 OK
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
- logger.debug("testSubmitRequest: url=" + url + " status=" + statusCode);
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
- }
-
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
@Override
protected PoxPayloadOut createInstance(String identifier) {
GroupClient client = new GroupClient();
- return createGroupInstance(identifier);
+ return createInstance(client.getCommonPartName(), identifier);
}
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ return createGroupInstance(identifier);
+ }
+
private PoxPayloadOut createGroupInstance(String uid) {
String identifier = "title-" + uid;
GroupsCommon group = new GroupsCommon();
return multipart;
}
+
+ @Override
+ public void CRUDTests(String testName) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected GroupsCommon updateInstance(GroupsCommon groupsCommon) {
+ GroupsCommon result = new GroupsCommon();
+
+ result.setTitle("updated-" + groupsCommon.getTitle());
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(GroupsCommon original,
+ GroupsCommon updated) throws Exception {
+ Assert.assertEquals(updated.getTitle(), original.getTitle());
+ }
}
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<!-- javax -->
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
-\r
-<!--\r
- $LastChangedRevision: 1341 $\r
- $LastChangedDate: 2010-02-15 22:01:55 -0800 (Mon, 15 Feb 2010) $\r
--->\r
-\r
-<xs:schema \r
- xmlns:xs="http://www.w3.org/2001/XMLSchema"\r
- xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"\r
- xmlns:hj="http://hyperjaxb3.jvnet.org/ejb/schemas/customizations"\r
- xmlns:ns="http://collectionspace.org/services/hyperjaxb"\r
- xmlns="http://collectionspace.org/services/hyperjaxb"\r
- targetNamespace="http://collectionspace.org/services/hyperjaxb"\r
- jaxb:extensionBindingPrefixes="hj"\r
- version="0.9">\r
- \r
- <xs:annotation>\r
- <xs:appinfo>\r
- <jaxb:globalBindings generateIsSetMethod="true" localScoping="toplevel">\r
- <jaxb:serializable/>\r
- </jaxb:globalBindings>\r
- </xs:appinfo>\r
- </xs:annotation>\r
- \r
- <xs:element name="abstract-common-list">\r
- <xs:complexType>\r
- <xs:annotation>\r
- <xs:documentation>\r
- </xs:documentation>\r
- <xs:appinfo>\r
- <hj:ignored/>\r
- </xs:appinfo>\r
- </xs:annotation> \r
- <xs:sequence>\r
- <xs:element name="pageNum" type="xs:unsignedInt" />\r
- <xs:element name="pageSize" type="xs:unsignedInt" />\r
- <!-- "itemsInPage" is useful to our testing framework's unit tests -->\r
- <xs:element name="itemsInPage" type="xs:unsignedInt" />\r
- <xs:element name="totalItems" type="xs:unsignedInt" />\r
- </xs:sequence>\r
- </xs:complexType>\r
- </xs:element>\r
- \r
-</xs:schema>
\ No newline at end of file
<!--
Avoid XmlRootElement nightmare:
See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
--->
-
+ -->
<xs:include schemaLocation="permissions.xsd"/>
</xs:complexType>
</xs:element>
- <xs:element name="foo_permissions_list">
- <xs:complexType>
- <xs:annotation>
- <xs:appinfo>
- <hj:ignored/>
- </xs:appinfo>
- </xs:annotation>
- <xs:complexContent>
- <xs:extension base="abstractCommonList">
- <xs:sequence>
- <xs:element name="permissions-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:annotation>
- <xs:appinfo>
- <hj:ignored/>
- </xs:appinfo>
- </xs:annotation>
- <xs:sequence>
- <xs:element name="screenName" type="xs:string" minOccurs="1"/>
- <xs:element name="personRefName" type="xs:string" minOccurs="1" />
- <xs:element name="email" type="xs:string" minOccurs="1" />
- <!-- uri to retrive collection object details -->
- <xs:element name="uri" type="xs:anyURI" minOccurs="1" />
- <xs:element name="csid" type="xs:string" minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
- <!-- This is the base class for paginated lists -->
- <xs:complexType name="abstractCommonList">
- <xs:annotation>
- <xs:appinfo>
- <jaxb:class ref="org.collectionspace.services.hyperjaxb.AbstractCommonList"/>
- </xs:appinfo>
- </xs:annotation>
- </xs:complexType>
-
- <xs:element name="foo-common-list">
- <xs:complexType>
- <xs:annotation>
- <xs:documentation>
- AccountsCommonList contains information about one or more
- accounts. An instance of this type could be returned on
- index and search operations.
- </xs:documentation>
- <xs:appinfo>
- <hj:ignored/>
- </xs:appinfo>
- </xs:annotation>
- <xs:complexContent>
- <xs:extension base="abstractCommonList">
- <xs:sequence>
- <xs:element name="foo-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:annotation>
- <xs:appinfo>
- <hj:ignored/>
- </xs:appinfo>
- </xs:annotation>
- <xs:sequence>
- <xs:element name="screenName" type="xs:string" minOccurs="1"/>
- <xs:element name="personRefName" type="xs:string" minOccurs="1" />
- <xs:element name="email" type="xs:string" minOccurs="1" />
- <!-- uri to retrive collection object details -->
- <xs:element name="uri" type="xs:anyURI" minOccurs="1" />
- <xs:element name="csid" type="xs:string" minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
-
</xs:schema>
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-public class IdClient extends AbstractServiceClientImpl<String, IdProxy> {
+public class IdClient extends AbstractServiceClientImpl<String, String, String, IdProxy> {
/* (non-Javadoc)
* @see org.collectionspace.services.client.BaseServiceClient#getServicePathComponent()
public ClientResponse<String> createId(String csid) {
return getProxy().createId(csid);
}
+
+ @Override
+ public ClientResponse<String> update(String csid, String payload) {
+ throw new UnsupportedOperationException("ID client does not support an update operation."); }
}
*/
@Override
protected CollectionSpaceClient getClientInstance() {
- return new IdClient();
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- throw new UnsupportedOperationException(
- "IdServiceTest.getAbstractCommonList method is not currently supported.");
+ return (CollectionSpaceClient) new IdClient();
}
// ---------------------------------------------------------------
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- };
-
// Perform setup.
testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
if(logger.isDebugEnabled()){
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
String newID = extractId(res);
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
dependsOnMethods = {"create"})
public void createId(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- };
-
// 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).
// Submit the request to the service and store the response.
IdClient client = new IdClient();
ClientResponse<String> res = client.createId(knownResourceId);
- assertStatusCode(res, testName);
-
- String generatedId = res.getEntity();
- Assert.assertNotNull(generatedId);
- Assert.assertFalse(generatedId.isEmpty());
- if (logger.isDebugEnabled()) {
- logger.debug("generated ID=" + generatedId);
+ String generatedId = null;
+ try {
+ assertStatusCode(res, testName);
+ generatedId = res.getEntity();
+ Assert.assertNotNull(generatedId);
+ Assert.assertFalse(generatedId.isEmpty());
+ if (logger.isDebugEnabled()) {
+ logger.debug("generated ID=" + generatedId);
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
-
// Create a second ID. Verify that it is different from the first.
// Assumes that the last part in the ID pattern generates values
// that will always differ at each generation.
res = client.createId(knownResourceId);
- assertStatusCode(res, testName);
-
- String secondGeneratedId = res.getEntity();
- Assert.assertNotNull(secondGeneratedId);
- Assert.assertFalse(secondGeneratedId.isEmpty());
- Assert.assertFalse(secondGeneratedId.equals(generatedId));
- if (logger.isDebugEnabled()) {
- logger.debug("second generated ID=" + secondGeneratedId);
+ try {
+ assertStatusCode(res, testName);
+ String secondGeneratedId = res.getEntity();
+ Assert.assertNotNull(secondGeneratedId);
+ Assert.assertFalse(secondGeneratedId.isEmpty());
+ Assert.assertFalse(secondGeneratedId.equals(generatedId));
+ if (logger.isDebugEnabled()) {
+ logger.debug("second generated ID=" + secondGeneratedId);
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
dependsOnMethods = {"create"})
public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- };
-
// Perform setup.
testSetup(STATUS_OK, ServiceRequestType.READ);
// Submit the request to the service and store the response.
IdClient client = new IdClient();
ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
String entity = res.getEntity();
Assert.assertNotNull(entity);
if (logger.isDebugEnabled()) {
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
dependsOnMethods = {"create"})
public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- };
-
// Perform setup.
testSetup(STATUS_OK, ServiceRequestType.READ_LIST);
// Submit the request to the service and store the response.
IdClient client = new IdClient();
ClientResponse<String> res = client.readList();
- assertStatusCode(res, testName);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
String entity = res.getEntity();
Assert.assertNotNull(entity);
if (logger.isDebugEnabled()) {
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
dependsOnMethods = {"create", "createId", "read", "readList"})
public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Perform setup.
testSetup(STATUS_OK, ServiceRequestType.DELETE);
if(logger.isDebugEnabled()){
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<!-- javax -->
\r
package org.collectionspace.services.imports;\r
\r
-import java.io.*;\r
import java.util.UUID;\r
\r
import org.collectionspace.services.common.IFragmentHandler;\r
\r
import org.dom4j.Document;\r
import org.dom4j.Element;\r
-import org.hibernate.sql.Template;\r
-import org.testng.annotations.Test;\r
import org.xml.sax.InputSource;\r
\r
/** This class expands templates specifically for the imports service.\r
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
<dependency>\r
<groupId>org.jboss.resteasy</groupId>\r
@Override
public Class<IntakeProxy> getProxyClass() {
- // TODO Auto-generated method stub
return IntakeProxy.class;
}
}
import java.util.List;
import java.util.Map;
-import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.collectionspace.services.PersonJAXBSchema;
* $LastChangedRevision: 1327 $
* $LastChangedDate: 2010-02-12 10:35:11 -0800 (Fri, 12 Feb 2010) $
*/
-public class IntakeAuthRefsTest extends BaseServiceTest {
+public class IntakeAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
private final String CLASS_NAME = IntakeAuthRefsTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
+ protected AbstractCommonList getCommonList(
ClientResponse<AbstractCommonList> response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
// Success outcomes
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
public void createWithAuthRefs(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
// Submit the request to the service and store the response.
if(logger.isDebugEnabled()){
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Store the ID returned from the first resource created
// for additional tests below.
ClientResponse<Response> res = personAuthClient.create(multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
personAuthCSID = extractId(res);
ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
return extractId(res);
}
// Success outcomes
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ @Test(dataProvider="testName",
dependsOnMethods = {"createWithAuthRefs"})
public void readAndCheckAuthRefs(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
testSetup(STATUS_OK, ServiceRequestType.READ);
// Submit the request to the service and store the response.
IntakeClient intakeClient = new IntakeClient();
ClientResponse<String> res = intakeClient.read(knownResourceId);
- assertStatusCode(res, testName);
-
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- IntakesCommon intake = (IntakesCommon) extractPart(input,
- intakeClient.getCommonPartName(), IntakesCommon.class);
- Assert.assertNotNull(intake);
- // Check a couple of fields
- Assert.assertEquals(intake.getCurrentOwner(), currentOwnerRefName);
- Assert.assertEquals(intake.getConditionCheckersOrAssessors().getConditionCheckerOrAssessor().get(0), conditionCheckerOrAssessorRefName);
- Assert.assertEquals(intake.getInsurers().getInsurer().get(0), insurerRefName);
+ try {
+ assertStatusCode(res, testName);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ IntakesCommon intake = (IntakesCommon) extractPart(input,
+ intakeClient.getCommonPartName(), IntakesCommon.class);
+ Assert.assertNotNull(intake);
+ // Check a couple of fields
+ Assert.assertEquals(intake.getCurrentOwner(), currentOwnerRefName);
+ Assert.assertEquals(intake.getConditionCheckersOrAssessors().getConditionCheckerOrAssessor().get(0), conditionCheckerOrAssessorRefName);
+ Assert.assertEquals(intake.getInsurers().getInsurer().get(0), insurerRefName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
// Get the auth refs and check them
ClientResponse<AuthorityRefList> res2 = intakeClient.getAuthorityRefs(knownResourceId);
- assertStatusCode(res2, testName);
-
- AuthorityRefList list = res2.getEntity();
+ AuthorityRefList list = null;
+ try {
+ assertStatusCode(res2, testName);
+ list = res2.getEntity();
+ } finally {
+ if (res2 != null) {
+ res2.releaseConnection();
+ }
+ }
List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
int numAuthRefsFound = items.size();
PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
PayloadOutputPart commonPart =
- multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(new IntakeClient().getCommonPartName());
+ multipart.addPart(new IntakeClient().getCommonPartName(), intake);
if(logger.isDebugEnabled()){
logger.debug("to be created, intake common");
import java.util.List;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import org.dom4j.Element;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.intake.EntryMethodList;
import org.collectionspace.services.intake.FieldCollectionEventNameList;
* $LastChangedRevision$
* $LastChangedDate$
*/
-public class IntakeServiceTest extends AbstractServiceTestImpl {
+public class IntakeServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, IntakesCommon> {
/** The logger. */
private final String CLASS_NAME = IntakeServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(IntakeServiceTest.class);
- /** The known resource id. */
- private String knownResourceId = null;
private final static String CURRENT_DATE_UTC =
GregorianCalendarDateTimeUtils.currentDateUTC();
return IntakeClient.SERVICE_NAME;
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
- }
-
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
- // Success outcomes
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // 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();
-
- // Submit the request to the service and store the response.
- IntakeClient client = new IntakeClient();
- String identifier = createIdentifier();
- PoxPayloadOut multipart = createInstance(identifier);
- ClientResponse<Response> res = client.create(multipart);
-
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Store the ID returned from the first resource created
- // for additional tests below.
- if (knownResourceId == null) {
- knownResourceId = extractId(res);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
- }
-
- // Store the IDs from every resource created by tests,
- // so they can be deleted after tests have been run.
- allResourceIdsCreated.add(extractId(res));
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void createList(String testName) throws Exception {
- for (int i = 0; i < 3; i++) {
- create(testName);
- }
- }
-
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
-
// See Issue CSPACE-401.
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
// CRUD tests : READ tests
// ---------------------------------------------------------------
- // Success outcomes
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- IntakeClient client = new IntakeClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
-
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
- IntakesCommon intakeCommons = null;
- if (payloadInputPart != null) {
- intakeCommons = (IntakesCommon) payloadInputPart.getBody();
- }
-// IntakesCommon intake = (IntakesCommon) extractPart(input,
-// client.getCommonPartName(), IntakesCommon.class);
- Assert.assertNotNull(intakeCommons);
-
+ protected void compareReadInstances(IntakesCommon original, IntakesCommon fromRead) throws Exception {
// Verify the number and contents of values in repeatable fields,
// as created in the instance record used for testing.
List<String> entryMethods =
- intakeCommons.getEntryMethods().getEntryMethod();
+ fromRead.getEntryMethods().getEntryMethod();
Assert.assertTrue(entryMethods.size() > 0);
Assert.assertNotNull(entryMethods.get(0));
List<String> fieldCollectionEventNames =
- intakeCommons.getFieldCollectionEventNames().getFieldCollectionEventName();
+ fromRead.getFieldCollectionEventNames().getFieldCollectionEventName();
Assert.assertTrue(fieldCollectionEventNames.size() > 0);
Assert.assertNotNull(fieldCollectionEventNames.get(0));
- CurrentLocationGroupList currentLocationGroupList = intakeCommons.getCurrentLocationGroupList();
+ CurrentLocationGroupList currentLocationGroupList = fromRead.getCurrentLocationGroupList();
Assert.assertNotNull(currentLocationGroupList);
List<CurrentLocationGroup> currentLocationGroups = currentLocationGroupList.getCurrentLocationGroup();
Assert.assertNotNull(currentLocationGroups);
// Check the values of fields containing Unicode UTF-8 (non-Latin-1) characters.
if (logger.isDebugEnabled()) {
logger.debug("UTF-8 data sent=" + getUTF8DataFragment() + "\n"
- + "UTF-8 data received=" + intakeCommons.getEntryNote());
+ + "UTF-8 data received=" + fromRead.getEntryNote());
}
- Assert.assertEquals(intakeCommons.getEntryNote(), getUTF8DataFragment(),
- "UTF-8 data retrieved '" + intakeCommons.getEntryNote()
+ Assert.assertEquals(fromRead.getEntryNote(), getUTF8DataFragment(),
+ "UTF-8 data retrieved '" + fromRead.getEntryNote()
+ "' does not match expected data '" + getUTF8DataFragment());
- }
-
- // Failure outcomes
+ }
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void readNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- IntakeClient client = new IntakeClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
+ // Failure outcomes
- // ---------------------------------------------------------------
- // CRUD tests : READ_LIST tests
- // ---------------------------------------------------------------
-
- // Success outcomes
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
- */
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
- public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadList();
-
- // Submit the request to the service and store the response.
- IntakeClient client = new IntakeClient();
- ClientResponse<AbstractCommonList> res = client.readList();
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
-
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = true;
- if (iterateThroughList && logger.isDebugEnabled()) {
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
-
+ public void delete(String testName) throws Exception {
+ // Do nothing because this test is not ready to delete the "knownResourceId".
+ // Instead, the method localDelete() will get called later in the dependency chain. The
+ // method localDelete() has a dependency on the test "verifyReadOnlyCoreFields". Once the "verifyReadOnlyCoreFields"
+ // test is run, the localDelete() test/method will get run. The localDelete() test/method in turn
+ // calls the inherited delete() test/method.
}
-
- // Failure outcomes
- // None at present.
-
- // ---------------------------------------------------------------
- // CRUD tests : UPDATE tests
- // ---------------------------------------------------------------
- // Success outcomes
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void update(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
-
- // Retrieve the contents of a resource to update.
- IntakeClient client = new IntakeClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
-
- if (logger.isDebugEnabled()) {
- logger.debug("got object to update with ID: " + knownResourceId);
- }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
- IntakesCommon intakeCommons = null;
- if (payloadInputPart != null) {
- intakeCommons = (IntakesCommon) payloadInputPart.getBody();
- }
-// IntakesCommon intake = (IntakesCommon) extractPart(input,
-// client.getCommonPartName(), IntakesCommon.class);
- Assert.assertNotNull(intakeCommons);
-
- // Update the content of this resource.
- intakeCommons.setEntryNumber("updated-" + intakeCommons.getEntryNumber());
- if (logger.isDebugEnabled()) {
- logger.debug("to be updated object");
- logger.debug(objectAsXmlString(intakeCommons, IntakesCommon.class));
- }
-
- CurrentLocationGroupList currentLocationGroupList = intakeCommons.getCurrentLocationGroupList();
- Assert.assertNotNull(currentLocationGroupList);
- List<CurrentLocationGroup> currentLocationGroups = currentLocationGroupList.getCurrentLocationGroup();
- Assert.assertNotNull(currentLocationGroups);
- Assert.assertTrue(currentLocationGroups.size() > 0);
- CurrentLocationGroup currentLocationGroup = currentLocationGroups.get(0);
- Assert.assertNotNull(currentLocationGroup);
- String currentLocationNote = currentLocationGroup.getCurrentLocationNote();
- Assert.assertNotNull(currentLocationNote);
- String updatedCurrentLocationNote = "updated-" + currentLocationNote;
- currentLocationGroups.get(0).setCurrentLocationNote(updatedCurrentLocationNote);
- intakeCommons.setCurrentLocationGroupList(currentLocationGroupList);
-
- // Create an output payload to send to the service, and add teh common part
- PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());
- PayloadOutputPart commonPart = output.addPart(intakeCommons, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
-
- // Submit the request to the service and store the response.
- res = client.update(knownResourceId, output);
- assertStatusCode(res, testName);
-
- input = new PoxPayloadIn(res.getEntity());
- IntakesCommon updatedIntake =
- (IntakesCommon) extractPart(input,
- client.getCommonPartName(), IntakesCommon.class);
-
- Assert.assertNotNull(updatedIntake);
-
- Assert.assertEquals(updatedIntake.getEntryNumber(),
- intakeCommons.getEntryNumber(),
- "Data in updated object did not match submitted data.");
-
- currentLocationGroupList = updatedIntake.getCurrentLocationGroupList();
- Assert.assertNotNull(currentLocationGroupList);
- currentLocationGroups = currentLocationGroupList.getCurrentLocationGroup();
- Assert.assertNotNull(currentLocationGroups);
- Assert.assertTrue(currentLocationGroups.size() > 0);
- Assert.assertNotNull(currentLocationGroups.get(0));
- Assert.assertEquals(updatedCurrentLocationNote,
- currentLocationGroups.get(0).getCurrentLocationNote(),
- "Data in updated object did not match submitted data.");
-
- if (logger.isDebugEnabled()) {
- logger.debug("UTF-8 data sent=" + intakeCommons.getEntryNote() + "\n"
- + "UTF-8 data received=" + updatedIntake.getEntryNote());
- }
- Assert.assertTrue(updatedIntake.getEntryNote().contains(getUTF8DataFragment()),
- "UTF-8 data retrieved '" + updatedIntake.getEntryNote()
- + "' does not contain expected data '" + getUTF8DataFragment());
- Assert.assertEquals(updatedIntake.getEntryNote(),
- intakeCommons.getEntryNote(),
- "Data in updated object did not match submitted data.");
-
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests", "verifyReadOnlyCoreFields"})
+ public void localDelete(String testName) throws Exception {
+ // Because of issues with TestNG not allowing @Test annotations on on override methods,
+ // and because we want the "updateWrongUser" to run before the "delete" test, we need
+ // this method. This method will call super.delete() after all the dependencies have been
+ // met.
+ super.delete(testName);
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"update"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
public void verifyReadOnlyCoreFields(String testName) throws Exception {
// TODO These should be in some core client utils
final String COLLECTIONSPACE_CORE_SCHEMA = "collectionspace_core";
final String COLLECTIONSPACE_CORE_CREATED_BY = "createdBy";
final String COLLECTIONSPACE_CORE_UPDATED_BY = "updatedBy";
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupUpdate();
// Retrieve the contents of a resource to update.
IntakeClient client = new IntakeClient();
ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
PayloadInputPart payloadInputPart = input.getPart(COLLECTIONSPACE_CORE_SCHEMA);
// Submit the request to the service and store the response.
res = client.update(knownResourceId, output);
- assertStatusCode(res, testName);
+ int statusCode = res.getStatus();
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
input = new PoxPayloadIn(res.getEntity());
PayloadInputPart updatedCorePart = input.getPart(COLLECTIONSPACE_CORE_SCHEMA);
}
*/
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateNonExistent();
-
- // 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 update(), below.
- IntakeClient client = new IntakeClient();
- PoxPayloadOut multipart = createInstance(NON_EXISTENT_ID);
- ClientResponse<String> 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(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : DELETE tests
- // ---------------------------------------------------------------
-
- // Success outcomes
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "readList", "testSubmitRequest", "update", "verifyReadOnlyCoreFields"})
- public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- // Submit the request to the service and store the response.
- IntakeClient client = new IntakeClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // Failure outcomes
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDeleteNonExistent();
-
- // Submit the request to the service and store the response.
- IntakeClient client = new IntakeClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
// ---------------------------------------------------------------
// Utility tests : tests of code used in tests above
// ---------------------------------------------------------------
- /**
- * Tests the code for manually submitting data that is used by several
- * of the methods above.
- */
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() {
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testSubmitRequest: url=" + url
- + " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
- }
-
- // ---------------------------------------------------------------
- // Utility methods used by tests above
- // ---------------------------------------------------------------
-
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
*/
return multipart;
}
+
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ return this.createInstance(identifier);
+ }
+
+ @Override
+ protected IntakesCommon updateInstance(IntakesCommon intakesCommon) {
+ IntakesCommon result = new IntakesCommon();
+
+ result.setEntryNumber("updated-" + intakesCommon.getEntryNumber());
+ result.setEntryNote(intakesCommon.getEntryNote());
+
+ CurrentLocationGroupList currentLocationGroupList = intakesCommon.getCurrentLocationGroupList();
+ Assert.assertNotNull(currentLocationGroupList);
+ List<CurrentLocationGroup> currentLocationGroups = currentLocationGroupList.getCurrentLocationGroup();
+ Assert.assertNotNull(currentLocationGroups);
+ Assert.assertTrue(currentLocationGroups.size() > 0);
+ CurrentLocationGroup currentLocationGroup = currentLocationGroups.get(0);
+ Assert.assertNotNull(currentLocationGroup);
+ String currentLocationNote = currentLocationGroup.getCurrentLocationNote();
+ Assert.assertNotNull(currentLocationNote);
+ String updatedCurrentLocationNote = "updated-" + currentLocationNote;
+ currentLocationGroups.get(0).setCurrentLocationNote(updatedCurrentLocationNote);
+ result.setCurrentLocationGroupList(currentLocationGroupList);
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(IntakesCommon original,
+ IntakesCommon updated) throws Exception {
+ Assert.assertEquals(updated.getEntryNumber(),
+ original.getEntryNumber(),
+ "Data in updated object did not match submitted data.");
+
+ CurrentLocationGroupList currentLocationGroupList = updated.getCurrentLocationGroupList();
+ Assert.assertNotNull(currentLocationGroupList);
+ List<CurrentLocationGroup> currentLocationGroups = currentLocationGroupList.getCurrentLocationGroup();
+ Assert.assertNotNull(currentLocationGroups);
+ Assert.assertTrue(currentLocationGroups.size() > 0);
+ Assert.assertNotNull(currentLocationGroups.get(0));
+
+ String updatedCurrentLocationNote = original.getCurrentLocationGroupList()
+ .getCurrentLocationGroup().get(0).getCurrentLocationNote();
+ Assert.assertEquals(updatedCurrentLocationNote,
+ currentLocationGroups.get(0).getCurrentLocationNote(),
+ "Data in updated object did not match submitted data.");
+
+ Assert.assertEquals(updated.getEntryNote(), original.getEntryNote(),
+ "Data in updated object did not match submitted data.");
+ //
+ // UTF-8 Checks
+ //
+ if (logger.isDebugEnabled()) {
+ logger.debug("UTF-8 data sent=" + original.getEntryNote() + "\n"
+ + "UTF-8 data received=" + updated.getEntryNote());
+ }
+ Assert.assertTrue(updated.getEntryNote().contains(getUTF8DataFragment()),
+ "UTF-8 data retrieved '" + updated.getEntryNote()
+ + "' does not contain expected data '" + getUTF8DataFragment());
+ }
+
+ /*
+ * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
+ * refer to this method in their @Test annotation declarations.
+ */
+ @Override
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {
+ "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
+ public void CRUDTests(String testName) {
+ // TODO Auto-generated method stub
+ }
}
* $LastChangedRevision: 1327 $\r
* $LastChangedDate: 2010-02-12 10:35:11 -0800 (Fri, 12 Feb 2010) $\r
*/\r
-public class OrganizationAuthRefDocsTest extends BaseServiceTest {\r
+public class OrganizationAuthRefDocsTest extends BaseServiceTest<AbstractCommonList> {\r
\r
private final String CLASS_NAME = OrganizationAuthRefDocsTest.class.getName();\r
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);\r
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)\r
*/\r
@Override\r
- protected AbstractCommonList getAbstractCommonList(\r
+ protected AbstractCommonList getCommonList(\r
ClientResponse<AbstractCommonList> response) {\r
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class\r
}\r
// Success outcomes\r
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)\r
public void createIntakeWithAuthRefs(String testName) throws Exception {\r
-\r
- if (logger.isDebugEnabled()) {\r
- logger.debug(testBanner(testName, CLASS_NAME));\r
- }\r
testSetup(STATUS_CREATED, ServiceRequestType.CREATE);\r
\r
// Submit the request to the service and store the response.\r
if(logger.isDebugEnabled()){\r
logger.debug(testName + ": status = " + statusCode);\r
}\r
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),\r
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);\r
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
+ invalidStatusCodeMessage(testRequestType, statusCode));\r
+ Assert.assertEquals(statusCode, testExpectedStatusCode);\r
} finally {\r
res.releaseConnection();\r
}\r
ClientResponse<Response> res = orgAuthClient.create(multipart);\r
int statusCode = res.getStatus();\r
\r
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),\r
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
+ invalidStatusCodeMessage(testRequestType, statusCode));\r
Assert.assertEquals(statusCode, STATUS_CREATED);\r
orgAuthCSID = extractId(res);\r
\r
ClientResponse<Response> res = orgAuthClient.createItem(orgAuthCSID, multipart);\r
int statusCode = res.getStatus();\r
\r
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),\r
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
+ invalidStatusCodeMessage(testRequestType, statusCode));\r
Assert.assertEquals(statusCode, STATUS_CREATED);\r
return extractId(res);\r
}\r
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,\r
dependsOnMethods = {"createIntakeWithAuthRefs"})\r
public void readAndCheckAuthRefDocs(String testName) throws Exception {\r
-\r
- if (logger.isDebugEnabled()) {\r
- logger.debug(testBanner(testName, CLASS_NAME));\r
- }\r
// Perform setup.\r
testSetup(STATUS_OK, ServiceRequestType.READ);\r
\r
OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();\r
ClientResponse<AuthorityRefDocList> refDocListResp =\r
orgAuthClient.getReferencingObjects(orgAuthCSID, currentOwnerOrgCSID);\r
- assertStatusCode(refDocListResp, testName);\r
-\r
- AuthorityRefDocList list = refDocListResp.getEntity();\r
+ AuthorityRefDocList list = null;\r
+ try {\r
+ assertStatusCode(refDocListResp, testName);\r
+ list = refDocListResp.getEntity();\r
+ Assert.assertNotNull(list);\r
+ } finally {\r
+ if (refDocListResp != null) {\r
+ refDocListResp.releaseConnection();\r
+ }\r
+ }\r
\r
// Optionally output additional data about list members for debugging.\r
boolean iterateThroughList = true;\r
\r
PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());\r
PayloadOutputPart commonPart =\r
- multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);\r
- commonPart.setLabel(new IntakeClient().getCommonPartName());\r
+ multipart.addPart(new IntakeClient().getCommonPartName(), intake);\r
\r
if(logger.isDebugEnabled()){\r
logger.debug("to be created, intake common");\r
import java.util.List;
import java.util.Map;
-import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.collectionspace.services.PersonJAXBSchema;
* $LastChangedRevision: 1327 $
* $LastChangedDate: 2010-02-12 10:35:11 -0800 (Fri, 12 Feb 2010) $
*/
-public class PersonAuthRefDocsTest extends BaseServiceTest {
+public class PersonAuthRefDocsTest extends BaseServiceTest<AbstractCommonList> {
private final String CLASS_NAME = PersonAuthRefDocsTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
+ protected AbstractCommonList getCommonList(
ClientResponse<AbstractCommonList> response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
// Success outcomes
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+ @Test(dataProvider = "testName")
public void createIntakeWithAuthRefs(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
// Submit the request to the service and store the response.
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
res.releaseConnection();
}
ClientResponse<Response> res = personAuthClient.create(multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
personAuthCSID = extractId(res);
ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
return extractId(res);
}
// Success outcomes
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createIntakeWithAuthRefs"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"createIntakeWithAuthRefs"})
public void readAndCheckAuthRefDocs(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
testSetup(STATUS_OK, ServiceRequestType.READ);
// Get the auth ref docs and check them
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
- ClientResponse<AuthorityRefDocList> refDocListResp =
+ ClientResponse<AuthorityRefDocList> res =
personAuthClient.getReferencingObjects(personAuthCSID, currentOwnerPersonCSID);
- assertStatusCode(refDocListResp, testName);
-
- AuthorityRefDocList list = refDocListResp.getEntity();
+ AuthorityRefDocList list = null;
+ try {
+ assertStatusCode(res, testName);
+ list = res.getEntity();
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
+
List<AuthorityRefDocList.AuthorityRefDocItem> items =
list.getAuthorityRefDocItem();
Assert.assertTrue(items != null);
}
Assert.assertTrue(fFoundIntake, "Did not find Intake with authref!");
}
-
+ //
+ // Get the referencing objects
+ //
personAuthClient = new PersonAuthorityClient();
- refDocListResp =
- personAuthClient.getReferencingObjects(personAuthCSID, depositorPersonCSID);
- assertStatusCode(refDocListResp, testName);
-
- list = refDocListResp.getEntity();
+ res = personAuthClient.getReferencingObjects(personAuthCSID, depositorPersonCSID);
+ try {
+ assertStatusCode(res, testName);
+ list = res.getEntity();
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
+
items = list.getAuthorityRefDocItem();
Assert.assertTrue(items != null);
Assert.assertTrue(items.size() > 0);
* Read and check the list of referencing objects, where the authRef field
* is a value instance of a repeatable scalar field.
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createIntakeWithAuthRefs"}, groups = {"repeatableScalar"})
+ @Test(dataProvider = "testName", dependsOnMethods = {"createIntakeWithAuthRefs"},
+ groups = {"repeatableScalar"})
public void readAndCheckAuthRefDocsRepeatableScalar(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
testSetup(STATUS_OK, ServiceRequestType.READ);
// Single scalar field
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
- ClientResponse<AuthorityRefDocList> refDocListResp =
+ ClientResponse<AuthorityRefDocList> res =
personAuthClient.getReferencingObjects(personAuthCSID, insurerPersonCSID);
- assertStatusCode(refDocListResp, testName);
-
- AuthorityRefDocList list = refDocListResp.getEntity();
+ AuthorityRefDocList list = null;
+ try {
+ assertStatusCode(res, testName);
+ list = res.getEntity();
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
+
List<AuthorityRefDocList.AuthorityRefDocItem> items =
list.getAuthorityRefDocItem();
Assert.assertTrue(items != null);
PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
PayloadOutputPart commonPart =
- multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(new IntakeClient().getCommonPartName());
+ multipart.addPart(new IntakeClient().getCommonPartName(), intake);
if (logger.isDebugEnabled()) {
logger.debug("to be created, intake common");
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
\r
<!-- javax -->\r
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
import javax.ws.rs.core.Response;
import org.collectionspace.services.PersonJAXBSchema;
-import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.LoaninClient;
import org.collectionspace.services.client.PersonAuthorityClient;
import org.collectionspace.services.client.PersonAuthorityClientUtils;
-import org.collectionspace.services.client.PayloadInputPart;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
* $LastChangedRevision$
* $LastChangedDate$
*/
-public class LoaninAuthRefsTest extends BaseServiceTest {
+public class LoaninAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
private final String CLASS_NAME = LoaninAuthRefsTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
+ protected AbstractCommonList getCommonList(
ClientResponse<AbstractCommonList> response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
// Success outcomes
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
public void createWithAuthRefs(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
// Submit the request to the service and store the response.
if(logger.isDebugEnabled()){
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Store the ID returned from the first resource created
// for additional tests below.
ClientResponse<Response> res = personAuthClient.create(multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
personAuthCSID = extractId(res);
ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
return extractId(res);
}
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
dependsOnMethods = {"createWithAuthRefs"})
public void readAndCheckAuthRefs(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
testSetup(STATUS_OK, ServiceRequestType.READ);
// Submit the request to the service and store the response.
LoaninClient loaninClient = new LoaninClient();
ClientResponse<String> res = loaninClient.read(knownResourceId);
- assertStatusCode(res, testName);
-
- // Extract the common part from the response.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- LoansinCommon loaninCommon = (LoansinCommon) extractPart(input,
- loaninClient.getCommonPartName(), LoansinCommon.class);
- Assert.assertNotNull(loaninCommon);
- if(logger.isDebugEnabled()){
- logger.debug(objectAsXmlString(loaninCommon, LoansinCommon.class));
+ LoansinCommon loaninCommon = null;
+ try {
+ assertStatusCode(res, testName);
+ // Extract the common part from the response.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ loaninCommon = (LoansinCommon) extractPart(input,
+ loaninClient.getCommonPartName(), LoansinCommon.class);
+ Assert.assertNotNull(loaninCommon);
+ if(logger.isDebugEnabled()){
+ logger.debug(objectAsXmlString(loaninCommon, LoansinCommon.class));
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
-
+ //
// Check a couple of fields
// Assert.assertEquals(loaninCommon.getLender(), lenderRefName);
// Assert.assertEquals(loaninCommon.getLendersAuthorizer(), lendersAuthorizerRefName);
// Assert.assertEquals(loaninCommon.getLendersContact(), lendersContactRefName);
+ //
Assert.assertEquals(loaninCommon.getLoanInContact(), loanInContactRefName);
Assert.assertEquals(loaninCommon.getBorrowersAuthorizer(), borrowersAuthorizerRefName);
// Get the auth refs and check them
- ClientResponse<AuthorityRefList> res2 =
- loaninClient.getAuthorityRefs(knownResourceId);
- assertStatusCode(res2, testName);
- AuthorityRefList list = res2.getEntity();
+ ClientResponse<AuthorityRefList> res2 = loaninClient.getAuthorityRefs(knownResourceId);
+ AuthorityRefList list = null;
+ try {
+ assertStatusCode(res2, testName);
+ list = res2.getEntity();
+ Assert.assertNotNull(list);
+ } finally {
+ if (res2 != null) {
+ res2.releaseConnection();
+ }
+ }
List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
int numAuthRefsFound = items.size();
return SERVICE_PATH_COMPONENT;
}
-
- private PoxPayloadOut createLoaninInstance(String loaninNumber,
+ private PoxPayloadOut createLoaninInstance(String loaninNumber,
String returnDate,
- String lender,
- String lendersAuthorizer,
- String lendersContact,
- String loaninContact,
- String borrowersAuthorizer) {
- LoansinCommon loaninCommon = new LoansinCommon();
- loaninCommon.setLoanInNumber(loaninNumber);
- loaninCommon.setLoanInNumber(returnDate);
- LenderGroupList lenderGroupList = new LenderGroupList();
- LenderGroup lenderGroup = new LenderGroup();
- lenderGroup.setLender(lender);
- lenderGroup.setLendersAuthorizer(lendersAuthorizer);
- lenderGroup.setLendersContact(lendersContact);
- lenderGroupList.getLenderGroup().add(lenderGroup);
- loaninCommon.setLenderGroupList(lenderGroupList);
- loaninCommon.setLoanInContact(loaninContact);
- loaninCommon.setBorrowersAuthorizer(borrowersAuthorizer);
-
- PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
- PayloadOutputPart commonPart =
- multipart.addPart(loaninCommon, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(new LoaninClient().getCommonPartName());
+ String lender,
+ String lendersAuthorizer,
+ String lendersContact,
+ String loaninContact,
+ String borrowersAuthorizer) {
+ LoansinCommon loaninCommon = new LoansinCommon();
+ loaninCommon.setLoanInNumber(loaninNumber);
+ loaninCommon.setLoanInNumber(returnDate);
+ LenderGroupList lenderGroupList = new LenderGroupList();
+ LenderGroup lenderGroup = new LenderGroup();
+ lenderGroup.setLender(lender);
+ lenderGroup.setLendersAuthorizer(lendersAuthorizer);
+ lenderGroup.setLendersContact(lendersContact);
+ lenderGroupList.getLenderGroup().add(lenderGroup);
+ loaninCommon.setLenderGroupList(lenderGroupList);
+ loaninCommon.setLoanInContact(loaninContact);
+ loaninCommon.setBorrowersAuthorizer(borrowersAuthorizer);
+
+ PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
+ PayloadOutputPart commonPart =
+ multipart.addPart(new LoaninClient().getCommonPartName(), loaninCommon);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("to be created, loanin common");
+ logger.debug(objectAsXmlString(loaninCommon, LoansinCommon.class));
+ }
- if(logger.isDebugEnabled()){
- logger.debug("to be created, loanin common");
- logger.debug(objectAsXmlString(loaninCommon, LoansinCommon.class));
- }
+ return multipart;
+ }
- return multipart;
+ @Override
+ protected Class<AbstractCommonList> getCommonListType() {
+ return AbstractCommonList.class;
}
}
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.LoaninClient;
import org.collectionspace.services.client.PayloadInputPart;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.loanin.LenderGroup;
import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
-import org.testng.annotations.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* $LastChangedRevision$
* $LastChangedDate$
*/
-public class LoaninServiceTest extends AbstractServiceTestImpl {
+public class LoaninServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, LoansinCommon> {
/** The logger. */
private final String CLASS_NAME = LoaninServiceTest.class.getName();
/** The service path component. */
final String SERVICE_NAME = "loansin";
final String SERVICE_PATH_COMPONENT = "loansin";
- /** The known resource id. */
- private String knownResourceId = null;
private String LENDER_REF_NAME =
"urn:cspace:org.collectionspace.demo:personauthorities:name(TestPersonAuth):item:name(HarryLender)'Harry Lender'";
private final static String CURRENT_DATE_UTC =
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
+ protected AbstractCommonList getCommonList(
ClientResponse<AbstractCommonList> response) {
return response.getEntity(AbstractCommonList.class);
}
* @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// 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).
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
newID = extractId(res);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
// Store the ID returned from the first resource created
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"create"})
public void createList(String testName) throws Exception {
for (int i = 0; i < 3; i++) {
create(testName);
}
}
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
- */
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty?
- }
/*
@Override
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"create"})
public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupRead();
// Submit the request to the service and store the response.
LoaninClient client = new LoaninClient();
ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
PoxPayloadIn input = null;
try {
+ assertStatusCode(res, testName);
input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
// Get the common part of the response and verify that it is not null.
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"read"})
public void readNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupReadNonExistent();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"createList", "read"})
public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupReadList();
ClientResponse<AbstractCommonList> res = client.readList();
assertStatusCode(res, testName);
try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
list = res.getEntity();
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
// Optionally output additional data about list members for debugging.
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"read"})
public void update(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
- setupUpdate();
+ setupRead();
// Retrieve the contents of a resource to update.
LoaninClient client = new LoaninClient();
ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
PoxPayloadIn input = null;
try {
- if (logger.isDebugEnabled()) {
+ assertStatusCode(res, testName);
+ input = new PoxPayloadIn(res.getEntity());
+ if (logger.isDebugEnabled()) {
logger.debug("got object to update with ID: " + knownResourceId);
}
- input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
// Extract the common part from the response.
logger.debug(objectAsXmlString(loaninCommon, LoansinCommon.class));
}
+ setupUpdate();
+
// Submit the updated common part in an update request to the service
// and store the response.
PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());
- PayloadOutputPart commonPart = output.addPart(loaninCommon, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
+ PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), loaninCommon);
res = client.update(knownResourceId, output);
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
+ int statusCode = res.getStatus();
+ // Check the status code of the response: does it match the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
// Extract the updated common part from the response.
"Data in updated object did not match submitted data.");
}
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
- */
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
- */
@Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /*
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithEmptyEntityBody();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithWrongXmlSchema(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithWrongXmlSchema();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
- */
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"update", "testSubmitRequest"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"update", "testSubmitRequest"})
public void updateNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupUpdateNonExistent();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupDelete();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"delete"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"delete"})
public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupDeleteNonExistent();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
* Tests the code for manually submitting data that is used by several
* of the methods above.
*/
- @Test(dependsOnMethods = {"create", "read"})
+// @Test(dependsOnMethods = {"create", "read"})
public void testSubmitRequest() {
// Expected status code: 200 OK
PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
PayloadOutputPart commonPart =
- multipart.addPart(loaninCommon, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(new LoaninClient().getCommonPartName());
+ multipart.addPart(new LoaninClient().getCommonPartName(), loaninCommon);
if (logger.isDebugEnabled()) {
logger.debug("to be created, loanin common");
return multipart;
}
+
+ @Override
+ public void CRUDTests(String testName) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ PoxPayloadOut result = createLoaninInstance(identifier);
+ return result;
+ }
+
+ @Override
+ protected LoansinCommon updateInstance(LoansinCommon commonPartObject) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(LoansinCommon original,
+ LoansinCommon updated) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
}
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<!-- javax -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
@Override
public Class<LoanoutProxy> getProxyClass() {
- // TODO Auto-generated method stub
return LoanoutProxy.class;
}
import java.util.List;
import java.util.Map;
-import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.collectionspace.services.PersonJAXBSchema;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
-//import org.collectionspace.services.common.authorityref.AuthorityRefList.AuthorityRefItem;
import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.loanout.LoansoutCommon;
-//import org.collectionspace.services.loanout.LoansoutCommonList;
import org.jboss.resteasy.client.ClientResponse;
* $LastChangedRevision$
* $LastChangedDate$
*/
-public class LoanoutAuthRefsTest extends BaseServiceTest {
+public class LoanoutAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
private final String CLASS_NAME = LoanoutAuthRefsTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
+ protected AbstractCommonList getCommonList(
ClientResponse<AbstractCommonList> response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
// Success outcomes
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
public void createWithAuthRefs(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
// Submit the request to the service and store the response.
if(logger.isDebugEnabled()){
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Store the ID returned from the first resource created
// for additional tests below.
ClientResponse<Response> res = personAuthClient.create(multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
personAuthCSID = extractId(res);
ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
return extractId(res);
}
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
dependsOnMethods = {"createWithAuthRefs"})
public void readAndCheckAuthRefs(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
testSetup(STATUS_OK, ServiceRequestType.READ);
// Submit the request to the service and store the response.
LoanoutClient loanoutClient = new LoanoutClient();
ClientResponse<String> res = loanoutClient.read(knownResourceId);
- assertStatusCode(res, testName);
-
- // Extract the common part from the response.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- LoansoutCommon loanoutCommon = (LoansoutCommon) extractPart(input,
- loanoutClient.getCommonPartName(), LoansoutCommon.class);
- Assert.assertNotNull(loanoutCommon);
- if(logger.isDebugEnabled()){
- logger.debug(objectAsXmlString(loanoutCommon, LoansoutCommon.class));
+ LoansoutCommon loanoutCommon = null;
+ try {
+ assertStatusCode(res, testName);
+ // Extract the common part from the response.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ loanoutCommon = (LoansoutCommon) extractPart(input,
+ loanoutClient.getCommonPartName(), LoansoutCommon.class);
+ Assert.assertNotNull(loanoutCommon);
+ if(logger.isDebugEnabled()){
+ logger.debug(objectAsXmlString(loanoutCommon, LoansoutCommon.class));
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
+
// Check a couple of fields
Assert.assertEquals(loanoutCommon.getBorrower(), borrowerRefName);
Assert.assertEquals(loanoutCommon.getBorrowersContact(), borrowersContactRefName);
Assert.assertEquals(loanoutCommon.getLendersContact(), lendersContactRefName);
// Get the auth refs and check them
- ClientResponse<AuthorityRefList> res2 =
- loanoutClient.getAuthorityRefs(knownResourceId);
- assertStatusCode(res2, testName);
-
- AuthorityRefList list = res2.getEntity();
+ ClientResponse<AuthorityRefList> res2 = loanoutClient.getAuthorityRefs(knownResourceId);
+ AuthorityRefList list = null;
+ try {
+ assertStatusCode(res2, testName);
+ list = res2.getEntity();
+ } finally {
+ if (res2 != null) {
+ res2.releaseConnection();
+ }
+ }
List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
int numAuthRefsFound = items.size();
return SERVICE_PATH_COMPONENT;
}
- private PoxPayloadOut createLoanoutInstance(String loanoutNumber,
+ private PoxPayloadOut createLoanoutInstance(String loanoutNumber,
String returnDate,
- String borrower,
- String borrowersContact,
- String lendersAuthorizer,
- String lendersContact) {
- LoansoutCommon loanoutCommon = new LoansoutCommon();
- loanoutCommon.setLoanOutNumber(loanoutNumber);
- loanoutCommon.setLoanReturnDate(returnDate);
- loanoutCommon.setBorrower(borrower);
- loanoutCommon.setBorrowersContact(borrowersContact);
- loanoutCommon.setLendersAuthorizer(lendersAuthorizer);
- loanoutCommon.setLendersContact(lendersContact);
-
- PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
- PayloadOutputPart commonPart =
- multipart.addPart(loanoutCommon, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(new LoanoutClient().getCommonPartName());
+ String borrower,
+ String borrowersContact,
+ String lendersAuthorizer,
+ String lendersContact) {
+ LoansoutCommon loanoutCommon = new LoansoutCommon();
+ loanoutCommon.setLoanOutNumber(loanoutNumber);
+ loanoutCommon.setLoanReturnDate(returnDate);
+ loanoutCommon.setBorrower(borrower);
+ loanoutCommon.setBorrowersContact(borrowersContact);
+ loanoutCommon.setLendersAuthorizer(lendersAuthorizer);
+ loanoutCommon.setLendersContact(lendersContact);
+
+ PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
+ PayloadOutputPart commonPart =
+ multipart.addPart(new LoanoutClient().getCommonPartName(), loanoutCommon);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("to be created, loanout common");
+ logger.debug(objectAsXmlString(loanoutCommon, LoansoutCommon.class));
+ }
- if(logger.isDebugEnabled()){
- logger.debug("to be created, loanout common");
- logger.debug(objectAsXmlString(loanoutCommon, LoansoutCommon.class));
- }
+ return multipart;
+ }
- return multipart;
+ @Override
+ protected Class<AbstractCommonList> getCommonListType() {
+ // TODO Auto-generated method stub
+ return null;
}
}
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.LoanoutClient;
import org.collectionspace.services.client.PayloadInputPart;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.loanout.LoanStatusGroup;
import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
-import org.testng.annotations.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* $LastChangedRevision$
* $LastChangedDate$
*/
-public class LoanoutServiceTest extends AbstractServiceTestImpl {
+public class LoanoutServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, LoansoutCommon> {
/** The logger. */
private final String CLASS_NAME = LoanoutServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
/** The known resource id. */
- private String knownResourceId = null;
private final static String CURRENT_DATE_UTC =
GregorianCalendarDateTimeUtils.currentDateUTC();
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
+ protected AbstractCommonList getCommonList(
ClientResponse<AbstractCommonList> response) {
return response.getEntity(AbstractCommonList.class);
}
* @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// 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).
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Store the ID returned from the first resource created
// for additional tests below.
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"create"})
public void createList(String testName) throws Exception {
for (int i = 0; i < 3; i++) {
create(testName);
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"create"})
public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupRead();
// Submit the request to the service and store the response.
LoanoutClient client = new LoanoutClient();
ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
-
- // Get the common part of the response and verify that it is not null.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
LoansoutCommon loanoutCommon = null;
- if (payloadInputPart != null) {
- loanoutCommon = (LoansoutCommon) payloadInputPart.getBody();
+ try {
+ assertStatusCode(res, testName);
+ // Get the common part of the response and verify that it is not null.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
+ if (payloadInputPart != null) {
+ loanoutCommon = (LoansoutCommon) payloadInputPart.getBody();
+ }
+ Assert.assertNotNull(loanoutCommon);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertNotNull(loanoutCommon);
// Check selected fields in the common part.
Assert.assertNotNull(loanoutCommon.getLoanOutNumber());
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"read"})
public void readNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupReadNonExistent();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"createList", "read"})
public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupReadList();
// Submit the request to the service and store the response.
LoanoutClient client = new LoanoutClient();
ClientResponse<AbstractCommonList> res = client.readList();
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
-
+ AbstractCommonList list = null;
+ try {
+ assertStatusCode(res, testName);
+ list = res.getEntity();
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
// Optionally output additional data about list members for debugging.
boolean iterateThroughList = true;
- if(iterateThroughList && logger.isDebugEnabled()){
+ if (iterateThroughList && logger.isDebugEnabled()){
AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"read"})
public void update(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
- setupUpdate();
+ setupRead();
// Retrieve the contents of a resource to update.
LoanoutClient client = new LoanoutClient();
ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
-
- // Extract the common part from the response.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
LoansoutCommon loanoutCommon = null;
- if (payloadInputPart != null) {
- loanoutCommon = (LoansoutCommon) payloadInputPart.getBody();
+ try {
+ assertStatusCode(res, testName);
+ // Extract the common part from the response.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
+ if (payloadInputPart != null) {
+ loanoutCommon = (LoansoutCommon) payloadInputPart.getBody();
+ }
+ Assert.assertNotNull(loanoutCommon);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertNotNull(loanoutCommon);
// Update the content of this resource.
loanoutCommon.setLoanOutNumber("updated-" + loanoutCommon.getLoanOutNumber());
}
loanoutCommon.setLoanOutNote("updated-" + loanoutCommon.getLoanOutNote());
+ setupUpdate();
+
// Submit the updated resource in an update request to the service and store the response.
PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());
- PayloadOutputPart commonPart = output.addPart(loanoutCommon, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
- res = client.update(knownResourceId, output);
- assertStatusCode(res, testName);
+ PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), loanoutCommon);
- // Extract the updated common part from the response.
- input = new PoxPayloadIn(res.getEntity());
- payloadInputPart = input.getPart(client.getCommonPartName());
+ res = client.update(knownResourceId, output);
LoansoutCommon updatedLoanoutCommon = null;
- if (payloadInputPart != null) {
- updatedLoanoutCommon = (LoansoutCommon) payloadInputPart.getBody();
+ try {
+ assertStatusCode(res, testName);
+ // Extract the updated common part from the response.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
+ if (payloadInputPart != null) {
+ updatedLoanoutCommon = (LoansoutCommon) payloadInputPart.getBody();
+ }
+ Assert.assertNotNull(updatedLoanoutCommon);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertNotNull(updatedLoanoutCommon);
// Check selected fields in the updated resource.
Assert.assertEquals(updatedLoanoutCommon.getLoanOutNumber(),
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"update", "testSubmitRequest"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"update", "testSubmitRequest"})
public void updateNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupUpdateNonExistent();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupDelete();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// Failure outcomes
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"delete"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// dependsOnMethods = {"delete"})
public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupDeleteNonExistent();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
* Tests the code for manually submitting data that is used by several
* of the methods above.
*/
- @Test(dependsOnMethods = {"create", "read"})
+// @Test(dependsOnMethods = {"create", "read"})
public void testSubmitRequest() {
// Expected status code: 200 OK
PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
PayloadOutputPart commonPart =
- multipart.addPart(loanoutCommon, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(new LoanoutClient().getCommonPartName());
+ multipart.addPart(new LoanoutClient().getCommonPartName(), loanoutCommon);
if (logger.isDebugEnabled()) {
logger.debug("to be created, loanout common");
protected String getServiceName() {
return LoanoutClient.SERVICE_NAME;
}
+
+ @Override
+ public void CRUDTests(String testName) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ PoxPayloadOut result = createLoanoutInstance(identifier);
+ return result;
+ }
+
+ @Override
+ protected LoansoutCommon updateInstance(LoansoutCommon commonPartObject) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(LoansoutCommon original,
+ LoansoutCommon updated) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
}
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<!-- javax -->
</parent>\r
\r
<modelVersion>4.0.0</modelVersion>\r
- <groupId>org.collectionspace.services</groupId>\r
<artifactId>org.collectionspace.services.location.client</artifactId>\r
<name>services.location.client</name>\r
\r
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
<dependency>\r
<groupId>org.jboss.resteasy</groupId>\r
<dependency>\r
<groupId>commons-httpclient</groupId>\r
<artifactId>commons-httpclient</artifactId>\r
- <version>3.1</version>\r
</dependency>\r
</dependencies>\r
\r
*/
package org.collectionspace.services.client;
+import org.collectionspace.services.location.LocationsCommon;
+
/**
* The Class LocationAuthorityClient.
*/
-public class LocationAuthorityClient extends AuthorityClientImpl<LocationAuthorityProxy> {
+public class LocationAuthorityClient extends AuthorityClientImpl<LocationsCommon, LocationAuthorityProxy> {
public static final String SERVICE_NAME = "locationauthorities";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
public Class<LocationAuthorityProxy> getProxyClass() {
return LocationAuthorityProxy.class;
}
+
+ @Override
+ public String getInAuthority(LocationsCommon item) {
+ return item.getInAuthority();
+ }
+
+ @Override
+ public void setInAuthority(LocationsCommon item, String inAuthorityCsid) {
+ item.setInAuthority(inAuthorityCsid);
+ }
}
\r
import java.io.File;\r
import java.util.ArrayList;\r
-import java.util.Arrays;\r
import java.util.List;\r
import java.util.Map;\r
\r
import org.jboss.resteasy.client.ClientResponse;\r
import org.slf4j.Logger;\r
import org.slf4j.LoggerFactory;\r
-import org.testng.Assert;\r
\r
public class LocationAuthorityClientUtils {\r
private static final Logger logger =\r
*/\r
public static PoxPayloadOut createLocationAuthorityInstance(\r
String displayName, String shortIdentifier, String headerLabel ) {\r
+ \r
LocationauthoritiesCommon locationAuthority = new LocationauthoritiesCommon();\r
locationAuthority.setDisplayName(displayName);\r
locationAuthority.setShortIdentifier(shortIdentifier);\r
// String refName = createLocationAuthRefName(shortIdentifier, displayName);\r
// locationAuthority.setRefName(refName);\r
locationAuthority.setVocabType("LocationAuthority"); //FIXME: REM - Should this really be hard-coded?\r
+ \r
PoxPayloadOut multipart = new PoxPayloadOut(LocationAuthorityClient.SERVICE_PAYLOAD_NAME);\r
- PayloadOutputPart commonPart = multipart.addPart(locationAuthority, MediaType.APPLICATION_XML_TYPE);\r
- commonPart.setLabel(headerLabel);\r
+ PayloadOutputPart commonPart = multipart.addPart(headerLabel, locationAuthority);\r
\r
if(logger.isDebugEnabled()){\r
logger.debug("to be created, locationAuthority common ", \r
*/
package org.collectionspace.services.client.test;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.collectionspace.services.LocationJAXBSchema;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.AuthorityClient;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.client.LocationAuthorityClient;
import org.collectionspace.services.client.LocationAuthorityClientUtils;
import org.collectionspace.services.location.LocationauthoritiesCommon;
import org.collectionspace.services.location.LocationsCommon;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import org.jboss.resteasy.client.ClientResponse;
import org.slf4j.Logger;
* $LastChangedRevision: 753 $
* $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
*/
-public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME: Test classes for Vocab, Person, Org, and Location should have a base class!
+public class LocationAuthorityServiceTest extends AbstractAuthorityServiceTest<LocationauthoritiesCommon, LocationsCommon> {
/** The logger. */
private final String CLASS_NAME = LocationAuthorityServiceTest.class.getName();
final String TEST_STATUS = "Approved";
/** The known resource id. */
- private String knownResourceId = null;
private String knownResourceShortIdentifer = null;
private String knownResourceRefName = null;
- private String knownLocationTypeRefName = null;
- private String knownItemResourceId = null;
- private String knownItemResourceShortIdentifer = null;
- private String knownContactResourceId = null;
-
- /** The n items to create in list. */
- private int nItemsToCreateInList = 3;
-
- /** The all resource ids created. */
- private List<String> allResourceIdsCreated = new ArrayList<String>();
-
- /** The all item resource ids created. */
- private Map<String, String> allItemResourceIdsCreated =
- new HashMap<String, String>();
-
- protected void setKnownResource( String id, String shortIdentifer,
- String refName ) {
- knownResourceId = id;
- knownResourceShortIdentifer = shortIdentifer;
- knownResourceRefName = refName;
- }
-
- protected void setKnownItemResource( String id, String shortIdentifer ) {
- knownItemResourceId = id;
- knownItemResourceShortIdentifer = shortIdentifer;
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
- */
- @Override
- protected CollectionSpaceClient getClientInstance() {
- return new LocationAuthorityClient();
- }
-
- @Override
- protected PoxPayloadOut createInstance(String identifier) {
- LocationAuthorityClient client = new LocationAuthorityClient();
- String shortId = identifier;
- String displayName = "displayName-" + shortId;
- // String baseRefName = LocationAuthorityClientUtils.createLocationAuthRefName(shortId, null);
- PoxPayloadOut multipart =
- LocationAuthorityClientUtils.createLocationAuthorityInstance(
- displayName, shortId, client.getCommonPartName());
- return multipart;
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : CREATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"create"})
- public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // 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();
-
- // Submit the request to the service and store the response.
- LocationAuthorityClient client = new LocationAuthorityClient();
- String shortId = createIdentifier();
- String displayName = "displayName-" + shortId;
- // String baseRefName = LocationAuthorityClientUtils.createLocationAuthRefName(shortId, null);
-
- PoxPayloadOut multipart =
- LocationAuthorityClientUtils.createLocationAuthorityInstance(
- displayName, shortId, client.getCommonPartName());
- String newID = null;
- ClientResponse<Response> res = client.create(multipart);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
-
- newID = LocationAuthorityClientUtils.extractId(res);
- } finally {
- res.releaseConnection();
- }
- // Store the ID returned from the first resource created
- // for additional tests below.
- final String EMPTY_REFNAME = "";
- if (knownResourceId == null){
- setKnownResource( newID, shortId, EMPTY_REFNAME );
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
- }
- // Store the IDs from every resource created by tests,
- // so they can be deleted after tests have been run.
- allResourceIdsCreated.add(newID);
- }
-
- /**
- * Creates the item.
- *
- * @param testName the test name
- */
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"create"}, dependsOnMethods = {"create"})
- public void createItem(String testName) {
- if(logger.isDebugEnabled()){
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- setupCreate();
- createItemInAuthority(knownResourceId, knownResourceRefName);
- }
-
- /**
- * Creates the item in authority.
- *
- * @param vcsid the vcsid
- * @param authRefName the auth ref name
- * @return the string
- */
- private String createItemInAuthority(String vcsid, String authRefName) {
-
- final String testName = "createItemInAuthority("+vcsid+","+authRefName+")";
- if(logger.isDebugEnabled()){
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
- // Submit the request to the service and store the response.
- LocationAuthorityClient client = new LocationAuthorityClient();
- Map<String, String> shelf1Map = new HashMap<String,String>();
- // TODO Make loc type and status be controlled vocabs.
- shelf1Map.put(LocationJAXBSchema.NAME, TEST_NAME);
- shelf1Map.put(LocationJAXBSchema.SHORT_IDENTIFIER, TEST_SHORTID);
- shelf1Map.put(LocationJAXBSchema.CONDITION_NOTE, TEST_CONDITION_NOTE);
- shelf1Map.put(LocationJAXBSchema.CONDITION_NOTE_DATE, TEST_CONDITION_NOTE_DATE);
- shelf1Map.put(LocationJAXBSchema.SECURITY_NOTE, TEST_SECURITY_NOTE);
- shelf1Map.put(LocationJAXBSchema.ACCESS_NOTE, TEST_ACCESS_NOTE);
- shelf1Map.put(LocationJAXBSchema.ADDRESS, TEST_ADDRESS);
- shelf1Map.put(LocationJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
- shelf1Map.put(LocationJAXBSchema.TERM_STATUS, TEST_STATUS);
-
- String newID = LocationAuthorityClientUtils.createItemInAuthority(vcsid,
- authRefName, shelf1Map, client );
-
- // Store the ID returned from the first item resource created
- // for additional tests below.
- if (knownItemResourceId == null){
- setKnownItemResource(newID, TEST_SHORTID);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownItemResourceId=" + newID);
- }
- }
-
- // Store the IDs from any item resources created
- // by tests, along with the IDs of their parents, so these items
- // can be deleted after all tests have been run.
- allItemResourceIdsCreated.put(newID, vcsid);
-
- return newID;
- }
-
-
-
- // Failure outcomes
-
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
- */
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- }
-
-
- // ---------------------------------------------------------------
- // CRUD tests : CREATE LIST tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"createList"}, dependsOnGroups = {"create"})
- public void createList(String testName) throws Exception {
- for (int i = 0; i < nItemsToCreateInList; i++) {
- create(testName);
- }
- }
-
- /**
- * Creates the item list.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"createList"}, dependsOnMethods = {"createList"})
- public void createItemList(String testName) throws Exception {
- // Add items to the initially-created, known parent record.
- for (int j = 0; j < nItemsToCreateInList; j++) {
- createItem(testName);
- }
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : READ tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnGroups = {"create"})
- public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- LocationAuthorityClient client = new LocationAuthorityClient();
- String newID = null;
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
- try {
- //FIXME: remove the following try catch once Aron fixes signatures
- try {
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- LocationauthoritiesCommon locationAuthority =
- (LocationauthoritiesCommon) extractPart(input,
- client.getCommonPartName(), LocationauthoritiesCommon.class);
- Assert.assertNotNull(locationAuthority);
- Assert.assertNotNull(locationAuthority.getDisplayName());
- Assert.assertNotNull(locationAuthority.getShortIdentifier());
- Assert.assertNotNull(locationAuthority.getRefName());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- } finally {
- res.releaseConnection();
- }
- }
-
- /**
- * Read by name.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnGroups = {"create"})
- public void readByName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName+"("+knownResourceShortIdentifer+")", CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<String> res = client.readByName(knownResourceShortIdentifer);
- assertStatusCode(res, testName);
- try {
- //FIXME: remove the following try catch once Aron fixes signatures
- try {
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
- client.getCommonPartName(), LocationauthoritiesCommon.class);
- Assert.assertNotNull(locationAuthority);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- } finally {
- res.releaseConnection();
- }
- }
-
-
- /**
- * Read item.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnMethods = {"read"})
- public void readItem(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
- assertStatusCode(res, testName);
- try {
- // Check whether we've received a location.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- LocationsCommon location = (LocationsCommon) extractPart(input,
- client.getItemCommonPartName(), LocationsCommon.class);
- Assert.assertNotNull(location);
- boolean showFull = true;
- if(showFull && logger.isDebugEnabled()){
- logger.debug(testName + ": returned payload:");
- logger.debug(objectAsXmlString(location, LocationsCommon.class));
- }
- Assert.assertEquals(location.getInAuthority(), knownResourceId);
- } finally {
- res.releaseConnection();
- }
-
- }
-
- /**
- * Verify item display name.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"readItem", "updateItem"})
- public void verifyItemDisplayName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
-
- // Submit the request to the service and store the response.
- LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
- assertStatusCode(res, testName);
- try {
- // Check whether location has expected displayName.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- LocationsCommon location = (LocationsCommon) extractPart(input,
- client.getItemCommonPartName(), LocationsCommon.class);
- Assert.assertNotNull(location);
- String displayName = location.getDisplayName();
- // Make sure displayName matches computed form
- String expectedDisplayName =
- LocationAuthorityClientUtils.prepareDefaultDisplayName(TEST_NAME);
- Assert.assertNotNull(displayName, expectedDisplayName);
-
- // Update the shortName and verify the computed name is updated.
- location.setCsid(null);
- location.setDisplayNameComputed(true);
- location.setName("updated-" + TEST_NAME);
- expectedDisplayName =
- LocationAuthorityClientUtils.prepareDefaultDisplayName("updated-" + TEST_NAME);
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(LocationAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
- res.releaseConnection();
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
- LocationsCommon updatedLocation =
- (LocationsCommon) extractPart(input,
- client.getItemCommonPartName(), LocationsCommon.class);
- Assert.assertNotNull(updatedLocation);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedLocation.getName(), location.getName(),
- "Updated ForeName in Location did not match submitted data.");
- // Verify that the updated resource computes the right displayName.
- Assert.assertEquals(updatedLocation.getDisplayName(), expectedDisplayName,
- "Updated ForeName in Location not reflected in computed DisplayName.");
-
- // Now Update the displayName, not computed and verify the computed name is overriden.
- location.setDisplayNameComputed(false);
- expectedDisplayName = "TestName";
- location.setDisplayName(expectedDisplayName);
-
- // Submit the updated resource to the service and store the response.
- output = new PoxPayloadOut(LocationAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
- res.releaseConnection();
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
- updatedLocation =
- (LocationsCommon) extractPart(input,
- client.getItemCommonPartName(), LocationsCommon.class);
- Assert.assertNotNull(updatedLocation);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedLocation.isDisplayNameComputed(), false,
- "Updated displayNameComputed in Location did not match submitted data.");
- // Verify that the updated resource computes the right displayName.
- Assert.assertEquals(updatedLocation.getDisplayName(),
- expectedDisplayName,
- "Updated DisplayName (not computed) in Location not stored.");
- } finally {
- res.releaseConnection();
- }
- }
-
- /**
- * Verify illegal item display name.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"verifyItemDisplayName"})
- public void verifyIllegalItemDisplayName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
- // Perform setup for read.
- setupRead();
-
- // Submit the request to the service and store the response.
- LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
- assertStatusCode(res, testName);
-
- // Perform setup for update.
- testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE);
-
- try {
-
- // Check whether Location has expected displayName.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- LocationsCommon location = (LocationsCommon) extractPart(input,
- client.getItemCommonPartName(), LocationsCommon.class);
- Assert.assertNotNull(location);
- // Try to Update with computed false and no displayName
- location.setDisplayNameComputed(false);
- location.setDisplayName(null);
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(LocationAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
- res.releaseConnection();
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
- } finally {
- res.releaseConnection();
- }
- }
-
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnMethods = {"read"})
- public void readNonExistent(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- /**
- * Read item non existent.
- *
- * @param testName the test name
- */
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnMethods = {"readItem"})
- public void readItemNonExistent(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<String> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
-
- // ---------------------------------------------------------------
- // CRUD tests : READ_LIST tests
- // ---------------------------------------------------------------
- // Success outcomes
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readList"}, dependsOnGroups = {"createList", "read"})
- public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadList();
-
- // Submit the request to the service and store the response.
- LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<AbstractCommonList> res = client.readList();
- assertStatusCode(res, testName);
- try {
- AbstractCommonList list = res.getEntity();
-
- // Optionally output additional data about list members for debugging.
- if(logger.isTraceEnabled()){
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
- } finally {
- res.releaseConnection();
- }
- }
-
- /**
- * Read item list.
- */
- @Test(groups = {"readList"}, dependsOnMethods = {"readList"})
- public void readItemList() {
- String testName = "readItemList";
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- readItemList(knownResourceId, null);
- }
-
- /**
- * Read item list by authority name.
- */
- @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
- public void readItemListByAuthorityName() {
- String testName = "readItemListByAuthorityName";
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- readItemList(null, knownResourceShortIdentifer);
- }
-
- /**
- * Read item list.
- *
- * @param vcsid the vcsid
- * @param name the name
- */
- private void readItemList(String vcsid, String shortId) {
-
- String testName = "readItemList";
-
- // Perform setup.
- setupReadList();
-
- // Submit the request to the service and store the response.
- LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<AbstractCommonList> res = null;
- if(vcsid!= null) {
- res = client.readItemList(vcsid, null, null);
- } else if(shortId!= null) {
- res = client.readItemListForNamedAuthority(shortId, null, null);
- } else {
- Assert.fail("readItemList passed null csid and name!");
- }
- assertStatusCode(res, testName);
- try {
- AbstractCommonList list = res.getEntity();
-
- List<AbstractCommonList.ListItem> items =
- list.getListItem();
- int nItemsReturned = items.size();
- // There will be one item created, associated with a
- // known parent resource, by the createItem test.
- //
- // In addition, there will be 'nItemsToCreateInList'
- // additional items created by the createItemList test,
- // all associated with the same parent resource.
- int nExpectedItems = nItemsToCreateInList + 1;
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": Expected "
- + nExpectedItems +" items; got: "+nItemsReturned);
- }
- Assert.assertEquals(nItemsReturned, nExpectedItems);
-
- for (AbstractCommonList.ListItem item : items) {
- String value =
- AbstractCommonListUtils.ListItemGetElementValue(item, REFNAME);
- Assert.assertTrue((null != value), "Item refName is null!");
- value =
- AbstractCommonListUtils.ListItemGetElementValue(item, DISPLAYNAME);
- Assert.assertTrue((null != value), "Item displayName is null!");
- }
- if(logger.isTraceEnabled()){
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
- } finally {
- res.releaseConnection();
- }
- }
-
-
- // Failure outcomes
- // None at present.
-
- // ---------------------------------------------------------------
- // CRUD tests : UPDATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnGroups = {"read", "readList"})
- public void update(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
-
- // Retrieve the contents of a resource to update.
- LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
- try {
-
- if(logger.isDebugEnabled()){
- logger.debug("got LocationAuthority to update with ID: " + knownResourceId);
- }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
- client.getCommonPartName(), LocationauthoritiesCommon.class);
- Assert.assertNotNull(locationAuthority);
-
- // Update the contents of this resource.
- locationAuthority.setDisplayName("updated-" + locationAuthority.getDisplayName());
- locationAuthority.setVocabType("updated-" + locationAuthority.getVocabType());
- if(logger.isDebugEnabled()){
- logger.debug("to be updated LocationAuthority");
- logger.debug(objectAsXmlString(locationAuthority, LocationauthoritiesCommon.class));
- }
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(LocationAuthorityClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(locationAuthority, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
- res.releaseConnection();
- res = client.update(knownResourceId, output);
- assertStatusCode(res, testName);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
- LocationauthoritiesCommon updatedLocationAuthority =
- (LocationauthoritiesCommon) extractPart(input,
- client.getCommonPartName(), LocationauthoritiesCommon.class);
- Assert.assertNotNull(updatedLocationAuthority);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedLocationAuthority.getDisplayName(),
- locationAuthority.getDisplayName(),
- "Data in updated object did not match submitted data.");
- } finally {
- res.releaseConnection();
- }
- }
-
- /**
- * Update item.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"update"})
- public void updateItem(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
-
- // Retrieve the contents of a resource to update.
- LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<String> res =
- client.readItem(knownResourceId, knownItemResourceId);
- assertStatusCode(res, testName);
- try {
- if(logger.isDebugEnabled()){
- logger.debug("got Location to update with ID: " +
- knownItemResourceId +
- " in LocationAuthority: " + knownResourceId );
- }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- LocationsCommon location = (LocationsCommon) extractPart(input,
- client.getItemCommonPartName(), LocationsCommon.class);
- Assert.assertNotNull(location);
-
- // Update the contents of this resource.
- location.setCsid(null);
- location.setName("updated-" + location.getName());
- if(logger.isDebugEnabled()){
- logger.debug("to be updated Location");
- logger.debug(objectAsXmlString(location,
- LocationsCommon.class));
- }
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(LocationAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
- res.releaseConnection();
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
- LocationsCommon updatedLocation =
- (LocationsCommon) extractPart(input,
- client.getItemCommonPartName(), LocationsCommon.class);
- Assert.assertNotNull(updatedLocation);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedLocation.getName(), location.getName(),
- "Data in updated Location did not match submitted data.");
- } finally {
- res.releaseConnection();
- }
- }
-
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- }
-
+
+ private String knownLocationTypeRefName = null;
+ private String knownContactResourceId = null;
+
/* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
+ * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- public void updateWithMalformedXml(String testName) throws Exception {
+ protected CollectionSpaceClient getClientInstance() {
+ return new LocationAuthorityClient();
}
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
+
+ /**
+ * Creates the item in authority.
+ *
+ * @param vcsid the vcsid
+ * @param authRefName the auth ref name
+ * @return the string
*/
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- }
-
+ private String createItemInAuthority(String vcsid, String authRefName) {
+ final String testName = "createItemInAuthority("+vcsid+","+authRefName+")";
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
- */
-@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent(String testName) throws Exception {
+ // Submit the request to the service and store the response.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ Map<String, String> shelf1Map = new HashMap<String,String>();
+ // TODO Make loc type and status be controlled vocabs.
+ shelf1Map.put(LocationJAXBSchema.NAME, TEST_NAME);
+ shelf1Map.put(LocationJAXBSchema.SHORT_IDENTIFIER, TEST_SHORTID);
+ shelf1Map.put(LocationJAXBSchema.CONDITION_NOTE, TEST_CONDITION_NOTE);
+ shelf1Map.put(LocationJAXBSchema.CONDITION_NOTE_DATE, TEST_CONDITION_NOTE_DATE);
+ shelf1Map.put(LocationJAXBSchema.SECURITY_NOTE, TEST_SECURITY_NOTE);
+ shelf1Map.put(LocationJAXBSchema.ACCESS_NOTE, TEST_ACCESS_NOTE);
+ shelf1Map.put(LocationJAXBSchema.ADDRESS, TEST_ADDRESS);
+ shelf1Map.put(LocationJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
+ shelf1Map.put(LocationJAXBSchema.TERM_STATUS, TEST_STATUS);
+
+ String newID = LocationAuthorityClientUtils.createItemInAuthority(vcsid,
+ authRefName, shelf1Map, client );
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
+ // Store the ID returned from the first item resource created
+ // for additional tests below.
+ if (knownItemResourceId == null){
+ setKnownItemResource(newID, TEST_SHORTID);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": knownItemResourceId=" + newID);
+ }
}
- // Perform setup.
- setupUpdateNonExistent();
- // Submit the request to the service and store the response.
- // Note: The ID(s) used when creating the request payload may be arbitrary.
- // The only relevant ID may be the one used in update(), below.
- LocationAuthorityClient client = new LocationAuthorityClient();
- String displayName = "displayName-NON_EXISTENT_ID";
- PoxPayloadOut multipart = LocationAuthorityClientUtils.createLocationAuthorityInstance(
- displayName, "nonEx", client.getCommonPartName());
- ClientResponse<String> res =
- client.update(NON_EXISTENT_ID, multipart);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ // Store the IDs from any item resources created
+ // by tests, along with the IDs of their parents, so these items
+ // can be deleted after all tests have been run.
+ allResourceItemIdsCreated.put(newID, vcsid);
+
+ return newID;
}
/**
- * Update non existent item.
+ * Verify item display name.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
- public void updateNonExistentItem(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
+ @Test(dataProvider="testName",
+ dependsOnMethods = {"readItem", "updateItem"})
+ public void verifyItemDisplayName(String testName) throws Exception {
// Perform setup.
- setupUpdateNonExistent();
-
- // 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 update(), below.
+ setupRead();
+ //
+ // First, read our known item resource
+ //
LocationAuthorityClient client = new LocationAuthorityClient();
- Map<String, String> nonexMap = new HashMap<String,String>();
- nonexMap.put(LocationJAXBSchema.NAME, TEST_NAME);
- nonexMap.put(LocationJAXBSchema.SHORT_IDENTIFIER, "nonEx");
- nonexMap.put(LocationJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
- nonexMap.put(LocationJAXBSchema.TERM_STATUS, TEST_STATUS);
- // PoxPayloadOut multipart =
- // LocationAuthorityClientUtils.createLocationInstance(
- // LocationAuthorityClientUtils.createLocationRefName(knownResourceRefName, "nonEx", "Non Existent"),
- // nonexMap, client.getItemCommonPartName() );
- final String EMPTY_REFNAME = "";
- PoxPayloadOut multipart =
- LocationAuthorityClientUtils.createLocationInstance(EMPTY_REFNAME,
- nonexMap, client.getItemCommonPartName() );
- ClientResponse<String> res =
- client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
+ ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+ LocationsCommon location = null;
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : DELETE tests
- // ---------------------------------------------------------------
- // Success outcomes
-
- // Note: delete sub-resources in ascending hierarchical order,
- // before deleting their parents.
-
- /**
- * Delete item.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- //groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "readListByPartialTerm", "update"})
- groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"})
- public void deleteItem(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- if(logger.isDebugEnabled()){
- logger.debug("parentcsid =" + knownResourceId +
- " itemcsid = " + knownItemResourceId);
+ assertStatusCode(res, testName);
+ // Check whether location has expected displayName.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ location = (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(location);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
-
- // Submit the request to the service and store the response.
- LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<Response> res =
- client.deleteItem(knownResourceId, knownItemResourceId);
+ //
+ // Now prepare an updated payload.
+ //
+ String displayName = location.getDisplayName();
+ // Make sure displayName matches computed form
+ String expectedDisplayName =
+ LocationAuthorityClientUtils.prepareDefaultDisplayName(TEST_NAME);
+ Assert.assertNotNull(displayName, expectedDisplayName);
+
+ // Update the shortName and verify the computed name is updated.
+ location.setCsid(null);
+ location.setDisplayNameComputed(true);
+ location.setName("updated-" + TEST_NAME);
+ expectedDisplayName =
+ LocationAuthorityClientUtils.prepareDefaultDisplayName("updated-" + TEST_NAME);
+
+ // Submit the updated resource to the service and store the response.
+ PoxPayloadOut output = new PoxPayloadOut(LocationAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), location);
+
+ setupUpdate();
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ LocationsCommon updatedLocation = null;
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteItem"})
- public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- if(logger.isDebugEnabled()){
- logger.debug("parentcsid =" + knownResourceId);
+ assertStatusCode(res, testName);
+ // Retrieve the updated resource and verify that its contents exist.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ updatedLocation = (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(updatedLocation);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- // Submit the request to the service and store the response.
- LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedLocation.getName(), location.getName(),
+ "Updated ForeName in Location did not match submitted data.");
+ // Verify that the updated resource computes the right displayName.
+ Assert.assertEquals(updatedLocation.getDisplayName(), expectedDisplayName,
+ "Updated ForeName in Location not reflected in computed DisplayName.");
+ //
+ // Now Update the displayName, not computed and verify the computed name is overriden.
+ //
+ location.setDisplayNameComputed(false);
+ expectedDisplayName = "TestName";
+ location.setDisplayName(expectedDisplayName);
+
+ // Submit the updated resource to the service and store the response.
+ output = new PoxPayloadOut(LocationAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
+ commonPart = output.addPart(client.getItemCommonPartName(), location);
+ setupUpdate();
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
+ assertStatusCode(res, testName);
+ // Retrieve the updated resource and verify that its contents exist.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ updatedLocation = (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(updatedLocation);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- // Perform setup.
- setupDeleteNonExistent();
- // Submit the request to the service and store the response.
- LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedLocation.isDisplayNameComputed(), false,
+ "Updated displayNameComputed in Location did not match submitted data.");
+ // Verify that the updated resource computes the right displayName.
+ Assert.assertEquals(updatedLocation.getDisplayName(),
+ expectedDisplayName,
+ "Updated DisplayName (not computed) in Location not stored.");
}
/**
- * Delete non existent item.
+ * Verify illegal item display name.
*
* @param testName the test name
+ * @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteItem"})
- public void deleteNonExistentItem(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDeleteNonExistent();
+ @Test(dataProvider="testName",
+ dependsOnMethods = {"verifyItemDisplayName"})
+ public void verifyIllegalItemDisplayName(String testName) throws Exception {
+ // Perform setup for read.
+ setupRead();
// Submit the request to the service and store the response.
LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
+ ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+ LocationsCommon location = null;
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ assertStatusCode(res, testName);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ location = (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(location);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
+
+ // Try to Update with computed false and no displayName
+ location.setDisplayNameComputed(false);
+ location.setDisplayName(null);
+
+ // Submit the updated resource to the service and store the response.
+ PoxPayloadOut output = new PoxPayloadOut(LocationAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), location);
+ setupUpdateWithInvalidBody(); // we expected a failure here.
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
}
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
/**
- * Tests the code for manually submitting data that is used by several
- * of the methods above.
+ * Read item list.
*/
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() {
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("testSubmitRequest: url=" + url +
- " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
+ @Test(dataProvider = "testName", groups = {"readList"},
+ dependsOnMethods = {"readList"})
+ public void readItemList(String testName) {
+ readItemList(knownAuthorityWithItems, null);
}
/**
- * Test item submit request.
+ * Read item list by authority name.
*/
- @Test(dependsOnMethods = {"createItem", "readItem", "testSubmitRequest"})
- public void testItemSubmitRequest() {
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getItemResourceURL(knownResourceId, knownItemResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("testItemSubmitRequest: url=" + url +
- " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
+ @Test(dataProvider = "testName", groups = {"readList"},
+ dependsOnMethods = {"readItemList"})
+ public void readItemListByAuthorityName(String testName) {
+ readItemList(null, READITEMS_SHORT_IDENTIFIER);
+ }
+
+ /**
+ * Read item list.
+ *
+ * @param vcsid
+ * the vcsid
+ * @param name
+ * the name
+ */
+ private void readItemList(String vcsid, String shortId) {
+ String testName = "readItemList";
+
+ // Perform setup.
+ setupReadList();
+
+ // Submit the request to the service and store the response.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ ClientResponse<AbstractCommonList> res = null;
+ if (vcsid != null) {
+ res = client.readItemList(vcsid, null, null);
+ } else if (shortId != null) {
+ res = client.readItemListForNamedAuthority(shortId, null, null);
+ } else {
+ Assert.fail("readItemList passed null csid and name!");
+ }
+
+ AbstractCommonList list = null;
+ try {
+ assertStatusCode(res, testName);
+ list = res.getEntity();
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
+
+ List<AbstractCommonList.ListItem> items = list.getListItem();
+ int nItemsReturned = items.size();
+ // There will be 'nItemsToCreateInList'
+ // items created by the createItemList test,
+ // all associated with the same parent resource.
+ int nExpectedItems = nItemsToCreateInList;
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": Expected " + nExpectedItems
+ + " items; got: " + nItemsReturned);
+ }
+ Assert.assertEquals(nItemsReturned, nExpectedItems);
+
+ for (AbstractCommonList.ListItem item : items) {
+ String value = AbstractCommonListUtils.ListItemGetElementValue(
+ item, REFNAME);
+ Assert.assertTrue((null != value), "Item refName is null!");
+ value = AbstractCommonListUtils.ListItemGetElementValue(item,
+ DISPLAYNAME);
+ Assert.assertTrue((null != value), "Item displayName is null!");
+ }
+ if (logger.isTraceEnabled()) {
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger,
+ testName);
+ }
+ }
+ @Override
+ public void delete(String testName) throws Exception {
+ // Do nothing. See localDelete(). This ensure proper test order.
+ }
+
+ @Test(dataProvider = "testName", dependsOnMethods = {"localDeleteItem"})
+ public void localDelete(String testName) throws Exception {
+ super.delete(testName);
}
+ @Override
+ public void deleteItem(String testName) throws Exception {
+ // Do nothing. We need to wait until after the test "localDelete" gets run. When it does,
+ // its dependencies will get run first and then we can call the base class' delete method.
+ }
+
+ @Test(dataProvider = "testName", groups = {"delete"},
+ dependsOnMethods = {"verifyIllegalItemDisplayName"})
+ public void localDeleteItem(String testName) throws Exception {
+ super.deleteItem(testName);
+ }
+
// ---------------------------------------------------------------
// Cleanup of resources created during testing
// ---------------------------------------------------------------
LocationAuthorityClient client = new LocationAuthorityClient();
parentResourceId = knownResourceId;
// Clean up item resources.
- for (Map.Entry<String, String> entry : allItemResourceIdsCreated.entrySet()) {
+ for (Map.Entry<String, String> entry : allResourceItemIdsCreated.entrySet()) {
itemResourceId = entry.getKey();
parentResourceId = entry.getValue();
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- ClientResponse<Response> res =
- client.deleteItem(parentResourceId, itemResourceId);
- res.releaseConnection();
+ client.deleteItem(parentResourceId, itemResourceId).releaseConnection();
}
// Clean up parent resources.
for (String resourceId : allResourceIdsCreated) {
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- ClientResponse<Response> res = client.delete(resourceId);
- res.releaseConnection();
+ client.delete(resourceId).releaseConnection();
}
}
return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier;
}
+ @Override
+ public void authorityTests(String testName) {
+ // TODO Auto-generated method stub
+
+ }
+
+ //
+ // Location specific overrides
+ //
+
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ // Submit the request to the service and store the response.
+ String shortId = identifier;
+ String displayName = "displayName-" + shortId;
+ // String baseRefName = LocationAuthorityClientUtils.createLocationAuthRefName(shortId, null);
+ PoxPayloadOut result =
+ LocationAuthorityClientUtils.createLocationAuthorityInstance(
+ displayName, shortId, commonPartName);
+ return result;
+ }
+
+ @Override
+ protected PoxPayloadOut createNonExistenceInstance(String commonPartName, String identifier) {
+ String displayName = "displayName-NON_EXISTENT_ID";
+ PoxPayloadOut result = LocationAuthorityClientUtils.createLocationAuthorityInstance(
+ displayName, "nonEx", commonPartName);
+ return result;
+ }
+
+ @Override
+ protected LocationauthoritiesCommon updateInstance(LocationauthoritiesCommon locationauthoritiesCommon) {
+ LocationauthoritiesCommon result = new LocationauthoritiesCommon();
+
+ result.setDisplayName("updated-" + locationauthoritiesCommon.getDisplayName());
+ result.setVocabType("updated-" + locationauthoritiesCommon.getVocabType());
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(LocationauthoritiesCommon original,
+ LocationauthoritiesCommon updated) throws Exception {
+ Assert.assertEquals(updated.getDisplayName(),
+ original.getDisplayName(),
+ "Display name in updated object did not match submitted data.");
+ }
+
+ protected void compareReadInstances(LocationauthoritiesCommon original,
+ LocationauthoritiesCommon fromRead) throws Exception {
+ Assert.assertNotNull(fromRead.getDisplayName());
+ Assert.assertNotNull(fromRead.getShortIdentifier());
+ Assert.assertNotNull(fromRead.getRefName());
+ }
+
+ //
+ // Authority item specific overrides
+ //
+
+ @Override
+ protected String createItemInAuthority(String authorityId) {
+ return createItemInAuthority(authorityId, null /*refname*/);
+ }
+
+ @Override
+ protected LocationsCommon updateItemInstance(LocationsCommon locationsCommon) {
+ LocationsCommon result = new LocationsCommon();
+
+ result.setName("updated-" + locationsCommon.getName());
+ result.setDisplayName("updated-" + locationsCommon.getDisplayName());
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedItemInstances(LocationsCommon original,
+ LocationsCommon updated) throws Exception {
+ Assert.assertEquals(updated.getName(), original.getName(),
+ "Data in updated Location did not match submitted data.");
+ }
+
+ @Override
+ protected void verifyReadItemInstance(LocationsCommon item)
+ throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+ @Override
+ protected PoxPayloadOut createNonExistenceItemInstance(
+ String commonPartName, String identifier) {
+ Map<String, String> nonexMap = new HashMap<String,String>();
+ nonexMap.put(LocationJAXBSchema.NAME, TEST_NAME);
+ nonexMap.put(LocationJAXBSchema.SHORT_IDENTIFIER, "nonEx");
+ nonexMap.put(LocationJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
+ nonexMap.put(LocationJAXBSchema.TERM_STATUS, TEST_STATUS);
+ // PoxPayloadOut multipart =
+ // LocationAuthorityClientUtils.createLocationInstance(
+ // LocationAuthorityClientUtils.createLocationRefName(knownResourceRefName, "nonEx", "Non Existent"),
+ // nonexMap, client.getItemCommonPartName() );
+ final String EMPTY_REFNAME = "";
+ PoxPayloadOut result =
+ LocationAuthorityClientUtils.createLocationInstance(EMPTY_REFNAME,
+ nonexMap, commonPartName);
+ return result;
+ }
}
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
\r
<!-- apache -->\r
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-public class MediaAuthRefsTest extends BaseServiceTest {
+public class MediaAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
private final String CLASS_NAME = MediaAuthRefsTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(MediaAuthRefsTest.class);
final String PERSON_AUTHORITY_NAME = "MediaPersonAuth";
}
@Override
- protected AbstractCommonList getAbstractCommonList(ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
media.setTitle(title);
PoxPayloadOut multipart = new PoxPayloadOut(MediaClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = multipart.addPart(media, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(new MediaClient().getCommonPartName());
+ PayloadOutputPart commonPart = multipart.addPart(new MediaClient().getCommonPartName(), media);
logger.debug("to be created, media common: " + objectAsXmlString(media, MediaCommon.class));
return multipart;
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+ @Test(dataProvider = "testName")
public void createWithAuthRefs(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
String identifier = createIdentifier(); // Submit the request to the service and store the response.
createPersonRefs();// Create all the person refs and entities
MediaClient mediaClient = new MediaClient();
PoxPayloadOut multipart = createMediaInstance(depositorRefName, "media.title-" + identifier);
ClientResponse<Response> res = mediaClient.create(multipart);
- assertStatusCode(res, testName);
- if (knownResourceId == null) {// Store the ID returned from the first resource created for additional tests below.
- knownResourceId = extractId(res);
+ try {
+ assertStatusCode(res, testName);
+ if (knownResourceId == null) {// Store the ID returned from the first resource created for additional tests below.
+ knownResourceId = extractId(res);
+ }
+ mediaIdsCreated.add(extractId(res));// Store the IDs from every resource created; delete on cleanup
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- mediaIdsCreated.add(extractId(res));// Store the IDs from every resource created; delete on cleanup
}
protected void createPersonRefs() {
PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
ClientResponse<Response> res = personAuthClient.create(multipart);
- assertStatusCode(res, "createPersonRefs (not a surefire test)");
- personAuthCSID = extractId(res);
+ try {
+ assertStatusCode(res, "createPersonRefs (not a surefire test)");
+ personAuthCSID = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
// Create temporary Person resources, and their corresponding refNames by which they can be identified.
String csid = "";
}
protected String createPerson(String firstName, String surName, String shortId, String authRefName) {
+ String result = null;
+
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
Map<String, String> personInfo = new HashMap<String, String>();
personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance(
personAuthCSID, authRefName, personInfo, personAuthClient.getItemCommonPartName());
ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
- assertStatusCode(res, "createPerson (not a surefire test)");
- return extractId(res);
+ try {
+ assertStatusCode(res, "createPerson (not a surefire test)");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
+
+ return result;
}
// @Test annotation commented out by Aron 2010-12-02 until media payload is set to the
//
// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"createWithAuthRefs"})
public void readAndCheckAuthRefs(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
testSetup(STATUS_OK, ServiceRequestType.READ);
+
MediaClient mediaClient = new MediaClient();
ClientResponse<String> res = mediaClient.read(knownResourceId);
- assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- MediaCommon media = (MediaCommon) extractPart(input, mediaClient.getCommonPartName(), MediaCommon.class);
- Assert.assertNotNull(media);
- logger.debug(objectAsXmlString(media, MediaCommon.class));
+ PoxPayloadIn input = null;
+ MediaCommon media = null;
+ try {
+ assertStatusCode(res, testName);
+ input = new PoxPayloadIn(res.getEntity());
+ media = (MediaCommon) extractPart(input, mediaClient.getCommonPartName(), MediaCommon.class);
+ Assert.assertNotNull(media);
+ logger.debug(objectAsXmlString(media, MediaCommon.class));
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
// Check a couple of fields
Assert.assertEquals(media.getTitle(), title);
// Get the auth refs and check them
ClientResponse<AuthorityRefList> res2 = mediaClient.getAuthorityRefs(knownResourceId);
- assertStatusCode(res2, testName);
- AuthorityRefList list = res2.getEntity();
+ AuthorityRefList list = null;
+ try {
+ assertStatusCode(res2, testName);
+ list = res2.getEntity();
+ } finally {
+ if (res2 != null) {
+ res2.releaseConnection();
+ }
+ }
+
List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
int numAuthRefsFound = items.size();
logger.debug("Authority references, found " + numAuthRefsFound);
import java.io.File;
import java.net.URL;
-import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.MediaClient;
import org.collectionspace.services.client.PayloadOutputPart;
-import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.media.LanguageList;
import org.collectionspace.services.media.MediaCommon;
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-public class MediaServiceTest extends AbstractServiceTestImpl {
+public class MediaServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, MediaCommon> {
private final String CLASS_NAME = MediaServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(MediaServiceTest.class);
- private String knownResourceId = null;
private boolean mediaCleanup = true;
}
@Override
- protected AbstractCommonList getAbstractCommonList(ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
return response.getEntity(AbstractCommonList.class);
}
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void create(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupCreate();
- MediaClient client = new MediaClient();
- PoxPayloadOut multipart = createMediaInstance(createIdentifier());
- ClientResponse<Response> res = client.create(multipart);
- assertStatusCode(res, testName);
- if (knownResourceId == null) {
- knownResourceId = extractId(res); // Store the ID returned from the first resource created for additional tests below.
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
- allResourceIdsCreated.add(extractId(res)); // Store the IDs from every resource created by tests so they can be deleted after tests have been run.
- }
-
/**
* Looks in the .../src/test/resources/blobs directory for files from which to create Blob
* instances.
* @param fromUri - if 'false' then send the service a multipart/form-data POST from which to create the blob.
* @throws Exception the exception
*/
- public void createBlob(String testName, boolean fromUri) throws Exception {
- setupCreate();
- MediaClient client = new MediaClient();
- PoxPayloadOut multipart = createMediaInstance(createIdentifier());
- ClientResponse<Response> mediaRes = null;
- String mediaCsid = null;
- try {
- mediaRes = client.create(multipart);
- assertStatusCode(mediaRes, testName);
- mediaCsid = extractId(mediaRes);
- } finally {
- mediaRes.releaseConnection();
- }
-
- String currentDir = this.getResourceDir();
- String blobsDirPath = currentDir + File.separator + BLOBS_DIR;
- File blobsDir = new File(blobsDirPath);
- if (blobsDir != null && blobsDir.exists()) {
- File[] children = blobsDir.listFiles();
- if (children != null && children.length > 0) {
- File blobFile = null;
- //
- // Since Media records can have only a single associated blob,
- // we'll stop after we find a valid candidate
- //
- for (File child : children) {
- if (isBlobbable(child) == true) {
- blobFile = child;
- break;
- }
- }
- //
- // If we found a good blob candidate file, then try to create the blob record
- //
- if (blobFile != null) {
- client = new MediaClient();
- ClientResponse<Response> res = null;
- String mimeType = this.getMimeType(blobFile);
- logger.debug("Processing file URI: " + blobFile.getAbsolutePath());
- logger.debug("MIME type is: " + mimeType);
- try {
- if (fromUri == true) {
- URL childUrl = blobFile.toURI().toURL();
- res = client.createBlobFromUri(mediaCsid, childUrl.toString());
- } else {
- MultipartFormDataOutput formData = new MultipartFormDataOutput();
- OutputPart outputPart = formData.addFormData("file", blobFile, MediaType.valueOf(mimeType));
- res = client.createBlobFromFormData(mediaCsid, formData);
- }
- } finally {
- res.releaseConnection();
- }
- assertStatusCode(res, testName);
- if (isMediaCleanup() == true) {
- allResourceIdsCreated.add(extractId(res));
- allResourceIdsCreated.add(mediaCsid);
- }
- } else {
- logger.debug("Directory: " + blobsDirPath + " contains no readable files.");
- }
- } else {
- logger.debug("Directory: " + blobsDirPath + " is empty or cannot be read.");
- }
- } else {
- logger.debug("Directory: " + blobsDirPath + " is missing or cannot be read.");
- }
- }
+ public void createBlob(String testName, boolean fromUri) throws Exception {
+ setupCreate();
+ //
+ // First create a media record
+ //
+ MediaClient client = new MediaClient();
+ PoxPayloadOut multipart = createMediaInstance(createIdentifier());
+ ClientResponse<Response> mediaRes = client.create(multipart);
+ String mediaCsid = null;
+ try {
+ assertStatusCode(mediaRes, testName);
+ mediaCsid = extractId(mediaRes);
+ } finally {
+ if (mediaRes != null) {
+ mediaRes.releaseConnection();
+ }
+ }
+ //
+ // Next, create a blob record to associate with the media record
+ // FIXME: REM - 1/2012, This method is too large. Break it up. The code below
+ // could be put into a utility class that could also be used by the blob service tests.
+ //
+ String currentDir = this.getResourceDir();
+ String blobsDirPath = currentDir + File.separator + BLOBS_DIR;
+ File blobsDir = new File(blobsDirPath);
+ if (blobsDir != null && blobsDir.exists()) {
+ File[] children = blobsDir.listFiles();
+ if (children != null && children.length > 0) {
+ File blobFile = null;
+ //
+ // Since Media records can have only a single associated
+ // blob, we'll stop after we find a valid candidate.
+ //
+ for (File child : children) {
+ if (isBlobbable(child) == true) {
+ blobFile = child;
+ break;
+ }
+ }
+ //
+ // If we found a good blob candidate file, then try to
+ // create the blob record
+ //
+ if (blobFile != null) {
+ client = new MediaClient();
+ ClientResponse<Response> res = null;
+ String mimeType = this.getMimeType(blobFile);
+ logger.debug("Processing file URI: " + blobFile.getAbsolutePath());
+ logger.debug("MIME type is: " + mimeType);
+ if (fromUri == true) {
+ URL childUrl = blobFile.toURI().toURL();
+ res = client.createBlobFromUri(mediaCsid,
+ childUrl.toString());
+ } else {
+ MultipartFormDataOutput formData = new MultipartFormDataOutput();
+ OutputPart outputPart = formData.addFormData("file",
+ blobFile, MediaType.valueOf(mimeType));
+ res = client
+ .createBlobFromFormData(mediaCsid, formData);
+ }
+ try {
+ assertStatusCode(res, testName);
+ String blobCsid = extractId(res);
+ if (isMediaCleanup() == true) {
+ allResourceIdsCreated.add(blobCsid);
+ allResourceIdsCreated.add(mediaCsid);
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
+ } else {
+ logger.debug("Directory: " + blobsDirPath
+ + " contains no readable files.");
+ }
+ } else {
+ logger.debug("Directory: " + blobsDirPath
+ + " is empty or cannot be read.");
+ }
+ } else {
+ logger.debug("Directory: " + blobsDirPath
+ + " is missing or cannot be read.");
+ }
+ }
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void createWithBlobUri(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
createBlob(testName, true /*with URI*/);
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ @Test(dataProvider = "testName",
dependsOnMethods = {"createWithBlobUri"})
public void createWithBlobPost(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
createBlob(testName, false /*with POST*/);
}
// allResourceIdsCreated.add(extractId(res)); // Store the IDs from every resource created by tests so they can be deleted after tests have been run.
// }
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
- public void createList(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- for (int i = 0; i < 3; i++) {
- create(testName);
- }
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
- public void read(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupRead();
- MediaClient client = new MediaClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- MediaCommon media = (MediaCommon) extractPart(input, client.getCommonPartName(), MediaCommon.class);
- Assert.assertNotNull(media);
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"createList", "read"})
- public void readList(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupReadList();
- MediaClient client = new MediaClient();
- ClientResponse<AbstractCommonList> res = client.readList();
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
- // Optionally output additional data about list members for debugging.
- if(logger.isTraceEnabled()){
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"read"})
- public void update(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupUpdate();
- MediaClient client = new MediaClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
- logger.debug("got object to update with ID: " + knownResourceId);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());;
- MediaCommon media = (MediaCommon) extractPart(input, client.getCommonPartName(), MediaCommon.class);
- Assert.assertNotNull(media);
-
- media.setTitle("updated-" + media.getTitle());
- logger.debug("Object to be updated:"+objectAsXmlString(media, MediaCommon.class));
- PoxPayloadOut output = new PoxPayloadOut(MediaClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(media, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
- res = client.update(knownResourceId, output);
- assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
- MediaCommon updatedMedia = (MediaCommon) extractPart(input, client.getCommonPartName(), MediaCommon.class);
- Assert.assertNotNull(updatedMedia);
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupUpdateNonExistent();
- // 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 update(), below.
- MediaClient client = new MediaClient();
- PoxPayloadOut multipart = createMediaInstance(NON_EXISTENT_ID);
- ClientResponse<String> res = client.update(NON_EXISTENT_ID, multipart);
- assertStatusCode(res, testName);
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
- public void delete(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupDelete();
- MediaClient client = new MediaClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- assertStatusCode(res, testName);
- }
-
- // ---------------------------------------------------------------
- // Failure outcome tests : means we expect response to fail, but test to succeed
- // ---------------------------------------------------------------
-
- // Failure outcome
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"read"})
- public void readNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupReadNonExistent();
- MediaClient client = new MediaClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
- assertStatusCode(res, testName);
- }
-
- // Failure outcome
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupDeleteNonExistent();
- MediaClient client = new MediaClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- assertStatusCode(res, testName);
- }
-
- // Failure outcomes
- // Placeholders until the tests below can be implemented. See Issue CSPACE-401.
-
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- }
-
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- }
-
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- }
-
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- }
-
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- }
-
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- }
-
// ---------------------------------------------------------------
// Utility tests : tests of code used in tests above
// ---------------------------------------------------------------
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() {
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode(); // Expected status code: 200 OK
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
- logger.debug("testSubmitRequest: url=" + url + " status=" + statusCode);
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
- }
-
@Override
protected PoxPayloadOut createInstance(String identifier) {
return createMediaInstance(identifier);
}
-
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
return multipart;
}
+
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ return createMediaInstance(identifier);
+ }
+
+ @Override
+ protected MediaCommon updateInstance(final MediaCommon original) {
+ MediaCommon result = new MediaCommon();
+
+ result.setTitle("updated-" + original.getTitle());
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(MediaCommon original,
+ MediaCommon updated) throws Exception {
+ Assert.assertEquals(updated.getTitle(), original.getTitle());
+ }
+
+ @Override
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {
+ "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
+ public void CRUDTests(String testName) {
+ // TODO Auto-generated method stub
+
+ }
}
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<!-- javax -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
* $LastChangedRevision$
* $LastChangedDate$
*/
-public class MovementAuthRefsTest extends BaseServiceTest {
+public class MovementAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
private final String CLASS_NAME = MovementAuthRefsTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
// Instance variables specific to this test.
final String PERSON_AUTHORITY_NAME = "TestPersonAuth";
- private String knownResourceId = null;
private List<String> movementIdsCreated = new ArrayList<String>();
private List<String> personIdsCreated = new ArrayList<String>();
private String personAuthCSID = null;
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
+ protected AbstractCommonList getCommonList(
ClientResponse<AbstractCommonList> response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
// Success outcomes
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
+ @Test(dataProvider="testName")
public void createWithAuthRefs(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
// Submit the request to the service and store the response.
if(logger.isDebugEnabled()){
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Store the ID returned from the first resource created
// for additional tests below.
ClientResponse<Response> res = personAuthClient.create(multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
personAuthCSID = extractId(res);
ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
return extractId(res);
}
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
dependsOnMethods = {"createWithAuthRefs"})
public void readAndCheckAuthRefs(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
testSetup(STATUS_OK, ServiceRequestType.READ);
// Submit the request to the service and store the response.
MovementClient movementClient = new MovementClient();
ClientResponse<String> res = movementClient.read(knownResourceId);
- assertStatusCode(res, testName);
-
- // Extract and return the common part of the record.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PayloadInputPart payloadInputPart = input.getPart(movementClient.getCommonPartName());
MovementsCommon movementCommon = null;
- if (payloadInputPart != null) {
- movementCommon = (MovementsCommon) payloadInputPart.getBody();
- }
- Assert.assertNotNull(movementCommon);
- if(logger.isDebugEnabled()){
- logger.debug(objectAsXmlString(movementCommon, MovementsCommon.class));
+ try {
+ assertStatusCode(res, testName);
+ // Extract and return the common part of the record.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PayloadInputPart payloadInputPart = input.getPart(movementClient.getCommonPartName());
+ if (payloadInputPart != null) {
+ movementCommon = (MovementsCommon) payloadInputPart.getBody();
+ }
+ Assert.assertNotNull(movementCommon);
+ if(logger.isDebugEnabled()){
+ logger.debug(objectAsXmlString(movementCommon, MovementsCommon.class));
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
// Check a couple of fields
// FIXME
Assert.assertEquals(movementCommon.getMovementContact(), movementContactRefName);
// Get the auth refs and check them
- ClientResponse<AuthorityRefList> res2 =
- movementClient.getAuthorityRefs(knownResourceId);
- assertStatusCode(res2, testName);
-
- AuthorityRefList list = res2.getEntity();
+ ClientResponse<AuthorityRefList> res2 = movementClient.getAuthorityRefs(knownResourceId);
+ AuthorityRefList list = null;
+ try {
+ assertStatusCode(res2, testName);
+ list = res2.getEntity();
+ } finally {
+ if (res2 != null) {
+ res2.releaseConnection();
+ }
+ }
List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
int numAuthRefsFound = items.size();
*/
package org.collectionspace.services.client.test;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
import java.util.List;
-import java.util.TimeZone;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.MovementClient;
import org.jboss.resteasy.client.ClientResponse;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.PayloadInputPart;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.slf4j.LoggerFactory;
/**
- * MovementServiceTest, carries out tests against a
- * deployed and running Movement Service.
- *
- * $LastChangedRevision$
- * $LastChangedDate$
+ * MovementServiceTest, carries out tests against a deployed and running
+ * Movement Service.
+ *
+ * $LastChangedRevision$ $LastChangedDate: 2011-11-14 23:26:36 -0800
+ * (Mon, 14 Nov 2011) $
*/
-public class MovementServiceTest extends AbstractServiceTestImpl {
-
- /** The logger. */
- private final String CLASS_NAME = MovementServiceTest.class.getName();
- private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
-
- final String SERVICE_NAME = "movements";
- final String SERVICE_PATH_COMPONENT = "movements";
-
- // Instance variables specific to this test.
- private String knownResourceId = null;
- private final static String TIMESTAMP_UTC =
- GregorianCalendarDateTimeUtils.timestampUTC();
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
- */
- @Override
- protected CollectionSpaceClient getClientInstance() {
- return new MovementClient();
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : CREATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
- public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // 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();
-
- // Submit the request to the service and store the response.
- MovementClient client = new MovementClient();
- String identifier = createIdentifier();
- PoxPayloadOut multipart = createMovementInstance(identifier);
- ClientResponse<Response> res = client.create(multipart);
-
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Store the ID returned from the first resource created
- // for additional tests below.
- if (knownResourceId == null){
- knownResourceId = extractId(res);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
- }
-
- // Store the IDs from every resource created by tests,
- // so they can be deleted after tests have been run.
- allResourceIdsCreated.add(extractId(res));
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void createList(String testName) throws Exception {
- for(int i = 0; i < 3; i++){
- create(testName);
- }
- }
-
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
- */
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /*
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithEmptyEntityBody();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("createWithEmptyEntityBody url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA; // Constant from base class.
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithWrongXmlSchema(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithWrongXmlSchema();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
- */
-
- // ---------------------------------------------------------------
- // CRUD tests : READ tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- MovementClient client = new MovementClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
-
- // Get the common part of the response and verify that it is not null.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
- MovementsCommon movementCommon = null;
- if (payloadInputPart != null) {
- movementCommon = (MovementsCommon) payloadInputPart.getBody();
- }
- Assert.assertNotNull(movementCommon);
-
- // Check selected fields.
-
- // Check the values of one or more date/time fields.
- if (logger.isDebugEnabled()) {
- logger.debug("locationDate=" + movementCommon.getLocationDate());
- logger.debug("TIMESTAMP_UTC=" + TIMESTAMP_UTC);
- }
- Assert.assertTrue(movementCommon.getLocationDate().equals(TIMESTAMP_UTC));
- Assert.assertTrue(movementCommon.getPlannedRemovalDate().equals(TIMESTAMP_UTC));
- Assert.assertNull(movementCommon.getRemovalDate());
-
- // Check the values of fields containing Unicode UTF-8 (non-Latin-1) characters.
- if(logger.isDebugEnabled()){
- logger.debug("UTF-8 data sent=" + getUTF8DataFragment() + "\n"
- + "UTF-8 data received=" + movementCommon.getMovementNote());
- }
- Assert.assertEquals(movementCommon.getMovementNote(), getUTF8DataFragment(),
- "UTF-8 data retrieved '" + movementCommon.getMovementNote()
- + "' does not match expected data '" + getUTF8DataFragment());
-
- }
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void readNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- MovementClient client = new MovementClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : READ_LIST tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
- public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadList();
-
- // Submit the request to the service and store the response.
- MovementClient client = new MovementClient();
- ClientResponse<AbstractCommonList> res = client.readList();
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
-
- // Optionally output additional data about list members for debugging.
- if(logger.isTraceEnabled()){
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
- }
-
- // Failure outcomes
- // None at present.
- // ---------------------------------------------------------------
- // CRUD tests : UPDATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void update(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
-
- // Retrieve the contents of a resource to update.
- MovementClient client = new MovementClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
- assertStatusCode(res, testName);
-
- // Extract the common part from the response.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
- MovementsCommon movementCommon = null;
- if (payloadInputPart != null) {
- movementCommon = (MovementsCommon) payloadInputPart.getBody();
- }
- Assert.assertNotNull(movementCommon);
-
- // Update its content.
- movementCommon.setMovementReferenceNumber("updated-" + movementCommon.getMovementReferenceNumber());
- movementCommon.setMovementNote("updated movement note-" + movementCommon.getMovementNote());
- movementCommon.setNormalLocation(""); // Test deletion of existing string value
-
- String currentTimestamp = GregorianCalendarDateTimeUtils.timestampUTC();
- movementCommon.setPlannedRemovalDate(""); // Test deletion of existing date or date/time value
- movementCommon.setRemovalDate(currentTimestamp);
-
- if(logger.isDebugEnabled()){
- logger.debug("to be updated object");
- logger.debug(objectAsXmlString(movementCommon, MovementsCommon.class));
- }
-
- // Submit the request to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());
- PayloadOutputPart commonPart = output.addPart(movementCommon, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
- res = client.update(knownResourceId, output);
- assertStatusCode(res, testName);
-
- // Extract the updated common part from the response.
- input = new PoxPayloadIn(res.getEntity());
- payloadInputPart = input.getPart(client.getCommonPartName());
- MovementsCommon updatedMovementCommon = null;
- if (payloadInputPart != null) {
- updatedMovementCommon = (MovementsCommon) payloadInputPart.getBody();
- }
- Assert.assertNotNull(movementCommon);
- if(logger.isDebugEnabled()){
- logger.debug("updated object");
- logger.debug(objectAsXmlString(updatedMovementCommon, MovementsCommon.class));
- }
-
- // Check selected fields in the updated common part.
-
- // By submitting an empty string in the update payload, the value of this field
- // in the object created from the response payload will be null.
- Assert.assertNull(updatedMovementCommon.getNormalLocation(), "Data in updated object did not match submitted data.");
- if(logger.isDebugEnabled()){
- logger.debug("Normal location after update=|" + updatedMovementCommon.getNormalLocation() + "|");
- }
-
- Assert.assertEquals(updatedMovementCommon.getMovementReferenceNumber(),
- movementCommon.getMovementReferenceNumber(),
- "Data in updated object did not match submitted data.");
- Assert.assertEquals(updatedMovementCommon.getMovementNote(),
- movementCommon.getMovementNote(),
- "Data in updated object did not match submitted data.");
- Assert.assertNull(updatedMovementCommon.getPlannedRemovalDate());
- Assert.assertEquals(updatedMovementCommon.getRemovalDate(),
- movementCommon.getRemovalDate(),
- "Data in updated object did not match submitted data.");
-
- if(logger.isDebugEnabled()){
- logger.debug("UTF-8 data sent=" + movementCommon.getMovementNote() + "\n"
- + "UTF-8 data received=" + updatedMovementCommon.getMovementNote());
- }
- Assert.assertTrue(updatedMovementCommon.getMovementNote().contains(getUTF8DataFragment()),
- "UTF-8 data retrieved '" + updatedMovementCommon.getMovementNote()
- + "' does not contain expected data '" + getUTF8DataFragment());
- Assert.assertEquals(updatedMovementCommon.getMovementNote(),
- movementCommon.getMovementNote(),
- "Data in updated object did not match submitted data.");
-
- }
-
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception{
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
- */
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /*
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithEmptyEntityBody();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithWrongXmlSchema(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithWrongXmlSchema();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
- */
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateNonExistent();
-
- // 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 update(), below.
- MovementClient client = new MovementClient();
- PoxPayloadOut multipart = createMovementInstance(NON_EXISTENT_ID);
- ClientResponse<String> 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(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : DELETE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
- */
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
- public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- /*
- // Perform setup.
- setupDelete();
-
- // Submit the request to the service and store the response.
- MovementClient client = new MovementClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- *
- */
- }
-
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDeleteNonExistent();
-
- // Submit the request to the service and store the response.
- MovementClient client = new MovementClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
- /**
- * Tests the code for manually submitting data that is used by several
- * of the methods above.
- */
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() {
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("testSubmitRequest: url=" + url +
- " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
- }
-
- // ---------------------------------------------------------------
- // Utility methods used by tests above
- // ---------------------------------------------------------------
-
- @Override
- protected String getServiceName() {
- return SERVICE_NAME;
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
- */
- @Override
- public String getServicePathComponent() {
- return SERVICE_PATH_COMPONENT;
- }
-
- /**
- * Creates the movement instance.
- *
- * @param identifier the identifier
- * @return the multipart output
- */
- private PoxPayloadOut createMovementInstance(String identifier) {
- return createInstance("movementReferenceNumber-" + identifier);
- }
-
- /**
- * Creates an instance of a Movement record for testing.
- *
- * @param movementReferenceNumber A movement reference number.
- * @return Multipart output suitable for use as a payload
- * in a create or update request.
- */
- @Override
- public PoxPayloadOut createInstance(String movementReferenceNumber) {
- MovementsCommon movementCommon = new MovementsCommon();
- // FIXME: Values of currentLocation, normalLocation,
- // and movementContact should be refNames.
- movementCommon.setCurrentLocation("currentLocation value");
- movementCommon.setCurrentLocationFitness("currentLocationFitness value");
- movementCommon.setCurrentLocationNote("currentLocationNote value");
- movementCommon.setLocationDate(TIMESTAMP_UTC);
- movementCommon.setNormalLocation("normalLocation value");
- movementCommon.setMovementContact("movementContact value");
- MovementMethodsList movementMethodsList = new MovementMethodsList();
- List<String> methods = movementMethodsList.getMovementMethod();
- // @TODO Use properly formatted refNames for representative movement
- // methods in this example record. The values below are placeholders.
- String identifier = createIdentifier();
- methods.add("First Movement Method-" + identifier);
- methods.add("Second Movement Method-" + identifier);
- movementCommon.setMovementMethods(movementMethodsList);
- movementCommon.setMovementNote(getUTF8DataFragment());
- movementCommon.setMovementReferenceNumber(movementReferenceNumber);
- movementCommon.setPlannedRemovalDate(TIMESTAMP_UTC);
- movementCommon.setRemovalDate(""); // Test empty date value
- movementCommon.setReasonForMove("reasonForMove value");
-
- PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
- PayloadOutputPart commonPart =
- multipart.addPart(movementCommon, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(new MovementClient().getCommonPartName());
-
- if(logger.isDebugEnabled()){
- logger.debug("to be created, movement common");
- logger.debug(objectAsXmlString(movementCommon, MovementsCommon.class));
- }
-
- return multipart;
- }
-
+public class MovementServiceTest extends
+ AbstractPoxServiceTestImpl<AbstractCommonList, MovementsCommon> {
+
+ /** The logger. */
+ private final String CLASS_NAME = MovementServiceTest.class.getName();
+ private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
+
+ final String SERVICE_NAME = "movements";
+ final String SERVICE_PATH_COMPONENT = "movements";
+
+ private final static String TIMESTAMP_UTC = GregorianCalendarDateTimeUtils
+ .timestampUTC();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.collectionspace.services.client.test.BaseServiceTest#getClientInstance
+ * ()
+ */
+ @Override
+ protected CollectionSpaceClient getClientInstance() {
+ return new MovementClient();
+ }
+
+ // ---------------------------------------------------------------
+ // Utility methods used by tests above
+ // ---------------------------------------------------------------
+
+ @Override
+ protected String getServiceName() {
+ return SERVICE_NAME;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.collectionspace.services.client.test.BaseServiceTest#
+ * getServicePathComponent()
+ */
+ @Override
+ public String getServicePathComponent() {
+ return SERVICE_PATH_COMPONENT;
+ }
+
+ /**
+ * Creates the movement instance.
+ *
+ * @param identifier
+ * the identifier
+ * @return the multipart output
+ */
+ private PoxPayloadOut createMovementInstance(String identifier) {
+ return createInstance("movementReferenceNumber-" + identifier);
+ }
+
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ PoxPayloadOut result = createMovementInstance(identifier);
+ return result;
+ }
+
+ /**
+ * Creates an instance of a Movement record for testing.
+ *
+ * @param movementReferenceNumber
+ * A movement reference number.
+ * @return Multipart output suitable for use as a payload in a create or
+ * update request.
+ */
+ @Override
+ protected PoxPayloadOut createInstance(String movementReferenceNumber) {
+ MovementsCommon movementCommon = new MovementsCommon();
+ // FIXME: Values of currentLocation, normalLocation,
+ // and movementContact should be refNames.
+ movementCommon.setCurrentLocation("currentLocation value");
+ movementCommon
+ .setCurrentLocationFitness("currentLocationFitness value");
+ movementCommon.setCurrentLocationNote("currentLocationNote value");
+ movementCommon.setLocationDate(TIMESTAMP_UTC);
+ movementCommon.setNormalLocation("normalLocation value");
+ movementCommon.setMovementContact("movementContact value");
+ MovementMethodsList movementMethodsList = new MovementMethodsList();
+ List<String> methods = movementMethodsList.getMovementMethod();
+ // @TODO Use properly formatted refNames for representative movement
+ // methods in this example record. The values below are placeholders.
+ String identifier = createIdentifier();
+ methods.add("First Movement Method-" + identifier);
+ methods.add("Second Movement Method-" + identifier);
+ movementCommon.setMovementMethods(movementMethodsList);
+ movementCommon.setMovementNote(getUTF8DataFragment());
+ movementCommon.setMovementReferenceNumber(movementReferenceNumber);
+ movementCommon.setPlannedRemovalDate(TIMESTAMP_UTC);
+ movementCommon.setRemovalDate(""); // Test empty date value
+ movementCommon.setReasonForMove("reasonForMove value");
+
+ PoxPayloadOut multipart = new PoxPayloadOut(
+ this.getServicePathComponent());
+ PayloadOutputPart commonPart = multipart.addPart(
+ new MovementClient().getCommonPartName(), movementCommon);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("to be created, movement common");
+ logger.debug(objectAsXmlString(movementCommon,
+ MovementsCommon.class));
+ }
+
+ return multipart;
+ }
+
+ @Override
+ protected MovementsCommon updateInstance(MovementsCommon movementsCommon) {
+ MovementsCommon result = new MovementsCommon();
+
+ result.setMovementReferenceNumber("updated-"
+ + movementsCommon.getMovementReferenceNumber());
+ result.setMovementNote("updated movement note-"
+ + movementsCommon.getMovementNote());
+ result.setNormalLocation(""); // Test deletion of existing
+ // string value
+
+ String currentTimestamp = GregorianCalendarDateTimeUtils.timestampUTC();
+ result.setPlannedRemovalDate(""); // Test deletion of existing
+ // date or date/time value
+ result.setRemovalDate(currentTimestamp);
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(MovementsCommon original,
+ MovementsCommon updated) throws Exception {
+ // By submitting an empty string in the update payload, the value of
+ // this field
+ // in the object created from the response payload will be null.
+ Assert.assertNull(updated.getNormalLocation(),
+ "Normal location in updated object did not match submitted data.");
+ if (logger.isDebugEnabled()) {
+ logger.debug("Normal location after update=|"
+ + updated.getNormalLocation() + "|");
+ }
+
+ Assert.assertEquals(updated.getMovementReferenceNumber(),
+ original.getMovementReferenceNumber(),
+ "Movement reference number in updated object did not match submitted data.");
+ Assert.assertEquals(updated.getMovementNote(),
+ original.getMovementNote(),
+ "Movement note in updated object did not match submitted data.");
+ Assert.assertNull(updated.getPlannedRemovalDate());
+ Assert.assertEquals(updated.getRemovalDate(),
+ original.getRemovalDate(),
+ "Removal date in updated object did not match submitted data.");
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("UTF-8 data sent=" + original.getMovementNote()
+ + "\n" + "UTF-8 data received="
+ + updated.getMovementNote());
+ }
+ Assert.assertTrue(
+ updated.getMovementNote().contains(
+ getUTF8DataFragment()), "UTF-8 data retrieved '"
+ + updated.getMovementNote()
+ + "' does not contain expected data '"
+ + getUTF8DataFragment());
+ Assert.assertEquals(updated.getMovementNote(),
+ original.getMovementNote(),
+ "Movement note in updated object did not match submitted data.");
+ }
+
+ protected void compareReadInstances(MovementsCommon original,
+ MovementsCommon fromRead) throws Exception {
+ // Check the values of one or more date/time fields.
+ if (logger.isDebugEnabled()) {
+ logger.debug("locationDate=" + fromRead.getLocationDate());
+ logger.debug("TIMESTAMP_UTC=" + TIMESTAMP_UTC);
+ }
+ Assert.assertTrue(fromRead.getLocationDate().equals(TIMESTAMP_UTC));
+ Assert.assertTrue(fromRead.getPlannedRemovalDate().equals(TIMESTAMP_UTC));
+ Assert.assertNull(fromRead.getRemovalDate());
+
+ // Check the values of fields containing Unicode UTF-8 (non-Latin-1)
+ // characters.
+ if (logger.isDebugEnabled()) {
+ logger.debug("UTF-8 data sent=" + getUTF8DataFragment() + "\n"
+ + "UTF-8 data received=" + fromRead.getMovementNote());
+ }
+ Assert.assertEquals(fromRead.getMovementNote(),
+ getUTF8DataFragment(), "UTF-8 data retrieved '"
+ + fromRead.getMovementNote()
+ + "' does not match expected data '"
+ + getUTF8DataFragment());
+ }
+
+ /*
+ * For convenience and terseness, this test method is the base of the test
+ * execution dependency chain. Other test methods may refer to this method
+ * in their @Test annotation declarations.
+ */
+ @Override
+ @Test(dataProvider = "testName", dependsOnMethods = { "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests" })
+ public void CRUDTests(String testName) {
+ // TODO Auto-generated method stub
+ }
}
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
-import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.collectionspace.services.MovementJAXBSchema;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.MovementClient;
import org.collectionspace.services.client.PayloadInputPart;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.movement.MovementsCommon;
import org.collectionspace.services.jaxb.AbstractCommonList;
* $LastChangedRevision: 2562 $
* $LastChangedDate: 2010-06-22 23:26:51 -0700 (Tue, 22 Jun 2010) $
*/
-public class MovementSortByTest extends BaseServiceTest {
+public class MovementSortByTest extends BaseServiceTest<AbstractCommonList> {
private final String CLASS_NAME = MovementSortByTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
+ protected AbstractCommonList getCommonList(
ClientResponse<AbstractCommonList> response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
* Tests whether a list of records, sorted by a String field in
* ascending order, is returned in the expected order.
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"createList"})
public void sortByStringFieldAscending(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
String sortFieldName = qualifySortFieldName(MovementJAXBSchema.MOVEMENT_NOTE);
if (logger.isDebugEnabled()) {
logger.debug("Sorting on field name=" + sortFieldName);
* This verifies that summary list results from keyword searches, in
* addition to 'read list' requests, can be returned in sorted order.
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"createList"})
public void sortKeywordSearchResultsByStringFieldAscending(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
String sortFieldName = qualifySortFieldName(MovementJAXBSchema.MOVEMENT_NOTE);
if (logger.isDebugEnabled()) {
logger.debug("Sorting on field name=" + sortFieldName);
* Tests whether a list of records, sorted by a String field in
* descending order, is returned in the expected order.
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"createList"})
public void sortByStringFieldDescending(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
String sortFieldName =
asDescendingSort(qualifySortFieldName(MovementJAXBSchema.MOVEMENT_NOTE));
if (logger.isDebugEnabled()) {
* Tests whether a list of records, sorted by a dateTime field in
* ascending order, is returned in the expected order.
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"createList"})
public void sortByDateTimeFieldAscending(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
String sortFieldName = qualifySortFieldName(MovementJAXBSchema.LOCATION_DATE);
if (logger.isDebugEnabled()) {
logger.debug("Sorting on field name=" + sortFieldName);
* Tests whether a list of records, sorted by a dateTime field in
* descending order, is returned in the expected order.
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"createList"})
public void sortByDateTimeFieldDescending(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
String sortFieldName =
asDescendingSort(qualifySortFieldName(MovementJAXBSchema.LOCATION_DATE));
if (logger.isDebugEnabled()) {
* Tests whether a list of records, sorted by two different fields in
* ascending order, is returned in the expected order.
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"createList"})
public void sortByTwoFieldsAscending(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
String firstSortFieldName = qualifySortFieldName(MovementJAXBSchema.MOVEMENT_NOTE);
String secondSortFieldName = qualifySortFieldName(MovementJAXBSchema.LOCATION_DATE);
if (logger.isDebugEnabled()) {
* Tests whether a list of records, sorted by one different fields in
* descending order and a second field in ascending order, is returned in the expected order.
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"createList"})
public void sortByOneFieldAscendingOneFieldsDescending(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
String firstSortFieldName =
asDescendingSort(qualifySortFieldName(MovementJAXBSchema.LOCATION_DATE));
String secondSortFieldName = qualifySortFieldName(MovementJAXBSchema.MOVEMENT_NOTE);
* as expected: the query parameter is simply ignored, and a list
* of records is returned, unsorted, with a success result.
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+ @Test(dataProvider = "testName")
public void sortWithEmptySortFieldName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
testSetup(STATUS_OK, ServiceRequestType.READ);
// Submit the request to the service and store the response.
final String EMPTY_SORT_FIELD_NAME = "";
ClientResponse<AbstractCommonList> res =
client.readListSortedBy(EMPTY_SORT_FIELD_NAME);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
}
// Failure outcomes
* handled as expected. The field name provided in this test is valid,
* but has not been qualified by being prefixed by a schema name and delimiter.
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+ @Test(dataProvider = "testName")
public void sortWithUnqualifiedFieldName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
testSetup(STATUS_BAD_REQUEST, ServiceRequestType.READ);
// Submit the request to the service and store the response.
MovementClient client = new MovementClient();
ClientResponse<AbstractCommonList> res =
client.readListSortedBy(MovementJAXBSchema.LOCATION_DATE);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
}
/*
* Tests whether a request to sort by an invalid identifier for the
* sort order (ascending or descending) is handled as expected.
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+ @Test(dataProvider = "testName")
public void sortWithInvalidSortOrderIdentifier(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
testSetup(STATUS_BAD_REQUEST, ServiceRequestType.READ);
// Submit the request to the service and store the response.
ClientResponse<AbstractCommonList> res =
client.readListSortedBy(MovementJAXBSchema.LOCATION_DATE
+ " " + INVALID_SORT_ORDER_IDENTIFIER);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- }
-
- /*
- * Tests whether a request to sort by a malformed field name is
- * handled as expected.
- */
-/*
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
- public void sortWithMalformedFieldName(String testName) throws Exception {
-
- // FIXME: Implement this stub method.
-
- // FIXME: Consider splitting this test into various tests, with
- // different malformed field name formats that might confuse parsers
- // and/or validation code.
-
- // FIXME: Consider fixing DocumentFilter.setSortOrder() to return
- // an error response to this test case, then revise this test case
- // to expect that response.
-
}
-*/
// ---------------------------------------------------------------
// Cleanup of resources created during testing
MovementClient movementClient = new MovementClient();
for (String resourceId : movementIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- movementClient.delete(resourceId);
+ movementClient.delete(resourceId).releaseConnection();
}
}
String testName = "createList";
if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
+ logger.debug(getTestBanner(testName, CLASS_NAME));
}
testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
}
private void create(String movementNote, String locationDate) throws Exception {
-
+ String result = null;
+
String testName = "create";
testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
movementNote, locationDate);
MovementClient client = new MovementClient();
ClientResponse<Response> res = client.create(multipart);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ assertStatusCode(res, testName);
+ // Store the IDs from every resource created by tests,
+ // so they can be deleted after tests have been run.
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
+
+ if (result != null) {
+ movementIdsCreated.add(result);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Store the IDs from every resource created by tests,
- // so they can be deleted after tests have been run.
- movementIdsCreated.add(extractId(res));
}
private MovementsCommon read(String csid) throws Exception {
-
String testName = "read";
testSetup(STATUS_OK, ServiceRequestType.READ);
// Submit the request to the service and store the response.
MovementClient client = new MovementClient();
ClientResponse<String> res = client.read(csid);
- assertStatusCode(res, testName);
-
- // Extract and return the common part of the record.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
MovementsCommon movementCommon = null;
- if (payloadInputPart != null) {
- movementCommon = (MovementsCommon) payloadInputPart.getBody();
+ try {
+ assertStatusCode(res, testName);
+ // Extract and return the common part of the record.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
+ if (payloadInputPart != null) {
+ movementCommon = (MovementsCommon) payloadInputPart.getBody();
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
return movementCommon;
PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
PayloadOutputPart commonPart =
- multipart.addPart(movementCommon, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(new MovementClient().getCommonPartName());
+ multipart.addPart(new MovementClient().getCommonPartName(), movementCommon);
if (logger.isDebugEnabled()) {
logger.debug("to be created, movement common");
logger.debug(objectAsXmlString(movementCommon, MovementsCommon.class));
}
private AbstractCommonList readSortedList(String sortFieldName) throws Exception {
-
String testName = "readSortedList";
testSetup(STATUS_OK, ServiceRequestType.READ);
// Submit the request to the service and store the response.
MovementClient client = new MovementClient();
- ClientResponse<AbstractCommonList> res =
- client.readListSortedBy(sortFieldName);
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
+ ClientResponse<AbstractCommonList> res = client.readListSortedBy(sortFieldName);
+ AbstractCommonList list = null;
+ try {
+ assertStatusCode(res, testName);
+ list = res.getEntity();
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
return list;
private AbstractCommonList keywordSearchSortedBy(String keywords,
String sortFieldName) throws Exception {
-
+ AbstractCommonList result = null;
+
String testName = "keywordSearchSortedBy";
testSetup(STATUS_OK, ServiceRequestType.READ);
ClientResponse<AbstractCommonList> res =
client.keywordSearchSortedBy(keywords, sortFieldName);
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
+ AbstractCommonList list = null;
+ try {
+ assertStatusCode(res, testName);
+ list = res.getEntity();
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
return list;
-
}
}
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<!-- javax -->
org.collectionspace.collectionspace_core\r
Provide-Package: org.collectionspace.note\r
Nuxeo-Component: OSGI-INF/core-types-contrib.xml,\r
+ OSGI-INF/life-cycle-contrib.xml,\r
OSGI-INF/ecm-types-contrib.xml,\r
OSGI-INF/layouts-contrib.xml\r
\r
--- /dev/null
+<?xml version="1.0"?>
+<component name="org.collectionspace.ecm.platform.note.LifeCycleManagerExtensions">
+
+ <extension target="org.nuxeo.ecm.core.lifecycle.LifeCycleService"
+ point="types">
+ <types>
+ <type name="CSNote">default</type>
+ </types>
+ </extension>
+
+</component>
</parent>\r
\r
<modelVersion>4.0.0</modelVersion>\r
- <groupId>org.collectionspace.services</groupId>\r
<artifactId>org.collectionspace.services.note.client</artifactId>\r
<name>services.note.client</name>\r
\r
</dependency>\r
\r
<!-- External dependencies -->\r
+ \r
+ <!-- \r
<dependency>\r
<groupId>dom4j</groupId>\r
<artifactId>dom4j</artifactId>\r
<version>1.6.1</version>\r
<scope>provided</scope>\r
- </dependency> \r
+ </dependency>\r
+ --> \r
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
<dependency>\r
<groupId>org.jboss.resteasy</groupId>\r
* $LastChangedDate: $\r
*/\r
\r
-public class NoteClient extends AbstractServiceClientImpl<NotesCommonList, NoteProxy> {\r
+public class NoteClient extends AbstractPoxServiceClientImpl<NotesCommonList, NoteProxy> {\r
\r
public static final String SERVICE_NAME = "notes";\r
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;\r
public ClientResponse<NotesCommonList> readList() {\r
return getProxy().readList();\r
}\r
-\r
- /**\r
- * @param csid\r
- * @return\r
- * @see org.collectionspace.services.client.Note#getNote(java.lang.String)\r
- */\r
-\r
- public ClientResponse<String> read(String csid) {\r
- return getProxy().read(csid);\r
- }\r
-\r
- /**\r
- * @param multipart\r
- * @param note\r
- * @return\r
- * @see org.collectionspace.services.client.Note#createNote(org.collectionspace.services.Note)\r
- */\r
- public ClientResponse<Response> create(PoxPayloadOut multipart) {\r
- String payload = multipart.toXML();\r
- return getProxy().create(payload);\r
- }\r
-\r
- /**\r
- * @param csid\r
- * @param multipart\r
- * @return\r
- * @see org.collectionspace.services.client.Note#updateNote(java.lang.Long, org.collectionspace.services.Note)\r
- */\r
- public ClientResponse<String> update(String csid, PoxPayloadOut multipart) {\r
- String payload = multipart.toXML();\r
- return getProxy().update(csid, payload);\r
-\r
- }\r
}\r
@Path("/notes/")\r
@Produces({"application/xml;charset=UTF-8"})\r
@Consumes({"application/xml"})\r
-public interface NoteProxy extends CollectionSpaceProxy<NotesCommonList> {\r
-\r
+public interface NoteProxy extends CollectionSpacePoxProxy<NotesCommonList> {\r
@GET\r
@Produces({"application/xml"})\r
ClientResponse<NotesCommonList> readList();\r
\r
+ @Override\r
+ @GET\r
+ @Produces({"application/xml"})\r
+ ClientResponse<NotesCommonList> readIncludeDeleted(\r
+ @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); \r
+\r
+ @Override\r
+ @GET\r
+ @Produces({"application/xml"})\r
+ ClientResponse<NotesCommonList> keywordSearchIncludeDeleted(\r
+ @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,\r
+ @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);\r
+ \r
+ /*\r
//(C)reate\r
@POST\r
ClientResponse<Response> create(String payload);\r
@DELETE\r
@Path("/{csid}")\r
ClientResponse<Response> delete(@PathParam("csid") String csid);\r
+ */\r
}\r
*/\r
package org.collectionspace.services.client.test;\r
\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
import org.collectionspace.services.client.CollectionSpaceClient;\r
import org.collectionspace.services.client.NoteClient;\r
import org.collectionspace.services.client.NoteClientUtils;\r
-import org.collectionspace.services.client.PayloadInputPart;\r
-import org.collectionspace.services.client.PayloadOutputPart;\r
-import org.collectionspace.services.client.PoxPayloadIn;\r
import org.collectionspace.services.client.PoxPayloadOut;\r
import org.collectionspace.services.note.NotesCommon;\r
import org.collectionspace.services.note.NotesCommonList;\r
-import org.collectionspace.services.jaxb.AbstractCommonList;\r
-\r
-import javax.ws.rs.core.MediaType;\r
-import javax.ws.rs.core.Response;\r
-import org.jboss.resteasy.client.ClientResponse;\r
-import org.dom4j.DocumentException;\r
-\r
-import org.testng.Assert;\r
-import org.testng.annotations.AfterClass;\r
-import org.testng.annotations.Test;\r
\r
import org.slf4j.Logger;\r
import org.slf4j.LoggerFactory;\r
+import org.testng.Assert;\r
\r
/**\r
* NoteServiceTest, carries out tests against a\r
* $LastChangedRevision: 917 $\r
* $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $\r
*/\r
-public class NoteServiceTest extends AbstractServiceTestImpl {\r
+public class NoteServiceTest extends AbstractPoxServiceTestImpl<NotesCommonList, NotesCommon> {\r
\r
private final String CLASS_NAME = NoteServiceTest.class.getName();\r
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);\r
private final String SERVICE_PATH_COMPONENT = "notes";\r
private final String SERVICE_NAME = "notes";\r
\r
- // Instance variables specific to this test.\r
- private String knownResourceId = null;\r
-\r
/* (non-Javadoc)\r
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()\r
*/\r
return new NoteClient();\r
}\r
\r
- /* (non-Javadoc)\r
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)\r
- */\r
- @Override\r
- protected AbstractCommonList getAbstractCommonList(\r
- ClientResponse<AbstractCommonList> response) {\r
- return response.getEntity(NotesCommonList.class);\r
- }\r
-\r
- // ---------------------------------------------------------------\r
- // CRUD tests : CREATE tests\r
- // ---------------------------------------------------------------\r
- // Success outcomes\r
- @Override\r
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)\r
- public void create(String testName) throws Exception {\r
-\r
- if (logger.isDebugEnabled()) {\r
- logger.debug(testBanner(testName, CLASS_NAME));\r
- }\r
- // Perform setup, such as initializing the type of service request\r
- // (e.g. CREATE, DELETE), its valid and expected status codes, and\r
- // its associated HTTP method name (e.g. POST, DELETE).\r
- setupCreate();\r
-\r
- // Submit the request to the service and store the response.\r
- NoteClient client = new NoteClient();\r
- String identifier = createIdentifier();\r
- PoxPayloadOut multipart =\r
- NoteClientUtils.createNoteInstance("owner"+identifier, identifier, \r
- client.getCommonPartName());\r
- ClientResponse<Response> res = client.create(multipart);\r
-\r
- int statusCode = res.getStatus();\r
-\r
- // Check the status code of the response: does it match\r
- // the expected response(s)?\r
- //\r
- // Specifically:\r
- // Does it fall within the set of valid status codes?\r
- // Does it exactly match the expected status code?\r
- if(logger.isDebugEnabled()){\r
- logger.debug(testName + ": status = " + statusCode);\r
- }\r
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),\r
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);\r
-\r
- // Store the ID returned from the first resource created\r
- // for additional tests below.\r
- if (knownResourceId == null){\r
- knownResourceId = extractId(res);\r
- if (logger.isDebugEnabled()) {\r
- logger.debug(testName + ": knownResourceId=" + knownResourceId);\r
- }\r
- }\r
-\r
- // Store the IDs from every resource created by tests,\r
- // so they can be deleted after tests have been run.\r
- allResourceIdsCreated.add(extractId(res));\r
- }\r
-\r
- @Override\r
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,\r
- dependsOnMethods = {"create"})\r
- public void createList(String testName) throws Exception {\r
- for(int i = 0; i < 3; i++){\r
- create(testName);\r
- }\r
- }\r
-\r
- // Failure outcomes\r
- // Placeholders until the three tests below can be uncommented.\r
- // See Issue CSPACE-401.\r
- @Override\r
- public void createWithEmptyEntityBody(String testName) throws Exception {\r
- //Should this really be empty?\r
- }\r
-\r
- @Override\r
- public void createWithMalformedXml(String testName) throws Exception {\r
- //Should this really be empty??\r
- }\r
-\r
- @Override\r
- public void createWithWrongXmlSchema(String testName) throws Exception {\r
- //Should this really be empty??\r
- }\r
-\r
-\r
- // ---------------------------------------------------------------\r
- // CRUD tests : READ tests\r
- // ---------------------------------------------------------------\r
- // Success outcomes\r
- @Override\r
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,\r
- dependsOnMethods = {"create"})\r
- public void read(String testName) throws Exception {\r
-\r
- if (logger.isDebugEnabled()) {\r
- logger.debug(testBanner(testName, CLASS_NAME));\r
- }\r
- // Perform setup.\r
- setupRead();\r
-\r
- // Submit the request to the service and store the response.\r
- NoteClient client = new NoteClient();\r
- ClientResponse<String> res = client.read(knownResourceId);\r
- assertStatusCode(res, testName);\r
-\r
- // Get the common part of the response and verify that it is not null.\r
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());\r
- PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());\r
- NotesCommon noteCommon = null;\r
- if (payloadInputPart != null) {\r
- noteCommon = (NotesCommon) payloadInputPart.getBody();\r
- }\r
- Assert.assertNotNull(noteCommon);\r
- }\r
-\r
- // Failure outcomes\r
- @Override\r
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,\r
- dependsOnMethods = {"read"})\r
- public void readNonExistent(String testName) throws Exception {\r
-\r
- if (logger.isDebugEnabled()) {\r
- logger.debug(testBanner(testName, CLASS_NAME));\r
- }\r
- // Perform setup.\r
- setupReadNonExistent();\r
-\r
- // Submit the request to the service and store the response.\r
- NoteClient client = new NoteClient();\r
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);\r
- int statusCode = res.getStatus();\r
-\r
- // Check the status code of the response: does it match\r
- // the expected response(s)?\r
- if(logger.isDebugEnabled()){\r
- logger.debug(testName + ": status = " + statusCode);\r
- }\r
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),\r
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);\r
- }\r
-\r
- // ---------------------------------------------------------------\r
- // CRUD tests : READ_LIST tests\r
- // ---------------------------------------------------------------\r
- // Success outcomes\r
- @Override\r
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,\r
- dependsOnMethods = {"read"})\r
- public void readList(String testName) throws Exception {\r
-\r
- if (logger.isDebugEnabled()) {\r
- logger.debug(testBanner(testName, CLASS_NAME));\r
- }\r
- // Perform setup.\r
- setupReadList();\r
-\r
- // Submit the request to the service and store the response.\r
- NoteClient client = new NoteClient();\r
- ClientResponse<NotesCommonList> res = client.readList();\r
- NotesCommonList list = res.getEntity();\r
- assertStatusCode(res, testName);\r
-\r
- // Optionally output additional data about list members for debugging.\r
- boolean iterateThroughList = false;\r
- if(iterateThroughList && logger.isDebugEnabled()){\r
- List<NotesCommonList.NoteListItem> items =\r
- list.getNoteListItem();\r
- int i = 0;\r
- for(NotesCommonList.NoteListItem item : items){\r
- logger.debug(testName + ": list-item[" + i + "] csid=" +\r
- item.getCsid());\r
- logger.debug(testName + ": list-item[" + i + "] content=" +\r
- item.getContent());\r
- logger.debug(testName + ": list-item[" + i + "] URI=" +\r
- item.getUri());\r
- i++;\r
- }\r
- }\r
-\r
- }\r
-\r
- // Failure outcomes\r
- // None at present.\r
- // ---------------------------------------------------------------\r
- // CRUD tests : UPDATE tests\r
- // ---------------------------------------------------------------\r
- // Success outcomes\r
- @Override\r
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,\r
- dependsOnMethods = {"read"})\r
- public void update(String testName) throws Exception {\r
-\r
- if (logger.isDebugEnabled()) {\r
- logger.debug(testBanner(testName, CLASS_NAME));\r
- }\r
- // Perform setup.\r
- setupUpdate();\r
-\r
- // Submit the request to the service and store the response.\r
- NoteClient client = new NoteClient();\r
- ClientResponse<String> res = client.read(knownResourceId);\r
- assertStatusCode(res, testName);\r
-\r
- // Get the common part of the response and verify that it is not null.\r
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());\r
- PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());\r
- NotesCommon noteCommon = null;\r
- if (payloadInputPart != null) {\r
- noteCommon = (NotesCommon) payloadInputPart.getBody();\r
- }\r
- Assert.assertNotNull(noteCommon);\r
-\r
- // Update the common part, both the subitem, and the content\r
- noteCommon.setContent("updated-" + noteCommon.getContent());\r
- noteCommon.setOrder(noteCommon.getOrder()+10);\r
- if(logger.isDebugEnabled()){\r
- logger.debug("to be updated object");\r
- logger.debug(objectAsXmlString(noteCommon, NotesCommon.class));\r
- }\r
-\r
- // Submit the common part in an update request to the service\r
- // and store the response.\r
- PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());\r
- PayloadOutputPart commonPart = output.addPart(noteCommon, MediaType.APPLICATION_XML_TYPE);\r
- commonPart.setLabel(client.getCommonPartName());\r
- res = client.update(knownResourceId, output);\r
-\r
- // Check the status code of the response: does it match the expected response(s)?\r
- int statusCode = res.getStatus();\r
- if(logger.isDebugEnabled()){\r
- logger.debug(testName + ": status = " + statusCode);\r
- }\r
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),\r
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);\r
-\r
- // Extract the updated common part from the response.\r
- payloadInputPart = input.getPart(client.getCommonPartName());\r
- NotesCommon updatedNoteCommon = null;\r
- if (payloadInputPart != null) {\r
- updatedNoteCommon = (NotesCommon) payloadInputPart.getBody();\r
- }\r
- Assert.assertNotNull(updatedNoteCommon);\r
-\r
- // Check selected fields in the updated common part.\r
- Assert.assertEquals(updatedNoteCommon.getContent(), noteCommon.getContent(),\r
- "Data in updated object did not match submitted data.");\r
- Assert.assertEquals(updatedNoteCommon.getOrder(), noteCommon.getOrder(),\r
- "Data in updated object (subitem) did not match submitted data.");\r
- }\r
-\r
- // Failure outcomes\r
- // Placeholders until the three tests below can be uncommented.\r
- // See Issue CSPACE-401.\r
- @Override\r
- public void updateWithEmptyEntityBody(String testName) throws Exception {\r
- //Should this really be empty??\r
- }\r
- \r
- /* (non-Javadoc)\r
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)\r
- */\r
- @Override\r
- public void updateWithMalformedXml(String testName) throws Exception {\r
- //Should this really be empty??\r
- }\r
-\r
- @Override\r
- public void updateWithWrongXmlSchema(String testName) throws Exception {\r
- //Should this really be empty??\r
- }\r
-\r
-\r
- @Override\r
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,\r
- dependsOnMethods = {"update", "testSubmitRequest"})\r
- public void updateNonExistent(String testName) throws Exception {\r
-\r
- if (logger.isDebugEnabled()) {\r
- logger.debug(testBanner(testName, CLASS_NAME));\r
- }\r
- // Perform setup.\r
- setupUpdateNonExistent();\r
-\r
- // Submit the request to the service and store the response.\r
- // Note: The ID used in this 'create' call may be arbitrary.\r
- // The only relevant ID may be the one used in update(), below.\r
- NoteClient client = new NoteClient();\r
- PoxPayloadOut multipart =\r
- NoteClientUtils.createNoteInstance(\r
- NON_EXISTENT_ID, NON_EXISTENT_ID, client.getCommonPartName());\r
- ClientResponse<String> res = client.update(NON_EXISTENT_ID, multipart);\r
- int statusCode = res.getStatus();\r
-\r
- // Check the status code of the response: does it match\r
- // the expected response(s)?\r
- if(logger.isDebugEnabled()){\r
- logger.debug(testName + ": status = " + statusCode);\r
- }\r
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),\r
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);\r
- }\r
-\r
- // ---------------------------------------------------------------\r
- // CRUD tests : DELETE tests\r
- // ---------------------------------------------------------------\r
- // Success outcomes\r
- @Override\r
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,\r
- dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})\r
- public void delete(String testName) throws Exception {\r
-\r
- if (logger.isDebugEnabled()) {\r
- logger.debug(testBanner(testName, CLASS_NAME));\r
- }\r
- // Perform setup.\r
- setupDelete();\r
-\r
- // Submit the request to the service and store the response.\r
- NoteClient client = new NoteClient();\r
- ClientResponse<Response> res = client.delete(knownResourceId);\r
- int statusCode = res.getStatus();\r
-\r
- // Check the status code of the response: does it match\r
- // the expected response(s)?\r
- if(logger.isDebugEnabled()){\r
- logger.debug(testName + ": status = " + statusCode);\r
- }\r
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),\r
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);\r
- }\r
-\r
- // Failure outcomes\r
- @Override\r
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,\r
- dependsOnMethods = {"delete"})\r
- public void deleteNonExistent(String testName) throws Exception {\r
- \r
- if (logger.isDebugEnabled()) {\r
- logger.debug(testBanner(testName, CLASS_NAME));\r
- }\r
- // Perform setup.\r
- setupDeleteNonExistent();\r
-\r
- // Submit the request to the service and store the response.\r
- NoteClient client = new NoteClient();\r
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);\r
- int statusCode = res.getStatus();\r
-\r
- // Check the status code of the response: does it match\r
- // the expected response(s)?\r
- if(logger.isDebugEnabled()){\r
- logger.debug(testName + ": status = " + statusCode);\r
- }\r
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),\r
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);\r
- }\r
- \r
- // ---------------------------------------------------------------\r
- // Search tests\r
- // ---------------------------------------------------------------\r
+ @Override\r
+ protected PoxPayloadOut createInstance(String commonPartName,\r
+ String identifier) {\r
+ PoxPayloadOut result =\r
+ NoteClientUtils.createNoteInstance("owner"+identifier, identifier, \r
+ commonPartName);\r
+ return result;\r
+ }\r
\r
- @Override\r
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)\r
- public void searchWorkflowDeleted(String testName) throws Exception {\r
- // Fixme: null test for now, overriding test in base class\r
- } \r
-\r
// ---------------------------------------------------------------\r
// Utility tests : tests of code used in tests above\r
// ---------------------------------------------------------------\r
return SERVICE_NAME;\r
}\r
\r
- /**\r
- * Tests the code for manually submitting data that is used by several\r
- * of the methods above.\r
- */\r
- @Test(dependsOnMethods = {"create", "read"})\r
- public void testSubmitRequest() {\r
-\r
- // Expected status code: 200 OK\r
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();\r
-\r
- // Submit the request to the service and store the response.\r
- String method = ServiceRequestType.READ.httpMethodName();\r
- String url = getResourceURL(knownResourceId);\r
- int statusCode = submitRequest(method, url);\r
-\r
- // Check the status code of the response: does it match\r
- // the expected response(s)?\r
- if(logger.isDebugEnabled()){\r
- logger.debug("testSubmitRequest: url=" + url +\r
- " status=" + statusCode);\r
- }\r
- Assert.assertEquals(statusCode, EXPECTED_STATUS);\r
-\r
- }\r
-\r
// ---------------------------------------------------------------\r
// Utility methods used by tests above\r
// ---------------------------------------------------------------\r
public String getServicePathComponent() {\r
return SERVICE_PATH_COMPONENT;\r
}\r
+ \r
+ @Override\r
+ protected Class<NotesCommonList> getCommonListType() {\r
+ return NotesCommonList.class;\r
+ }\r
\r
+ @Override\r
+ protected NotesCommon updateInstance(NotesCommon notesCommon) {\r
+ NotesCommon result = new NotesCommon();\r
+ \r
+ // Update the common part, both the subitem, and the content\r
+ result.setContent("updated-" + notesCommon.getContent());\r
+ result.setOrder(notesCommon.getOrder() + 10);\r
+ \r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ protected void compareUpdatedInstances(NotesCommon original,\r
+ NotesCommon updated) throws Exception {\r
+ // Check selected fields in the updated common part.\r
+ Assert.assertEquals(updated.getContent(), original.getContent(),\r
+ "Content in updated object did not match submitted data.");\r
+ Assert.assertEquals(updated.getOrder(), original.getOrder(),\r
+ "Order in updated object (subitem) did not match submitted data.");\r
+ }\r
+ \r
+ @Override\r
+ public void CRUDTests(String testName) {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
}\r
</parent>\r
\r
<modelVersion>4.0.0</modelVersion>\r
- <groupId>org.collectionspace.services</groupId>\r
<artifactId>org.collectionspace.services.note.jaxb</artifactId>\r
<name>services.note.jaxb</name>\r
\r
<artifactId>org.collectionspace.services.jaxb</artifactId>\r
<version>${project.version}</version>\r
</dependency> \r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.hyperjaxb</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
</dependencies>\r
\r
<build>\r
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
\r
-<!--\r
- Contact schema (XSD)\r
- \r
- Entity : Contact\r
- Part : Common\r
- Used for: JAXB binding between XML and Java objects\r
+<!-- Contact schema (XSD) Entity : Contact Part : Common Used for: JAXB binding \r
+ between XML and Java objects $LastChangedRevision: 1929 $ $LastChangedDate: \r
+ 2010-04-28 01:50:27 -0700 (Wed, 28 Apr 2010) $ -->\r
\r
- $LastChangedRevision: 1929 $\r
- $LastChangedDate: 2010-04-28 01:50:27 -0700 (Wed, 28 Apr 2010) $\r
--->\r
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"\r
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"\r
+ elementFormDefault="unqualified"\r
+ xmlns:ns="http://collectionspace.org/services/note"\r
+ xmlns="http://collectionspace.org/services/note"\r
+ targetNamespace="http://collectionspace.org/services/note"\r
+ version="0.1">\r
\r
-<xs:schema \r
- xmlns:xs="http://www.w3.org/2001/XMLSchema"\r
- xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"\r
- jaxb:version="1.0" elementFormDefault="unqualified"\r
- xmlns:ns="http://collectionspace.org/services/note"\r
- xmlns="http://collectionspace.org/services/note"\r
- targetNamespace="http://collectionspace.org/services/note"\r
- version="0.1"\r
->\r
+ <!-- Avoid XmlRootElement nightmare: See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html -->\r
+ <!-- See http://wiki.collectionspace.org/display/collectionspace/Contact+Schema -->\r
+\r
+ <!-- This is the base class for subitems -->\r
+ <xs:complexType name="subitem">\r
+ <xs:annotation>\r
+ <xs:appinfo>\r
+ <jaxb:class ref="org.collectionspace.services.common.subitem.Subitem" />\r
+ </xs:appinfo>\r
+ </xs:annotation>\r
+ </xs:complexType>\r
+\r
+ <xs:element name="notes_common">\r
+ <xs:complexType>\r
+ <xs:complexContent>\r
+ <xs:extension base="subitem">\r
+ <xs:sequence>\r
+ <xs:element name="content" type="xs:string" />\r
+ <xs:element name="author" type="xs:string" />\r
+ <xs:element name="date" type="xs:string" />\r
+ </xs:sequence>\r
+ </xs:extension>\r
+ </xs:complexContent>\r
+ </xs:complexType>\r
+ </xs:element>\r
+\r
+ <!-- This is the base class for subitems -->\r
+ <xs:complexType name="abstractCommonList">\r
+ <xs:annotation>\r
+ <xs:appinfo>\r
+ <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList" />\r
+ </xs:appinfo>\r
+ </xs:annotation>\r
+ </xs:complexType>\r
+\r
+ <!-- note records, as in Nuxeo repository -->\r
+ <xs:element name="notes-common-list">\r
+ <xs:complexType>\r
+ <xs:complexContent>\r
+ <xs:extension base="abstractCommonList">\r
+ <xs:sequence>\r
+ <xs:element name="note-list-item" maxOccurs="unbounded">\r
+ <xs:complexType>\r
+ <xs:sequence>\r
+ <xs:element name="content" type="xs:string"\r
+ minOccurs="1" />\r
+ <!-- uri to retrive note details -->\r
+ <xs:element name="uri" type="xs:anyURI" minOccurs="1" />\r
+ <xs:element name="csid" type="xs:string" minOccurs="1" />\r
+ </xs:sequence>\r
+ </xs:complexType>\r
+ </xs:element>\r
+ </xs:sequence>\r
+ </xs:extension>\r
+ </xs:complexContent>\r
+ </xs:complexType>\r
+ </xs:element>\r
\r
-<!--\r
- Avoid XmlRootElement nightmare:\r
- See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html\r
--->\r
-<!-- See http://wiki.collectionspace.org/display/collectionspace/Contact+Schema --> \r
- \r
- <!-- This is the base class for subitems -->\r
- <xs:complexType name="subitem">\r
- <xs:annotation>\r
- <xs:appinfo>\r
- <jaxb:class ref="org.collectionspace.services.common.subitem.Subitem"/>\r
- </xs:appinfo>\r
- </xs:annotation>\r
- </xs:complexType>\r
- \r
- <xs:element name="notes_common">\r
- <xs:complexType>\r
- <xs:complexContent>\r
- <xs:extension base="subitem"> \r
- <xs:sequence>\r
- <xs:element name="content" type="xs:string" />\r
- <xs:element name="author" type="xs:string" />\r
- <xs:element name="date" type="xs:string" />\r
- </xs:sequence>\r
- </xs:extension>\r
- </xs:complexContent> \r
- </xs:complexType>\r
- </xs:element>\r
- \r
- <!-- This is the base class for subitems -->\r
- <xs:complexType name="abstractCommonList">\r
- <xs:annotation>\r
- <xs:appinfo>\r
- <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>\r
- </xs:appinfo>\r
- </xs:annotation>\r
- </xs:complexType>\r
- \r
- <!-- note records, as in Nuxeo repository -->\r
- <xs:element name="notes-common-list">\r
- <xs:complexType>\r
- <xs:complexContent>\r
- <xs:extension base="abstractCommonList"> \r
- <xs:sequence>\r
- <xs:element name="note-list-item" maxOccurs="unbounded">\r
- <xs:complexType>\r
- <xs:sequence>\r
- <xs:element name="content" type="xs:string"\r
- minOccurs="1" />\r
- <!-- uri to retrive note details -->\r
- <xs:element name="uri" type="xs:anyURI"\r
- minOccurs="1" />\r
- <xs:element name="csid" type="xs:string"\r
- minOccurs="1" />\r
- </xs:sequence>\r
- </xs:complexType>\r
- </xs:element>\r
- </xs:sequence>\r
- </xs:extension>\r
- </xs:complexContent> \r
- </xs:complexType>\r
- </xs:element>\r
- \r
</xs:schema>\r
\r
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency> \r
\r
<!-- javax -->\r
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
import org.collectionspace.services.PersonJAXBSchema;
import org.collectionspace.services.client.CollectionSpaceClient;
-import org.collectionspace.services.client.ContactClient;
import org.collectionspace.services.client.ObjectExitClient;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PersonAuthorityClient;
import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-public class ObjectExitAuthRefsTest extends BaseServiceTest {
+public class ObjectExitAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
private final String CLASS_NAME = ObjectExitAuthRefsTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
final String PERSON_AUTHORITY_NAME = "ObjectexitPersonAuth";
- private String knownResourceId = null;
private List<String> objectexitIdsCreated = new ArrayList<String>();
private List<String> personIdsCreated = new ArrayList<String>();
private String personAuthCSID = null;
}
@Override
- protected AbstractCommonList getAbstractCommonList(ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
objectexit.setExitDate(exitDate);
PoxPayloadOut multipart = new PoxPayloadOut(ObjectExitClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = multipart.addPart(objectexit, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(new ObjectExitClient().getCommonPartName());
+ PayloadOutputPart commonPart = multipart.addPart(new ObjectExitClient().getCommonPartName(),
+ objectexit);
logger.debug("to be created, objectexit common: " + objectAsXmlString(objectexit, ObjectexitCommon.class));
return multipart;
}
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void createWithAuthRefs(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
String identifier = createIdentifier(); // Submit the request to the service and store the response.
createPersonRefs();// Create all the person refs and entities
PoxPayloadOut multipart = createObjectExitInstance(depositorRefName,
"exitNumber-" + identifier, CURRENT_DATE_UTC);
ClientResponse<Response> res = objectexitClient.create(multipart);
- assertStatusCode(res, testName);
- if (knownResourceId == null) {// Store the ID returned from the first resource created for additional tests below.
- knownResourceId = extractId(res);
+ try {
+ assertStatusCode(res, testName);
+ if (knownResourceId == null) {// Store the ID returned from the first resource created for additional tests below.
+ knownResourceId = extractId(res);
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
objectexitIdsCreated.add(extractId(res));// Store the IDs from every resource created; delete on cleanup
}
// Create a temporary PersonAuthority resource, and its corresponding refName by which it can be identified.
PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
ClientResponse<Response> res = personAuthClient.create(multipart);
- assertStatusCode(res, "createPersonRefs (not a surefire test)");
- personAuthCSID = extractId(res);
+ try {
+ assertStatusCode(res, "createPersonRefs (not a surefire test)");
+ personAuthCSID = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
// Create temporary Person resources, and their corresponding refNames by which they can be identified.
String csid = "";
}
protected String createPerson(String firstName, String surName, String shortId, String authRefName) {
+ String result = null;
+
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
Map<String, String> personInfo = new HashMap<String, String>();
personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance(personAuthCSID, authRefName, personInfo, personAuthClient.getItemCommonPartName());
ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
- assertStatusCode(res, "createPerson (not a surefire test)");
- return extractId(res);
+ try {
+ assertStatusCode(res, "createPerson (not a surefire test)");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
+
+ return result;
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"createWithAuthRefs"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"createWithAuthRefs"})
public void readAndCheckAuthRefs(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
testSetup(STATUS_OK, ServiceRequestType.READ);
ObjectExitClient objectexitClient = new ObjectExitClient();
ClientResponse<String> res = objectexitClient.read(knownResourceId);
- assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- ObjectexitCommon objectexit = (ObjectexitCommon) extractPart(input, objectexitClient.getCommonPartName(), ObjectexitCommon.class);
- Assert.assertNotNull(objectexit);
- logger.debug(objectAsXmlString(objectexit, ObjectexitCommon.class));
+ ObjectexitCommon objectexit = null;
+ try {
+ assertStatusCode(res, testName);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ objectexit = (ObjectexitCommon) extractPart(input, objectexitClient.getCommonPartName(), ObjectexitCommon.class);
+ Assert.assertNotNull(objectexit);
+ logger.debug(objectAsXmlString(objectexit, ObjectexitCommon.class));
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
// Check a couple of fields
Assert.assertEquals(objectexit.getDepositor(), depositorRefName);
// Get the auth refs and check them
ClientResponse<AuthorityRefList> res2 = objectexitClient.getAuthorityRefs(knownResourceId);
- assertStatusCode(res2, testName);
- AuthorityRefList list = res2.getEntity();
+ AuthorityRefList list = null;
+ try {
+ assertStatusCode(res2, testName);
+ list = res2.getEntity();
+ } finally {
+ if (res2 != null) {
+ res2.releaseConnection();
+ }
+ }
List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
int numAuthRefsFound = items.size();
logger.debug("Authority references, found " + numAuthRefsFound);
}
}
+ @Override
+ protected Class<AbstractCommonList> getCommonListType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.ObjectExitClient;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.objectexit.ObjectexitCommon;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-//import org.w3c.dom.Element;
-//import org.w3c.dom.Node;
+
/**
* ObjectExitServiceTest, carries out tests against a deployed and running ObjectExit Service. <p/>
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-public class ObjectExitServiceTest extends AbstractServiceTestImpl {
+public class ObjectExitServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, ObjectexitCommon> {
private final String CLASS_NAME = ObjectExitServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
final String SERVICE_PATH_COMPONENT = "objectexit";
- private String knownResourceId = null;
@Override
public String getServicePathComponent() {
}
@Override
- protected AbstractCommonList getAbstractCommonList(ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
return response.getEntity(AbstractCommonList.class);
}
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void create(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupCreate();
- ObjectExitClient client = new ObjectExitClient();
- PoxPayloadOut multipart = createObjectExitInstance(createIdentifier());
- ClientResponse<Response> res = client.create(multipart);
- assertStatusCode(res, testName);
- if (knownResourceId == null) {
- knownResourceId = extractId(res); // Store the ID returned from the first resource created for additional tests below.
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
- allResourceIdsCreated.add(extractId(res)); // Store the IDs from every resource created by tests so they can be deleted after tests have been run.
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
- public void createList(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- for (int i = 0; i < 3; i++) {
- create(testName);
- }
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
- public void read(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupRead();
- ObjectExitClient client = new ObjectExitClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- ObjectexitCommon objectexit = (ObjectexitCommon) extractPart(input, client.getCommonPartName(), ObjectexitCommon.class);
- Assert.assertNotNull(objectexit);
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"createList", "read"})
- public void readList(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupReadList();
- ObjectExitClient client = new ObjectExitClient();
- ClientResponse<AbstractCommonList> res = client.readList();
- assertStatusCode(res, testName);
- String bar = "\r\n\r\n=================================\r\n\r\n";
- System.out.println(bar+" res: "+res);
- AbstractCommonList list = res.getEntity();
- System.out.println(bar+" list: "+list);
-
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = true;
- if(iterateThroughList && logger.isDebugEnabled()){
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
-
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"read"})
- public void update(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupUpdate();
- ObjectExitClient client = new ObjectExitClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
- logger.debug("got object to update with ID: " + knownResourceId);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- ObjectexitCommon objectexit = (ObjectexitCommon) extractPart(input, client.getCommonPartName(), ObjectexitCommon.class);
- Assert.assertNotNull(objectexit);
-
- objectexit.setExitNumber("updated-" + objectexit.getExitNumber());
- logger.debug("Object to be updated:"+objectAsXmlString(objectexit, ObjectexitCommon.class));
- PoxPayloadOut output = new PoxPayloadOut(ObjectExitClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(objectexit, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
- res = client.update(knownResourceId, output);
- assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
- ObjectexitCommon updatedObjectExit = (ObjectexitCommon) extractPart(input, client.getCommonPartName(), ObjectexitCommon.class);
- Assert.assertNotNull(updatedObjectExit);
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupUpdateNonExistent();
- // 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 update(), below.
- ObjectExitClient client = new ObjectExitClient();
- PoxPayloadOut multipart = createObjectExitInstance(NON_EXISTENT_ID);
- ClientResponse<String> res = client.update(NON_EXISTENT_ID, multipart);
- assertStatusCode(res, testName);
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
- public void delete(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupDelete();
- ObjectExitClient client = new ObjectExitClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- assertStatusCode(res, testName);
- }
-
- // ---------------------------------------------------------------
- // Failure outcome tests : means we expect response to fail, but test to succeed
- // ---------------------------------------------------------------
-
- // Failure outcome
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"read"})
- public void readNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupReadNonExistent();
- ObjectExitClient client = new ObjectExitClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
- assertStatusCode(res, testName);
- }
-
- // Failure outcome
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupDeleteNonExistent();
- ObjectExitClient client = new ObjectExitClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- assertStatusCode(res, testName);
- }
-
- // Failure outcomes
- // Placeholders until the tests below can be implemented. See Issue CSPACE-401.
-
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- }
-
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- }
-
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- }
-
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- }
-
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- }
-
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- }
-
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
-
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() {
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode(); // Expected status code: 200 OK
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
- logger.debug("testSubmitRequest: url=" + url + " status=" + statusCode);
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
- }
-
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
return multipart;
}
+
+ @Override
+ public void CRUDTests(String testName) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ PoxPayloadOut result = createObjectExitInstance(createIdentifier());
+ return result;
+ }
+
+ @Override
+ protected ObjectexitCommon updateInstance(ObjectexitCommon objectexitCommon) {
+ ObjectexitCommon result = new ObjectexitCommon();
+
+ result.setExitNumber("updated-" + objectexitCommon.getExitNumber());
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(ObjectexitCommon original,
+ ObjectexitCommon updated) throws Exception {
+ Assert.assertEquals(updated.getExitNumber(), original.getExitNumber());
+ }
}
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<!-- javax -->
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
<dependency>\r
<groupId>org.jboss.resteasy</groupId>\r
*/
package org.collectionspace.services.client;
+import org.collectionspace.services.organization.OrganizationsCommon;
+
/**
* The Class OrgAuthorityClient.
*/
-public class OrgAuthorityClient extends AuthorityWithContactsClientImpl<OrgAuthorityProxy> {
+public class OrgAuthorityClient extends AuthorityWithContactsClientImpl<OrganizationsCommon, OrgAuthorityProxy> {
public static final String SERVICE_NAME = "orgauthorities";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
public String getItemCommonPartName() {
return getCommonPartName(SERVICE_ITEM_NAME);
}
+
+ @Override
+ public String getInAuthority(OrganizationsCommon item) {
+ return item.getInAuthority();
+ }
+
+ @Override
+ public void setInAuthority(OrganizationsCommon item, String inAuthorityCsid) {
+ item.setInAuthority(inAuthorityCsid);
+ }
}
* $LastChangedRevision$
* $LastChangedDate$
*/
-public class OrgAuthorityAuthRefsTest extends BaseServiceTest {
+public class OrgAuthorityAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
/** The logger. */
private final String CLASS_NAME = OrgAuthorityAuthRefsTest.class.getName();
return OrgAuthorityClient.SERVICE_NAME;
}
- private String knownResourceId = null;
+ protected String knownItemResourceId = null;
+
private String knownResourceRefName = null;
-
- /** The known item id. */
- private String knownItemResourceId = null;
-
- /** The all resource ids created. */
- private List<String> allResourceIdsCreated = new ArrayList<String>();
-
- /** The all item resource ids created. */
- private Map<String, String> allItemResourceIdsCreated =
- new HashMap<String, String>();
-
+
/** The person ids created. */
private List<String> personIdsCreated = new ArrayList<String>();
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
+ protected AbstractCommonList getCommonList(
ClientResponse<AbstractCommonList> response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
+ @Test(dataProvider="testName")
public void createWithAuthRefs(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
// Create a new Organization Authority resource.
if(logger.isDebugEnabled()){
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Store the IDs from every resource created by tests,
// so they can be deleted after tests have been run.
// Store the IDs from every item created by tests,
// so they can be deleted after tests have been run.
- allItemResourceIdsCreated.put(knownItemResourceId, knownResourceId);
+ allResourceItemIdsCreated.put(knownItemResourceId, knownResourceId);
}
/**
ClientResponse<Response> res = personAuthClient.create(multipart);
try {
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
personAuthCSID = extractId(res);
} finally {
try {
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
result = extractId(res);
} finally {
// Organization authority as its parent Organization resource.
String subBodyResourceId = createSubBodyOrganization("Test SubBody Organization");
- allItemResourceIdsCreated.put(subBodyResourceId, knownResourceId);
+ allResourceItemIdsCreated.put(subBodyResourceId, knownResourceId);
subBodyRefName = OrgAuthorityClientUtils.getOrgRefName(knownResourceId, subBodyResourceId, null);
}
ClientResponse<Response> res = orgAuthClient.createItem(knownResourceId, multipart);
try {
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
result = extractId(res);
} finally {
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ @Test(dataProvider="testName",
dependsOnMethods = {"createWithAuthRefs"})
public void readAndCheckAuthRefs(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
testSetup(STATUS_OK, ServiceRequestType.READ);
// Submit the request to the service and store the response.
OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
- ClientResponse<String> res =
- orgAuthClient.readItem(knownResourceId, knownItemResourceId);
- assertStatusCode(res, testName);
-
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
- orgAuthClient.getItemCommonPartName(), OrganizationsCommon.class);
- Assert.assertNotNull(organization);
- if(logger.isDebugEnabled()){
- logger.debug(objectAsXmlString(organization, OrganizationsCommon.class));
+ ClientResponse<String> res = orgAuthClient.readItem(knownResourceId, knownItemResourceId);
+ OrganizationsCommon organization = null;
+ try {
+ assertStatusCode(res, testName);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ organization = (OrganizationsCommon) extractPart(input,
+ orgAuthClient.getItemCommonPartName(), OrganizationsCommon.class);
+ Assert.assertNotNull(organization);
+ if (logger.isDebugEnabled()){
+ logger.debug(objectAsXmlString(organization, OrganizationsCommon.class));
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
// Check one or more of the authority fields in the Organization item
Assert.assertEquals(organization.getContactNames().getContactName().get(0),
// and get the ID for the organization item
ClientResponse<AuthorityRefList> res2 =
orgAuthClient.getItemAuthorityRefs(knownResourceId, knownItemResourceId);
- assertStatusCode(res2, testName);
-
- AuthorityRefList list = res2.getEntity();
+ AuthorityRefList list = null;
+ try {
+ assertStatusCode(res2, testName);
+ list = res2.getEntity();
+ } finally {
+ if (res2 != null) {
+ res2.releaseConnection();
+ }
+ }
List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
int numAuthRefsFound = items.size();
String itemResourceId;
OrgAuthorityClient client = new OrgAuthorityClient();
// Clean up item resources.
- for (Map.Entry<String, String> entry : allItemResourceIdsCreated.entrySet()) {
+ for (Map.Entry<String, String> entry : allResourceItemIdsCreated.entrySet()) {
itemResourceId = entry.getKey();
parentResourceId = entry.getValue();
// Note: Any non-success responses from the delete operation
import javax.ws.rs.core.Response;
import org.collectionspace.services.OrganizationJAXBSchema;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.AuthorityClient;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.ContactClient;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.contact.AddressGroup;
import org.collectionspace.services.contact.AddressGroupList;
import org.collectionspace.services.contact.ContactsCommon;
* $LastChangedRevision$
* $LastChangedDate$
*/
-public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME: Test classes for Vocab, Person, Org, and Location should have a base class!
+public class OrgAuthorityServiceTest extends AbstractAuthorityServiceTest<OrgauthoritiesCommon, OrganizationsCommon> {
/** The logger. */
private final String CLASS_NAME = OrgAuthorityServiceTest.class.getName();
}
/** The test organization shortname. */
private final String TEST_ORG_SHORTNAME = "Test Org";
+
/** The test organization founding place. */
private final String TEST_ORG_FOUNDING_PLACE = "Anytown, USA";
- // Hold some values for a recently created item to verify upon read.
- private String knownResourceId = null;
- private String knownResourceShortIdentifer = null;
- private String knownResourceRefName = null;
- private String knownItemResourceId = null;
+
private String knownItemResourceShortIdentifer = null;
+
/** The known contact resource id. */
private String knownContactResourceId = null;
- /** The n items to create in list. */
- private int nItemsToCreateInList = 3;
- /** The all item resource ids created. */
- private Map<String, String> allItemResourceIdsCreated =
- new HashMap<String, String>();
+
/** The all contact resource ids created. */
private Map<String, String> allContactResourceIdsCreated =
new HashMap<String, String>();
- protected void setKnownResource(String id, String shortIdentifer,
- String refName) {
- knownResourceId = id;
- knownResourceShortIdentifer = shortIdentifer;
- knownResourceRefName = refName;
- }
-
protected void setKnownItemResource(String id, String shortIdentifer) {
knownItemResourceId = id;
knownItemResourceShortIdentifer = shortIdentifer;
return new OrgAuthorityClient();
}
- // ---------------------------------------------------------------
- // CRUD tests : CREATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"create"})
- public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // 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();
-
- // Submit the request to the service and store the response.
- OrgAuthorityClient client = new OrgAuthorityClient();
- String shortId = createIdentifier();
- String displayName = "displayName-" + shortId;
- //String baseRefName = OrgAuthorityClientUtils.createOrgAuthRefName(shortId, null);
- PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance(
- displayName, shortId, client.getCommonPartName());
-
- String newID = null;
- ClientResponse<Response> res = client.create(multipart);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- newID = OrgAuthorityClientUtils.extractId(res);
- } finally {
- res.releaseConnection();
- }
-
- // Store the ID returned from the first resource created
- // for additional tests below.
- if (knownResourceId == null) {
- setKnownResource(newID, shortId, null ); //baseRefName);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
- }
- // Store the IDs from every resource created by tests,
- // so they can be deleted after tests have been run.
- allResourceIdsCreated.add(newID);
- }
-
@Override
protected PoxPayloadOut createInstance(String identifier) {
OrgAuthorityClient client = new OrgAuthorityClient();
return OrgAuthorityClientUtils.createOrganizationInstance(identifier, testOrgMap, headerLabel);
}
- /**
- * Creates the item.
- *
- * @param testName the test name
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"create"}, dependsOnMethods = {"create"})
- public void createItem(String testName) {
- setupCreate();
- String newID = createItemInAuthority(knownResourceId, knownResourceRefName);
- }
-
/**
* Creates the item in authority.
*
// Store the IDs from any item resources created
// by tests, along with the IDs of their parents, so these items
// can be deleted after all tests have been run.
- allItemResourceIdsCreated.put(newID, vcsid);
+ allResourceItemIdsCreated.put(newID, vcsid);
return newID;
}
*
* @param testName the test name
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"create"}, dependsOnMethods = {"createItem"})
+ @Test(dataProvider = "testName", groups = {"create"},
+ dependsOnMethods = {"createItem"})
public void createContact(String testName) {
setupCreate();
String newID = createContactInItem(knownResourceId, knownItemResourceId);
final String testName = "createContactInItem";
if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
+ logger.debug(getTestBanner(testName, CLASS_NAME));
}
setupCreate();
ClientResponse<Response> res =
client.createContact(parentcsid, itemcsid, multipart);
try {
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+ assertStatusCode(res, testName);
newID = OrgAuthorityClientUtils.extractId(res);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
// Store the ID returned from the first contact resource created
return newID;
}
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
- */
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /*
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithEmptyEntityBody();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()) {
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA; // Constant from base class.
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithWrongXmlSchema(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithWrongXmlSchema();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
- */
- // ---------------------------------------------------------------
- // CRUD tests : CREATE LIST tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"createList"}, dependsOnGroups = {"create"})
- public void createList(String testName) throws Exception {
- for (int i = 0; i < nItemsToCreateInList; i++) {
- create(testName);
- }
- }
-
- /**
- * Creates the item list.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"createList"}, dependsOnMethods = {"createList"})
- public void createItemList(String testName) throws Exception {
- // Add items to the initially-created, known parent record.
- for (int j = 0; j < nItemsToCreateInList; j++) {
- createItem(testName);
- }
- }
-
/**
* Creates the contact list.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"createList"}, dependsOnMethods = {"createItemList"})
+ @Test(dataProvider = "testName", groups = {"createList"},
+ dependsOnMethods = {"createItemList"})
public void createContactList(String testName) throws Exception {
// Add contacts to the initially-created, known item record.
for (int j = 0; j < nItemsToCreateInList; j++) {
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnGroups = {"create"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// groups = {"read"}, dependsOnGroups = {"create"})
public void read(String testName) throws Exception {
readInternal(testName, knownResourceId, null);
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnGroups = {"create"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// groups = {"read"}, dependsOnGroups = {"create"})
public void readByName(String testName) throws Exception {
readInternal(testName, null, knownResourceShortIdentifer);
}
protected void readInternal(String testName, String CSID, String shortId) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupRead();
} else {
Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
}
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
//FIXME: remove the following try catch once Aron fixes signatures
try {
PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
throw new RuntimeException(e);
}
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
- /**
- * Read item.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnGroups = {"read"})
- public void readItem(String testName) throws Exception {
- readItemInternal(testName, knownResourceId, null, knownItemResourceId, null);
- }
-
/**
* Read item in Named Auth.
*
readItemInternal(testName, null, knownResourceShortIdentifer, knownItemResourceId, null);
}
*/
+
/**
* Read named item.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnGroups = {"read"})
+ @Test(dataProvider = "testName", groups = {"readItem"},
+ dependsOnMethods = {"readItemInNamedAuth"})
public void readNamedItem(String testName) throws Exception {
readItemInternal(testName, knownResourceId, null, null, knownItemResourceShortIdentifer);
}
+
+ /**
+ * Read item in Named Auth.
+ *
+ * @param testName the test name
+ * @throws Exception the exception
+ */
+ @Test(dataProvider = "testName", groups = {"readItem"},
+ dependsOnMethods = {"readItem"})
+ public void readItemInNamedAuth(String testName) throws Exception {
+ readItemInternal(testName, null, knownResourceShortIdentifer, knownItemResourceId, null);
+ }
/**
* Read Named item in Named Auth.
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnGroups = {"read"})
+ @Test(dataProvider = "testName", groups = {"readItem"},
+ dependsOnMethods = {"readItem"})
public void readNamedItemInNamedAuth(String testName) throws Exception {
readItemInternal(testName, null, knownResourceShortIdentifer, null, knownItemResourceShortIdentifer);
}
protected void readItemInternal(String testName,
String authCSID, String authShortId, String itemCSID, String itemShortId)
throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupRead();
} else {
Assert.fail("readInternal: Internal error. One of authCSID or authShortId must be non-null");
}
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
// Check whether we've received a organization.
PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
Assert.assertNotNull(contactNames.get(0));
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
+
+ @Override
+ protected void verifyReadItemInstance(OrganizationsCommon item) throws Exception {
+ List<String> contactNames = item.getContactNames().getContactName();
+ Assert.assertTrue(contactNames.size() > 0);
+ Assert.assertNotNull(contactNames.get(0));
+ }
/**
* Verify item display name.
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"readItem", "updateItem"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.updateItem"})
public void verifyItemDisplayName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
- setupUpdate();
-
- // Submit the request to the service and store the response.
+ setupRead();
+ //
+ // First, read our known resource.
+ //
OrgAuthorityClient client = new OrgAuthorityClient();
PoxPayloadIn input = null;
ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
+ // Check whether organization has expected displayName.
input = new PoxPayloadIn(res.getEntity());
+ Assert.assertNotNull(input);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
// Check whether organization has expected displayName.
MainBodyGroup mainBodyGroup = new MainBodyGroup();
String updatedShortName = "updated-" + TEST_ORG_SHORTNAME;
mainBodyGroup.setShortName(updatedShortName);
+ mainBodyGroups.clear(); //clear all the elements and do a sparse update
mainBodyGroups.add(mainBodyGroup);
organization.setMainBodyGroupList(mainBodyList);
expectedDisplayName =
OrgAuthorityClientUtils.prepareDefaultDisplayName(
updatedShortName, TEST_ORG_FOUNDING_PLACE);
-
- // Submit the updated resource to the service and store the response.
+ //
+ // Next, submit the updated resource to the service and store the response.
+ //
+ setupUpdate();
PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
+ PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), organization);
res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
// Retrieve the updated resource and verify that its contents exist.
input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
-
+ //
+ // Now verify the update was correct.
+ //
OrganizationsCommon updatedOrganization =
(OrganizationsCommon) extractPart(input,
client.getItemCommonPartName(), OrganizationsCommon.class);
// Verify that the updated resource computes the right displayName.
Assert.assertEquals(updatedOrganization.getDisplayName(), expectedDisplayName,
"Updated ShortName in Organization not reflected in computed DisplayName.");
-
+ //
// Now Update the displayName, not computed and verify the computed name is overriden.
+ //
organization.setDisplayNameComputed(false);
expectedDisplayName = "TestName";
organization.setDisplayName(expectedDisplayName);
// Submit the updated resource to the service and store the response.
output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
+ commonPart = output.addPart(client.getItemCommonPartName(), organization);
res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
+ input = null;
try {
+ assertStatusCode(res, testName);
// Retrieve the updated resource and verify that its contents exist.
input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
-
updatedOrganization =
(OrganizationsCommon) extractPart(input,
client.getItemCommonPartName(), OrganizationsCommon.class);
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"verifyItemDisplayName"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"verifyItemDisplayName"})
public void verifyIllegalItemDisplayName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Perform setup for read.
setupRead();
-
- // Submit the request to the service and store the response.
+ //
+ // First read our known resource.
+ //
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
- assertStatusCode(res, testName);
-
- // Perform setup for update.
- testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE);
-
+ OrganizationsCommon organization = null;
try {
+ assertStatusCode(res, testName);
// Check whether organization has expected displayName.
PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
+ organization = (OrganizationsCommon) extractPart(input,
client.getItemCommonPartName(), OrganizationsCommon.class);
Assert.assertNotNull(organization);
- // Try to Update with computed false and no displayName
- organization.setDisplayNameComputed(false);
- organization.setDisplayName(null);
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
- } finally {
- res.releaseConnection();
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
+ //
+ // Try to Update with 'displayNameComputed' flag set to false and no displayName
+ //
+ organization.setDisplayNameComputed(false);
+ organization.setDisplayName(null);
+
+ setupUpdateWithInvalidBody(); // we expect a failure
+ // Submit the updated resource to the service and store the response.
+ PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(),
+ organization);
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readItem"})
+ @Test(dataProvider = "testName", groups = {"readItem"},
+ dependsOnMethods = {"readItem"})
public void readContact(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupRead();
ClientResponse<String> res =
client.readContact(knownResourceId, knownItemResourceId,
knownContactResourceId);
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
// Check whether we've received a contact.
PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
ContactsCommon contact = (ContactsCommon) extractPart(input,
Assert.assertEquals(contact.getInAuthority(), knownResourceId);
Assert.assertEquals(contact.getInItem(), knownItemResourceId);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
+ /**
+ * Read contact non existent.
+ *
+ * @param testName the test name
*/
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnMethods = {"read"})
- public void readNonExistent(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
+ @Test(dataProvider = "testName", groups = {"readItem"},
+ dependsOnMethods = {"readContact"})
+ public void readContactNonExistent(String testName) {
// Perform setup.
setupReadNonExistent();
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
+ ClientResponse<String> res =
+ client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
try {
int statusCode = res.getStatus();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
/**
- * Read item non existent.
- *
- * @param testName the test name
+ * Read item list.
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readItem"})
- public void readItemNonExistent(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- OrgAuthorityClient client = new OrgAuthorityClient();
- ClientResponse<String> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
- try {
- int statusCode = res.getStatus();
+ @Override
+// @Test(groups = {"readList"}, dependsOnMethods = {"readList"})
+ public void readItemList(String testName) {
+ readItemList(knownAuthorityWithItems, null);
+ }
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ /**
+ * Read item list by authority name.
+ */
+ @Override
+// @Test(dataProvider = "testName",
+// dependsOnMethods = {"readItem"})
+ public void readItemListByName(String testName) {
+ readItemList(null, READITEMS_SHORT_IDENTIFIER);
}
/**
- * Read contact non existent.
+ * Read item list.
*
- * @param testName the test name
+ * @param vcsid the vcsid
+ * @param name the name
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readContact"})
- public void readContactNonExistent(String testName) {
+ private void readItemList(String vcsid, String name) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
+ final String testName = "readItemList";
// Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- OrgAuthorityClient client = new OrgAuthorityClient();
- ClientResponse<String> res =
- client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : READ_LIST tests
- // ---------------------------------------------------------------
- // Success outcomes
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readList"}, dependsOnGroups = {"createList", "read"})
- public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadList();
-
- // Submit the request to the service and store the response.
- OrgAuthorityClient client = new OrgAuthorityClient();
- ClientResponse<AbstractCommonList> res = client.readList();
- assertStatusCode(res, testName);
- try {
- AbstractCommonList list = res.getEntity();
- // Optionally output additional data about list members for debugging.
- if (logger.isTraceEnabled()) {
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
- } finally {
- res.releaseConnection();
- }
- }
-
- /**
- * Read item list.
- */
- @Test(groups = {"readList"}, dependsOnMethods = {"readList"})
- public void readItemList() {
- readItemList(knownResourceId, null);
- }
-
- /**
- * Read item list by authority name.
- */
- @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
- public void readItemListByAuthorityName() {
- readItemList(null, knownResourceShortIdentifer);
- }
-
- /**
- * Read item list.
- *
- * @param vcsid the vcsid
- * @param name the name
- */
- private void readItemList(String vcsid, String name) {
-
- final String testName = "readItemList";
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadList();
+ setupReadList();
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
} else {
Assert.fail("readItemList passed null csid and name!");
}
- assertStatusCode(res, testName);
+
+ AbstractCommonList list = null;
try {
- AbstractCommonList list = res.getEntity();
- List<AbstractCommonList.ListItem> items =
- list.getListItem();
- int nItemsReturned = items.size();
- // There will be one item created, associated with a
- // known parent resource, by the createItem test.
- //
- // In addition, there will be 'nItemsToCreateInList'
- // additional items created by the createItemList test,
- // all associated with the same parent resource.
- int nExpectedItems = nItemsToCreateInList + 1;
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": Expected "
- + nExpectedItems + " items; got: " + nItemsReturned);
- }
- Assert.assertEquals(nItemsReturned, nExpectedItems);
-
- for (AbstractCommonList.ListItem item : items) {
- String value =
- AbstractCommonListUtils.ListItemGetElementValue(item, REFNAME);
- Assert.assertTrue((null != value), "Item refName is null!");
- value =
- AbstractCommonListUtils.ListItemGetElementValue(item, DISPLAYNAME);
- Assert.assertTrue((null != value), "Item displayName is null!");
- }
- if (logger.isTraceEnabled()) {
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
+ assertStatusCode(res, testName);
+ list = res.getEntity();
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
+
+ List<AbstractCommonList.ListItem> items = list.getListItem();
+ int nItemsReturned = items.size();
+ // There will be 'nItemsToCreateInList'
+ // items created by the createItemList test,
+ // all associated with the same parent resource.
+ int nExpectedItems = nItemsToCreateInList;
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": Expected "
+ + nExpectedItems + " items; got: " + nItemsReturned);
+ }
+ Assert.assertEquals(nItemsReturned, nExpectedItems);
+
+ for (AbstractCommonList.ListItem item : items) {
+ String value =
+ AbstractCommonListUtils.ListItemGetElementValue(item, REFNAME);
+ Assert.assertTrue((null != value), "Item refName is null!");
+ value =
+ AbstractCommonListUtils.ListItemGetElementValue(item, DISPLAYNAME);
+ Assert.assertTrue((null != value), "Item displayName is null!");
+ }
+ if (logger.isTraceEnabled()) {
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
}
/**
* Read contact list.
*/
- @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
+ @Test(groups = {"readList"},
+ dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.readItemList"})
public void readContactList() {
readContactList(knownResourceId, knownItemResourceId);
}
*/
private void readContactList(String parentcsid, String itemcsid) {
final String testName = "readContactList";
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupReadList();
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
- AbstractCommonList list = null;
ClientResponse<AbstractCommonList> res =
client.readContactList(parentcsid, itemcsid);
- assertStatusCode(res, testName);
+ AbstractCommonList list = null;
try {
+ assertStatusCode(res, testName);
list = res.getEntity();
-
- List<AbstractCommonList.ListItem> listitems =
- list.getListItem();
- int nItemsReturned = listitems.size();
- // There will be one item created, associated with a
- // known parent resource, by the createItem test.
- //
- // In addition, there will be 'nItemsToCreateInList'
- // additional items created by the createItemList test,
- // all associated with the same parent resource.
- int nExpectedItems = nItemsToCreateInList + 1;
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": Expected "
- + nExpectedItems + " items; got: " + nItemsReturned);
- }
- Assert.assertEquals(nItemsReturned, nExpectedItems);
-
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = false;
- if (iterateThroughList && logger.isDebugEnabled()) {
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
} finally {
- res.releaseConnection();
- }
- }
-
- // Failure outcomes
- // None at present.
- // ---------------------------------------------------------------
- // CRUD tests : UPDATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnGroups = {"read", "readList"})
- public void update(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
-
- // Retrieve the contents of a resource to update.
- OrgAuthorityClient client = new OrgAuthorityClient();
- ClientResponse<String> res =
- client.read(knownResourceId);
- assertStatusCode(res, testName);
- try {
- if (logger.isDebugEnabled()) {
- logger.debug("got OrgAuthority to update with ID: " + knownResourceId);
- }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
- client.getCommonPartName(), OrgauthoritiesCommon.class);
- Assert.assertNotNull(orgAuthority);
-
- // Update the contents of this resource.
- orgAuthority.setDisplayName("updated-" + orgAuthority.getDisplayName());
- orgAuthority.setVocabType("updated-" + orgAuthority.getVocabType());
- if (logger.isDebugEnabled()) {
- logger.debug("to be updated OrgAuthority");
- logger.debug(objectAsXmlString(orgAuthority, OrgauthoritiesCommon.class));
+ if (res != null) {
+ res.releaseConnection();
}
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
- res.releaseConnection();
- res = client.update(knownResourceId, output);
- assertStatusCode(res, testName);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
- OrgauthoritiesCommon updatedOrgAuthority =
- (OrgauthoritiesCommon) extractPart(input,
- client.getCommonPartName(), OrgauthoritiesCommon.class);
- Assert.assertNotNull(updatedOrgAuthority);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedOrgAuthority.getDisplayName(),
- orgAuthority.getDisplayName(),
- "Data in updated object did not match submitted data.");
- } finally {
- res.releaseConnection();
}
- }
-
- /**
- * Update item.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"update"})
- public void updateItem(String testName) throws Exception {
+ List<AbstractCommonList.ListItem> listitems =
+ list.getListItem();
+ int nItemsReturned = listitems.size();
+ // There will be one item created, associated with a
+ // known parent resource, by the createItem test.
+ //
+ // In addition, there will be 'nItemsToCreateInList'
+ // additional items created by the createItemList test,
+ // all associated with the same parent resource.
+ int nExpectedItems = nItemsToCreateInList + 1;
if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
+ logger.debug(testName + ": Expected "
+ + nExpectedItems + " items; got: " + nItemsReturned);
}
- // Perform setup.
- setupUpdate();
-
- // Retrieve the contents of a resource to update.
- OrgAuthorityClient client = new OrgAuthorityClient();
- ClientResponse<String> res =
- client.readItem(knownResourceId, knownItemResourceId);
- assertStatusCode(res, testName);
- try {
- if (logger.isDebugEnabled()) {
- logger.debug("got Organization to update with ID: "
- + knownItemResourceId
- + " in OrgAuthority: " + knownResourceId);
- }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
- client.getItemCommonPartName(), OrganizationsCommon.class);
- Assert.assertNotNull(organization);
-
- // Update the contents of this resource.
- organization.setCsid(null);
+ Assert.assertEquals(nItemsReturned, nExpectedItems);
- MainBodyGroupList mainBodyList = organization.getMainBodyGroupList();
- Assert.assertNotNull(mainBodyList);
- List<MainBodyGroup> mainBodyGroups = mainBodyList.getMainBodyGroup();
- Assert.assertTrue(mainBodyList.getMainBodyGroup().size() > 0);
- String updatedShortName = "updated-" + mainBodyGroups.get(0).getShortName();
- mainBodyGroups.get(0).setShortName(updatedShortName);
-
- if (logger.isDebugEnabled()) {
- logger.debug("to be updated Organization");
- logger.debug(objectAsXmlString(organization,
- OrganizationsCommon.class));
- }
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
- res.releaseConnection();
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
- OrganizationsCommon updatedOrganization =
- (OrganizationsCommon) extractPart(input,
- client.getItemCommonPartName(), OrganizationsCommon.class);
- Assert.assertNotNull(updatedOrganization);
-
- // Verify that the updated resource received the correct data.
- mainBodyList = organization.getMainBodyGroupList();
- Assert.assertNotNull(mainBodyList);
- Assert.assertTrue(mainBodyList.getMainBodyGroup().size() > 0);
- Assert.assertEquals(updatedOrganization.getMainBodyGroupList().getMainBodyGroup().get(0).getShortName(),
- updatedShortName, "Data in updated Organization did not match submitted data.");
- } finally {
- res.releaseConnection();
+ // Optionally output additional data about list members for debugging.
+ boolean iterateThroughList = false;
+ if (iterateThroughList && logger.isDebugEnabled()) {
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"updateItem"})
+ @Test(dataProvider = "testName", groups = {"update"},
+ dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.updateItem"})
public void updateContact(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupUpdate();
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<String> res =
client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
- assertStatusCode(res, testName);
+ ContactsCommon contact = null;
try {
+ assertStatusCode(res, testName);
if (logger.isDebugEnabled()) {
logger.debug("got Contact to update with ID: "
+ knownContactResourceId
+ " in parent: " + knownResourceId);
}
PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- ContactsCommon contact = (ContactsCommon) extractPart(input,
+ contact = (ContactsCommon) extractPart(input,
new ContactClient().getCommonPartName(), ContactsCommon.class);
Assert.assertNotNull(contact);
-
- // Verify the contents of this resource
- AddressGroupList addressGroupList = contact.getAddressGroupList();
- Assert.assertNotNull(addressGroupList);
- List<AddressGroup> addressGroups = addressGroupList.getAddressGroup();
- Assert.assertNotNull(addressGroups);
- Assert.assertTrue(addressGroups.size() > 0);
- String addressPlace1 = addressGroups.get(0).getAddressPlace1();
- Assert.assertNotNull(addressPlace1);
-
- // Update the contents of this resource.
- addressGroups.get(0).setAddressPlace1("updated-" + addressPlace1);
- contact.setAddressGroupList(addressGroupList);
- if (logger.isDebugEnabled()) {
- logger.debug("to be updated Contact");
- logger.debug(objectAsXmlString(contact,
- ContactsCommon.class));
- }
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(ContactClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(new ContactClient().getCommonPartName());
- res.releaseConnection();
- res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
- assertStatusCode(res, testName);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
- ContactsCommon updatedContact =
- (ContactsCommon) extractPart(input,
- new ContactClient().getCommonPartName(), ContactsCommon.class);
- Assert.assertNotNull(updatedContact);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedContact.getAddressGroupList().getAddressGroup().get(0).getAddressPlace1(),
- contact.getAddressGroupList().getAddressGroup().get(0).getAddressPlace1(),
- "Data in updated object did not match submitted data.");
-
} finally {
- res.releaseConnection();
- }
- }
-
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
- */
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /*
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithEmptyEntityBody();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateWithWrongXmlSchema(String testName) throws Exception {
-
- // Perform setup.
- setupUpdateWithWrongXmlSchema(testName, logger);
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("updateWithWrongXmlSchema: url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
- */
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateNonExistent();
-
- // 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 update(), below.
- OrgAuthorityClient client = new OrgAuthorityClient();
- PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance(
- NON_EXISTENT_ID, NON_EXISTENT_ID,
- new OrgAuthorityClient().getCommonPartName());
- ClientResponse<String> res =
- client.update(NON_EXISTENT_ID, multipart);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ if (res != null) {
+ res.releaseConnection();
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
}
- }
- /**
- * Update non existent item.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
- public void updateNonExistentItem(String testName) throws Exception {
+ // Verify the contents of this resource
+ AddressGroupList addressGroupList = contact.getAddressGroupList();
+ Assert.assertNotNull(addressGroupList);
+ List<AddressGroup> addressGroups = addressGroupList.getAddressGroup();
+ Assert.assertNotNull(addressGroups);
+ Assert.assertTrue(addressGroups.size() > 0);
+ String addressPlace1 = addressGroups.get(0).getAddressPlace1();
+ Assert.assertNotNull(addressPlace1);
+ // Update the contents of this resource.
+ addressGroups.get(0).setAddressPlace1("updated-" + addressPlace1);
+ contact.setAddressGroupList(addressGroupList);
if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
+ logger.debug("to be updated Contact");
+ logger.debug(objectAsXmlString(contact,
+ ContactsCommon.class));
}
- // Perform setup.
- setupUpdateNonExistent();
- // Submit the request to the service and store the response.
- // Note: The ID(s) used when creating the request payload may be arbitrary.
- // The only relevant ID may be the one used in update(), below.
- OrgAuthorityClient client = new OrgAuthorityClient();
- Map<String, String> nonexOrgMap = new HashMap<String, String>();
- nonexOrgMap.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, "nonExistent");
- nonexOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "Non-existent");
- PoxPayloadOut multipart =
- OrgAuthorityClientUtils.createOrganizationInstance(
- knownResourceRefName,
- nonexOrgMap, client.getItemCommonPartName());
- ClientResponse<String> res =
- client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
- try {
- int statusCode = res.getStatus();
+ // Submit the updated resource to the service and store the response.
+ PoxPayloadOut output = new PoxPayloadOut(ContactClient.SERVICE_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE);
+ commonPart.setLabel(new ContactClient().getCommonPartName());
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
+ try {
+ assertStatusCode(res, testName);
+ // Retrieve the updated resource and verify that its contents exist.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ ContactsCommon updatedContact =
+ (ContactsCommon) extractPart(input,
+ new ContactClient().getCommonPartName(), ContactsCommon.class);
+ Assert.assertNotNull(updatedContact);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedContact.getAddressGroupList().getAddressGroup().get(0).getAddressPlace1(),
+ contact.getAddressGroupList().getAddressGroup().get(0).getAddressPlace1(),
+ "Data in updated object did not match submitted data.");
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"updateContact", "testContactSubmitRequest"})
+ @Test(dataProvider = "testName", groups = {"update"},
+ dependsOnMethods = {"updateContact", "testContactSubmitRequest"})
public void updateNonExistentContact(String testName) throws Exception {
// Currently a no-op test
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"})
+ @Test(dataProvider = "testName", groups = {"delete"},
+ dependsOnMethods = {"updateContact"})
public void deleteContact(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupDelete();
ClientResponse<Response> res =
client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ assertStatusCode(res, testName);
} finally {
- res.releaseConnection();
- }
- }
-
- /**
- * Delete item.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteContact"})
- public void deleteItem(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- if (logger.isDebugEnabled()) {
- logger.debug("parentcsid =" + knownResourceId
- + " itemcsid = " + knownItemResourceId);
- }
-
- // Submit the request to the service and store the response.
- OrgAuthorityClient client = new OrgAuthorityClient();
- ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ if (res != null) {
+ res.releaseConnection();
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
}
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
- */
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteItem"})
public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- if (logger.isDebugEnabled()) {
- logger.debug("parentcsid =" + knownResourceId);
- }
-
- // Submit the request to the service and store the response.
- OrgAuthorityClient client = new OrgAuthorityClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ // Do nothing. See localDelete(). This ensure proper test order.
}
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDeleteNonExistent();
-
- // Submit the request to the service and store the response.
- OrgAuthorityClient client = new OrgAuthorityClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+
+ @Test(dataProvider = "testName", dependsOnMethods = {"localDeleteItem"})
+ public void localDelete(String testName) throws Exception {
+ super.delete(testName);
}
- /**
- * Delete non existent item.
- *
- * @param testName the test name
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteItem"})
- public void deleteNonExistentItem(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDeleteNonExistent();
-
- // Submit the request to the service and store the response.
- OrgAuthorityClient client = new OrgAuthorityClient();
- ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ @Override
+ public void deleteItem(String testName) throws Exception {
+ // Do nothing. We need to wait until after the test "localDelete" gets run. When it does,
+ // its dependencies will get run first and then we can call the base class' delete method.
}
-
+
+ @Test(dataProvider = "testName", groups = {"delete"},
+ dependsOnMethods = {"verifyIllegalItemDisplayName", "testContactSubmitRequest", "deleteContact"})
+ public void localDeleteItem(String testName) throws Exception {
+ super.deleteItem(testName);
+ }
+
/**
* Delete non existent contact.
*
* @param testName the test name
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteContact"})
+ @Test(dataProvider = "testName", groups = {"delete"},
+ dependsOnMethods = {"deleteContact"})
public void deleteNonExistentContact(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupDeleteNonExistent();
ClientResponse<Response> res =
client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ assertStatusCode(res, testName);
} finally {
- res.releaseConnection();
- }
- }
-
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
- /**
- * Tests the code for manually submitting data that is used by several
- * of the methods above.
- */
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() {
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testSubmitRequest: url=" + url
- + " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
- }
-
- /**
- * Test item submit request.
- */
- @Test(dependsOnMethods = {"createItem", "readItem", "testSubmitRequest"})
- public void testItemSubmitRequest() {
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getItemResourceURL(knownResourceId, knownItemResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testItemSubmitRequest: url=" + url
- + " status=" + statusCode);
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
}
/**
// Check the status code of the response: does it match
// the expected response(s)?
if (logger.isDebugEnabled()) {
- logger.debug("testItemSubmitRequest: url=" + url
+ logger.debug("testContactSubmitRequest: url=" + url
+ " status=" + statusCode);
}
Assert.assertEquals(statusCode, EXPECTED_STATUS);
res.releaseConnection();
}
// Clean up item resources.
- for (Map.Entry<String, String> entry : allItemResourceIdsCreated.entrySet()) {
+ for (Map.Entry<String, String> entry : allResourceItemIdsCreated.entrySet()) {
itemResourceId = entry.getKey();
parentResourceId = entry.getValue();
// Note: Any non-success responses from the delete operation
return getContactServiceRootURL(parentResourceIdentifier,
itemResourceIdentifier) + "/" + contactResourceIdentifier;
}
+
+ @Override
+ public void authorityTests(String testName) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected String createItemInAuthority(String authorityId) {
+ return createItemInAuthority(authorityId, null /*refname*/);
+ }
+
+ @Override
+ protected OrganizationsCommon updateItemInstance(OrganizationsCommon organizationsCommon) {
+ OrganizationsCommon result = organizationsCommon; //new OrganizationsCommon();
+
+ MainBodyGroupList mainBodyList = organizationsCommon.getMainBodyGroupList();
+ Assert.assertNotNull(mainBodyList);
+ List<MainBodyGroup> mainBodyGroups = mainBodyList.getMainBodyGroup();
+ Assert.assertTrue(mainBodyList.getMainBodyGroup().size() > 0);
+ String updatedShortName = "updated-" + mainBodyGroups.get(0).getShortName();
+ mainBodyGroups.get(0).setShortName(updatedShortName);
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedItemInstances(OrganizationsCommon original,
+ OrganizationsCommon updated) throws Exception {
+ MainBodyGroupList mainBodyList = original.getMainBodyGroupList();
+ Assert.assertNotNull(mainBodyList);
+ Assert.assertTrue(mainBodyList.getMainBodyGroup().size() > 0);
+ Assert.assertEquals(updated.getMainBodyGroupList().getMainBodyGroup().get(0).getShortName(),
+ original.getMainBodyGroupList().getMainBodyGroup().get(0).getShortName(),
+ "Short name in updated Organization did not match submitted data.");
+ }
+
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ String shortId = identifier;
+ String displayName = "displayName-" + shortId;
+ //String baseRefName = OrgAuthorityClientUtils.createOrgAuthRefName(shortId, null);
+ PoxPayloadOut result = OrgAuthorityClientUtils.createOrgAuthorityInstance(
+ displayName, shortId, commonPartName);
+ return result;
+ }
+
+ @Override
+ protected PoxPayloadOut createNonExistenceInstance(String commonPartName,
+ String identifier) {
+ String shortId = identifier;
+ String displayName = "displayName-" + shortId;
+ //String baseRefName = OrgAuthorityClientUtils.createOrgAuthRefName(shortId, null);
+ PoxPayloadOut result = OrgAuthorityClientUtils.createOrgAuthorityInstance(
+ displayName, shortId, commonPartName);
+ return result;
+ }
+
+ protected PoxPayloadOut createNonExistenceItemInstance(String commonPartName,
+ String identifier) {
+ Map<String, String> nonexOrgMap = new HashMap<String, String>();
+ nonexOrgMap.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, "nonExistent");
+ nonexOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "Non-existent");
+ PoxPayloadOut result =
+ OrgAuthorityClientUtils.createOrganizationInstance(
+ knownResourceRefName,
+ nonexOrgMap, commonPartName);
+ return result;
+ }
+
+ @Override
+ protected OrgauthoritiesCommon updateInstance(OrgauthoritiesCommon orgauthoritiesCommon) {
+ OrgauthoritiesCommon result = new OrgauthoritiesCommon();
+
+ result.setDisplayName("updated-" + orgauthoritiesCommon.getDisplayName());
+ result.setVocabType("updated-" + orgauthoritiesCommon.getVocabType());
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(OrgauthoritiesCommon original,
+ OrgauthoritiesCommon updated) throws Exception {
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updated.getDisplayName(),
+ original.getDisplayName(),
+ "Display name in updated object did not match submitted data.");
+ }
}
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
\r
<!-- apache -->\r
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
<!-- RESTEasy -->\r
<dependency>\r
*/
package org.collectionspace.services.client;
+import org.collectionspace.services.person.PersonsCommon;
+
/**
* The Class PersonAuthorityClient.
*/
-public class PersonAuthorityClient extends AuthorityWithContactsClientImpl<PersonAuthorityProxy> {
+public class PersonAuthorityClient extends AuthorityWithContactsClientImpl<PersonsCommon, PersonAuthorityProxy> {
public static final String SERVICE_NAME = "personauthorities";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
public Class<PersonAuthorityProxy> getProxyClass() {
return PersonAuthorityProxy.class;
}
+
+ @Override
+ public String getInAuthority(PersonsCommon item) {
+ return item.getInAuthority();
+ }
+
+ @Override
+ public void setInAuthority(PersonsCommon item, String inAuthorityCsid) {
+ item.setInAuthority(inAuthorityCsid);
+ }
}
*/
package org.collectionspace.services.client.test;
-import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
-import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
* $LastChangedRevision: 753 $
* $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
*/
-public class PersonAuthoritySearchTest extends BaseServiceTest {
+public class PersonAuthoritySearchTest extends BaseServiceTest<AbstractCommonList> {
private final String CLASS_NAME = PersonAuthoritySearchTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
+ protected AbstractCommonList getCommonList(
ClientResponse<AbstractCommonList> response) {
return response.getEntity(AbstractCommonList.class);
}
/**
* Reads an item list by partial term.
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readListByPartialTerm"})
+ @Test(dataProvider="testName", groups = {"readListByPartialTerm"})
public void partialTermMatch(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
int numMatchesFound = 0;
String partialTerm = getPartialTermCommon();
if (logger.isDebugEnabled()) {
* of an all-lowercase variation of the expected match, to test case-insensitive
* matching.
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
+ @Test(dataProvider="testName", groups = {"readListByPartialTerm"},
+ dependsOnMethods = {"partialTermMatch"})
public void partialTermMatchCaseInsensitiveLowerCase(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
int numMatchesFound = 0;
final String partialTerm = getPartialTermCommon().toLowerCase();
* of an all-uppercase variation of the expected match, to test case-insensitive
* matching.
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ @Test(dataProvider="testName",
groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
public void partialTermMatchCaseInsensitiveUpperCase(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
int numMatchesFound = 0;
final String partialTerm = getPartialTermCommon().toUpperCase();
* Reads an item list by partial term, with a partial term that is of
* the minimum character length that may be expected to be matched.
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ @Test(dataProvider="testName",
groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
public void partialTermMatchMinimumLength(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
int numMatchesFound = 0;
String partialTerm = getPartialTermMinimumLength();
if (logger.isDebugEnabled()) {
* Reads an item list by partial term, with a partial term that contains
* at least one Unicode UTF-8 character (outside the USASCII range).
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ @Test(dataProvider="testName",
groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
public void partialTermMatchUTF8(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
int numMatchesFound = 0;
String partialTerm = getPartialTermUtf8();
String ptEncoded;
* Reads an item list by partial term, with a partial term that contains
* at least one Unicode UTF-8 character (outside the USASCII range).
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ @Test(dataProvider="testName",
groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
public void partialTermMatchQuote(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
int numMatchesFound = 0;
String partialTerm = getPartialTermQuote();
if (logger.isDebugEnabled()) {
/**
* Finds terms by keywords.
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readListByKwdTerm"})
+ @Test(dataProvider="testName", groups = {"readListByKwdTerm"})
public void keywordTermMatch(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
int numMatchesFound = 0;
String kwdTerm = getKwdTerm();
if (logger.isDebugEnabled()) {
/**
* Finds terms by keywords.
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ @Test(dataProvider="testName",
groups = {"readListByKwdTerm"}, dependsOnMethods = {"keywordTermMatch"})
public void keywordTermMatchUTF8(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
int numMatchesFound = 0;
String kwdTerm = getKwdTermUTF8();
if (logger.isDebugEnabled()) {
* Reads an item list by partial term, with a partial term that is not
* expected to be matched by any term in any resource.
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ @Test(dataProvider="testName",
groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
public void partialTermMatchOnNonexistentTerm(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
int numMatchesFound = 0;
int ZERO_MATCHES_EXPECTED = 0;
String partialTerm = getPartialTermNonExistent();
* Reads an item list by partial term, with a partial term that is not
* expected to be matched by any term in any resource.
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"readListByKwdTerm"}, dependsOnMethods = {"keywordTermMatch"})
+ @Test(dataProvider="testName", groups = {"readListByKwdTerm"},
+ dependsOnMethods = {"keywordTermMatch"})
public void keywordTermMatchOnNonexistentTerm(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
int numMatchesFound = 0;
int ZERO_MATCHES_EXPECTED = 0;
String kwdTerm = getKwdTermNonExistent();
} else {
Assert.fail("readItemListByPartialTerm passed null csid!");
}
- assertStatusCode(res, testName);
AbstractCommonList list = null;
try {
+ assertStatusCode(res, testName);
list = res.getEntity();
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
List<AbstractCommonList.ListItem> items = list.getListItem();
String testName = "createAuthority";
if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
+ logger.debug(getTestBanner(testName, CLASS_NAME));
}
// Perform setup.
String newID = null;
ClientResponse<Response> res = client.create(multipart);
try {
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
+ assertStatusCode(res, testName);
newID = PersonAuthorityClientUtils.extractId(res);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
// Store the refname from the first resource created
// for additional tests below.
String newID = null;
ClientResponse<Response> res = client.createItem(authorityCsid, multipart);
try {
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
newID = PersonAuthorityClientUtils.extractId(res);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
// Store the ID returned from the first item resource created
* $LastChangedRevision: 753 $
* $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
*/
-public class PersonAuthorityServicePerfTest extends BaseServiceTest {
+public class PersonAuthorityServicePerfTest extends BaseServiceTest<AbstractCommonList> {
private final String CLASS_NAME = PersonAuthorityServicePerfTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
+ protected AbstractCommonList getCommonList(
ClientResponse<AbstractCommonList> response) {
return response.getEntity(AbstractCommonList.class);
}
String newID = null;
ClientResponse<Response> res = client.create(multipart);
try {
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match
- // the expected response(s)?
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
+ assertStatusCode(res, testName);
newID = PersonAuthorityClientUtils.extractId(res);
logger.info("{}: succeeded.", testName);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
// Store the refname from the first resource created
// for additional tests below.
String newID = null;
ClientResponse<Response> res = client.createItem(authId, multipart);
try {
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match
- // the expected response(s)?
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+ assertStatusCode(res, "createItem");
newID = PersonAuthorityClientUtils.extractId(res);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
// Store the IDs from any item resources created
/**
* Reads an item list by partial term.
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
+ @Test(dataProvider="testName")
public void partialTermMatch(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
for(int i=0; i<partialTerms.length; i++) {
long startTime = System.currentTimeMillis();
int numMatchesFound = readItemListWithFilters(testName, authId,
Assert.fail(testName+" passed null csid!");
}
AbstractCommonList list = null;
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
list = res.getEntity();
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
List<AbstractCommonList.ListItem> items = list.getListItem();
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.AuthorityClient;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.ContactClient;
import org.collectionspace.services.client.ContactClientUtils;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.contact.AddressGroup;
import org.collectionspace.services.contact.AddressGroupList;
import org.collectionspace.services.contact.ContactsCommon;
* $LastChangedRevision: 753 $
* $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
*/
-public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME: Test classes for Vocab, Person, Org, and Location should have a base class!
+public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<PersonauthoritiesCommon, PersonsCommon> { //FIXME: Test classes for Vocab, Person, Org, and Location should have a base class!
/** The logger. */
private final String CLASS_NAME = PersonAuthorityServiceTest.class.getName();
final String TEST_BIRTH_DATE = "May 26, 1907";
/** The test death date. */
final String TEST_DEATH_DATE = "June 11, 1979";
- // Hold some values for a recently created item to verify upon read.
- private String knownResourceId = null;
- private String knownResourceShortIdentifer = null;
//private String knownResourceRefName = null;
- private String knownItemResourceId = null;
private String knownItemResourceShortIdentifer = null;
// The resource ID of an item resource used for partial term matching tests.
private String knownItemPartialTermResourceId = null;
/** The known contact resource id. */
private String knownContactResourceId = null;
- /** The n items to create in list. */
- private int nItemsToCreateInList = 3;
- /** The all item resource ids created. */
- private Map<String, String> allItemResourceIdsCreated =
- new HashMap<String, String>();
/** The all contact resource ids created. */
private Map<String, String> allContactResourceIdsCreated =
new HashMap<String, String>();
* @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"create"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// groups = {"create"})
public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// 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).
String newID = null;
ClientResponse<Response> res = client.create(multipart);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
-
- newID = PersonAuthorityClientUtils.extractId(res);
+ assertStatusCode(res, testName);
+ newID = extractId(res);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
// Save values for additional tests
if (knownResourceId == null) {
return PersonAuthorityClientUtils.createPersonInstance(parentCsid, identifier, personInfo, headerLabel);
}
- /**
- * Creates the item.
- *
- * @param testName the test name
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"create"}, dependsOnMethods = {"create"})
- public void createItem(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- setupCreate();
- String newID = createItemInAuthority(knownResourceId, null ); //knownResourceRefName);
- }
-
- /**
- * Creates the item with an empty short identifier.
- *
- * @param testName the test name
- */
- /*
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- groups = {"create"}, dependsOnMethods = {"create"})
- public void createItemWithEmptyShortId(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- setupCreate();
-
- // Fill the property map
- String shortId = "";
- Map<String, String> fieldProperties = new HashMap<String,String>();
- fieldProperties.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false");
- fieldProperties.put(PersonJAXBSchema.DISPLAY_NAME, "Rod Beck");
- fieldProperties.put(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED, "false");
- fieldProperties.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, "RodBeck");
-
- final Map NULL_REPEATABLE_FIELD_PROPERTIES = null;
- String newID = createItemInAuthority(knownResourceId, knownResourceRefName,
- shortId, fieldProperties, NULL_REPEATABLE_FIELD_PROPERTIES);
- allResourceIdsCreated.add(newID);
- }
- */
/**
* Creates an item in an authority, using test data.
*
* @param authRefName the auth ref name
* @return the string
*/
- private String createItemInAuthority(String vcsid, String authRefName) {
+ @Override
+ protected String createItemInAuthority(String vcsid) {
final String testName = "createItemInAuthority";
if (logger.isDebugEnabled()) {
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
-
PoxPayloadOut multipart =
PersonAuthorityClientUtils.createPersonInstance(vcsid, null /*authRefName*/, itemFieldProperties,
itemRepeatableFieldProperties, client.getItemCommonPartName());
-
- String newID = null;
+ setupCreate();
ClientResponse<Response> res = client.createItem(vcsid, multipart);
+ String newID = null;
try {
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+ assertStatusCode(res, testName);
newID = PersonAuthorityClientUtils.extractId(res);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
// Store the ID returned from the first item resource created
// Store the IDs from any item resources created
// by tests, along with the IDs of their parents, so these items
// can be deleted after all tests have been run.
- allItemResourceIdsCreated.put(newID, vcsid);
+ allResourceItemIdsCreated.put(newID, vcsid);
return newID;
}
*
* @param testName the test name
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"create"}, dependsOnMethods = {"createItem"})
+ @Test(dataProvider = "testName", groups = {"create"},
+ dependsOnMethods = {"createItem"})
public void createContact(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
String newID = createContactInItem(knownResourceId, knownItemResourceId);
}
if (logger.isDebugEnabled()) {
logger.debug(testName + ":...");
}
-
- setupCreate();
-
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
String identifier = createIdentifier();
PoxPayloadOut multipart = ContactClientUtils.createContactInstance(parentcsid,
itemcsid, identifier, new ContactClient().getCommonPartName());
- String newID = null;
+ setupCreate();
ClientResponse<Response> res =
client.createContact(parentcsid, itemcsid, multipart);
+ String newID = null;
try {
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+ assertStatusCode(res, testName);
newID = PersonAuthorityClientUtils.extractId(res);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
// Store the ID returned from the first contact resource created
return newID;
}
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
- */
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /*
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithEmptyEntityBody();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()) {
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA; // Constant from base class.
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithWrongXmlSchema(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithWrongXmlSchema();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
- */
/**
* Attempts to create an authority with an short identifier that contains
* non-word characters.
*
* @param testName the test name
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"create", "nonWordCharsInShortId"})
+ @Test(dataProvider = "testName", groups = {"create", "nonWordCharsInShortId"})
public void createWithShortIdNonWordChars(String testName) throws Exception {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- EXPECTED_STATUS_CODE = STATUS_BAD_REQUEST;
- REQUEST_TYPE = ServiceRequestType.CREATE;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
+ testExpectedStatusCode = STATUS_BAD_REQUEST;
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
// Create the payload to be included in the body of the request
PersonAuthorityClient client = new PersonAuthorityClient();
// Check the status code of the response: does it match
// the expected response(s)?
try {
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
+ assertStatusCode(res, testName);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
-
}
/**
*
* @param testName the test name
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"create", "nonWordCharsInShortId"}, dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName", groups = {"create", "nonWordCharsInShortId"},
+ dependsOnMethods = {"org.collectionspace.services.client.test.AbstractServiceTestImpl.create"})
public void createItemWithShortIdNonWordChars(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- EXPECTED_STATUS_CODE = STATUS_BAD_REQUEST;
- REQUEST_TYPE = ServiceRequestType.CREATE;
- testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
+ testExpectedStatusCode = STATUS_BAD_REQUEST;
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
PersonAuthorityClient client = new PersonAuthorityClient();
-
// Create the payload to be included in the body of the request
String shortId = "7-Eleven";
Map<String, String> fieldProperties = new HashMap<String, String>();
// Send the request and receive a response
ClientResponse<Response> res = client.createItem(knownResourceId, multipart);
-
// Check the status code of the response: does it match
// the expected response(s)?
try {
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ assertStatusCode(res, testName);
} finally {
- res.releaseConnection();
-
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"createList"}, dependsOnGroups = {"create"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// groups = {"createList"}, dependsOnGroups = {"create"})
public void createList(String testName) throws Exception {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
for (int i = 0; i < nItemsToCreateInList; i++) {
create(testName);
}
}
- /**
- * Creates the item list.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"createList"}, dependsOnMethods = {"createList"})
- public void createItemList(String testName) throws Exception {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Add items to the initially-created, known parent record.
- for (int j = 0; j < nItemsToCreateInList; j++) {
- createItem(testName);
- }
- }
-
/**
* Creates the contact list.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"createList"}, dependsOnMethods = {"createItemList"})
+ @Test(dataProvider = "testName", groups = {"createList"},
+ dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.createItemList"})
public void createContactList(String testName) throws Exception {
// Add contacts to the initially-created, known item record.
for (int j = 0; j < nItemsToCreateInList; j++) {
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnGroups = {"create"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// groups = {"read"}, dependsOnGroups = {"create"})
public void read(String testName) throws Exception {
readInternal(testName, knownResourceId, null);
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnMethods = {"read"})
+ @Override
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// groups = {"read"}, dependsOnMethods = {"read"})
public void readByName(String testName) throws Exception {
readInternal(testName, null, knownResourceShortIdentifer);
}
protected void readInternal(String testName, String CSID, String shortId) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<String> res = null;
+ setupRead();
if (CSID != null) {
res = client.read(CSID);
} else if (shortId != null) {
} else {
Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
}
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
//FIXME: remove the following try catch once Aron fixes signatures
try {
PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
throw new RuntimeException(e);
}
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
/**
- * Read item.
+ * Read named item.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnGroups = {"read"})
- public void readItem(String testName) throws Exception {
- readItemInternal(testName, knownResourceId, null, knownItemResourceId, null);
+ @Test(dataProvider = "testName", groups = {"readItem", "readNamedItemInNamedAuth"},
+ dependsOnMethods = {"readItemInNamedAuth"})
+ public void readNamedItem(String testName) throws Exception {
+ readItemInternal(testName, knownResourceId, null, null, knownItemResourceShortIdentifer);
}
/**
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readItem"})
+ @Test(dataProvider = "testName", groups = {"readItem"},
+ dependsOnMethods = {"readItem"})
public void readItemInNamedAuth(String testName) throws Exception {
readItemInternal(testName, null, knownResourceShortIdentifer, knownItemResourceId, null);
}
- /**
- * Read named item.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readItem"})
- public void readNamedItem(String testName) throws Exception {
- readItemInternal(testName, knownResourceId, null, null, knownItemResourceShortIdentifer);
- }
-
+
/**
* Read Named item in Named Auth.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readItem"})
+ @Test(dataProvider = "testName", groups = {"readItem"},
+ dependsOnMethods = {"readNamedItem"})
public void readNamedItemInNamedAuth(String testName) throws Exception {
readItemInternal(testName, null, knownResourceShortIdentifer, null, knownItemResourceShortIdentifer);
}
throws Exception {
if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
logger.debug("Reading:" + ((authCSID != null) ? authCSID : authShortId) + "/"
+ ((itemCSID != null) ? authCSID : itemShortId));
}
- // Perform setup.
- setupRead();
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
+ setupRead();
ClientResponse<String> res = null;
if (authCSID != null) {
if (itemCSID != null) {
} else {
Assert.fail("readInternal: Internal error. One of authCSID or authShortId must be non-null");
}
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
// Check whether we've received a person.
PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
PersonsCommon person = (PersonsCommon) extractPart(input,
List<String> groups = person.getGroups().getGroup();
Assert.assertTrue(groups.size() > 0);
Assert.assertNotNull(groups.get(0));
-
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"updateItem"})
- public void verifyItemDisplayNames(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
+ @Test(dataProvider = "testName", groups = {"update"},
+ dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.updateItem"})
+ public void verifyItemDisplayName(String testName) throws Exception {
// Perform setup.
setupUpdate();
PersonAuthorityClient client = new PersonAuthorityClient();
PoxPayloadIn input = null;
ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
+ // Check whether person has expected displayName.
input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
PersonsCommon person = (PersonsCommon) extractPart(input,
// Submit the updated resource to the service and store the response.
PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
+ PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), person);
res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
// Retrieve the updated resource and verify that its contents exist.
input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
PersonsCommon updatedPerson =
// Submit the updated resource to the service and store the response.
output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
+ commonPart = output.addPart(client.getItemCommonPartName(), person);
res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
// Retrieve the updated resource and verify that its contents exist.
input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
updatedPerson =
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"verifyItemDisplayNames"})
+ @Test(dataProvider = "testName", groups = {"update"},
+ dependsOnMethods = {"verifyItemDisplayName"})
public void verifyIllegalItemDisplayName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Perform setup for read.
setupRead();
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
- assertStatusCode(res, testName);
-
- // Perform setup for update.
- testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE);
-
PoxPayloadIn input = null;
try {
+ assertStatusCode(res, testName);
input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
-
+ //
+ // Make an invalid UPDATE request -i.e., if we don't want the display name computed, then
+ // we need to supply one.
+ //
PersonsCommon person = (PersonsCommon) extractPart(input,
client.getItemCommonPartName(), PersonsCommon.class);
Assert.assertNotNull(person);
// Submit the updated resource to the service and store the response.
PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
+ PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), person);
+ setupUpdateWithInvalidBody();
res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
try {
- // intentionally empty try block
+ assertStatusCode(res, testName);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readItem"})
+ @Test(dataProvider = "testName", groups = {"readItem"},
+ dependsOnMethods = {"createContact", "org.collectionspace.services.client.test.AbstractAuthorityServiceTest.readItem"})
public void readContact(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupRead();
ClientResponse<String> res =
client.readContact(knownResourceId, knownItemResourceId,
knownContactResourceId);
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
// Check whether we've received a contact.
input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
ContactsCommon contact = (ContactsCommon) extractPart(input,
}
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnMethods = {"read"})
- public void readNonExistent(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- PersonAuthorityClient client = new PersonAuthorityClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
- try {
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- /**
- * Read item non existent.
- *
- * @param testName the test name
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readItem"})
- public void readItemNonExistent(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- PersonAuthorityClient client = new PersonAuthorityClient();
- ClientResponse<String> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
/**
* Read contact non existent.
*
* @param testName the test name
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readItem"}, dependsOnMethods = {"readContact"})
+ @Test(dataProvider = "testName", groups = {"readItem"},
+ dependsOnMethods = {"readContact"})
public void readContactNonExistent(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupReadNonExistent();
ClientResponse<String> res =
client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ assertStatusCode(res, testName);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
// ---------------------------------------------------------------
// CRUD tests : READ_LIST tests
// ---------------------------------------------------------------
- // Success outcomes
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readList"}, dependsOnGroups = {"createList", "read"})
- public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadList();
-
- // Submit the request to the service and store the response.
- PersonAuthorityClient client = new PersonAuthorityClient();
- AbstractCommonList list = null;
- ClientResponse<AbstractCommonList> res = client.readList();
- assertStatusCode(res, testName);
- try {
- list = res.getEntity();
- } finally {
- res.releaseConnection();
- }
-
- // Optionally output additional data about list members for debugging.
- if (logger.isTraceEnabled()) {
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
- }
/**
* Read item list.
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readList"}, dependsOnMethods = {"readList"})
+ @Override
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// groups = {"readList"}, dependsOnMethods = {"readList"})
public void readItemList(String testName) {
- readItemList(knownResourceId, null, testName);
+ readItemList(knownAuthorityWithItems, null, testName);
}
/**
* Read item list by authority name.
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readList"}, dependsOnMethods = {"readItemList"})
- public void readItemListByAuthorityName(String testName) {
- readItemList(null, knownResourceShortIdentifer, testName);
+ @Override
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// groups = {"readList"}, dependsOnMethods = {"readItemList"})
+ public void readItemListByName(String testName) {
+ readItemList(null, READITEMS_SHORT_IDENTIFIER, testName);
}
/**
* @param name the name
*/
private void readItemList(String vcsid, String name, String testName) {
-
- // Perform setup.
setupReadList();
-
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<AbstractCommonList> res = null;
} else {
Assert.fail("readItemList passed null csid and name!");
}
- assertStatusCode(res, testName);
AbstractCommonList list = null;
try {
+ assertStatusCode(res, testName);
list = res.getEntity();
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- List<AbstractCommonList.ListItem> items =
- list.getListItem();
+ List<AbstractCommonList.ListItem> items = list.getListItem();
int nItemsReturned = items.size();
- // There will be one item created, associated with a
- // known parent resource, by the createItem test.
- //
- // In addition, there will be 'nItemsToCreateInList'
- // additional items created by the createItemList test,
+ // There will be 'nItemsToCreateInList'
+ // items created by the createItemList test,
// all associated with the same parent resource.
- int nExpectedItems = nItemsToCreateInList + 1;
+ int nExpectedItems = nItemsToCreateInList;
if (logger.isDebugEnabled()) {
logger.debug(testName + ": Expected "
+ nExpectedItems + " items; got: " + nItemsReturned);
/**
* Read contact list.
*/
- @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
+ @Test(groups = {"readList"},
+ dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.readItemList"})
public void readContactList() {
readContactList(knownResourceId, knownItemResourceId);
}
AbstractCommonList list = null;
ClientResponse<AbstractCommonList> res =
client.readContactList(parentcsid, itemcsid);
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
list = res.getEntity();
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
List<AbstractCommonList.ListItem> listitems =
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnGroups = {"readItem", "readList"})
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// groups = {"update"}, dependsOnGroups = {"readItem", "readList"})
public void update(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
-
// Retrieve the contents of a resource to update.
PersonAuthorityClient client = new PersonAuthorityClient();
PoxPayloadIn input = null;
+ setupRead();
ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
+ if (logger.isDebugEnabled()) {
+ logger.debug("got PersonAuthority to update with ID: " + knownResourceId);
+ }
input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
// Submit the updated resource to the service and store the response.
PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(personAuthority, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
+ PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), personAuthority);
+ setupUpdate();
res = client.update(knownResourceId, output);
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
// Retrieve the updated resource and verify that its contents exist.
input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
PersonauthoritiesCommon updatedPersonAuthority =
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"update"})
+ @Override
+// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+// groups = {"update"}, dependsOnMethods = {"update"})
public void updateItem(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
-
// Retrieve the contents of a resource to update.
PersonAuthorityClient client = new PersonAuthorityClient();
PoxPayloadIn input = null;
+ setupRead();
ClientResponse<String> res =
client.readItem(knownResourceId, knownItemResourceId);
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
+ if (logger.isDebugEnabled()) {
+ logger.debug("got Person to update with ID: "
+ + knownItemResourceId
+ + " in PersonAuthority: " + knownResourceId);
+ }
input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
PersonsCommon person = (PersonsCommon) extractPart(input,
// Submit the updated resource to the service and store the response.
PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
+ PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), person);
+ setupUpdate();
res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
// Retrieve the updated resource and verify that its contents exist.
input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
PersonsCommon updatedPerson =
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"updateItem"})
+ @Test(dataProvider = "testName", groups = {"update"},
+ dependsOnMethods = {"readContact", "testContactSubmitRequest",
+ "org.collectionspace.services.client.test.AbstractAuthorityServiceTest.updateItem"})
public void updateContact(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
+ String contactsCommonLabel = new ContactClient().getCommonPartName();
// Retrieve the contents of a resource to update.
PersonAuthorityClient client = new PersonAuthorityClient();
PoxPayloadIn input = null;
+ setupRead();
ClientResponse<String> res =
client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
+ if (logger.isDebugEnabled()) {
+ logger.debug("got Contact to update with ID: "
+ + knownContactResourceId
+ + " in item: " + knownItemResourceId
+ + " in parent: " + knownResourceId);
+ }
input = new PoxPayloadIn(res.getEntity());
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
ContactsCommon contact = (ContactsCommon) extractPart(input,
- new ContactClient().getCommonPartName(), ContactsCommon.class);
+ contactsCommonLabel, ContactsCommon.class);
Assert.assertNotNull(contact);
// Verify the contents of this resource
// Submit the updated resource to the service and store the response.
PoxPayloadOut output = new PoxPayloadOut(ContactClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE); //FIXME: REM - Replace with output.addPart(contact, client.getCommonPartName())
- commonPart.setLabel(client.getCommonPartName());
+ PayloadOutputPart commonPart = output.addPart(contactsCommonLabel, contact);
+ setupUpdate();
res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
- assertStatusCode(res, testName);
try {
+ assertStatusCode(res, testName);
// Retrieve the updated resource and verify that its contents exist.
input = new PoxPayloadIn(res.getEntity());;
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- ContactsCommon updatedContact =
- (ContactsCommon) extractPart(input,
- new ContactClient().getCommonPartName(), ContactsCommon.class);
+ ContactsCommon updatedContact = (ContactsCommon) extractPart(input,
+ contactsCommonLabel, ContactsCommon.class);
Assert.assertNotNull(updatedContact);
// Verify that the updated resource received the correct data.
"Data in updated object did not match submitted data.");
}
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
- */
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* //FIXME: REM - Can we kill all this dead code please?
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithEmptyEntityBody(testName, logger);
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateWithWrongXmlSchema(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithWrongXmlSchema();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("updateWithWrongXmlSchema: url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
- */
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateNonExistent();
-
- // Submit the request to the service and store the response.
- // Note: The ID(s) used when creating the request payload may be arbitrary.
- // The only relevant ID may be the one used in update(), below.
- PersonAuthorityClient client = new PersonAuthorityClient();
- String displayName = "displayName-NON_EXISTENT_ID";
- PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
- displayName, "NON_EXISTENT_SHORT_ID", client.getCommonPartName());
- ClientResponse<String> res =
- client.update(NON_EXISTENT_ID, multipart);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- /**
- * Update non existent item.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
- public void updateNonExistentItem(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateNonExistent();
-
- // 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 update(), below.
- PersonAuthorityClient client = new PersonAuthorityClient();
- Map<String, String> nonexMap = new HashMap<String, String>();
- nonexMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, "nonEX");
- nonexMap.put(PersonJAXBSchema.FORE_NAME, "John");
- nonexMap.put(PersonJAXBSchema.SUR_NAME, "Wayne");
- nonexMap.put(PersonJAXBSchema.GENDER, "male");
- Map<String, List<String>> nonexRepeatablesMap = new HashMap<String, List<String>>();
- PoxPayloadOut multipart =
- PersonAuthorityClientUtils.createPersonInstance(NON_EXISTENT_ID,
- null, //PersonAuthorityClientUtils.createPersonAuthRefName(NON_EXISTENT_ID, null),
- nonexMap, nonexRepeatablesMap, client.getItemCommonPartName());
- ClientResponse<String> res =
- client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
/**
* Update non existent contact.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"updateContact", "testContactSubmitRequest"})
+ @Test(dataProvider = "testName", groups = {"update"},
+ dependsOnMethods = {"updateContact", "testContactSubmitRequest"})
public void updateNonExistentContact(String testName) throws Exception {
// Currently a no-op test
}
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnGroups = {"update"})
+ @Test(dataProvider = "testName", groups = {"delete"},
+ dependsOnMethods = {"updateContact"})
public void deleteContact(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
if (logger.isDebugEnabled()) {
logger.debug("parentcsid =" + knownResourceId
+ " itemcsid = " + knownItemResourceId
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
+ setupDelete();
ClientResponse<Response> res =
client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ assertStatusCode(res, testName);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
}
- /**
- * Delete item.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteContact"})
- public void deleteItem(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- if (logger.isDebugEnabled()) {
- logger.debug("parentcsid =" + knownResourceId
- + " itemcsid = " + knownItemResourceId);
- }
-
- // Submit the request to the service and store the response.
- PersonAuthorityClient client = new PersonAuthorityClient();
- ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
- */
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteItem"})
public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- if (logger.isDebugEnabled()) {
- logger.debug("parentcsid =" + knownResourceId);
- }
-
- // Submit the request to the service and store the response.
- PersonAuthorityClient client = new PersonAuthorityClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ // Do nothing. See localDelete(). This ensure proper test order.
+ }
+
+ @Test(dataProvider = "testName", dependsOnMethods = {"localDeleteItem"})
+ public void localDelete(String testName) throws Exception {
+ super.delete(testName);
}
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
- */
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDeleteNonExistent();
-
- // Submit the request to the service and store the response.
- PersonAuthorityClient client = new PersonAuthorityClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+ public void deleteItem(String testName) throws Exception {
+ // Do nothing. We need to wait until after the test "localDelete" gets run. When it does,
+ // its dependencies will get run first and then we can call the base class' delete method.
}
-
- /**
- * Delete non existent item.
- *
- * @param testName the test name
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteItem"})
- public void deleteNonExistentItem(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDeleteNonExistent();
-
- // Submit the request to the service and store the response.
- PersonAuthorityClient client = new PersonAuthorityClient();
- ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
+
+ @Test(dataProvider = "testName", groups = {"delete"},
+ dependsOnMethods = {"verifyIllegalItemDisplayName", "testContactSubmitRequest", "deleteContact"})
+ public void localDeleteItem(String testName) throws Exception {
+ super.deleteItem(testName);
}
/**
*
* @param testName the test name
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteContact"})
+ @Test(dataProvider = "testName", groups = {"delete"},
+ dependsOnMethods = {"deleteContact"})
public void deleteNonExistentContact(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDeleteNonExistent();
-
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
+ setupDeleteNonExistent();
ClientResponse<Response> res =
client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ assertStatusCode(res, testName);
} finally {
- res.releaseConnection();
- }
- }
-
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
- /**
- * Tests the code for manually submitting data that is used by several
- * of the methods above.
- */
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() {
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testSubmitRequest: url=" + url
- + " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
- }
-
- /**
- * Test item submit request.
- */
- @Test(dependsOnMethods = {"createItem", "readItem", "testSubmitRequest"})
- public void testItemSubmitRequest() {
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getItemResourceURL(knownResourceId, knownItemResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testItemSubmitRequest: url=" + url
- + " status=" + statusCode);
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
}
/**
* Test contact submit request.
*/
- @Test(dependsOnMethods = {"createContact", "readContact", "testItemSubmitRequest"})
- public void testContactSubmitRequest() {
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"createContact", "readContact", "testItemSubmitRequest"})
+ public void testContactSubmitRequest(String testName) {
// Expected status code: 200 OK
final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
// Check the status code of the response: does it match
// the expected response(s)?
if (logger.isDebugEnabled()) {
- logger.debug("testItemSubmitRequest: url=" + url
+ logger.debug("testContactSubmitRequest: url=" + url
+ " status=" + statusCode);
}
Assert.assertEquals(statusCode, EXPECTED_STATUS);
res.releaseConnection();
}
// Clean up item resources.
- for (Map.Entry<String, String> entry : allItemResourceIdsCreated.entrySet()) {
+ for (Map.Entry<String, String> entry : allResourceItemIdsCreated.entrySet()) {
itemResourceId = entry.getKey();
parentResourceId = entry.getValue();
// Note: Any non-success responses from the delete operation
return getContactServiceRootURL(parentResourceIdentifier,
itemResourceIdentifier) + "/" + contactResourceIdentifier;
}
+
+ @Override
+ public void authorityTests(String testName) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected PersonsCommon updateItemInstance(PersonsCommon authorityItem) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void compareUpdatedItemInstances(PersonsCommon original,
+ PersonsCommon updated) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ String shortId = identifier;
+ String displayName = "displayName-" + shortId;
+ PoxPayloadOut result =
+ PersonAuthorityClientUtils.createPersonAuthorityInstance(
+ displayName, shortId, commonPartName);
+ return result;
+ }
+
+ @Override
+ protected PoxPayloadOut createNonExistenceInstance(String commonPartName,
+ String identifier) {
+ String displayName = "displayName-NON_EXISTENT_ID";
+ PoxPayloadOut result = PersonAuthorityClientUtils.createPersonAuthorityInstance(
+ displayName, "NON_EXISTENT_SHORT_ID", commonPartName);
+ return result;
+ }
+
+ protected PoxPayloadOut createNonExistenceItemInstance(String commonPartName, String identifier) {
+ Map<String, String> nonexMap = new HashMap<String, String>();
+ nonexMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, "nonEX");
+ nonexMap.put(PersonJAXBSchema.FORE_NAME, "John");
+ nonexMap.put(PersonJAXBSchema.SUR_NAME, "Wayne");
+ nonexMap.put(PersonJAXBSchema.GENDER, "male");
+ Map<String, List<String>> nonexRepeatablesMap = new HashMap<String, List<String>>();
+ PoxPayloadOut result =
+ PersonAuthorityClientUtils.createPersonInstance(NON_EXISTENT_ID,
+ null, //PersonAuthorityClientUtils.createPersonAuthRefName(NON_EXISTENT_ID, null),
+ nonexMap, nonexRepeatablesMap, commonPartName);
+ return result;
+ }
+
+
+ @Override
+ protected PersonauthoritiesCommon updateInstance(
+ PersonauthoritiesCommon commonPartObject) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(PersonauthoritiesCommon original,
+ PersonauthoritiesCommon updated) throws Exception {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ protected void verifyReadItemInstance(PersonsCommon item) throws Exception {
+ // Do nothing for now. Add more 'read' validation checks here if applicable.
+ }
}
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
\r
<!-- apache -->\r
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
- <classifier>jdk15</classifier>
</dependency>
</dependencies>
<args>
<arg>-Xannotate</arg>
<arg>-verbose</arg>
- <arg>-XtoString</arg>
+ <!-- <arg>-XtoString</arg> -->
<arg>-Xequals</arg>
<arg>-XhashCode</arg>
- <arg>-Xcopyable</arg>
+ <!-- <arg>-Xcopyable</arg> -->
</args>
<plugins>
<plugin>
</plugins>
</reporting>
+
<dependencyManagement>
<dependencies>
<dependency>
<groupId>net.java.dev.jaxb2-commons</groupId>
<artifactId>jaxb-fluent-api</artifactId>
<version>2.0.2</version>
- </dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <version>5.6</version>
- <scope>test</scope>
- <classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
\r
<!-- apache -->\r
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
<dependency>\r
<groupId>org.jboss.resteasy</groupId>\r
import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import org.slf4j.Logger;
* $LastChangedRevision$
* $LastChangedDate$
*/
-public class RelationServiceTest extends AbstractServiceTestImpl {
+public class RelationServiceTest extends AbstractPoxServiceTestImpl<RelationsCommonList, RelationsCommon> {
/** The logger. */
private final String CLASS_NAME = RelationServiceTest.class.getName();
private final String PERSON_AUTHORITY_NAME = "TestPersonAuth";
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
private List<String> personIdsCreated = new ArrayList<String>();
- private String samSubjectPersonCSID = null;
- private String oliveObjectPersonCSID = null;
- private String samSubjectRefName = null;
- private String oliveObjectRefName = null;
+
+ private static final String UNINITIALIZED_CSID = "-1";
+ private static final String UNINITIALIZED_REFNAME = "null";
+
+ private static final String PERSONS_DOCUMENT_TYPE = "Person";
+ private String samSubjectPersonCSID = UNINITIALIZED_CSID;
+ private String oliveObjectPersonCSID = UNINITIALIZED_REFNAME;
+ private String samSubjectRefName = UNINITIALIZED_CSID;
+ private String oliveObjectRefName = UNINITIALIZED_REFNAME;
+
private String personAuthCSID = null;
private String personShortId = PERSON_AUTHORITY_NAME;
/** The SERVICE path component. */
final String SERVICE_PATH_COMPONENT = "relations";
- /** The known resource id. */
- private String knownResourceId = null;
-
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
protected CollectionSpaceClient getClientInstance() {
return new RelationClient();
}
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(RelationsCommonList.class);
+
+ protected Class<RelationsCommonList> getCommonListType() {
+ return (Class<RelationsCommonList>)RelationsCommonList.class;
}
-
- // ---------------------------------------------------------------
- // CRUD tests : CREATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
+
+ /**
+ * Creates the person refs as a precondition for running the tests in this class.
*/
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
- @Override
- public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // 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).
+ @BeforeSuite
+ private void createPersonRefs() {
setupCreate();
- createPersonRefs();
- // Submit the request to the service and store the response.
- RelationClient client = new RelationClient();
- String identifier = createIdentifier();
- PoxPayloadOut multipart = createRelationInstance(identifier);
- ClientResponse<Response> res = client.create(multipart);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Store the ID returned from the first resource created
- // for additional tests below.
- if (knownResourceId == null){
- knownResourceId = extractId(res);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
- }
-
- // Store the IDs from every resource created by tests,
- // so they can be deleted after tests have been run.
- allResourceIdsCreated.add(extractId(res));
- }
-
- /**
- * Creates the person refs.
- */
- protected void createPersonRefs() {
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
ClientResponse<Response> res = personAuthClient.create(multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
personAuthCSID = extractId(res);
Assert.assertNotNull(oliveObjectRefName);
personIdsCreated.add(csid);
}
+
+ @AfterSuite
+ private void deletePersonRefs() {
+ //
+ // Delete all the persons we created for the tests
+ //
+ }
- protected String createPerson(String firstName, String surName, String shortId, String authRefName) {
+ private String createPerson(String firstName, String surName, String shortId, String authRefName) {
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
Map<String, String> personInfo = new HashMap<String, String>();
personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
int statusCode = res.getStatus();
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_CREATED);
return extractId(res);
- }
-
+ }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void createList(String testName) throws Exception {
- for(int i = 0; i < 3; i++){
- create(testName);
- }
- }
-
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ @Test(dataProvider="testName",
dependsOnMethods = {"create"})
public void createWithSelfRelation(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
+ // Test result codes setup
setupCreateWithInvalidBody();
// Submit the request to the service and store the response.
if(logger.isDebugEnabled()){
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, STATUS_BAD_REQUEST); //should be an error: same objectID and subjectID are not allowed by validator.
}
-
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- //Should this test really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
- */
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- //Should this test really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- //Should this test really be empty?
- }
-
- /*
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithEmptyEntityBody();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA; // Constant from base class.
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithWrongXmlSchema(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithWrongXmlSchema();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
- */
-
- // ---------------------------------------------------------------
- // CRUD tests : READ tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- RelationClient client = new RelationClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
-
- // Get the common part from the response and check that it is not null.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
- RelationsCommon relationCommon = null;
- if (payloadInputPart != null) {
- relationCommon = (RelationsCommon) payloadInputPart.getBody();
- }
- Assert.assertNotNull(relationCommon);
-
- }
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void readNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- RelationClient client = new RelationClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : READ_LIST tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
- public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadList();
-
- // Submit the request to the service and store the response.
- RelationClient client = new RelationClient();
- ClientResponse<RelationsCommonList> res = client.readList();
- assertStatusCode(res, testName);
- RelationsCommonList list = res.getEntity();
-
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = false;
- if(iterateThroughList && logger.isDebugEnabled()){
- List<RelationsCommonList.RelationListItem> items =
- list.getRelationListItem();
- int i = 0;
- for(RelationsCommonList.RelationListItem item : items){
- logger.debug(testName + ": list-item[" + i + "] csid=" +
- item.getCsid());
- logger.debug(testName + ": list-item[" + i + "] URI=" +
- item.getUri());
- i++;
- }
- }
-
- }
-
-
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
- public void readListPaginated(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadList();
-
- Long pageSize=1L;
- Long pageNumber=0L;
- RelationClient client = new RelationClient();
- ClientResponse<RelationsCommonList> res = client.readList("", //subjectCsid,
- "", //subjectType,
- "", //predicate,
- "", //objectCsid,
- "", //objectType,
- "", //sortBy,
- pageSize,
- pageNumber);
- RelationsCommonList list = res.getEntity();
- assertStatusCode(res, testName);
-
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = false;
- if(iterateThroughList && logger.isDebugEnabled()){
- List<RelationsCommonList.RelationListItem> items =
- list.getRelationListItem();
- int i = 0;
- for(RelationsCommonList.RelationListItem item : items){
- logger.debug(testName + ": list-item[" + i + "] csid=" +
- item.getCsid());
- logger.debug(testName + ": list-item[" + i + "] URI=" +
- item.getUri());
- i++;
- }
- }
-
- }
-
-
- // Failure outcomes
- // None at present.
-
- // ---------------------------------------------------------------
- // CRUD tests : UPDATE tests
- // ---------------------------------------------------------------
-
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void update(String testName) throws Exception {
-
- logger.debug(testBanner(testName, CLASS_NAME));
- // Perform setup.
- setupUpdate();
-
- // Retrieve an existing resource that we can update.
- RelationClient client = new RelationClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
- logger.debug("Got object to update with ID: " + knownResourceId);
-
- // Extract the common part and verify that it is not null.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
- RelationsCommon relationCommon = null;
- if (payloadInputPart != null) {
- relationCommon = (RelationsCommon) payloadInputPart.getBody();
- }
- Assert.assertNotNull(relationCommon);
- logger.trace("object before update");
- logger.trace(objectAsXmlString(relationCommon, RelationsCommon.class));
-
- String newSubjectDocType = relationCommon.getObjectDocumentType();
- String newObjectDocType = relationCommon.getSubjectDocumentType();
- String newSubjectId = relationCommon.getObjectCsid();
- String newObjectId = relationCommon.getSubjectCsid();
- // Update the content of this resource, inverting subject and object
- relationCommon.setSubjectCsid(newSubjectId);
- relationCommon.setSubjectDocumentType("Hooey");
- relationCommon.setObjectCsid(newObjectId);
- relationCommon.setObjectDocumentType("Fooey");
- relationCommon.setPredicateDisplayName("updated-" + relationCommon.getPredicateDisplayName());
- logger.trace("updated object to send");
- logger.trace(objectAsXmlString(relationCommon, RelationsCommon.class));
-
- // Submit the request containing the updated resource to the service
- // and store the response.
- PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());
- PayloadOutputPart commonPart = output.addPart(relationCommon, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
- res = client.update(knownResourceId, output);
- assertStatusCode(res, testName);
-
- // Extract the common part of the updated resource and verify that it is not null.
- input = new PoxPayloadIn(res.getEntity());
- RelationsCommon updatedRelationCommon =
- (RelationsCommon) extractPart(input,
- client.getCommonPartName(), RelationsCommon.class);
- Assert.assertNotNull(updatedRelationCommon);
-
- logger.trace("updated object as received");
- logger.trace(objectAsXmlString(updatedRelationCommon, RelationsCommon.class));
-
- final String msg =
- "Data in updated object did not match submitted data.";
- final String msg2 =
- "Data in updated object was not correctly computed.";
- Assert.assertEquals(
- updatedRelationCommon.getSubjectCsid(), newSubjectId, msg);
- Assert.assertEquals(
- updatedRelationCommon.getSubjectDocumentType(), newSubjectDocType, msg2);
- Assert.assertEquals(
- updatedRelationCommon.getObjectCsid(), newObjectId, msg);
- Assert.assertEquals(
- updatedRelationCommon.getObjectDocumentType(), newObjectDocType, msg2);
- Assert.assertEquals(
- updatedRelationCommon.getPredicateDisplayName(), relationCommon.getPredicateDisplayName(), msg);
-
- }
-
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- //Should this test really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
- */
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- //Should this test really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- //Should this test really be empty?
- }
-
- /*
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithEmptyEntityBody();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA; // Constant from abstract base class.
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithWrongXmlSchema(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithWrongXmlSchema();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA; // Constant from abstract base class.
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
- */
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateNonExistent();
-
- // 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 update(), below.
- RelationClient client = new RelationClient();
- PoxPayloadOut multipart = createRelationInstance(NON_EXISTENT_ID);
- ClientResponse<String> 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(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : DELETE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
- public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- // Submit the request to the service and store the response.
- RelationClient client = new RelationClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDeleteNonExistent();
-
- // Submit the request to the service and store the response.
- RelationClient client = new RelationClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // RELATE_OBJECT tests
- // ---------------------------------------------------------------
- /**
- * Relate objects.
- */
- @Test(dependsOnMethods = {"create"})
- public void relateObjects() {
- //Should this test really be empty?
- }
-
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
+
/**
- * Tests the code for manually submitting data that is used by several
- * of the methods above.
+ * This method is called by the base class method (test) readList().
+ * @param testName
+ * @param list
*/
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() {
-
- setupRead();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("testSubmitRequest: url=" + url +
- " status=" + statusCode);
+ @Override
+ protected void printList(String testName, RelationsCommonList list) {
+ List<RelationsCommonList.RelationListItem> items =
+ list.getRelationListItem();
+ int i = 0;
+ for(RelationsCommonList.RelationListItem item : items){
+ logger.debug(testName + ": list-item[" + i + "] csid=" +
+ item.getCsid());
+ logger.debug(testName + ": list-item[" + i + "] URI=" +
+ item.getUri());
+ i++;
}
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
}
// ---------------------------------------------------------------
private PoxPayloadOut createRelationInstance(RelationsCommon relation) {
PoxPayloadOut result = new PoxPayloadOut(this.getServicePathComponent());
PayloadOutputPart commonPart =
- result.addPart(relation, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(new RelationClient().getCommonPartName());
+ result.addPart(new RelationClient().getCommonPartName(), relation);
if(logger.isDebugEnabled()){
logger.debug("to be created, relation common");
logger.debug(objectAsXmlString(relation, RelationsCommon.class));
private void fillRelation(RelationsCommon relationCommon, String identifier) {
fillRelation(relationCommon, samSubjectPersonCSID, null, oliveObjectPersonCSID, null,
RelationshipType.COLLECTIONOBJECT_INTAKE.toString(),
- RelationshipType.COLLECTIONOBJECT_INTAKE + ".displayName");
+ RelationshipType.COLLECTIONOBJECT_INTAKE + ".displayName-" + identifier);
}
/**
protected String getServiceName() {
return RelationClient.SERVICE_NAME;
}
+
+ @Override
+ public void CRUDTests(String testName) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ return createRelationInstance(identifier);
+ }
+
+ @Override
+ protected RelationsCommon updateInstance(RelationsCommon relationCommon) {
+ RelationsCommon result = new RelationsCommon();
+
+ // Update the content of this resource, inverting subject and object
+ result.setSubjectCsid(relationCommon.getObjectCsid());
+ result.setSubjectDocumentType("Hooey"); // DocumentType changes should be ignored.
+ result.setObjectCsid(relationCommon.getSubjectCsid());
+ result.setObjectDocumentType("Fooey"); // DocumentType changes should be ignored.
+ result.setPredicateDisplayName("updated-" + relationCommon.getPredicateDisplayName());
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(RelationsCommon original,
+ RelationsCommon updated) throws Exception {
+ final String msg =
+ "Data in updated object did not match submitted data.";
+ final String msg2 =
+ "Data in updated object was not correctly computed.";
+ Assert.assertEquals(
+ updated.getSubjectCsid(), original.getSubjectCsid(), msg);
+ Assert.assertEquals(
+ updated.getSubjectDocumentType(), PERSONS_DOCUMENT_TYPE, msg2); // DocumentType changes should have been ignored.
+ Assert.assertEquals(
+ updated.getObjectCsid(), original.getObjectCsid(), msg);
+ Assert.assertEquals(
+ updated.getObjectDocumentType(), PERSONS_DOCUMENT_TYPE, msg2); // DocumentType changes should have been ignored.
+ Assert.assertEquals(
+ updated.getPredicateDisplayName(), original.getPredicateDisplayName(), msg);
+ }
}
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
\r
<dependency>\r
import org.collectionspace.services.common.ServiceMessages;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.document.DocumentHandler;
+import org.collectionspace.services.common.query.QueryManager;
import org.collectionspace.services.common.relation.IRelationsManager;
import org.collectionspace.services.common.relation.nuxeo.RelationsUtils;
import org.slf4j.Logger;
String relationClause = RelationsUtils.buildWhereClause(subjectCsid, subjectType, predicate, objectCsid, objectType);
handler.getDocumentFilter().appendWhereClause(relationClause, IQueryManager.SEARCH_QUALIFIER_AND);
+ //
+ // Handle keyword clause
+ //
+ String keywords = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW);
+ if (keywords != null && keywords.isEmpty() == false) {
+ String keywordClause = QueryManager.createWhereClauseFromKeywords(keywords);
+ handler.getDocumentFilter().appendWhereClause(keywordClause, IQueryManager.SEARCH_QUALIFIER_AND);
+ }
+
return (RelationsCommonList)finish_getList(ctx, handler);
} catch (Exception e) {
throw bigReThrow(e, ServiceMessages.LIST_FAILED);
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
<dependency>\r
<groupId>org.jboss.resteasy</groupId>\r
return ReportProxy.class;
}
+ /*
+ * Proxied service calls
+ */
+
/**
* @return
* @see org.collectionspace.services.client.ReportProxy#getReport()
import java.util.ArrayList;
import java.util.List;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.CollectionSpaceClient;
-import org.collectionspace.services.client.PayloadInputPart;
import org.collectionspace.services.client.PayloadOutputPart;
-import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.ReportClient;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.report.ReportsCommon;
import org.collectionspace.services.jaxb.AbstractCommonList;
* $LastChangedRevision: 2261 $
* $LastChangedDate: 2010-05-28 16:52:22 -0700 (Fri, 28 May 2010) $
*/
-public class ReportServiceTest extends AbstractServiceTestImpl {
+public class ReportServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, ReportsCommon> {
/** The logger. */
private final String CLASS_NAME = ReportServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
final String SERVICE_NAME = "reports";
final String SERVICE_PATH_COMPONENT = "reports";
- // Instance variables specific to this test.
- /** The known resource id. */
- private String knownResourceId = null;
-
+ // Instance variables specific to this test.
private String testDocType = "Acquisition";
/* (non-Javadoc)
protected CollectionSpaceClient getClientInstance() {
return new ReportClient();
}
-
-// @Override
-// protected PoxPayloadOut createInstance(String identifier) {
-// PoxPayloadOut multipart = createReportInstance(identifier);
-// return multipart;
-// }
-
- // ---------------------------------------------------------------
- // CRUD tests : CREATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // 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();
-
- // Submit the request to the service and store the response.
- ReportClient client = new ReportClient();
- String identifier = createIdentifier();
- PoxPayloadOut multipart = createReportInstance(identifier);
- ClientResponse<Response> res = client.create(multipart);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Store the ID returned from the first resource created
- // for additional tests below.
- if (knownResourceId == null) {
- knownResourceId = extractId(res);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
- }
-
- // Store the IDs from every resource created by tests,
- // so they can be deleted after tests have been run.
- allResourceIdsCreated.add(extractId(res));
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void createList(String testName) throws Exception {
- for (int i = 0; i < 3; i++) {
- create(testName);
- }
- }
-
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
- */
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty?
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : READ tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- ReportClient client = new ReportClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
-
- // Get the common part of the response and verify that it is not null.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
- ReportsCommon reportCommon = null;
- if (payloadInputPart != null) {
- reportCommon = (ReportsCommon) payloadInputPart.getBody();
- }
- Assert.assertNotNull(reportCommon);
-
- // Check the values of fields containing Unicode UTF-8 (non-Latin-1) characters.
- if (logger.isDebugEnabled()) {
- logger.debug("UTF-8 data sent=" + getUTF8DataFragment() + "\n"
- + "UTF-8 data received=" + reportCommon.getNotes());
- }
- Assert.assertEquals(reportCommon.getNotes(), getUTF8DataFragment(),
- "UTF-8 data retrieved '" + reportCommon.getNotes()
- + "' does not match expected data '" + getUTF8DataFragment());
- }
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void readNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- ReportClient client = new ReportClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : READ_LIST tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
- public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadList();
-
- // Submit the request to the service and store the response.
- ReportClient client = new ReportClient();
- ClientResponse<AbstractCommonList> res = client.readList();
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
-
- // Optionally output additional data about list members for debugging.
- if(logger.isTraceEnabled()){
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
- }
-
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"readList"})
+
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"CRUDTests"})
public void readListFiltered(String testName) throws Exception {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupReadList();
// Submit the request to the service and store the response.
ReportClient client = new ReportClient();
- ClientResponse<AbstractCommonList> res = client.readListFiltered(
- testDocType, "single");
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
-
- List<AbstractCommonList.ListItem> items =
- list.getListItem();
+ ClientResponse<AbstractCommonList> res = client.readListFiltered(testDocType, "single");
+ AbstractCommonList list = null;
+ try {
+ assertStatusCode(res, testName);
+ list = res.getEntity();
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
+ List<AbstractCommonList.ListItem> items = list.getListItem();
// We must find the basic one we created
boolean fFoundBaseItem = false;
for (AbstractCommonList.ListItem item : items) {
- if(knownResourceId.equalsIgnoreCase(AbstractCommonListUtils.ListItemGetCSID(item))) {
+ String itemCsid = AbstractCommonListUtils.ListItemGetCSID(item);
+ if (knownResourceId.equalsIgnoreCase(itemCsid)) {
fFoundBaseItem = true;
break;
}
}
- if(!fFoundBaseItem)
+ if(!fFoundBaseItem) {
Assert.fail("readListFiltered failed to return base item");
+ }
// Now filter for something else, and ensure it is NOT returned
res = client.readListFiltered("Intake", "single");
- assertStatusCode(res, testName);
- list = res.getEntity();
+ try {
+ assertStatusCode(res, testName);
+ list = res.getEntity();
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
items = list.getListItem();
// We must NOT find the basic one we created
// Now filter for something else, and ensure it is NOT returned
res = client.readListFiltered(testDocType, "group");
- assertStatusCode(res, testName);
- list = res.getEntity();
+ try {
+ assertStatusCode(res, testName);
+ list = res.getEntity();
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
items = list.getListItem();
// We must NOT find the basic one we created
}
}
- // ---------------------------------------------------------------
- // CRUD tests : UPDATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read", "readListFiltered"})
- public void update(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
-
- // Retrieve the contents of a resource to update.
- ReportClient client = new ReportClient();
- ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
- if (logger.isDebugEnabled()) {
- logger.debug("got object to update with ID: " + knownResourceId);
- }
-
- // Extract the common part from the response.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
- ReportsCommon reportCommon = null;
- if (payloadInputPart != null) {
- reportCommon = (ReportsCommon) payloadInputPart.getBody();
- }
- Assert.assertNotNull(reportCommon);
-
- // Update its content.
- reportCommon.setName("updated-" + reportCommon.getName());
- reportCommon.setOutputMIME("updated-" + reportCommon.getOutputMIME());
- if (logger.isDebugEnabled()) {
- logger.debug("to be updated object");
- logger.debug(objectAsXmlString(reportCommon, ReportsCommon.class));
- }
- reportCommon.setNotes("updated-" + reportCommon.getNotes());
-
- // Submit the updated common part in an update request to the service
- // and store the response.
- PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());
- PayloadOutputPart commonPart = output.addPart(reportCommon, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
- res = client.update(knownResourceId, output);
- assertStatusCode(res, testName);
-
- // Extract the updated common part from the response.
- input = new PoxPayloadIn(res.getEntity());
- payloadInputPart = input.getPart(client.getCommonPartName());
- ReportsCommon updatedReportCommon = null;
- if (payloadInputPart != null) {
- updatedReportCommon = (ReportsCommon) payloadInputPart.getBody();
- }
- Assert.assertNotNull(updatedReportCommon);
- if (logger.isDebugEnabled()) {
- logger.debug("updated object");
- logger.debug(objectAsXmlString(updatedReportCommon, ReportsCommon.class));
- }
-
- // Check selected fields in the updated common part.
- Assert.assertEquals(updatedReportCommon.getName(),
- reportCommon.getName(),
- "Data in updated object did not match submitted data.");
-
- // Check the values of fields containing Unicode UTF-8 (non-Latin-1) characters.
- if (logger.isDebugEnabled()) {
- logger.debug("UTF-8 data sent=" + reportCommon.getNotes() + "\n"
- + "UTF-8 data received=" + updatedReportCommon.getNotes());
- }
- Assert.assertTrue(updatedReportCommon.getNotes().contains(getUTF8DataFragment()),
- "UTF-8 data retrieved '" + updatedReportCommon.getNotes()
- + "' does not contain expected data '" + getUTF8DataFragment());
- Assert.assertEquals(updatedReportCommon.getNotes(),
- reportCommon.getNotes(),
- "Data in updated object did not match submitted data.");
- }
-
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
- */
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- //Should this really be empty?
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateNonExistent();
-
- // 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 update(), below.
- ReportClient client = new ReportClient();
- PoxPayloadOut multipart = createReportInstance(NON_EXISTENT_ID);
- ClientResponse<String> 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(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : DELETE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
+ /**
+ * This method overrides the delete method in the base class which is marked with the TestNG @Test annotation.
+ * Since we don't want the actually delete test to happen until later in the dependency test chain, we're make this
+ * an empty method. Later in the test suite, the method localDelete() will get called and it will call super.delete()
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "readListFiltered", "testSubmitRequest", "update", "readWorkflow"})
public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- // Submit the request to the service and store the response.
- ReportClient client = new ReportClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDeleteNonExistent();
-
- // Submit the request to the service and store the response.
- ReportClient client = new ReportClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ //
+ // Do nothing for now. The test localDelete() will get called later in the dependency chain.
+ //
}
-
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
+
/**
- * Tests the code for manually submitting data that is used by several
- * of the methods above.
+ * This test will delete the known resource after the test readListFiltered() is run
*/
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() {
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testSubmitRequest: url=" + url
- + " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"readListFiltered"})
+ public void localDelete(String testName) throws Exception {
+ super.delete(testName);
}
// ---------------------------------------------------------------
List<String> docTypes = new ArrayList<String>();
docTypes.add(testDocType);
return createReportInstance(
- "Acquisition Summary",
+ "Acquisition Summary " + identifier,
docTypes, true, false, false, true,
"acq_basic.jasper",
"application/pdf");
PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
PayloadOutputPart commonPart =
- multipart.addPart(reportCommon, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(new ReportClient().getCommonPartName());
+ multipart.addPart(new ReportClient().getCommonPartName(), reportCommon);
if (logger.isDebugEnabled()) {
logger.debug("to be created, report common");
return multipart;
}
+
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ PoxPayloadOut result = createReportInstance(identifier);
+ return result;
+ }
+
+ @Override
+ protected ReportsCommon updateInstance(ReportsCommon reportsCommon) {
+ ReportsCommon result = new ReportsCommon();
+
+ result.setSupportsSingleDoc(true);
+ result.setName("updated-" + reportsCommon.getName());
+ result.setOutputMIME("updated-" + reportsCommon.getOutputMIME());
+ result.setNotes("updated-" + reportsCommon.getNotes());
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(ReportsCommon original,
+ ReportsCommon updated) throws Exception {
+ // Check selected fields in the updated common part.
+ Assert.assertEquals(updated.getName(),
+ original.getName(),
+ "Name in updated object did not match submitted data.");
+
+ // Check the values of fields containing Unicode UTF-8 (non-Latin-1) characters.
+ if (logger.isDebugEnabled()) {
+ logger.debug("UTF-8 data sent=" + original.getNotes() + "\n"
+ + "UTF-8 data received=" + updated.getNotes());
+ }
+ Assert.assertTrue(updated.getNotes().contains(getUTF8DataFragment()),
+ "UTF-8 data retrieved '" + updated.getNotes()
+ + "' does not contain expected data '" + getUTF8DataFragment());
+ Assert.assertEquals(updated.getNotes(),
+ original.getNotes(),
+ "Notes in updated object did not match submitted data.");
+ }
+
+ protected void compareReadInstances(ReportsCommon original, ReportsCommon fromRead) throws Exception {
+ Assert.assertEquals(fromRead.getNotes(), getUTF8DataFragment(),
+ "UTF-8 data retrieved '" + fromRead.getNotes()
+ + "' does not match expected data '" + getUTF8DataFragment());
+ }
+
+ /*
+ * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
+ * refer to this method in their @Test annotation declarations.
+ */
+ @Override
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {
+ "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
+ public void CRUDTests(String testName) {
+ // TODO Auto-generated method stub
+ }
}
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
\r
<!-- javax -->\r
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
<dependency>\r
<groupId>org.jboss.resteasy</groupId>\r
package org.collectionspace.services.security.client.test;
import java.util.List;
-
import javax.ws.rs.core.Response;
-
-//import org.apache.commons.codec.binary.Base64;
import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
import org.testng.Assert;
import org.testng.annotations.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.collectionspace.services.account.AccountTenant;
import org.collectionspace.services.account.AccountsCommon;
import org.collectionspace.services.client.CollectionObjectFactory;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.client.test.AbstractServiceTestImpl;
import org.collectionspace.services.client.test.BaseServiceTest;
import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
import org.collectionspace.services.collectionobject.TitleGroup;
import org.collectionspace.services.collectionobject.TitleGroupList;
import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* AuthenticationServiceTest uses CollectionObject service to test
* authentication
* $LastChangedRevision: 434 $ $LastChangedDate: 2009-07-28 14:34:15 -0700 (Tue,
* 28 Jul 2009) $
*/
-public class AuthenticationServiceTest extends AbstractServiceTestImpl {
+public class AuthenticationServiceTest extends BaseServiceTest<AbstractCommonList> {
+ private final Logger logger = LoggerFactory.getLogger(AuthenticationServiceTest.class);
/** The known resource id. */
- private String knownResourceId = null;
private String barneyAccountId = null; //active
private String georgeAccountId = null; //inactive
/** The logger. */
private final String CLASS_NAME = AuthenticationServiceTest.class.getName();
- private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTest#getServicePathComponent()
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
+ protected AbstractCommonList getCommonList(
ClientResponse<AbstractCommonList> response) {
throw new UnsupportedOperationException(); //Since this test does not support lists, this method is not needed.
}
@Test(dataProvider = "testName")
- @Override
- public void readPaginatedList(String testName) throws Exception {
- // Test not supported.
- }
-
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
public void createActiveAccount(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// 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).
if (logger.isDebugEnabled()) {
logger.debug(testName + ": barney status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Store the ID returned from this create operation
// for additional tests below.
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+ @Test(dataProvider = "testName")
public void createInactiveAccount(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupCreate();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": george status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
// Store the ID returned from this create operation
// for additional tests below.
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
res1.releaseConnection();
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTest#create()
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createActiveAccount"})
- @Override
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"createActiveAccount"})
public void create(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
+
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
collectionObjectClient.setAuth(true, "barney", true, "barney08", true);
- String identifier = BaseServiceTest.createIdentifier();
+ String identifier = createIdentifier();
PoxPayloadOut multipart = createCollectionObjectInstance(
collectionObjectClient.getCommonPartName(), identifier);
ClientResponse<Response> res = collectionObjectClient.create(multipart);
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createActiveAccount"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"createActiveAccount"})
public void createWithoutAuthn(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
+
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
String user = collectionObjectClient.getProperty(collectionObjectClient.USER_PROPERTY);
String pass = collectionObjectClient.getProperty(collectionObjectClient.PASSWORD_PROPERTY);
collectionObjectClient.setAuth(false, user, true, pass, true);
- String identifier = BaseServiceTest.createIdentifier();
+ String identifier = createIdentifier();
PoxPayloadOut multipart = createCollectionObjectInstance(
collectionObjectClient.getCommonPartName(), identifier);
ClientResponse<Response> res = collectionObjectClient.create(multipart);
}
- @Test(dataProvider = "testName", dependsOnMethods = {"createInactiveAccount"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"createInactiveAccount"})
public void createWithInactiveAccount(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName));
- }
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
collectionObjectClient.setAuth(true, "george", true, "george08", true);
- String identifier = BaseServiceTest.createIdentifier();
+ String identifier = createIdentifier();
PoxPayloadOut multipart = createCollectionObjectInstance(
collectionObjectClient.getCommonPartName(), identifier);
/**
* Creates the collection object instance without password.
*/
- @Test(dataProvider = "testName", dependsOnMethods = {"createActiveAccount"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"createActiveAccount"})
public void createWithoutPassword(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName));
- }
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
String user = collectionObjectClient.getProperty(collectionObjectClient.USER_PROPERTY);
collectionObjectClient.setAuth(true, user, true, "", false);
- String identifier = BaseServiceTest.createIdentifier();
+ String identifier = createIdentifier();
PoxPayloadOut multipart = createCollectionObjectInstance(
collectionObjectClient.getCommonPartName(), identifier);
ClientResponse<Response> res = collectionObjectClient.create(multipart);
/**
* Creates the collection object with unknown user
*/
- @Test(dataProvider = "testName", dependsOnMethods = {"createActiveAccount"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"createActiveAccount"})
public void createWithUnknownUser(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName));
- }
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
collectionObjectClient.setAuth(true, "foo", true, "bar", true);
- String identifier = BaseServiceTest.createIdentifier();
+ String identifier = createIdentifier();
PoxPayloadOut multipart = createCollectionObjectInstance(
collectionObjectClient.getCommonPartName(), identifier);
ClientResponse<Response> res = collectionObjectClient.create(multipart);
/**
* Creates the collection object instance with incorrect password.
*/
- @Test(dataProvider = "testName", dependsOnMethods = {"createActiveAccount"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"createActiveAccount"})
public void createWithIncorrectPassword(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName));
- }
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
String user = collectionObjectClient.getProperty(collectionObjectClient.USER_PROPERTY);
collectionObjectClient.setAuth(true, user, true, "bar", true);
- String identifier = BaseServiceTest.createIdentifier();
+ String identifier = createIdentifier();
PoxPayloadOut multipart = createCollectionObjectInstance(
collectionObjectClient.getCommonPartName(), identifier);
ClientResponse<Response> res = collectionObjectClient.create(multipart);
*/
@Test(dataProvider = "testName", dependsOnMethods = {"createActiveAccount"})
public void createWithIncorrectUserPassword(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName));
- }
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
collectionObjectClient.setAuth(true, "foo", true, "bar", true);
- String identifier = BaseServiceTest.createIdentifier();
+ String identifier = createIdentifier();
PoxPayloadOut multipart = createCollectionObjectInstance(
collectionObjectClient.getCommonPartName(), identifier);
ClientResponse<Response> res = collectionObjectClient.create(multipart);
*/
@Test(dataProvider = "testName", dependsOnMethods = {"createActiveAccount"})
public void createWithoutTenant(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName));
- }
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
collectionObjectClient.setAuth(true, "babybop", true, "babybop09", true);
- String identifier = BaseServiceTest.createIdentifier();
+ String identifier = createIdentifier();
PoxPayloadOut multipart = createCollectionObjectInstance(
collectionObjectClient.getCommonPartName(), identifier);
ClientResponse<Response> res = collectionObjectClient.create(multipart);
res.releaseConnection();
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTest#delete()
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void delete(String testName) {
- setupDelete();
-
- }
-
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "createWithInactiveAccount"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"create", "createWithInactiveAccount"})
public void deleteAccounts(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupDelete();
AccountClient accountClient = new AccountClient();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": barney status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
res = accountClient.delete(georgeAccountId);
statusCode = res.getStatus();
if (logger.isDebugEnabled()) {
logger.debug(testName + ": george status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
res.releaseConnection();
}
- // ---------------------------------------------------------------
- // Search tests
- // ---------------------------------------------------------------
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void searchWorkflowDeleted(String testName) throws Exception {
- // Fixme: null test for now, overriding test in base class
- }
-
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTest#createList()
- */
- @Override
- public void createList(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTest#createWithEmptyEntityBody()
- */
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTest#createWithMalformedXml()
- */
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTest#createWithWrongXmlSchema()
- */
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTest#read()
- */
- @Override
- public void read(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTest#readNonExistent()
- */
- @Override
- public void readNonExistent(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTest#readList()
- */
- @Override
- public void readList(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTest#update()
- */
- @Override
- public void update(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTest#updateWithEmptyEntityBody()
- */
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTest#updateWithMalformedXml()
- */
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTest#updateWithWrongXmlSchema()
- */
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTest#updateNonExistent()
- */
- @Override
- public void updateNonExistent(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTest#deleteNonExistent()
- */
- @Override
- public void deleteNonExistent(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
+ @Override
+ protected Class<AbstractCommonList> getCommonListType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
import java.util.Date;
import java.util.Hashtable;
import java.util.List;
+
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.jboss.resteasy.client.ClientResponse;
+
import org.collectionspace.services.account.AccountsCommon;
import org.collectionspace.services.authorization.AccountRole;
import org.collectionspace.services.authorization.AccountValue;
import org.collectionspace.services.authorization.perms.ActionType;
import org.collectionspace.services.authorization.perms.EffectType;
-
import org.collectionspace.services.authorization.perms.Permission;
import org.collectionspace.services.authorization.perms.PermissionAction;
import org.collectionspace.services.authorization.PermissionRole;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.RoleClient;
import org.collectionspace.services.client.RoleFactory;
-import org.collectionspace.services.client.test.AbstractServiceTestImpl;
+import org.collectionspace.services.client.test.BaseServiceTest;
import org.collectionspace.services.dimension.DimensionsCommon;
import org.collectionspace.services.intake.IntakesCommon;
import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.testng.Assert;
import org.testng.annotations.Test;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
/**
* AuthorizationServiceTest, carries out tests against a
* $LastChangedRevision: 917 $
* $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
*/
-public class AuthorizationServiceTest extends AbstractServiceTestImpl {
+public class AuthorizationServiceTest extends BaseServiceTest<AbstractCommonList> {
private final String CLASS_NAME = AuthorizationServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
// Instance variables specific to this test.
- private String knownResourceId = null;
- private List<String> allResourceIdsCreated = new ArrayList();
- //key for accValues is userId
private Hashtable<String, AccountValue> accValues = new Hashtable<String, AccountValue>();
//key for permValues is id as there could be several perms for the same resource
private Hashtable<String, PermissionValue> permValues = new Hashtable<String, PermissionValue>();
*/
@Override
protected CollectionSpaceClient getClientInstance() {
+ // This method is meaningless to this test.
return null;
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
- throw new UnsupportedOperationException();
- }
-
- @Test(dataProvider = "testName")
- @Override
- public void readPaginatedList(String testName) throws Exception {
- //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
- }
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
// Success outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+ @Test(dataProvider = "testName")
public void create(String testName) throws Exception {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
// Submit the request to the service and store the response.
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.CREATED.getStatusCode());
knownResourceId = extractId(res);
if (logger.isDebugEnabled()) {
if (logger.isDebugEnabled()) {
logger.debug(testName + " (verify not allowed): status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
//Finally, verify that elmo has no access to Intakes
if (logger.isDebugEnabled()) {
logger.debug(testName + " (verify create intake not allowed): status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
}
return multipart;
}
-
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ @Test(dataProvider = "testName",
dependsOnMethods = {"delete"})
public void verifyCreateWithFlippedRoles(String testName) throws Exception {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreate();
// Submit the request to the service and store the response.
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.CREATED.getStatusCode());
knownResourceId = extractId(res);
if (logger.isDebugEnabled()) {
if (logger.isDebugEnabled()) {
logger.debug(testName + " (verify not allowed): status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
restoreInitialAccountRoles();
}
- //to not cause uniqueness violation for permRole, createList is removed
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void createList(String testName) throws Exception {
- }
-
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- }
-
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- }
-
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- }
-
// ---------------------------------------------------------------
// CRUD tests : READ tests
// ---------------------------------------------------------------
// Success outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"create"})
public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupRead();
//elmo allowed to read
client.setAuth(true, "elmo2010", true, "elmo2010", true);
ClientResponse<String> res = client.read(knownResourceId);
- assertStatusCode(res, testName);
-
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- DimensionsCommon dimension = (DimensionsCommon) extractPart(input,
- client.getCommonPartName(), DimensionsCommon.class);
- Assert.assertNotNull(dimension);
+ try {
+ assertStatusCode(res, testName);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ DimensionsCommon dimension = (DimensionsCommon) extractPart(input,
+ client.getCommonPartName(), DimensionsCommon.class);
+ Assert.assertNotNull(dimension);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
+ @Test(dataProvider = "testName",
dependsOnMethods = {"read"})
public void readLockedOut(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
- setupRead();
+ setupForbidden();
// Submit the request to the service and store the response.
DimensionClient client = new DimensionClient();
//lockedOut allowed to read
client.setAuth(true, "lockedOut", true, "lockedOut", true);
ClientResponse<String> res = client.read(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + " (test lockedOut): status = " + statusCode);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
- }
-
- // Failure outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void readNonExistent(String testName) throws Exception {
-
- // Perform setup.
- setupReadNonExistent();
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : READ_LIST tests
- // ---------------------------------------------------------------
- // Success outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
- public void readList(String testName) throws Exception {
- setupReadList();
- }
-
- // Failure outcomes
- // None at present.
- // ---------------------------------------------------------------
- // CRUD tests : UPDATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read", "readList", "readNonExistent"})
- public void update(String testName) throws Exception {
- setupUpdate();
-
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read", "readList", "readNonExistent"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"read"})
public void updateNotAllowed(String testName) throws Exception {
+ setupForbidden();
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- setupUpdate();
-
+ // Create a new client and change its AuthN credentials
DimensionClient client = new DimensionClient();
-
//elmo not allowed to update
client.setAuth(true, "elmo2010", true, "elmo2010", true);
-
+ //
+ // Create a new dimension object
+ //
DimensionsCommon dimension = new DimensionsCommon();
dimension.setDimension("dimensionType");
// Update the content of this resource.
dimension.setMeasurementUnit("updated-" + dimension.getMeasurementUnit());
dimension.setValueDate("updated-" + dimension.getValueDate());
- // Submit the request to the service and store the response.
+ //
+ // Create and submit the request to the service and store the response.
+ //
PoxPayloadOut output = new PoxPayloadOut(DimensionClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(dimension, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
-
+ PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), dimension);
ClientResponse<String> 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(testName + ": status = " + statusCode);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
-
+ //
+ // Create another new client with new credentials
+ //
client = new DimensionClient();
-
//lockedOut not allowed to update
client.setAuth(true, "lockedOut", true, "lockedOut", true);
+ //
+ // Try the update again.
+ //
res = client.update(knownResourceId, output);
- statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": (lockedOut) status = " + statusCode);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
}
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- }
-
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- }
-
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
- public void updateNonExistent(String testName) throws Exception {
- }
-
// ---------------------------------------------------------------
// CRUD tests : DELETE tests
// ---------------------------------------------------------------
// Success outcomes
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"updateNotAllowed"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"updateNotAllowed"})
public void deleteNotAllowed(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
- setupDelete();
-
- // Submit the request to the service and store the response.
+ setupForbidden();
+ //
+ // Create a new client and change the AuthN credentials
+ //
DimensionClient client = new DimensionClient();
//bigbird can not delete
client.setAuth(true, "bigbird2010", true, "bigbird2010", true);
+ //
+ // Try to make a DELETE request
+ //
ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
-
}
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"deleteNotAllowed"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"deleteNotAllowed"})
public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
setupDelete();
DimensionClient client = new DimensionClient();
ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- }
-
- // Failure outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void deleteNonExistent(String testName) throws Exception {
- //ignoring this test as the service side returns 200 now even if it does
- //not find a record in the db
- }
-
- // ---------------------------------------------------------------
- // Search tests
- // ---------------------------------------------------------------
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void searchWorkflowDeleted(String testName) throws Exception {
- // Fixme: null test for now, overriding test in base class
- }
-
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
- /**
- * Tests the code for manually submitting data that is used by several
- * of the methods above.
- */
- @Test(dependsOnMethods = {"create"})
- public void testSubmitRequest() throws Exception {
}
// ---------------------------------------------------------------
}
private void deletePermissionRoles() {
-
List<RoleValue> bigbirdRoleValues = new ArrayList<RoleValue>();
bigbirdRoleValues.add(roleValues.get("ROLE_TEST_CM"));
deletePermissionRole(permValues.get(bigbirdPermId), bigbirdRoleValues);
List<RoleValue> elmoRoleValues = new ArrayList<RoleValue>();
elmoRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
deletePermissionRole(permValues.get(elmoPermId), elmoRoleValues);
-
}
private void deleteAccountRoles() {
}
}
-
-
private void deletePermissions() {
//delete entities
for (PermissionValue pv : permValues.values()) {
private String createPermission(String resName,
List<PermissionAction> actions, EffectType effect) {
+ String result = null;
+
setupCreate();
PermissionClient permClient = new PermissionClient();
Permission permission = PermissionFactory.createPermissionInstance(resName,
- "default permissions for " + resName,
- actions, effect, true, true, true);
+ "default permissions for " + resName, actions, effect, true, true, true);
ClientResponse<Response> res = permClient.create(permission);
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug("createPermission: resName=" + resName
- + " status = " + statusCode);
+ try {
+ assertStatusCode(res, "CreatePermission");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
- return extractId(res);
+
+ return result;
}
private void deletePermission(String permId) {
setupDelete();
PermissionClient permClient = new PermissionClient();
ClientResponse<Response> res = permClient.delete(permId);
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug("deletePermission: delete permission id="
- + permId + " status=" + statusCode);
+ try {
+ assertStatusCode(res, "DeletePermission");
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
}
private String createRole(String roleName) {
+ String result = null;
+
setupCreate();
RoleClient roleClient = new RoleClient();
-
Role role = RoleFactory.createRoleInstance(roleName,
roleName, //the display name
"role for " + roleName, true);
ClientResponse<Response> res = roleClient.create(role);
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug("createRole: name=" + roleName
- + " status = " + statusCode);
+ try {
+ assertStatusCode(res, "CreateRole");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
- return extractId(res);
+
+ return result;
}
private void deleteRole(String roleId) {
setupDelete();
RoleClient roleClient = new RoleClient();
ClientResponse<Response> res = roleClient.delete(roleId);
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug("deleteRole: delete role id=" + roleId
- + " status=" + statusCode);
+ try {
+ assertStatusCode(res, "DeleteRole");
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
}
private String createAccount(String userName, String email) {
+ String result = null;
+
setupCreate();
AccountClient accountClient = new AccountClient();
AccountsCommon account = AccountFactory.createAccountInstance(
userName, userName, userName, email, accountClient.getTenantId(),
true, false, true, true);
ClientResponse<Response> res = accountClient.create(account);
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug("createAccount: userName=" + userName
- + " status = " + statusCode);
+ try {
+ assertStatusCode(res, "CreateAccount");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
- return extractId(res);
+
+ return result;
}
private void deleteAccount(String accId) {
setupDelete();
AccountClient accClient = new AccountClient();
ClientResponse<Response> res = accClient.delete(accId);
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug("deleteAccount: delete account id="
- + accId + " status=" + statusCode);
+ try {
+ assertStatusCode(res, "DeleteAccount");
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
}
private String createAccountRole(AccountValue av,
Collection<RoleValue> rvs) {
+ String result = null;
+
setupCreate();
-
// Submit the request to the service and store the response.
AccountRole accRole = AccountRoleFactory.createAccountRoleInstance(
av, rvs, true, true);
AccountRoleClient client = new AccountRoleClient();
ClientResponse<Response> res = client.create(av.getAccountId(), accRole);
- int statusCode = res.getStatus();
-
- if (logger.isDebugEnabled()) {
- logger.debug("createAccountRole: status = " + statusCode);
+ try {
+ assertStatusCode(res, "CreateAccountRole");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
- return extractId(res);
+
+ return result;
}
private void deleteAccountRole(AccountValue av,
AccountRoleClient client = new AccountRoleClient();
AccountRole accRole = AccountRoleFactory.createAccountRoleInstance(
av, rvs, true, true);
- ClientResponse<Response> res = client.delete(
- av.getAccountId());
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("deleteAccountRole: status = " + statusCode);
+ ClientResponse<Response> res = client.delete(av.getAccountId());
+ try {
+ assertStatusCode(res, "DeleteAccountRole");
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
}
- private String createPermissionRole(PermissionValue pv,
- Collection<RoleValue> rvs) {
+ private String createPermissionRole(PermissionValue pv, Collection<RoleValue> rvs) {
+ String result = null;
+
setupCreate();
List<RoleValue> rvls = new ArrayList<RoleValue>();
rvls.addAll(rvs);
pv, rvls, true, true);
PermissionRoleClient client = new PermissionRoleClient();
ClientResponse<Response> res = client.create(pv.getPermissionId(), permRole);
- int statusCode = res.getStatus();
-
- if (logger.isDebugEnabled()) {
- logger.debug("createPermissionRole: status = " + statusCode);
+ try {
+ assertStatusCode(res, "CreatePermissionRole");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
- return extractId(res);
+
+ return result;
}
private void deletePermissionRole(PermissionValue pv,
PermissionRole permRole = PermissionRoleFactory.createPermissionRoleInstance(
pv, rvls, true, true);
ClientResponse<Response> res = client.delete(pv.getPermissionId());
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("deletePermissionRole : status = " + statusCode);
+ try {
+ assertStatusCode(res, "DeletePermissionRole");
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
}
+
+ @Override
+ protected Class<AbstractCommonList> getCommonListType() {
+ throw new UnsupportedOperationException();
+ }
}
import java.util.Date;
import java.util.Hashtable;
import java.util.List;
-import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.collectionspace.services.account.AccountsCommon;
import org.collectionspace.services.authorization.AccountRole;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.RoleClient;
import org.collectionspace.services.client.RoleFactory;
-import org.collectionspace.services.client.test.AbstractServiceTestImpl;
+import org.collectionspace.services.client.test.BaseServiceTest;
import org.collectionspace.services.dimension.DimensionsCommon;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.testng.Assert;
import org.testng.annotations.Test;
* $LastChangedRevision: 917 $
* $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
*/
-public class MultiTenancyTest extends AbstractServiceTestImpl {
+public class MultiTenancyTest extends BaseServiceTest<AbstractCommonList> {
+ private static class UserInfo {
+ String userName;
+ String password;
+
+ UserInfo(String u, String p) {
+ userName = u;
+ password = p;
+ }
+ }
+
private final String CLASS_NAME = MultiTenancyTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
private final static String TENANT_1_ADMIN_USER = "admin@core.collectionspace.org";
private final static String TEST_ROLE_NAME = "ROLE_TEST_REGISTRAR";
private final static String TEST_SERVICE_A = "dimensions";
- private static class UserInfo {
-
- String userName;
- String password;
-
- UserInfo(String u, String p) {
- userName = u;
- password = p;
- }
- }
// Instance variables specific to this test.
private String TENANT_RESOURCE_1 = null;
private String TENANT_RESOURCE_2 = null;
- private List<String> allResourceIdsCreated = new ArrayList();
//key for userAccounts is userId
private Hashtable<String, AccountValue> userAccounts = new Hashtable<String, AccountValue>();
//key for permValues is id as there could be several perms for the same resource
private Hashtable<String, Role> tenantAdminRoles = new Hashtable<String, Role>();
private Hashtable<String, PermissionValue> tenantPermissions = new Hashtable<String, PermissionValue>();
-// private String permId1;
-// private String permId2;
-
/*
* This method is called only by the parent class, AbstractServiceTestImpl
*/
@BeforeClass(alwaysRun = true)
public void seedData() {
- if (logger.isDebugEnabled()) {
- testBanner("seedData", CLASS_NAME);
- }
-
//tenant admin users are used to create accounts, roles and permissions and relationships
//assumption : two tenant admin users exist before running this test
tenantAdminUsers.put(TENANT_1, new UserInfo(TENANT_1_ADMIN_USER, TENANT_ADMIN_PASS));
}
private void seedAccountRoles() {
-
for (String tenantId : tenantAccounts.keySet()) {
AccountValue av = (AccountValue) tenantAccounts.get(tenantId);
seedAccountRole(tenantId, av.getUserId());
}
private void seedPermissionRoles() {
-
for (String tenantId : tenantPermissions.keySet()) {
PermissionValue pv = tenantPermissions.get(tenantId);
seedPermissionRole(tenantId, pv.getPermissionId());
}
}
-
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
+ protected AbstractCommonList getCommonList(
ClientResponse<AbstractCommonList> response) {
//FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
throw new UnsupportedOperationException();
}
- @Test(dataProvider = "testName")
- @Override
- public void readPaginatedList(String testName) throws Exception {
- //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
- }
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
// Success outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+ @Test(dataProvider = "testName")
public void create(String testName) throws Exception {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
- ClientResponse<Response> res = create(testName, TENANT_1_USER, TENANT_1);
-
- TENANT_RESOURCE_1 = extractId(res);
-
+ TENANT_RESOURCE_1 = create(testName, TENANT_1_USER, TENANT_1);
if (logger.isDebugEnabled()) {
logger.debug(testName + ": tenantId= " + TENANT_1
+ " userId=" + TENANT_1_USER
}
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+ @Test(dataProvider = "testName")
public void create2(String testName) throws Exception {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
- ClientResponse<Response> res = create(testName, TENANT_2_USER, TENANT_2);
-
- TENANT_RESOURCE_2 = extractId(res);
+ TENANT_RESOURCE_2 = create(testName, TENANT_2_USER, TENANT_2);
if (logger.isDebugEnabled()) {
logger.debug(testName + ": tenantId= " + TENANT_2
+ " userId=" + TENANT_2_USER
}
}
- private ClientResponse<Response> create(String testName, String userName, String tenatnId) {
+ private String create(String testName, String userName, String tenatnId) {
+ String result = null;
+
setupCreate();
- // Submit the request to the service and store the response.
+ //
+ // Create a new client and change the default AuthN credentials
+ //
DimensionClient client = new DimensionClient();
client.setAuth(true, userName, true, userName, true);
+ //
+ // Setup a dimension object to create
+ //
String identifier = createIdentifier();
DimensionsCommon dimension = new DimensionsCommon();
dimension.setDimension("dimensionType");
dimension.setMeasurementUnit("measurementUnit-" + identifier);
dimension.setValueDate(new Date().toString());
+ //
+ // Create a payload and send the POST request
+ //
PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(client.getCommonPartName(),
dimension);
ClientResponse<Response> res = client.create(multipart);
- int statusCode = res.getStatus();
-
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ assertStatusCode(res, testName);
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, Response.Status.CREATED.getStatusCode());
- return res;
- }
+ return result;
- //to not cause uniqueness violation for permRole, createList is removed
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void createList(String testName) throws Exception {
- }
-
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- }
-
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- }
-
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
}
// ---------------------------------------------------------------
// CRUD tests : READ tests
// ---------------------------------------------------------------
// Success outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"create"})
public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
DimensionsCommon dimension = read(testName, TENANT_RESOURCE_1, TENANT_1_USER);
Assert.assertNotNull(dimension);
if (logger.isDebugEnabled()) {
}
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create2"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"create2"})
public void read2(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
DimensionsCommon dimension = read(testName, TENANT_RESOURCE_2, TENANT_2_USER);
Assert.assertNotNull(dimension);
if (logger.isDebugEnabled()) {
}
private DimensionsCommon read(String testName, String id, String userName) throws Exception {
- setupRead();
+ DimensionsCommon result = null;
+
+ setupRead();
// Submit the request to the service and store the response.
DimensionClient client = new DimensionClient();
client.setAuth(true, userName, true, userName, true);
ClientResponse<String> res = client.read(id);
- assertStatusCode(res, testName);
+ try {
+ assertStatusCode(res, testName);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ result = (DimensionsCommon) extractPart(input,
+ client.getCommonPartName(), DimensionsCommon.class);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- return (DimensionsCommon) extractPart(input,
- client.getCommonPartName(), DimensionsCommon.class);
- }
- // Failure outcomes
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void readNonExistent(String testName) throws Exception {
-
- // Perform setup.
- setupReadNonExistent();
+ return result;
}
// ---------------------------------------------------------------
// CRUD tests : READ_LIST tests
// ---------------------------------------------------------------
- // Success outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
- public void readList(String testName) throws Exception {
- setupReadList();
- }
-
- // Failure outcomes
- // None at present.
- // ---------------------------------------------------------------
- // CRUD tests : UPDATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read", "readList", "readNonExistent"})
- public void update(String testName) throws Exception {
- setupUpdate();
-
- }
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- }
-
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- }
-
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read2", "readNonExistent", "testSubmitRequest"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"read2"})
public void updateNonExistent(String testName) throws Exception {
-
+
+ setupUpdateNonExistent();
+ //
+ // Create a new client and change the default AuthN credentials
+ //
DimensionClient client = new DimensionClient();
//TENANT_1_USER is not allowed to update the resource of TENANT_2
client.setAuth(true, TENANT_1_USER, true, TENANT_1_USER, true);
-
+ //
+ // Create a new dimension object to try to update
+ //
DimensionsCommon dimension = new DimensionsCommon();
dimension.setDimension("dimensionType");
// Update the content of this resource.
dimension.setMeasurementUnit("updated-" + dimension.getMeasurementUnit());
dimension.setValueDate("updated-" + dimension.getValueDate());
- // Submit the request to the service and store the response.
+ //
+ // Create and send a dimension payload for the UPDATE request
+ //
PoxPayloadOut output = new PoxPayloadOut(DimensionClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(dimension, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
-
+ PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), dimension);
ClientResponse<String> res = client.update(TENANT_RESOURCE_2, output);
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + " resource = " + TENANT_RESOURCE_2
- + " status = " + statusCode);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- //going to incorrect Nuxeo domain would give DocumentNotFoundException
- //instead of giving FORBIDDEN
- Assert.assertEquals(statusCode, Response.Status.NOT_FOUND.getStatusCode());
}
// ---------------------------------------------------------------
// CRUD tests : DELETE tests
// ---------------------------------------------------------------
// Success outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"deleteNonExistent"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"deleteNonExistent"})
public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
int statusCode = delete(testName, TENANT_RESOURCE_1, TENANT_1_USER);
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"updateNonExistent"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"updateNonExistent"})
public void delete2(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
int statusCode = delete(testName, TENANT_RESOURCE_2, TENANT_2_USER);
}
private int delete(String testName, String id, String userName) throws Exception {
+ int result = -1;
+
// Perform setup.
setupDelete();
// Submit the request to the service and store the response.
DimensionClient client = new DimensionClient();
client.setAuth(true, userName, true, userName, true);
ClientResponse<Response> res = client.delete(id);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ result = assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- return statusCode;
+
+ return result;
}
// Failure outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"read"})
public void deleteNonExistent(String testName) throws Exception {
//ignoring this test as the service side returns 200 now even if it does
//not find a record in the db
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
+ // Perform setup.
setupDelete();
// Submit the request to the service and store the response.
//TENANT_2_USER of TENANT_2 is not allowed to delete the resource of TENANT_1
client.setAuth(true, TENANT_2_USER, true, TENANT_2_USER, true);
ClientResponse<Response> res = client.delete(TENANT_RESOURCE_1);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ int statusCode = res.getStatus();
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ //going to incorrect Nuxeo domain would give DocumentNotFoundException
+ //instead of giving FORBIDDEN
+ Assert.assertEquals(statusCode, Response.Status.NOT_FOUND.getStatusCode());
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- //going to incorrect Nuxeo domain would give DocumentNotFoundException
- //instead of giving FORBIDDEN
- Assert.assertEquals(statusCode, Response.Status.NOT_FOUND.getStatusCode());
}
- // ---------------------------------------------------------------
- // Search tests
- // ---------------------------------------------------------------
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void searchWorkflowDeleted(String testName) throws Exception {
- // Fixme: null test for now, overriding test in base class
- }
-
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
- /**
- * Tests the code for manually submitting data that is used by several
- * of the methods above.
- */
- @Test(dependsOnMethods = {"create"})
- public void testSubmitRequest() throws Exception {
- }
-
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
@AfterClass(alwaysRun = true)
public void cleanUp() {
- if (logger.isDebugEnabled()) {
- testBanner("cleanUp", CLASS_NAME);
- }
setupDelete();
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
}
private void deletePermissionRoles() {
-
for (String tenantId : tenantPermissions.keySet()) {
List<RoleValue> tenantRoleValues = new ArrayList<RoleValue>();
tenantRoleValues.add(tenantRoles.get(tenantId));
}
private void deleteAccounts() {
-
for (String tenantId : tenantAccounts.keySet()) {
AccountValue av = tenantAccounts.get(tenantId);
deleteAccount(tenantId, av.getAccountId());
private String createPermission(String tenantId, String resName,
List<PermissionAction> actions, EffectType effect) {
+ String result = null;
+
setupCreate();
PermissionClient permClient = new PermissionClient();
UserInfo ui = tenantAdminUsers.get(tenantId);
actions, effect, true, true, true);
permission.setTenantId(tenantId);
ClientResponse<Response> res = permClient.create(permission);
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug("createPermission: resName=" + resName
- + " status = " + statusCode);
+ try {
+ assertStatusCode(res, "CreatePermission");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
- return extractId(res);
+
+ return result;
}
private void deletePermission(String tenantId, String permId) {
UserInfo ui = tenantAdminUsers.get(tenantId);
permClient.setAuth(true, ui.userName, true, ui.password, true);
ClientResponse<Response> res = permClient.delete(permId);
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug("deletePermission: delete permission id="
- + permId + " status=" + statusCode);
+ try {
+ assertStatusCode(res, "DeletePermission");
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
}
private String createRole(String tenantId, String roleName) {
+ String result = null;
+
setupCreate();
RoleClient roleClient = new RoleClient();
UserInfo ui = tenantAdminUsers.get(tenantId);
"role for " + roleName, true);
role.setTenantId(tenantId);
ClientResponse<Response> res = roleClient.create(role);
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug("createRole: name=" + roleName
- + " status = " + statusCode);
+ try {
+ assertStatusCode(res, "CreateRole");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
- return extractId(res);
+
+ return result;
}
private void deleteRole(String tenantId, String roleId) {
UserInfo ui = tenantAdminUsers.get(tenantId);
roleClient.setAuth(true, ui.userName, true, ui.password, true);
ClientResponse<Response> res = roleClient.delete(roleId);
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug("deleteRole: delete role id=" + roleId
- + " status=" + statusCode);
+ try {
+ assertStatusCode(res, "DeleteRole");
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
}
private String createAccount(String tenantId, String userName, String email) {
+ String result = null;
+
setupCreate();
AccountClient accountClient = new AccountClient();
UserInfo ui = tenantAdminUsers.get(tenantId);
userName, userName, userName, email, tenantId,
true, false, true, true);
ClientResponse<Response> res = accountClient.create(account);
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug("createAccount: tenantId=" + tenantId + " userName=" + userName
- + " status = " + statusCode);
+ try {
+ assertStatusCode(res, "CreateAccount");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
- return extractId(res);
+
+ return result;
}
private void deleteAccount(String tenantId, String accId) {
UserInfo ui = tenantAdminUsers.get(tenantId);
accClient.setAuth(true, ui.userName, true, ui.password, true);
ClientResponse<Response> res = accClient.delete(accId);
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug("deleteAccount: delete account id="
- + accId + " status=" + statusCode);
+ try {
+ assertStatusCode(res, "DeleteAccount");
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
}
private String createAccountRole(String tenantId, AccountValue av,
Collection<RoleValue> rvs) {
+ String result = null;
+
setupCreate();
-
// Submit the request to the service and store the response.
AccountRole accRole = AccountRoleFactory.createAccountRoleInstance(
av, rvs, true, true);
UserInfo ui = tenantAdminUsers.get(tenantId);
client.setAuth(true, ui.userName, true, ui.password, true);
ClientResponse<Response> res = client.create(av.getAccountId(), accRole);
- int statusCode = res.getStatus();
-
- if (logger.isDebugEnabled()) {
- logger.debug("createAccountRole: status = " + statusCode);
+ try {
+ assertStatusCode(res, "CreateAccountRole");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
- return extractId(res);
+
+ return result;
}
private void deleteAccountRole(String tenantId, AccountValue av,
client.setAuth(true, ui.userName, true, ui.password, true);
AccountRole accRole = AccountRoleFactory.createAccountRoleInstance(
av, rvs, true, true);
- ClientResponse<Response> res = client.delete(
- av.getAccountId());
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("deleteAccountRole: status = " + statusCode);
+ ClientResponse<Response> res = client.delete(av.getAccountId());
+ try {
+ assertStatusCode(res, "DeleteAccountRole");
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
}
private String createPermissionRole(String tenantId, PermissionValue pv,
Collection<RoleValue> rvs) {
+ String result = null;
+
setupCreate();
List<RoleValue> rvls = new ArrayList<RoleValue>();
rvls.addAll(rvs);
UserInfo ui = tenantAdminUsers.get(tenantId);
client.setAuth(true, ui.userName, true, ui.password, true);
ClientResponse<Response> res = client.create(pv.getPermissionId(), permRole);
- int statusCode = res.getStatus();
-
- if (logger.isDebugEnabled()) {
- logger.debug("createPermissionRole: status = " + statusCode);
+ try {
+ assertStatusCode(res, "createPermissionRole");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
- return extractId(res);
+
+ return result;
}
private void deletePermissionRole(String tenantId, PermissionValue pv, List<RoleValue> rvls) {
-
// Perform setup.
setupDelete();
PermissionRole permRole = PermissionRoleFactory.createPermissionRoleInstance(
pv, rvls, true, true);
ClientResponse<Response> res = client.delete(pv.getPermissionId());
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("deletePermissionRole : status = " + statusCode);
+ try {
+ assertStatusCode(res, "DeletePermissionRole");
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- res.releaseConnection();
}
@Override
// TODO Auto-generated method stub
throw new UnsupportedOperationException();
}
+
+ @Override
+ protected Class<AbstractCommonList> getCommonListType() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException();
+ }
}
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
*/
package org.collectionspace.services.client;
+import org.collectionspace.services.taxonomy.TaxonCommon;
+
/**
* The Class TaxonomyAuthorityClient.
*/
-public class TaxonomyAuthorityClient extends AuthorityClientImpl<TaxonomyAuthorityProxy> {
+public class TaxonomyAuthorityClient extends AuthorityClientImpl<TaxonCommon, TaxonomyAuthorityProxy> {
public static final String SERVICE_NAME = "taxonomyauthority";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public Class<TaxonomyAuthorityProxy> getProxyClass() {
return TaxonomyAuthorityProxy.class;
}
+
+ @Override
+ public String getInAuthority(TaxonCommon item) {
+ return item.getInAuthority();
+ }
+
+ @Override
+ public void setInAuthority(TaxonCommon item, String inAuthorityCsid) {
+ item.setInAuthority(inAuthorityCsid);
+ }
}
import java.io.File;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
import java.util.Map;
import javax.ws.rs.core.MediaType;
import org.jboss.resteasy.client.ClientResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testng.Assert;
public class TaxonomyAuthorityClientUtils {
*/
package org.collectionspace.services.client.test;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.collectionspace.services.TaxonJAXBSchema;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.AuthorityClient;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.TaxonomyAuthorityClient;
import org.collectionspace.services.client.TaxonomyAuthorityClientUtils;
-import org.collectionspace.services.common.AbstractCommonListUtils;
+import org.collectionspace.services.client.TaxonomyAuthorityProxy;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.taxonomy.TaxonAuthorGroup;
import org.collectionspace.services.taxonomy.TaxonAuthorGroupList;
import org.collectionspace.services.taxonomy.TaxonomyauthorityCommon;
import org.collectionspace.services.taxonomy.TaxonCommon;
-import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.jboss.resteasy.client.ClientResponse;
* $LastChangedRevision$
* $LastChangedDate$
*/
-public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME: Test classes for Vocab, Person, Org, and Taxonomy should have a base class!
+public class TaxonomyAuthorityServiceTest extends AbstractAuthorityServiceTest<TaxonomyauthorityCommon, TaxonCommon> {
/** The logger. */
private final String CLASS_NAME = TaxonomyAuthorityServiceTest.class.getName();
private final String REFNAME = "refName";
private final String DISPLAYNAME = "displayName";
- @Override
- public String getServicePathComponent() {
- return TaxonomyAuthorityClient.SERVICE_PATH_COMPONENT;
- }
-
- @Override
- protected String getServiceName() {
- return TaxonomyAuthorityClient.SERVICE_NAME;
- }
-
- public String getItemServicePathComponent() {
- return AuthorityClient.ITEMS;
- }
final String TEST_SHORTID = "CentauruspleurexanthemusGreen1832";
final String TEST_TERM_STATUS = "accepted";
final String TEST_TAXON_FULL_NAME = "Centaurus pleurexanthemus Green 1832";
final String TEST_TAXON_IS_NAMED_HYBRID = "false";
final TaxonAuthorGroupList NULL_TAXON_AUTHOR_GROUP_LIST = null;
final TaxonCitationList NULL_TAXON_CITATION_LIST = null;
- /** The known resource id. */
- private String knownResourceId = null;
+
private String knownResourceShortIdentifer = null;
- private String knownResourceRefName = null;
private String knownTaxonomyTypeRefName = null;
- private String knownItemResourceId = null;
- private String knownItemResourceShortIdentifer = null;
- /** The n items to create in list. */
- private int nItemsToCreateInList = 3;
- /** The all resource ids created. */
- private List<String> allResourceIdsCreated = new ArrayList<String>();
- /** The all item resource ids created. */
- private Map<String, String> allItemResourceIdsCreated =
- new HashMap<String, String>();
-
- protected void setKnownResource(String id, String shortIdentifer,
- String refName) {
- knownResourceId = id;
- knownResourceShortIdentifer = shortIdentifer;
- knownResourceRefName = refName;
- }
-
- protected void setKnownItemResource(String id, String shortIdentifer) {
- knownItemResourceId = id;
- knownItemResourceShortIdentifer = shortIdentifer;
- }
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
- */
@Override
- protected CollectionSpaceClient getClientInstance() {
- return new TaxonomyAuthorityClient();
+ public String getServicePathComponent() {
+ return TaxonomyAuthorityClient.SERVICE_PATH_COMPONENT;
}
@Override
- protected PoxPayloadOut createInstance(String identifier) {
- TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- String shortId = identifier;
- String displayName = "displayName-" + shortId;
- String baseRefName =
- TaxonomyAuthorityClientUtils.createTaxonomyAuthRefName(shortId, null);
- PoxPayloadOut multipart =
- TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance(
- displayName, shortId, client.getCommonPartName());
- return multipart;
+ protected String getServiceName() {
+ return TaxonomyAuthorityClient.SERVICE_NAME;
}
- // ---------------------------------------------------------------
- // CRUD tests : CREATE tests
- // ---------------------------------------------------------------
- // Success outcomes
+ public String getItemServicePathComponent() {
+ return AuthorityClient.ITEMS;
+ }
+
/* (non-Javadoc)
- * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
+ * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"create"})
- public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // 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();
-
- // Submit the request to the service and store the response.
- TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- String shortId = createIdentifier();
- String displayName = "displayName-" + shortId;
- // String baseRefName =
- // TaxonomyAuthorityClientUtils.createTaxonomyAuthRefName(shortId, null);
- final String EMPTY_REFNAME = "";
- PoxPayloadOut multipart =
- TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance(
- displayName, shortId, client.getCommonPartName());
- String newID = null;
- ClientResponse<Response> res = client.create(multipart);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
-
- newID = TaxonomyAuthorityClientUtils.extractId(res);
- } finally {
- res.releaseConnection();
- }
- // Store the ID returned from the first resource created
- // for additional tests below.
- if (knownResourceId == null) {
- setKnownResource(newID, shortId, EMPTY_REFNAME);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
- }
- // Store the IDs from every resource created by tests,
- // so they can be deleted after tests have been run.
- allResourceIdsCreated.add(newID);
- }
-
- /**
- * Creates the item.
- *
- * @param testName the test name
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"create"}, dependsOnMethods = {"create"})
- public void createItem(String testName) {
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- setupCreate();
- createItemInAuthority(knownResourceId, knownResourceRefName);
+ protected CollectionSpaceClient<AbstractCommonList, PoxPayloadOut, String, TaxonomyAuthorityProxy> getClientInstance() {
+ return new TaxonomyAuthorityClient();
}
/**
final String testName = "createItemInAuthority(" + vcsid + "," + authRefName + ")";
if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
+ logger.debug(getTestBanner(testName, CLASS_NAME));
}
// Submit the request to the service and store the response.
// Store the IDs from any item resources created
// by tests, along with the IDs of their parents, so these items
// can be deleted after all tests have been run.
- allItemResourceIdsCreated.put(newID, vcsid);
+ allResourceItemIdsCreated.put(newID, vcsid);
return newID;
}
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
- */
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : CREATE LIST tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"createList"}, dependsOnGroups = {"create"})
- public void createList(String testName) throws Exception {
- for (int i = 0; i < nItemsToCreateInList; i++) {
- create(testName);
- }
- }
-
- /**
- * Creates the item list.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"createList"}, dependsOnMethods = {"createList"})
- public void createItemList(String testName) throws Exception {
- // Add items to the initially-created, known parent record.
- for (int j = 0; j < nItemsToCreateInList; j++) {
- createItem(testName);
- }
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : READ tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnGroups = {"create"})
- public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- String newID = null;
- ClientResponse<String> res = client.read(knownResourceId);
- try {
- assertStatusCode(res, testName);
- //FIXME: remove the following try catch once Aron fixes signatures
- try {
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- TaxonomyauthorityCommon taxonomyAuthority =
- (TaxonomyauthorityCommon) extractPart(input,
- client.getCommonPartName(), TaxonomyauthorityCommon.class);
- Assert.assertNotNull(taxonomyAuthority);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- } finally {
- res.releaseConnection();
- }
- }
-
- /**
- * Read by name.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnGroups = {"create"})
- public void readByName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName + "(" + knownResourceShortIdentifer + ")", CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- ClientResponse<String> res = client.readByName(knownResourceShortIdentifer);
- try {
- assertStatusCode(res, testName);
- //FIXME: remove the following try catch once Aron fixes signatures
- try {
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- TaxonomyauthorityCommon taxonomyAuthority = (TaxonomyauthorityCommon) extractPart(input,
- client.getCommonPartName(), TaxonomyauthorityCommon.class);
- Assert.assertNotNull(taxonomyAuthority);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- } finally {
- res.releaseConnection();
- }
- }
-
/**
- * Read item.
+ * Verify item display name.
*
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnMethods = {"read"})
- public void readItem(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"readItem", "updateItem"})
+ public void verifyItemDisplayName(String testName) throws Exception {
+ //
+ // First read in our known resource
+ //
+ setupRead();
TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+ TaxonCommon taxon = null;
try {
- assertStatusCode(res, testName);
- // Check whether we've received an authority item record.
+ assertStatusCode(res, testName);
+ // Check whether taxon has expected displayName.
PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- TaxonCommon taxon = (TaxonCommon) extractPart(input,
+ taxon = (TaxonCommon) extractPart(input,
client.getItemCommonPartName(), TaxonCommon.class);
Assert.assertNotNull(taxon);
- boolean showFull = true;
- if (showFull && logger.isDebugEnabled()) {
- logger.debug(testName + ": returned payload:");
- logger.debug(objectAsXmlString(taxon, TaxonCommon.class));
- }
-
- // Check that this authority item record has the correct identifier
- // pointing to its parent authority record.
- Assert.assertNotNull(taxon.getInAuthority(), "inAuthority field value is unexpectedly null.");
- Assert.assertEquals(taxon.getInAuthority(), knownResourceId,
- "Value of item's inAuthority field does not contain the correct identifier "
- + "pointing to its parent authority record.");
-
- // Check individual fields in the authority item record.
- Assert.assertNotNull(taxon.getTaxonFullName(), "Field value is unexpectedly null.");
- Assert.assertEquals(taxon.getTaxonFullName(), TEST_TAXON_FULL_NAME,
- "Field value " + taxon.getTaxonFullName()
- + "does not match expected value " + TEST_TAXON_FULL_NAME);
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- }
-
- /**
- * Verify item display name.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"readItem", "updateItem"})
- public void verifyItemDisplayName(String testName) throws Exception {
+ //
+ // Now setup for an update
+ //
+ String displayName = taxon.getDisplayName();
+ // Make sure displayName matches computed form
+ String expectedDisplayName =
+ TaxonomyAuthorityClientUtils.prepareDefaultDisplayName(TEST_TAXON_FULL_NAME);
+ Assert.assertNotNull(displayName, "Display name was null. Expected it to be: " + expectedDisplayName);
+ // Update the shortName and verify the computed name is updated.
+ taxon.setCsid(null);
+ taxon.setDisplayNameComputed(true);
+ taxon.setTaxonFullName("updated-" + TEST_TAXON_FULL_NAME);
+ expectedDisplayName =
+ TaxonomyAuthorityClientUtils.prepareDefaultDisplayName("updated-" + TEST_TAXON_FULL_NAME);
+
+ // Create the update payload.
+ PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), taxon);
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
setupUpdate();
-
- // Submit the request to the service and store the response.
- TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ TaxonCommon updatedTaxon = null;
try {
- assertStatusCode(res, testName);
- // Check whether taxon has expected displayName.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- TaxonCommon taxon = (TaxonCommon) extractPart(input,
- client.getItemCommonPartName(), TaxonCommon.class);
- Assert.assertNotNull(taxon);
- String displayName = taxon.getDisplayName();
- // Make sure displayName matches computed form
- String expectedDisplayName =
- TaxonomyAuthorityClientUtils.prepareDefaultDisplayName(TEST_TAXON_FULL_NAME);
- Assert.assertNotNull(displayName, expectedDisplayName);
-
- // Update the shortName and verify the computed name is updated.
- taxon.setCsid(null);
- taxon.setDisplayNameComputed(true);
- taxon.setTaxonFullName("updated-" + TEST_TAXON_FULL_NAME);
- expectedDisplayName =
- TaxonomyAuthorityClientUtils.prepareDefaultDisplayName("updated-" + TEST_TAXON_FULL_NAME);
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(taxon, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
- res.releaseConnection();
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
+ assertStatusCode(res, testName);
// Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
- TaxonCommon updatedTaxon =
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ updatedTaxon =
(TaxonCommon) extractPart(input,
client.getItemCommonPartName(), TaxonCommon.class);
Assert.assertNotNull(updatedTaxon);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedTaxon.getTaxonFullName(), taxon.getTaxonFullName(),
- "Updated ForeName in Taxonomy did not match submitted data.");
- // Verify that the updated resource computes the right displayName.
- Assert.assertEquals(updatedTaxon.getDisplayName(), expectedDisplayName,
- "Updated ForeName in Taxonomy not reflected in computed DisplayName.");
-
- // Now Update the displayName, not computed and verify the computed name is overriden.
- taxon.setDisplayNameComputed(false);
- expectedDisplayName = "TestName";
- taxon.setDisplayName(expectedDisplayName);
-
- // Submit the updated resource to the service and store the response.
- output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- commonPart = output.addPart(taxon, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
- res.releaseConnection();
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedTaxon.getTaxonFullName(), taxon.getTaxonFullName(),
+ "Updated ForeName in Taxonomy did not match submitted data.");
+ // Verify that the updated resource computes the right displayName.
+ Assert.assertEquals(updatedTaxon.getDisplayName(), expectedDisplayName,
+ "Updated ForeName in Taxonomy not reflected in computed DisplayName.");
+ //
+ // Now Update the displayName, not computed and verify the computed name is overriden.
+ //
+ taxon.setDisplayNameComputed(false);
+ expectedDisplayName = "TestName";
+ taxon.setDisplayName(expectedDisplayName);
+
+ // Submit the updated resource to the service and store the response.
+ output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
+ commonPart = output.addPart(client.getItemCommonPartName(), taxon);
+ setupUpdate(); // setup expected status code for result
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ try {
+ assertStatusCode(res, testName);
// Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
updatedTaxon =
(TaxonCommon) extractPart(input,
client.getItemCommonPartName(), TaxonCommon.class);
Assert.assertNotNull(updatedTaxon);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedTaxon.isDisplayNameComputed(), false,
- "Updated displayNameComputed in Taxonomy did not match submitted data.");
- // Verify that the updated resource computes the right displayName.
- Assert.assertEquals(updatedTaxon.getDisplayName(),
- expectedDisplayName,
- "Updated DisplayName (not computed) in Taxonomy not stored.");
} finally {
- res.releaseConnection();
+ if (res != null) {
+ res.releaseConnection();
+ }
}
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedTaxon.isDisplayNameComputed(), false,
+ "Updated displayNameComputed in Taxonomy did not match submitted data.");
+ // Verify that the updated resource computes the right displayName.
+ Assert.assertEquals(updatedTaxon.getDisplayName(),
+ expectedDisplayName,
+ "Updated DisplayName (not computed) in Taxonomy not stored.");
}
/**
* @param testName the test name
* @throws Exception the exception
*/
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"verifyItemDisplayName"})
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"verifyItemDisplayName"})
public void verifyIllegalItemDisplayName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
- // Perform setup for read.
+ //
+ // First read in our known resource.
+ //
setupRead();
-
- // Submit the request to the service and store the response.
TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
- assertStatusCode(res, testName);
-
- // Perform setup for update.
- testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE);
-
+ TaxonCommon taxon = null;
try {
+ assertStatusCode(res, testName);
// Check whether Taxonomy has expected displayName.
PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- TaxonCommon taxon = (TaxonCommon) extractPart(input,
+ taxon = (TaxonCommon) extractPart(input,
client.getItemCommonPartName(), TaxonCommon.class);
Assert.assertNotNull(taxon);
- // Try to Update with computed false and no displayName
- taxon.setDisplayNameComputed(false);
- taxon.setDisplayName(null);
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(taxon, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
- res.releaseConnection();
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
+ //
+ // Try to Update with computed false and no displayName
+ //
+ taxon.setDisplayNameComputed(false);
+ taxon.setDisplayName(null);
+
+ PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), taxon);
+ setupUpdateWithInvalidBody(); // we expect a failure here
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ try {
+ assertStatusCode(res, testName);
} finally {
res.releaseConnection();
}
}
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
+ /**
+ * Read item list.
*/
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnMethods = {"read"})
- public void readNonExistent(String testName) {
+ @Test(dataProvider = "testName", groups = {"readList"},
+ dependsOnMethods = {"readList"})
+ public void readItemList(String testName) {
+ readItemList(knownAuthorityWithItems, null);
+ }
+
+ /**
+ * Read item list by authority name.
+ */
+ @Test(dataProvider = "testName", groups = {"readList"},
+ dependsOnMethods = {"readItemList"})
+ public void readItemListByAuthorityName(String testName) {
+ readItemList(null, READITEMS_SHORT_IDENTIFIER);
+ }
+
+ /**
+ * Read item list.
+ *
+ * @param vcsid the vcsid
+ * @param name the name
+ */
+ private void readItemList(String vcsid, String shortId) {
+ String testName = "readItemList";
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
// Perform setup.
- setupReadNonExistent();
+ setupReadList();
// Submit the request to the service and store the response.
TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
+ ClientResponse<AbstractCommonList> res = null;
+ if (vcsid != null) {
+ res = client.readItemList(vcsid, null, null);
+ } else if (shortId != null) {
+ res = client.readItemListForNamedAuthority(shortId, null, null);
+ } else {
+ Assert.fail("readItemList passed null csid and name!");
+ }
try {
+ assertStatusCode(res, testName);
+ AbstractCommonList list = res.getEntity();
int statusCode = res.getStatus();
// Check the status code of the response: does it match
if (logger.isDebugEnabled()) {
logger.debug(testName + ": status = " + statusCode);
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
- /**
- * Read item non existent.
- *
- * @param testName the test name
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"read"}, dependsOnMethods = {"readItem"})
- public void readItemNonExistent(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- ClientResponse<String> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : READ_LIST tests
- // ---------------------------------------------------------------
- // Success outcomes
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"readList"}, dependsOnGroups = {"createList", "read"})
- public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadList();
-
- // Submit the request to the service and store the response.
- TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- ClientResponse<AbstractCommonList> res = client.readList();
- try {
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
- // Optionally output additional data about list members for debugging.
- if(logger.isTraceEnabled()){
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
- } finally {
- res.releaseConnection();
- }
- }
-
- /**
- * Read item list.
- */
- @Test(groups = {"readList"}, dependsOnMethods = {"readList"})
- public void readItemList() {
- String testName = "readItemList";
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- readItemList(knownResourceId, null);
- }
-
- /**
- * Read item list by authority name.
- */
- @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
- public void readItemListByAuthorityName() {
- String testName = "readItemListByAuthorityName";
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- readItemList(null, knownResourceShortIdentifer);
- }
-
- /**
- * Read item list.
- *
- * @param vcsid the vcsid
- * @param name the name
- */
- private void readItemList(String vcsid, String shortId) {
-
- String testName = "readItemList";
-
- // Perform setup.
- setupReadList();
-
- // Submit the request to the service and store the response.
- TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- ClientResponse<AbstractCommonList> res = null;
- if (vcsid != null) {
- res = client.readItemList(vcsid, null, null);
- } else if (shortId != null) {
- res = client.readItemListForNamedAuthority(shortId, null, null);
- } else {
- Assert.fail("readItemList passed null csid and name!");
- }
- try {
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
List<AbstractCommonList.ListItem> items =
list.getListItem();
int nItemsReturned = items.size();
- // There will be one item created, associated with a
- // known parent resource, by the createItem test.
- //
- // In addition, there will be 'nItemsToCreateInList'
- // additional items created by the createItemList test,
+ // There will be 'nItemsToCreateInList'
+ // items created by the createItemList test,
// all associated with the same parent resource.
- int nExpectedItems = nItemsToCreateInList + 1;
+ int nExpectedItems = nItemsToCreateInList;
if (logger.isDebugEnabled()) {
logger.debug(testName + ": Expected "
+ nExpectedItems + " items; got: " + nItemsReturned);
}
}
- // Failure outcomes
- // None at present.
- // ---------------------------------------------------------------
- // CRUD tests : UPDATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
- */
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnGroups = {"read", "readList"})
- public void update(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
-
- // Retrieve the contents of a resource to update.
- TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- ClientResponse<String> res = client.read(knownResourceId);
- try {
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
- if (logger.isDebugEnabled()) {
- logger.debug("got TaxonomyAuthority to update with ID: " + knownResourceId);
- }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- TaxonomyauthorityCommon taxonomyAuthority = (TaxonomyauthorityCommon) extractPart(input,
- client.getCommonPartName(), TaxonomyauthorityCommon.class);
- Assert.assertNotNull(taxonomyAuthority);
-
- // Update the contents of this resource.
- taxonomyAuthority.setDisplayName("updated-" + taxonomyAuthority.getDisplayName());
- taxonomyAuthority.setVocabType("updated-" + taxonomyAuthority.getVocabType());
- if (logger.isDebugEnabled()) {
- logger.debug("to be updated TaxonomyAuthority");
- logger.debug(objectAsXmlString(taxonomyAuthority, TaxonomyauthorityCommon.class));
- }
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(taxonomyAuthority, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
- res.releaseConnection();
- 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(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
- TaxonomyauthorityCommon updatedTaxonomyAuthority =
- (TaxonomyauthorityCommon) extractPart(input,
- client.getCommonPartName(), TaxonomyauthorityCommon.class);
- Assert.assertNotNull(updatedTaxonomyAuthority);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedTaxonomyAuthority.getDisplayName(),
- taxonomyAuthority.getDisplayName(),
- "Data in updated object did not match submitted data.");
- } finally {
- res.releaseConnection();
- }
- }
-
- /**
- * Update item.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"update"})
- public void updateItem(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
-
- // Retrieve the contents of a resource to update.
- TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- ClientResponse<String> res =
- client.readItem(knownResourceId, knownItemResourceId);
- try {
- assertStatusCode(res, testName);
- if (logger.isDebugEnabled()) {
- logger.debug("got Taxonomy to update with ID: "
- + knownItemResourceId
- + " in TaxonomyAuthority: " + knownResourceId);
- }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- TaxonCommon taxon = (TaxonCommon) extractPart(input,
- client.getItemCommonPartName(), TaxonCommon.class);
- Assert.assertNotNull(taxon);
-
- // Update the contents of this resource.
- taxon.setCsid(null);
- taxon.setTaxonFullName("updated-" + taxon.getTaxonFullName());
- if (logger.isDebugEnabled()) {
- logger.debug("to be updated Taxonomy");
- logger.debug(objectAsXmlString(taxon,
- TaxonCommon.class));
- }
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(taxon, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getItemCommonPartName());
- res.releaseConnection();
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
- TaxonCommon updatedTaxon =
- (TaxonCommon) extractPart(input,
- client.getItemCommonPartName(), TaxonCommon.class);
- Assert.assertNotNull(updatedTaxon);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedTaxon.getTaxonFullName(), taxon.getTaxonFullName(),
- "Data in updated Taxon did not match submitted data.");
- } finally {
- res.releaseConnection();
- }
- }
-
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
- */
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
- */
@Override
- public void updateWithMalformedXml(String testName) throws Exception {
+ public void delete(String testName) throws Exception {
+ // Do nothing. See localDelete(). This ensure proper test order.
}
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
+
+ @Test(dataProvider = "testName", dependsOnMethods = {"localDeleteItem"})
+ public void localDelete(String testName) throws Exception {
+ super.delete(testName);
}
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
- */
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateNonExistent();
-
- // Submit the request to the service and store the response.
- // Note: The ID(s) used when creating the request payload may be arbitrary.
- // The only relevant ID may be the one used in update(), below.
- TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- String displayName = "displayName-NON_EXISTENT_ID";
- PoxPayloadOut multipart = TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance(
- displayName, "nonEx", client.getCommonPartName());
- ClientResponse<String> res =
- client.update(NON_EXISTENT_ID, multipart);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- /**
- * Update non existent item.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
- public void updateNonExistentItem(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateNonExistent();
-
- // 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 update(), below.
- TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- Map<String, String> nonexMap = new HashMap<String, String>();
- nonexMap.put(TaxonJAXBSchema.NAME, TEST_TAXON_FULL_NAME);
- nonexMap.put(TaxonJAXBSchema.SHORT_IDENTIFIER, "nonEx");
- nonexMap.put(TaxonJAXBSchema.TERM_STATUS, TEST_TERM_STATUS);
- // PoxPayloadOut multipart =
- // TaxonomyAuthorityClientUtils.createTaxonInstance(
- // TaxonomyAuthorityClientUtils.createTaxonomyRefName(knownResourceRefName, "nonEx", "Non Existent"),
- // nonexMap, NULL_TAXON_AUTHOR_GROUP_LIST, NULL_TAXON_CITATION_LIST,
- // client.getItemCommonPartName());
- final String EMPTY_REFNAME = "";
- PoxPayloadOut multipart =
- TaxonomyAuthorityClientUtils.createTaxonInstance(EMPTY_REFNAME,
- nonexMap, NULL_TAXON_AUTHOR_GROUP_LIST, NULL_TAXON_CITATION_LIST,
- client.getItemCommonPartName());
- ClientResponse<String> res =
- client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : DELETE tests
- // ---------------------------------------------------------------
- // Success outcomes
- // Note: delete sub-resources in ascending hierarchical order,
- // before deleting their parents.
- /**
- * Delete item.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- //groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "readListByPartialTerm", "update"})
- groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"})
public void deleteItem(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- if (logger.isDebugEnabled()) {
- logger.debug("parentcsid =" + knownResourceId
- + " itemcsid = " + knownItemResourceId);
- }
-
- // Submit the request to the service and store the response.
- TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- ClientResponse<Response> res =
- client.deleteItem(knownResourceId, knownItemResourceId);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
- */
- @Override
- // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- // groups = {"delete"}, dependsOnMethods = {"deleteItem"})
- public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- if (logger.isDebugEnabled()) {
- logger.debug("parentcsid =" + knownResourceId);
- }
-
- // Submit the request to the service and store the response.
- TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- // Failure outcomes
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
- */
- @Override
- // @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- // groups = {"delete"}, dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDeleteNonExistent();
-
- // Submit the request to the service and store the response.
- TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- /**
- * Delete non existent item.
- *
- * @param testName the test name
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- groups = {"delete"}, dependsOnMethods = {"deleteItem"})
- public void deleteNonExistentItem(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDeleteNonExistent();
-
- // Submit the request to the service and store the response.
- TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
- try {
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- } finally {
- res.releaseConnection();
- }
- }
-
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
- /**
- * Tests the code for manually submitting data that is used by several
- * of the methods above.
- */
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() {
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testSubmitRequest: url=" + url
- + " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
+ // Do nothing. We need to wait until after the test "localDelete" gets run. When it does,
+ // its dependencies will get run first and then we can call the base class' delete method.
}
-
- /**
- * Test item submit request.
- */
- @Test(dependsOnMethods = {"createItem", "readItem", "testSubmitRequest"})
- public void testItemSubmitRequest() {
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getItemResourceURL(knownResourceId, knownItemResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testItemSubmitRequest: url=" + url
- + " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
+
+ @Test(dataProvider = "testName", groups = {"delete"},
+ dependsOnMethods = {"verifyIllegalItemDisplayName"})
+ public void localDeleteItem(String testName) throws Exception {
+ super.deleteItem(testName);
}
-
+
// ---------------------------------------------------------------
// Cleanup of resources created during testing
// ---------------------------------------------------------------
TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
parentResourceId = knownResourceId;
// Clean up item resources.
- for (Map.Entry<String, String> entry : allItemResourceIdsCreated.entrySet()) {
+ for (Map.Entry<String, String> entry : allResourceItemIdsCreated.entrySet()) {
itemResourceId = entry.getKey();
parentResourceId = entry.getValue();
// Note: Any non-success responses from the delete operation
protected String getItemResourceURL(String parentResourceIdentifier, String itemResourceIdentifier) {
return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier;
}
+
+ @Override
+ public void authorityTests(String testName) {
+ // TODO Auto-generated method stub
+ }
+
+ //
+ // Taxonomy authority specific instances
+ //
+
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ String shortId = identifier;
+ String displayName = "displayName-" + shortId;
+ String baseRefName =
+ TaxonomyAuthorityClientUtils.createTaxonomyAuthRefName(shortId, null);
+ PoxPayloadOut multipart =
+ TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance(
+ displayName, shortId, commonPartName);
+ return multipart;
+ }
+
+ @Override
+ protected PoxPayloadOut createNonExistenceInstance(String commonPartName, String identifier) {
+ String displayName = "displayName-NON_EXISTENT_ID";
+ PoxPayloadOut result = TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance(
+ displayName, "nonEx", commonPartName);
+ return result;
+ }
+
+ @Override
+ protected TaxonomyauthorityCommon updateInstance(
+ TaxonomyauthorityCommon taxonomyAuthority) {
+ TaxonomyauthorityCommon result = new TaxonomyauthorityCommon();
+
+ result.setDisplayName("updated-" + taxonomyAuthority.getDisplayName());
+ result.setVocabType("updated-" + taxonomyAuthority.getVocabType());
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(TaxonomyauthorityCommon original,
+ TaxonomyauthorityCommon updated) throws Exception {
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updated.getDisplayName(),
+ original.getDisplayName(),
+ "Display name in updated object did not match submitted data.");
+ }
+
+ //
+ // Authority item specific overrides
+ //
+
+ @Override
+ protected String createItemInAuthority(String authorityId) {
+ return createItemInAuthority(authorityId, null /*refname*/);
+ }
+
+ @Override
+ protected TaxonCommon updateItemInstance(TaxonCommon authorityItem) {
+ TaxonCommon result = new TaxonCommon();
+
+ result.setDisplayName("updated-" + authorityItem.getTaxonFullName());
+ result.setTaxonFullName("updated-" + authorityItem.getTaxonFullName());
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedItemInstances(TaxonCommon original,
+ TaxonCommon updated) throws Exception {
+ Assert.assertEquals(updated.getTaxonFullName(), original.getTaxonFullName(),
+ "Taxon full name in updated Taxon did not match submitted data.");
+ }
+
+ @Override
+ protected void verifyReadItemInstance(TaxonCommon item) throws Exception {
+ Assert.assertNotNull(item.getTaxonFullName(), "Field value is unexpectedly null.");
+ Assert.assertEquals(item.getTaxonFullName(), TEST_TAXON_FULL_NAME,
+ "Field value " + item.getTaxonFullName()
+ + "does not match expected value " + TEST_TAXON_FULL_NAME);
+ }
+
+ @Override
+ protected PoxPayloadOut createNonExistenceItemInstance(
+ String commonPartName, String identifier) {
+ Map<String, String> nonexMap = new HashMap<String, String>();
+ nonexMap.put(TaxonJAXBSchema.NAME, TEST_TAXON_FULL_NAME);
+ nonexMap.put(TaxonJAXBSchema.SHORT_IDENTIFIER, "nonEx");
+ nonexMap.put(TaxonJAXBSchema.TERM_STATUS, TEST_TERM_STATUS);
+ // PoxPayloadOut multipart =
+ // TaxonomyAuthorityClientUtils.createTaxonInstance(
+ // TaxonomyAuthorityClientUtils.createTaxonomyRefName(knownResourceRefName, "nonEx", "Non Existent"),
+ // nonexMap, NULL_TAXON_AUTHOR_GROUP_LIST, NULL_TAXON_CITATION_LIST,
+ // client.getItemCommonPartName());
+ final String EMPTY_REFNAME = "";
+ PoxPayloadOut result =
+ TaxonomyAuthorityClientUtils.createTaxonInstance(EMPTY_REFNAME,
+ nonexMap, NULL_TAXON_AUTHOR_GROUP_LIST, NULL_TAXON_CITATION_LIST,
+ commonPartName);
+ return result;
+ }
}
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<!-- apache -->
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
<dependency>\r
<groupId>org.jboss.resteasy</groupId>\r
*/
package org.collectionspace.services.client;
+import org.collectionspace.services.vocabulary.VocabularyitemsCommon;
+
/**
* The Class VocabularyClient.
*/
-public class VocabularyClient extends AuthorityClientImpl<VocabularyProxy> {
+public class VocabularyClient extends AuthorityClientImpl<VocabularyitemsCommon, VocabularyProxy> {
public static final String SERVICE_NAME = "vocabularies";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
public String getCommonPartItemName() {
return getCommonPartName(SERVICE_ITEM_PAYLOAD_NAME);
}
+
+ @Override
+ public void setInAuthority(VocabularyitemsCommon item, String inAuthorityCsid) {
+ item.setInAuthority(inAuthorityCsid);
+ }
+
+ @Override
+ public String getInAuthority(VocabularyitemsCommon item) {
+ return item.getInAuthority();
+ }
}
+"\" in personAuthority: \"" + vcsid +"\"");\r
}\r
PoxPayloadOut multipart = createVocabularyItemInstance(null, //vocabularyRefName,\r
- itemMap, client.getCommonPartItemName());\r
+ itemMap, client.getItemCommonPartName());\r
ClientResponse<Response> res = client.createItem(vcsid, multipart);\r
\r
int statusCode = res.getStatus();\r
*/
package org.collectionspace.services.client.test;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.collectionspace.services.client.AuthorityClient;
-import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.VocabularyClient;
import org.collectionspace.services.client.VocabularyClientUtils;
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.vocabulary.VocabulariesCommon;
import org.collectionspace.services.vocabulary.VocabularyitemsCommon;
import org.jboss.resteasy.client.ClientResponse;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
-import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
/**
* $LastChangedRevision: 753 $
* $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
*/
-public class VocabularyServiceTest extends AbstractServiceTestImpl {
+public class VocabularyServiceTest extends AbstractAuthorityServiceTest<VocabulariesCommon, VocabularyitemsCommon> {
private final String CLASS_NAME = VocabularyServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
final String SERVICE_PATH_COMPONENT = VocabularyClient.SERVICE_PATH_COMPONENT;//"vocabularies";
final String SERVICE_PAYLOAD_NAME = VocabularyClient.SERVICE_PAYLOAD_NAME;
final String SERVICE_ITEM_PAYLOAD_NAME = VocabularyClient.SERVICE_ITEM_PAYLOAD_NAME;
- private String knownResourceId = null;
- private String knownResourceShortIdentifer = null;
- //private String knownResourceRefName = null;
- //private String knownResourceFullRefName = null;
- private String knownItemResourceId = null;
- private int nItemsToCreateInList = 5;
-// private List<String> allResourceIdsCreated = new ArrayList<String>();
-// private Map<String, String> allResourceItemIdsCreated =
-// new HashMap<String, String>();
- protected void setKnownResource(String id, String shortIdentifer,
- String refName, String fullRefName) {
- knownResourceId = id;
- knownResourceShortIdentifer = shortIdentifer;
- //knownResourceRefName = refName;
- //knownResourceFullRefName = fullRefName;
- }
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
}
@Override
- protected PoxPayloadOut createInstance(String identifier) {
- VocabularyClient client = new VocabularyClient();
- String displayName = "displayName-" + identifier;
- PoxPayloadOut multipart = VocabularyClientUtils.createEnumerationInstance(
- displayName, identifier, client.getCommonPartName());
- return multipart;
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : CREATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void create(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // 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();
-
- // Submit the request to the service and store the response.
- VocabularyClient client = new VocabularyClient();
- String identifier = createIdentifier();
- String displayName = "displayName-" + identifier;
- PoxPayloadOut multipart = VocabularyClientUtils.createEnumerationInstance(
- displayName, identifier, client.getCommonPartName());
- ClientResponse<Response> res = client.create(multipart);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Store the ID returned from the first resource created
- // for additional tests below.
- if (knownResourceId == null) {
- setKnownResource(extractId(res), identifier, null, null );
- //VocabularyClientUtils.createVocabularyRefName(identifier, null),
- //VocabularyClientUtils.createVocabularyRefName(identifier, displayName));
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
- }
- // Store the IDs from every resource created by tests,
- // so they can be deleted after tests have been run.
- allResourceIdsCreated.add(extractId(res));
-
- }
-
- @Override
- protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) {
- String headerLabel = new VocabularyClient().getItemCommonPartName();
- HashMap<String, String> vocabItemInfo = new HashMap<String, String>();
- String shortId = createIdentifier();
- vocabItemInfo.put(AuthorityItemJAXBSchema.SHORT_IDENTIFIER, shortId);
- vocabItemInfo.put(AuthorityItemJAXBSchema.DISPLAY_NAME, "display-" + shortId);
-
- return VocabularyClientUtils.createVocabularyItemInstance(identifier, vocabItemInfo, headerLabel);
- }
-
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void createItem(String testName) {
-
- if (null != testName && logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreate();
-
+ protected String createItemInAuthority(String authorityId) {
+ String result = null;
+
VocabularyClient client = new VocabularyClient();
HashMap<String, String> itemInfo = new HashMap<String, String>();
String shortId = createIdentifier();
itemInfo.put(AuthorityItemJAXBSchema.SHORT_IDENTIFIER, shortId);
itemInfo.put(AuthorityItemJAXBSchema.DISPLAY_NAME, "display-" + shortId);
- String newID = VocabularyClientUtils.createItemInVocabulary(knownResourceId,
+ result = VocabularyClientUtils.createItemInVocabulary(authorityId,
null /*knownResourceRefName*/, itemInfo, client);
-
- // Store the ID returned from the first item resource created
- // for additional tests below.
- if (knownItemResourceId == null) {
- knownItemResourceId = newID;
- if (null != testName && logger.isDebugEnabled()) {
- logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
- }
- }
- // Store the IDs from any item resources created
- // by tests, along with the IDs of their parents, so these items
- // can be deleted after all tests have been run.
- allResourceItemIdsCreated.put(newID, knownResourceId);
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "createItem", "readItem"})
- public void createList(String testName) throws Exception {
- for (int i = 0; i < 3; i++) {
- // Force create to reset the known resource info
- setKnownResource(null, null, null, null);
- knownItemResourceId = null;
- create(testName);
- // Add nItemsToCreateInList items to each vocab
- for (int j = 0; j < nItemsToCreateInList; j++) {
- createItem(null);
- }
- }
- }
-
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- }
-
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- }
-
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
+ allResourceItemIdsCreated.put(result, authorityId);
+
+ return result;
}
-
+
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
+ dependsOnMethods = {"CRUDTests"})
public void createWithBadShortId(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
testSetup(STATUS_BAD_REQUEST, ServiceRequestType.CREATE);
// Submit the request to the service and store the response.
PoxPayloadOut multipart = VocabularyClientUtils.createEnumerationInstance(
"Vocab with Bad Short Id", "Bad Short Id!", client.getCommonPartName());
ClientResponse<Response> res = client.create(multipart);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
}
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createItem"})
+ dependsOnMethods = {"authorityTests"})
public void createItemWithBadShortId(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
setupCreateWithMalformedXml();
// Submit the request to the service and store the response.
itemInfo.put(AuthorityItemJAXBSchema.DISPLAY_NAME, "Bad Item!");
PoxPayloadOut multipart =
VocabularyClientUtils.createVocabularyItemInstance(null, //knownResourceRefName,
- itemInfo, client.getCommonPartItemName());
+ itemInfo, client.getItemCommonPartName());
ClientResponse<Response> res = client.createItem(knownResourceId, multipart);
+ try {
+ int statusCode = res.getStatus();
- int statusCode = res.getStatus();
-
- if (!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not create Item: \"" + itemInfo.get(AuthorityItemJAXBSchema.DISPLAY_NAME)
- + "\" in personAuthority: \"" + knownResourceId //knownResourceRefName
- + "\" " + invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if (statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when creating Item: \"" + itemInfo.get(AuthorityItemJAXBSchema.DISPLAY_NAME)
- + "\" in personAuthority: \"" + knownResourceId /*knownResourceRefName*/ + "\", Status:" + statusCode);
- }
- }
-
- /*
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithEmptyEntityBody(testName, CLASS_NAME);
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()) {
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA; // Constant from base class.
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "testSubmitRequest"})
- public void createWithWrongXmlSchema(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupCreateWithWrongXmlSchema();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getServiceRootURL();
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
- */
- // ---------------------------------------------------------------
- // CRUD tests : READ tests
- // ---------------------------------------------------------------
- // Success outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create"})
- public void read(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- VocabularyClient client = new VocabularyClient();
- ClientResponse<String> res = client.read(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- VocabulariesCommon vocabulary = (VocabulariesCommon) extractPart(input,
- client.getCommonPartName(), VocabulariesCommon.class);
-
- Assert.assertNotNull(vocabulary);
- //Assert.assertEquals(vocabulary.getRefName(), knownResourceFullRefName);
- }
-
- /**
- * Read by name.
- *
- * @param testName the test name
- * @throws Exception the exception
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void readByName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- VocabularyClient client = new VocabularyClient();
- ClientResponse<String> res = client.readByName(knownResourceShortIdentifer);
- assertStatusCode(res, testName);
-
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- VocabulariesCommon vocabulary = (VocabulariesCommon) extractPart(input,
- client.getCommonPartName(), VocabulariesCommon.class);
-
- Assert.assertNotNull(vocabulary);
- }
-
- /*
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"read"})
- public void readByName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- ClientResponse<PoxPayloadIn> res = client.read(knownResourceId);
- int statusCode = res.getStatus();
- assertStatusCode(res, testName);
-
- //FIXME: remove the following try catch once Aron fixes signatures
- try {
- PoxPayloadIn input = (PoxPayloadIn) res.getEntity();
- VocabulariesCommon vocabulary = (VocabulariesCommon) extractPart(input,
- client.getCommonPartName(), VocabulariesCommon.class);
- Assert.assertNotNull(vocabulary);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- */
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createItem", "read"})
- public void readItem(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
+ if (!testRequestType.isValidStatusCode(statusCode)) {
+ throw new RuntimeException("Could not create Item: \"" + itemInfo.get(AuthorityItemJAXBSchema.DISPLAY_NAME)
+ + "\" in personAuthority: \"" + knownResourceId //knownResourceRefName
+ + "\" " + invalidStatusCodeMessage(testRequestType, statusCode));
+ }
+ if (statusCode != testExpectedStatusCode) {
+ throw new RuntimeException("Unexpected Status when creating Item: \"" + itemInfo.get(AuthorityItemJAXBSchema.DISPLAY_NAME)
+ + "\" in personAuthority: \"" + knownResourceId /*knownResourceRefName*/ + "\", Status:" + statusCode);
+ }
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- VocabularyClient client = new VocabularyClient();
- ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
- assertStatusCode(res, testName);
-
- // Check whether we've received a vocabulary item.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- VocabularyitemsCommon vocabularyItem = (VocabularyitemsCommon) extractPart(input,
- client.getCommonPartItemName(), VocabularyitemsCommon.class);
- Assert.assertNotNull(vocabularyItem);
- Assert.assertEquals(vocabularyItem.getInAuthority(), knownResourceId);
}
-
+
// Failure outcomes
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"updateItem"})
+ dependsOnMethods = {"updateItem"})
public void verifyIllegalItemDisplayName(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
-
// Perform setup for read.
setupRead();
// Submit the request to the service and store the response.
VocabularyClient client = new VocabularyClient();
ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
- assertStatusCode(res, testName);
-
- // Perform setup for update.
- testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE);
-
- // Check whether Person has expected displayName.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- VocabularyitemsCommon vitem = (VocabularyitemsCommon) extractPart(input,
- client.getCommonPartItemName(), VocabularyitemsCommon.class);
- Assert.assertNotNull(vitem);
+ VocabularyitemsCommon vitem = null;
+ try {
+ assertStatusCode(res, testName);
+ // Check whether Person has expected displayName.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ vitem = (VocabularyitemsCommon) extractPart(input,
+ client.getItemCommonPartName(), VocabularyitemsCommon.class);
+ Assert.assertNotNull(vitem);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
+ }
+ //
// Try to Update with null displayName
+ //
+ setupUpdateWithInvalidBody();
vitem.setDisplayName(null);
-
// Submit the updated resource to the service and store the response.
PoxPayloadOut output = new PoxPayloadOut(SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(vitem, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartItemName());
+ PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), vitem);
res = client.updateItem(knownResourceId, knownItemResourceId, output);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("updateItem: status = " + statusCode);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE,
- "Expecting invalid message because of null displayName.");
-
+ //
// Now try to Update with 1-char displayName (too short)
+ //
+ setupUpdateWithInvalidBody();
vitem.setDisplayName("a");
-
// Submit the updated resource to the service and store the response.
output = new PoxPayloadOut(SERVICE_ITEM_PAYLOAD_NAME);
- commonPart = output.addPart(vitem, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartItemName());
+ commonPart = output.addPart(client.getItemCommonPartName(), vitem);
res = client.updateItem(knownResourceId, knownItemResourceId, output);
- statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("updateItem: status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE,
- "Expecting invalid message because of 1-char displayName.");
- }
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void readNonExistent(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- VocabularyClient client = new VocabularyClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"readItem", "readNonExistent"})
- public void readItemNonExistent(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadNonExistent();
-
- // Submit the request to the service and store the response.
- VocabularyClient client = new VocabularyClient();
- ClientResponse<String> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
- // ---------------------------------------------------------------
- // CRUD tests : READ_LIST tests
- // ---------------------------------------------------------------
- // Success outcomes
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "read"})
- public void readList(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupReadList();
-
- // Submit the request to the service and store the response.
- VocabularyClient client = new VocabularyClient();
- ClientResponse<AbstractCommonList> res = client.readList();
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
-
- // Optionally output additional data about list members for debugging.
- if(logger.isTraceEnabled()){
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
- }
-
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "readItem"})
- public void readItemList(String testName) {
- readItemListInt(knownResourceId, null, testName);
- }
-
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createList", "readItem"})
- public void readItemListByName(String testName) {
- readItemListInt(null, knownResourceShortIdentifer, testName);
- }
-
- private void readItemListInt(String vcsid, String shortId, String testName) {
-
- // Perform setup.
- setupReadList();
-
- // Submit the request to the service and store the response.
- VocabularyClient client = new VocabularyClient();
- ClientResponse<AbstractCommonList> res = null;
- if (vcsid != null) {
- res = client.readItemList(vcsid, null, null);
- } else if (shortId != null) {
- res = client.readItemListForNamedAuthority(shortId, null, null);
- } else {
- Assert.fail("Internal Error: readItemList both vcsid and shortId are null!");
- }
- assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
-
- List<AbstractCommonList.ListItem> items = list.getListItem();
- int nItemsReturned = items.size();
- long nItemsTotal = list.getTotalItems();
- if (logger.isDebugEnabled()) {
- logger.debug(" " + testName + ": Expected "
- + nItemsToCreateInList + " items; got: " + nItemsReturned + " of: " + nItemsTotal);
- }
- Assert.assertEquals(nItemsTotal, nItemsToCreateInList);
-
- if(logger.isTraceEnabled()){
- AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
- }
- }
-
- // Failure outcomes
- // None at present.
- // ---------------------------------------------------------------
- // CRUD tests : UPDATE tests
- // ---------------------------------------------------------------
- // Success outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"read"})
- public void update(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
-
- // Retrieve the contents of a resource to update.
- VocabularyClient client = new VocabularyClient();
- ClientResponse<String> res =
- client.read(knownResourceId);
- assertStatusCode(res, testName);
-
- if (logger.isDebugEnabled()) {
- logger.debug("got Vocabulary to update with ID: " + knownResourceId);
- }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- VocabulariesCommon vocabulary = (VocabulariesCommon) extractPart(input,
- client.getCommonPartName(), VocabulariesCommon.class);
- Assert.assertNotNull(vocabulary);
-
- // Update the contents of this resource.
- vocabulary.setDisplayName("updated-" + vocabulary.getDisplayName());
- vocabulary.setVocabType("updated-" + vocabulary.getVocabType());
- if (logger.isDebugEnabled()) {
- logger.debug("to be updated Vocabulary");
- logger.debug(objectAsXmlString(vocabulary, VocabulariesCommon.class));
- }
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(SERVICE_PAYLOAD_NAME);
-
- PayloadOutputPart commonPart = output.addPart(vocabulary, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartName());
- res = client.update(knownResourceId, output);
- assertStatusCode(res, testName);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
- VocabulariesCommon updatedVocabulary =
- (VocabulariesCommon) extractPart(input,
- client.getCommonPartName(), VocabulariesCommon.class);
- Assert.assertNotNull(updatedVocabulary);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedVocabulary.getDisplayName(),
- vocabulary.getDisplayName(),
- "Data in updated object did not match submitted data.");
- }
-
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"readItem", "update", "verifyIgnoredUpdateWithInAuthority"})
- public void updateItem(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
-
- // Retrieve the contents of a resource to update.
- VocabularyClient client = new VocabularyClient();
- ClientResponse<String> res =
- client.readItem(knownResourceId, knownItemResourceId);
- assertStatusCode(res, testName);
-
- if (logger.isDebugEnabled()) {
- logger.debug("got VocabularyItem to update with ID: "
- + knownItemResourceId
- + " in Vocab: " + knownResourceId);
- }
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- VocabularyitemsCommon vocabularyItem = (VocabularyitemsCommon) extractPart(input,
- client.getCommonPartItemName(), VocabularyitemsCommon.class);
- Assert.assertNotNull(vocabularyItem);
-
- // Update the contents of this resource.
- vocabularyItem.setDisplayName("updated-" + vocabularyItem.getDisplayName());
- if (logger.isDebugEnabled()) {
- logger.debug("to be updated VocabularyItem");
- logger.debug(objectAsXmlString(vocabularyItem,
- VocabularyitemsCommon.class));
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(vocabularyItem, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartItemName());
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
- VocabularyitemsCommon updatedVocabularyItem =
- (VocabularyitemsCommon) extractPart(input,
- client.getCommonPartItemName(), VocabularyitemsCommon.class);
- Assert.assertNotNull(updatedVocabularyItem);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedVocabularyItem.getDisplayName(),
- vocabularyItem.getDisplayName(),
- "Data in updated VocabularyItem did not match submitted data.");
}
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"readItem"})
- public void verifyIgnoredUpdateWithInAuthority(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdate();
-
- // Submit the request to the service and store the response.
- VocabularyClient client = new VocabularyClient();
- ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
- assertStatusCode(res, testName);
-
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- VocabularyitemsCommon vitem = (VocabularyitemsCommon) extractPart(input,
- client.getCommonPartItemName(), VocabularyitemsCommon.class);
- Assert.assertNotNull(vitem);
- // Try to Update with new parent vocab (use self, for test).
- Assert.assertEquals(vitem.getInAuthority(),
- knownResourceId,
- "VocabularyItem inAuthority does not match knownResourceId.");
- vitem.setInAuthority(knownItemResourceId);
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(vitem, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(client.getCommonPartItemName());
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- assertStatusCode(res, testName);
-
- // Retrieve the updated resource and verify that the parent did not change
- res = client.readItem(knownResourceId, knownItemResourceId);
- input = new PoxPayloadIn(res.getEntity());
- VocabularyitemsCommon updatedVocabularyItem =
- (VocabularyitemsCommon) extractPart(input,
- client.getCommonPartItemName(), VocabularyitemsCommon.class);
- Assert.assertNotNull(updatedVocabularyItem);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedVocabularyItem.getInAuthority(),
- knownResourceId,
- "VocabularyItem allowed update to the parent (inAuthority).");
+ @Test(dataProvider = "testName", dependsOnMethods = {"localDeleteItem"})
+ public void localDelete(String testName) throws Exception {
+ super.delete(testName);
}
- // Failure outcomes
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
@Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- }
-
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
+ public void delete(String testName) throws Exception {
+ //
+ // This overrides the base test. We don't want to do anything at this point
+ // in the test suite. See the localDelete() method for the actual "delete" test
+ //
}
-
+
@Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- }
+ public void deleteItem(String testName) throws Exception {
+ //Do nothing. We don't want to delete the known item until all the dependencies of the
+ // localDeleteItem() test have been fulfilled.
+ }
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {"authorityTests", "readItemList", "testItemSubmitRequest",
+ "updateItem", "verifyIllegalItemDisplayName", "verifyIgnoredUpdateWithInAuthority"})
+ public void localDeleteItem(String testName) throws Exception {
+ super.deleteItem(testName);
+ }
+
/*
+ * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
+ * refer to this method in their @Test annotation declarations.
+ */
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithEmptyEntityBody(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithEmptyEntityBody();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = "";
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
+ @Test(dataProvider = "testName",
+ dependsOnMethods = {
+ "org.collectionspace.services.client.test.AbstractAuthorityServiceTest.baseAuthorityTests"})
+ public void authorityTests(String testName) {
+ // This method only exists as a dependency target for TestNG
+ }
+
+ // ---------------------------------------------------------------
+ // Vocabulary test specific overrides
+ // ---------------------------------------------------------------
+
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithMalformedXml(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateWithMalformedXml();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = MALFORMED_XML_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ public String getServicePathComponent() {
+ return SERVICE_PATH_COMPONENT;
}
@Override
- @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
- dependsOnMethods = {"create", "update", "testSubmitRequest"})
- public void updateWithWrongXmlSchema(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
+ protected String getServiceName() {
+ return VocabularyClient.SERVICE_NAME;
}
- // Perform setup.
- setupUpdateWithWrongXmlSchema();
-
- // Submit the request to the service and store the response.
- String method = REQUEST_TYPE.httpMethodName();
- String url = getResourceURL(knownResourceId);
- String mediaType = MediaType.APPLICATION_XML;
- final String entity = WRONG_XML_SCHEMA_DATA;
- int statusCode = submitRequest(method, url, mediaType, entity);
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("updateWithWrongXmlSchema: url=" + url +
- " status=" + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
- */
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ String displayName = "displayName-" + identifier;
+ PoxPayloadOut result = VocabularyClientUtils.createEnumerationInstance(
+ displayName, identifier, commonPartName);
+ return result;
+ }
+
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateNonExistent();
-
- // 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 update(), below.
- VocabularyClient client = new VocabularyClient();
- String displayName = "displayName-" + NON_EXISTENT_ID;
- PoxPayloadOut multipart = VocabularyClientUtils.createEnumerationInstance(
- displayName, NON_EXISTENT_ID, client.getCommonPartName());
- ClientResponse<String> 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(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
+ protected PoxPayloadOut createInstance(String identifier) {
+ VocabularyClient client = new VocabularyClient();
+ return createInstance(client.getCommonPartName(), identifier);
+ }
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
- public void updateNonExistentItem(String testName) throws Exception {
+ @Override
+ protected VocabulariesCommon updateInstance(
+ VocabulariesCommon vocabulariesCommon) {
+ VocabulariesCommon result = new VocabulariesCommon();
+
+ result.setDisplayName("updated-" + vocabulariesCommon.getDisplayName());
+ result.setVocabType("updated-" + vocabulariesCommon.getVocabType());
+
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedInstances(VocabulariesCommon original,
+ VocabulariesCommon updated) throws Exception {
+ Assert.assertEquals(updated.getDisplayName(),
+ original.getDisplayName(),
+ "Display name in updated object did not match submitted data.");
+ Assert.assertEquals(updated.getVocabType(),
+ original.getVocabType(),
+ "Vocabulary tyype name in updated object did not match submitted data.");
+ }
+
+ //
+ // Vocabulary item specific overrides
+ //
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupUpdateNonExistent();
+ @Override
+ protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) {
+ String headerLabel = new VocabularyClient().getItemCommonPartName();
+ HashMap<String, String> vocabItemInfo = new HashMap<String, String>();
+ String shortId = createIdentifier();
+ vocabItemInfo.put(AuthorityItemJAXBSchema.SHORT_IDENTIFIER, shortId);
+ vocabItemInfo.put(AuthorityItemJAXBSchema.DISPLAY_NAME, "display-" + shortId);
- // 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 update(), below.
- VocabularyClient client = new VocabularyClient();
+ return VocabularyClientUtils.createVocabularyItemInstance(identifier, vocabItemInfo, headerLabel);
+ }
+
+ @Override
+ protected VocabularyitemsCommon updateItemInstance(
+ VocabularyitemsCommon authorityItem) {
+ VocabularyitemsCommon result = new VocabularyitemsCommon();
+ result.setDisplayName("updated-" + authorityItem.getDisplayName());
+ return result;
+ }
+
+ @Override
+ protected void compareUpdatedItemInstances(VocabularyitemsCommon original,
+ VocabularyitemsCommon updated) throws Exception {
+ Assert.assertEquals(updated.getDisplayName(),
+ original.getDisplayName(),
+ "Display name in updated VocabularyItem did not match submitted data.");
+ }
+
+ @Override
+ protected void verifyReadItemInstance(VocabularyitemsCommon item)
+ throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected PoxPayloadOut createNonExistenceItemInstance(
+ String commonPartName, String identifier) {
HashMap<String, String> itemInfo = new HashMap<String, String>();
itemInfo.put(AuthorityItemJAXBSchema.SHORT_IDENTIFIER, "nonex");
itemInfo.put(AuthorityItemJAXBSchema.DISPLAY_NAME, "display-nonex");
- PoxPayloadOut multipart =
+ PoxPayloadOut result =
VocabularyClientUtils.createVocabularyItemInstance(
null, //VocabularyClientUtils.createVocabularyRefName(NON_EXISTENT_ID, null),
- itemInfo, client.getCommonPartItemName());
- ClientResponse<String> res =
- client.updateItem(knownResourceId, 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(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : DELETE tests
- // ---------------------------------------------------------------
- // Success outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "readList", "testSubmitRequest", "update", "deleteItem"})
- public void delete(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- // Submit the request to the service and store the response.
- VocabularyClient client = new VocabularyClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"createItem", "readItemList", "testItemSubmitRequest",
- "updateItem", "verifyIllegalItemDisplayName", "verifyIgnoredUpdateWithInAuthority"})
- public void deleteItem(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDelete();
-
- // Submit the request to the service and store the response.
- VocabularyClient client = new VocabularyClient();
- ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("delete: status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // Failure outcomes
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDeleteNonExistent();
-
- // Submit the request to the service and store the response.
- VocabularyClient client = new VocabularyClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
- dependsOnMethods = {"deleteItem"})
- public void deleteNonExistentItem(String testName) {
-
- if (logger.isDebugEnabled()) {
- logger.debug(testBanner(testName, CLASS_NAME));
- }
- // Perform setup.
- setupDeleteNonExistent();
-
- // Submit the request to the service and store the response.
- VocabularyClient client = new VocabularyClient();
- ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- }
-
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
- /**
- * Tests the code for manually submitting data that is used by several
- * of the methods above.
- */
- @Test(dependsOnMethods = {"create", "read"})
- public void testSubmitRequest() {
-
- // Expected status code: 200 OK
- setupRead();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testSubmitRequest: url=" + url
- + " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- }
-
- @Test(dependsOnMethods = {"createItem", "readItem", "testSubmitRequest"})
- public void testItemSubmitRequest() {
-
- // Expected status code: 200 OK
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
-
- // Submit the request to the service and store the response.
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getItemResourceURL(knownResourceId, knownItemResourceId);
- int statusCode = submitRequest(method, url);
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug("testItemSubmitRequest: url=" + url
- + " status=" + statusCode);
- }
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
-
- }
-
- // ---------------------------------------------------------------
- // Cleanup of resources created during testing
- // ---------------------------------------------------------------
- /**
- * Deletes all resources created by tests, after all tests have been run.
- *
- * This cleanup method will always be run, even if one or more tests fail.
- * For this reason, it attempts to remove all resources created
- * at any point during testing, even if some of those resources
- * may be expected to be deleted by certain tests.
- */
-// @AfterClass(alwaysRun = true)
-// public void cleanUp() {
-// String noTest = System.getProperty("noTestCleanup");
-// if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
-// if (logger.isDebugEnabled()) {
-// logger.debug("Skipping Cleanup phase ...");
-// }
-// return;
-// }
-// if (logger.isDebugEnabled()) {
-// logger.debug("Cleaning up temporary resources created for testing ...");
-// }
-// VocabularyClient client = new VocabularyClient();
-// String vocabularyResourceId;
-// String vocabularyItemResourceId;
-// // Clean up vocabulary item resources.
-// for (Map.Entry<String, String> entry : allResourceItemIdsCreated.entrySet()) {
-// vocabularyItemResourceId = entry.getKey();
-// vocabularyResourceId = entry.getValue();
-// // Note: Any non-success responses are ignored and not reported.
-// client.deleteItem(vocabularyResourceId, vocabularyItemResourceId).releaseConnection();
-// }
-// // Clean up vocabulary resources.
-// for (String resourceId : allResourceIdsCreated) {
-// // Note: Any non-success responses are ignored and not reported.
-// client.delete(resourceId).releaseConnection();
-// }
-//
-// }
-
- // ---------------------------------------------------------------
- // Utility methods used by tests above
- // ---------------------------------------------------------------
- @Override
- public String getServicePathComponent() {
- return SERVICE_PATH_COMPONENT;
- }
-
- public String getServicePathItemsComponent() {
- return AuthorityClient.ITEMS;
- }
-
- /**
- * Returns the root URL for a service.
- *
- * This URL consists of a base URL for all services, followed by
- * a path component for the owning vocabulary, followed by the
- * path component for the items.
- *
- * @return The root URL for a service.
- */
- protected String getItemServiceRootURL(String parentResourceIdentifier) {
- return getResourceURL(parentResourceIdentifier) + "/" + getServicePathItemsComponent();
- }
-
- /**
- * Returns the URL of a specific resource managed by a service, and
- * designated by an identifier (such as a universally unique ID, or UUID).
- *
- * @param resourceIdentifier An identifier (such as a UUID) for a resource.
- *
- * @return The URL of a specific resource managed by a service.
- */
- protected String getItemResourceURL(String parentResourceIdentifier, String resourceIdentifier) {
- return getItemServiceRootURL(parentResourceIdentifier) + "/" + resourceIdentifier;
- }
-
- @Override
- protected String getServiceName() {
- return VocabularyClient.SERVICE_NAME;
- }
+ itemInfo, commonPartName);
+ return result;
+ }
+
}
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
- <version>5.6</version>\r
</dependency>\r
\r
<!-- apache -->\r
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.workflow.client</artifactId>
<name>services.workflow.client</name>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
- <version>3.1</version>
</dependency>
</dependencies>
*/
package org.collectionspace.services.client.test;
-
-import javax.ws.rs.core.Response;
-
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
-import org.testng.annotations.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-public class WorkflowServiceTest extends AbstractServiceTestImpl {
+public class WorkflowServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, WorkflowCommon> {
private final String CLASS_NAME = WorkflowServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
return new DimensionClient();
}
- @Override
- protected AbstractCommonList getAbstractCommonList(ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
- }
-
- @Override
- public void createList(String testName) throws Exception {
- //empty N/A
- }
+ //
+ // Test overrides
+ //
+
+ @Override
+ public void create(String testName) throws Exception {
+ String csid = this.createTestObject(testName);
+ if (this.knownResourceId == null) {
+ this.knownResourceId = csid;
+ }
+ }
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"})
public void read(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
setupRead();
DimensionClient client = new DimensionClient();
ClientResponse<String> res = client.getWorkflow(knownResourceId);
- assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- WorkflowCommon workflowsCommon = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
- if (logger.isDebugEnabled() == true) {
- logger.debug("Workflow payload is: " + input.getXmlPayload());
+ try {
+ assertStatusCode(res, testName);
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ WorkflowCommon workflowsCommon = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
+ if (logger.isDebugEnabled() == true) {
+ logger.debug("Workflow payload is: " + input.getXmlPayload());
+ }
+ Assert.assertNotNull(workflowsCommon);
+ } finally {
+ if (res != null) {
+ res.releaseConnection();
+ }
}
- Assert.assertNotNull(workflowsCommon);
}
-
-// @Override
-// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"createList", "read"})
-// public void readList(String testName) throws Exception {
-// logger.debug(testBanner(testName, CLASS_NAME));
-// setupReadList();
-// WorkflowClient client = new WorkflowClient();
-// ClientResponse<AbstractCommonList> res = client.readList();
-// assertStatusCode(res, testName);
-// AbstractCommonList list = res.getEntity();
-// if (logger.isDebugEnabled()) {
-// List<AbstractCommonList.ListItem> items =
-// list.getListItem();
-// int i = 0;
-// for(AbstractCommonList.ListItem item : items){
-// logger.debug(testName + ": list-item[" + i + "] " +
-// item.toString());
-// i++;
-// }
-// }
-// }
+
+ //
+ // FIXME: REM - This test should be a subclass of BaseServiceTest and *not* AbstractPoxServiceTestImpl
+ //
@Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"read"})
public void update(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
setupUpdate();
updateLifeCycleState(testName, knownResourceId, WorkflowClient.WORKFLOWSTATE_APPROVED);
}
-
- @Override
-// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"update", "testSubmitRequest"})
- public void updateNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupUpdateNonExistent();
- // 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 update(), below.
- WorkflowClient client = new WorkflowClient();
- PoxPayloadOut multipart = createDimensionInstance(NON_EXISTENT_ID);
- ClientResponse<String> res = client.update(NON_EXISTENT_ID, multipart);
- assertStatusCode(res, testName);
- }
-
@Override
-// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
public void delete(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupDelete();
- WorkflowClient client = new WorkflowClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- assertStatusCode(res, testName);
- }
-
- // ---------------------------------------------------------------
- // Failure outcome tests : means we expect response to fail, but test to succeed
- // ---------------------------------------------------------------
-
- // Failure outcome
- @Override
-// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"read"})
- public void readNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupReadNonExistent();
- WorkflowClient client = new WorkflowClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
- assertStatusCode(res, testName);
- }
-
- // Failure outcome
- @Override
-// @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"delete"})
- public void deleteNonExistent(String testName) throws Exception {
- logger.debug(testBanner(testName, CLASS_NAME));
- setupDeleteNonExistent();
- WorkflowClient client = new WorkflowClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- assertStatusCode(res, testName);
- }
-
- // Failure outcomes
- // Placeholders until the tests below can be implemented. See Issue CSPACE-401.
-
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- }
-
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
+ // Do nothing. N/A
}
+
+ public void searchWorkflowDeleted(String testName) throws Exception {
+ // Do nothing. N/A
+ }
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- }
+ @Override
+ public void readList(String testName) throws Exception {
+ // Do nothing. N/A
+ }
+
+ @Override
+ public void readPaginatedList(String testName) throws Exception {
+ // Do nothing. N/A
+ }
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- }
+ @Override
+ public void CRUDTests(String testName) {
+ // TODO Auto-generated method stub
+ }
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- }
+ @Override
+ protected WorkflowCommon updateInstance(WorkflowCommon commonPartObject) {
+ // TODO Auto-generated method stub
+ return null;
+ }
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- }
+ @Override
+ protected void compareUpdatedInstances(WorkflowCommon original,
+ WorkflowCommon updated) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
- // ---------------------------------------------------------------
- // Search tests
- // ---------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
+ */
+ @Override
+ public void createList(String testName) throws Exception {
+ //empty N/A
+ }
- public void searchWorkflowDeleted(String testName) throws Exception {
- }
-
- // ---------------------------------------------------------------
- // Utility tests : tests of code used in tests above
- // ---------------------------------------------------------------
-
-// @Test(dependsOnMethods = {"create", "read"})
public void testSubmitRequest() {
- final int EXPECTED_STATUS = Response.Status.OK.getStatusCode(); // Expected status code: 200 OK
- String method = ServiceRequestType.READ.httpMethodName();
- String url = getResourceURL(knownResourceId);
- int statusCode = submitRequest(method, url);
- logger.debug("testSubmitRequest: url=" + url + " status=" + statusCode);
- Assert.assertEquals(statusCode, EXPECTED_STATUS);
+ // Do nothing. N/A
}
// ---------------------------------------------------------------
@Override
protected PoxPayloadOut createInstance(String identifier) {
- return createDimensionInstance(identifier);
+ String dimensionsCommonPartName = new DimensionClient().getCommonPartName();
+ return createInstance(identifier, dimensionsCommonPartName);
}
+ @Override
+ protected PoxPayloadOut createInstance(String commonPartName,
+ String identifier) {
+ return createDimensionInstance(commonPartName, identifier);
+ }
+
+ /*
+ * We're using a DimensionsCommon instance to test the workflow service.
+ */
private PoxPayloadOut createDimensionInstance(String dimensionValue) {
+ String commonPartName = new DimensionClient().getCommonPartName();
+ return createDimensionInstance(commonPartName, dimensionValue);
+ }
+
+ /*
+ * We're using a DimensionsCommon instance to test the workflow service.
+ */
+ private PoxPayloadOut createDimensionInstance(String commonPartName,
+ String dimensionValue) {
String measurementUnit = "measurementUnit-" + dimensionValue;
- String dimensionsCommonPartName = new DimensionClient().getCommonPartName();
DimensionsCommon dimensionsCommon = new DimensionsCommon();
dimensionsCommon.setMeasurementUnit(measurementUnit);
PoxPayloadOut multipart = new PoxPayloadOut(DimensionClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = multipart.addPart(dimensionsCommonPartName, dimensionsCommon);
+ PayloadOutputPart commonPart = multipart.addPart(commonPartName, dimensionsCommon);
if (logger.isDebugEnabled()) {
logger.debug("To be created, Dimensions common: " + commonPart.asXML());
return multipart;
}
-
- @Override
- @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
- public void create(String testName) throws Exception {
- String csid = this.createTestObject(testName);
- if (this.knownResourceId == null) {
- this.knownResourceId = csid;
- }
- }
-
-
- @Override
- public void readList(String testName) throws Exception {
- }
-
- @Override
- public void readPaginatedList(String testName) throws Exception {
- //empty N/A
- }
}
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.6</version>
</dependency>
<!-- javax -->