String extractId(Response res) {
String result = null;
- MultivaluedMap mvm = res.getMetadata();
- String uri = (String) ((ArrayList) mvm.get("Location")).get(0);
+ MultivaluedMap<String, Object> mvm = res.getMetadata();
+ String uri = (String) ((ArrayList<Object>) mvm.get("Location")).get(0);
verbose("extractId:uri=" + uri);
String[] segments = uri.split("/");
result = segments[segments.length - 1];
* @throws Exception
* the exception
*/
- static Object extractPart(PoxPayloadIn input, String label, Class clazz) {
+ static Object extractPart(PoxPayloadIn input, String label) {
Object obj = null;
PayloadInputPart payloadInputPart = input.getPart(label);
if (payloadInputPart != null) {
obj = payloadInputPart.getBody();
- }
+ }
return obj;
}
//
// Get clients for the CollectionSpace services
//
- private CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
- private RelationClient relationClient = new RelationClient();
- private IntakeClient intakeClient = new IntakeClient();
- private DimensionClient dimensionClient = new DimensionClient();
+ private CollectionObjectClient collectionObjectClient;
+ private RelationClient relationClient;
+ private IntakeClient intakeClient;
+ private DimensionClient dimensionClient;
private static final int OBJECTS_TO_INTAKE = 1;
+ public RelationIntegrationTest() throws Exception {
+ collectionObjectClient = new CollectionObjectClient();
+ relationClient = new RelationClient();
+ intakeClient = new IntakeClient();
+ dimensionClient = new DimensionClient();
+ }
@AfterClass(alwaysRun = true)
public void cleanUp() {
return multipart;
}
- protected PoxPayloadOut createDimensionInstance(String identifier) {
+ protected PoxPayloadOut createDimensionInstance(String identifier) throws Exception {
DimensionClient client = new DimensionClient();
return createDimensionInstance(client.getCommonPartName(), identifier);
}
"entryDate-" + identifier);
}
- @Test void deleteCollectionObjectRelationshipToLockedDimension() {
+ @Test void deleteCollectionObjectRelationshipToLockedDimension() throws Exception {
// First create a CollectionObject
CollectionobjectsCommon co = new CollectionobjectsCommon();
fillCollectionObject(co, createIdentifier());
}
}
- @Test void createCollectionObjectRelationshipToManyDimensions() {
+ @Test void createCollectionObjectRelationshipToManyDimensions() throws Exception {
//
// First create a CollectionObject
//
}
}
- @Test void releteCollectionObjectToLockedDimension() {
+ @Test void releteCollectionObjectToLockedDimension() throws Exception {
//
// First create a CollectionObject
//
Assert.assertEquals(responseStatus, Response.Status.OK.getStatusCode());
PoxPayloadIn input = new PoxPayloadIn(multiPartResponse.readEntity(String.class));
resultRelation = (RelationsCommon) extractPart(input,
- relationClient.getCommonPartName(),
- RelationsCommon.class);
+ relationClient.getCommonPartName());
} catch (Exception e) {
e.printStackTrace();
} finally {
int responseStatus = multiPartResponse.getStatus();
Assert.assertEquals(responseStatus, Response.Status.OK.getStatusCode());
PoxPayloadIn input = new PoxPayloadIn(multiPartResponse.readEntity(String.class));
- resultRelation = (RelationsCommon) extractPart(input,
- relationClient.getCommonPartName(),
- RelationsCommon.class);
+ resultRelation = (RelationsCommon) extractPart(input, relationClient.getCommonPartName());
} catch (Exception e) {
e.printStackTrace();
} finally {
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
-import org.jboss.resteasy.client.ClientResponse;
-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;
import org.collectionspace.services.client.PoxPayloadOut;
public class I1591Multiple extends CollectionSpacePerformanceTest {
final Logger logger = LoggerFactory.getLogger(I1591Multiple.class);
- private final String COLLECTION_OBJECT_COMMON_PART_NAME =
- getCollectionObjectCommonPartName();
private static int MAX_RECORDS = 500;
String[] coList = new String[MAX_RECORDS];
+ private String COLLECTION_OBJECT_COMMON_PART_NAME;
+
+ public I1591Multiple() throws Exception {
+ COLLECTION_OBJECT_COMMON_PART_NAME = getCollectionObjectCommonPartName();
+ }
- private String getCollectionObjectCommonPartName() {
+ private String getCollectionObjectCommonPartName() throws Exception {
return new CollectionObjectClient().getCommonPartName();
}
@Test
- public void testCreateWithMultipleClientInstantiations() {
+ public void testCreateWithMultipleClientInstantiations() throws Exception {
coList = this.createCollectionObjects(MAX_RECORDS);
}
* @param identifier A arbitrary identifier to use when filling
* the CollectionObject's fields with values.
* @return A resource ID for the newly-created object.
+ * @throws Exception
*/
- private String createCollectionObject(long identifier) throws AssertionError {
+ private String createCollectionObject(long identifier) throws AssertionError, Exception {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
String resourceId = null;
*
* @param numberOfObjects The number of CollectionObject resources to create.
* @return A list of the resource IDs of the newly-created object resources.
+ * @throws Exception
*/
- public String[] createCollectionObjects(int numberOfObjects) {
+ public String[] createCollectionObjects(int numberOfObjects) throws Exception {
long identifier = 0;
int i = 0;
}
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
String resourceId = "";
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.jboss.resteasy.client.ClientResponse;
-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;
import org.collectionspace.services.client.PoxPayloadOut;
public class I1591OneInst extends CollectionSpacePerformanceTest {
final Logger logger = LoggerFactory.getLogger(I1591OneInst.class);
- private final String COLLECTION_OBJECT_COMMON_PART_NAME =
- getCollectionObjectCommonPartName();
private static int MAX_RECORDS = 500;
String[] coList = new String[MAX_RECORDS];
-
- private String getCollectionObjectCommonPartName() {
- return new CollectionObjectClient().getCommonPartName();
- }
-
+
@Test
- public void testCreateWithSingleClientInstantiation() {
+ public void testCreateWithSingleClientInstantiation() throws Exception {
createCollectionObjects(MAX_RECORDS);
}
* Creates multiple CollectionObject resources.
*
* @param numberOfObjects The number of CollectionObject resources to create.
+ * @throws Exception
*/
- public void createCollectionObjects(int numberOfObjects) {
-
+ public void createCollectionObjects(int numberOfObjects) throws Exception {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
long identifier = 0;
-
for (int i = 0; i <= numberOfObjects; i++) {
// Create a CollectionObject instance.
}
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
String resourceId = "";
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.jboss.resteasy.client.ClientResponse;
-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;
import org.collectionspace.services.client.PoxPayloadOut;
public class I1591OneInstOneClose extends CollectionSpacePerformanceTest {
final Logger logger = LoggerFactory.getLogger(I1591OneInstOneClose.class);
- private final String COLLECTION_OBJECT_COMMON_PART_NAME =
- getCollectionObjectCommonPartName();
private static int MAX_RECORDS = 500;
String[] coList = new String[MAX_RECORDS];
- private String getCollectionObjectCommonPartName() {
- return new CollectionObjectClient().getCommonPartName();
- }
-
@Test
- public void testCreateWithSingleClientInstantiationAndOneClose() {
+ public void testCreateWithSingleClientInstantiationAndOneClose() throws Exception {
createCollectionObjects(MAX_RECORDS);
}
* Creates multiple CollectionObject resources.
*
* @param numberOfObjects The number of CollectionObject resources to create.
+ * @throws Exception
*/
- public void createCollectionObjects(int numberOfObjects) {
+ public void createCollectionObjects(int numberOfObjects) throws Exception {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
long identifier = 0;
}
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
String resourceId = "";
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.util.HttpResponseCodes;
+import org.jboss.resteasy.util.HttpResponseCodes;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.CollectionObjectClient;
import org.collectionspace.services.client.PayloadOutputPart;
/**
* Performance test.
+ * @throws Exception
*/
@Test
- public void performanceTest() {
+ public void performanceTest() throws Exception {
roundTripOverhead(10);
deleteCollectionObjects();
String[] coList = this.createCollectionObjects(MAX_RECORDS);
*
* @param numOfCalls the num of calls
* @return the long
+ * @throws Exception
*/
- private long roundTripOverhead(int numOfCalls) {
+ private long roundTripOverhead(int numOfCalls) throws Exception {
long result = 0;
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
* Search collection objects.
*
* @param numberOfObjects the number of objects
+ * @throws Exception
*/
- private void searchCollectionObjects(int numberOfObjects) {
+ private void searchCollectionObjects(int numberOfObjects) throws Exception {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
Random randomGenerator = new Random(System.currentTimeMillis());
Response searchResultsResponse;
*
* @param numberOfObjects the number of objects
* @return the string[]
+ * @throws Exception
*/
- public String[] createCollectionObjects(int numberOfObjects) {
+ public String[] createCollectionObjects(int numberOfObjects) throws Exception {
Random randomGenerator = new Random(System.currentTimeMillis());
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
String[] coList = new String[numberOfObjects];
* Delete collection objects.
*
* @param arrayOfObjects the array of objects
+ * @throws Exception
*/
- public void readCollectionObjects(String[] arrayOfObjects) {
+ public void readCollectionObjects(String[] arrayOfObjects) throws Exception {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
Date startTime = new Date();
/**
* Delete collection objects.
* FIXME: Deletes a page at a time until there are no more CollectionObjects.
+ * @throws Exception
*/
- public void readCollectionObjects() {
+ public void readCollectionObjects() throws Exception {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
List<AbstractCommonList.ListItem> coListItems = null;
* Delete collection objects.
*
* @param arrayOfObjects the array of objects
+ * @throws Exception
*/
- private void deleteCollectionObjects(String[] arrayOfObjects) {
+ private void deleteCollectionObjects(String[] arrayOfObjects) throws Exception {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
Date startTime = new Date();
/**
* Delete collection objects.
* FIXME: Deletes a page at a time until there are no more CollectionObjects.
+ * @throws Exception
*/
- private void deleteCollectionObjects() {
+ private void deleteCollectionObjects() throws Exception {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
List<AbstractCommonList.ListItem> coListItems = null;
package org.collectionspace.services.client;
import javax.ws.rs.core.Response;
-import org.apache.http.HttpStatus;
+import org.apache.http.HttpStatus;
import org.collectionspace.services.account.AccountsCommon;
import org.collectionspace.services.account.AccountsCommonList;
import org.collectionspace.services.description.ServiceDescription;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
public final static String IMMUTABLE = "immutable";
- public AccountClient() {
+ public AccountClient() throws Exception {
super();
}
- public AccountClient(String clientPropertiesFilename) {
+ public AccountClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
}
public String getTenantId() {
- return getProperty(AccountClient.TENANT_PROPERTY);
+ return getProperty(AccountClient.TENANT_NAME_PROPERTY);
}
@Override
package org.collectionspace.services.client;
import javax.ws.rs.core.Response;
-import org.apache.http.HttpStatus;
+import org.apache.http.HttpStatus;
import org.collectionspace.services.authorization.AccountRole;
import org.collectionspace.services.description.ServiceDescription;
import org.collectionspace.services.jaxb.AbstractCommonList;
public class AccountRoleClient extends AbstractServiceClientImpl<AbstractCommonList, AccountRole, AccountRole, AccountRoleProxy> {
public static final String SERVICE_NAME = "accountroles";
- public AccountRoleClient() {
+ public AccountRoleClient() throws Exception {
super();
}
- public AccountRoleClient(String clientPropertiesFilename) {
+ public AccountRoleClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
*/
public class TenantClient extends AbstractServiceClientImpl<TenantsList, Tenant,
Tenant, TenantProxy> {
- public static final String SERVICE_NAME = "tenants";
+
+ public TenantClient() throws Exception {
+ super();
+ }
+
+ public static final String SERVICE_NAME = "tenants";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
* @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
*/
@Override
- protected String getServicePathComponent() {
+ protected String getServicePathComponent() throws Exception {
return new AccountRoleClient().getServicePathComponent();
}
/**
* Seed data.
+ * @throws Exception
*/
@BeforeClass(alwaysRun = true)
- public void seedData() {
+ public void seedData() throws Exception {
String userId = "acc-role-user1";
String accId = createAccount(userId, "acc-role-user1-test@cspace.org");
AccountValue ava = new AccountValue();
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new AccountRoleClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new AccountRoleClient(clientPropertiesFilename);
}
/**
* Clean up.
+ * @throws Exception
*/
@AfterClass(alwaysRun = true)
@Override
- public void cleanUp() {
-
+ public void cleanUp() throws Exception {
setupDelete();
String noTest = System.getProperty("noTestCleanup");
* @param userName the user name
* @param email the email
* @return the string
+ * @throws Exception
*/
- private String createAccount(String userName, String email) {
+ private String createAccount(String userName, String email) throws Exception {
AccountClient accClient = new AccountClient();
AccountsCommon account = AccountFactory.createAccountInstance(
userName, userName, userName, email, accClient.getTenantId(),
return result;
}
- private void findPrebuiltAdminAccount() {
+ private void findPrebuiltAdminAccount() throws Exception {
// Search for the prebuilt admin user and then hold its CSID
if (prebuiltAdminCSID == null) {
setupReadList();
* Delete account.
*
* @param accId the acc id
+ * @throws Exception
*/
- private void deleteAccount(String accId) {
+ private void deleteAccount(String accId) throws Exception {
AccountClient accClient = new AccountClient();
setupDelete();
Response res = accClient.delete(accId);
*
* @param roleName the role name
* @return the string
+ * @throws Exception
*/
- private String createRole(String roleName) {
+ private String createRole(String roleName) throws Exception {
String result = null;
RoleClient roleClient = new RoleClient();
* Delete role.
*
* @param roleId the role id
+ * @throws Exception
*/
- private void deleteRole(String roleId) {
+ private void deleteRole(String roleId) throws Exception {
setupDelete();
RoleClient roleClient = new RoleClient();
Response res = roleClient.delete(roleId);
import org.collectionspace.services.account.Status;
import org.collectionspace.services.client.AccountFactory;
import org.collectionspace.services.client.test.AbstractServiceTestImpl;
-
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
* @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
*/
@Override
- protected String getServicePathComponent() {
+ protected String getServicePathComponent() throws Exception {
return new AccountClient().getServicePathComponent();
}
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new AccountClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new AccountClient(clientPropertiesFilename);
}
}
}
- private void findPrebuiltAdminAccount() {
+ private void findPrebuiltAdminAccount() throws Exception {
// Search for the prebuilt admin user and then hold its CSID
if (prebuiltAdminCSID == null) {
setupReadList();
@Override
protected AccountsCommon createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
AccountClient client = new AccountClient();
AccountsCommon account =
createAccountInstance(knownUserId, knownUserId, knownUserPassword,
public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
- public AcquisitionClient() {
+ public AcquisitionClient() throws Exception {
super();
}
- public AcquisitionClient(String clientPropertiesFilename) {
+ public AcquisitionClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
acquisitionIdsCreated.add(extractId(res));
}
- protected void createPersonRefs(){
+ protected void createPersonRefs() throws Exception{
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
personIdsCreated.add(csid);
}
- protected String createPerson(String firstName, String surName, String shortId, String authRefName ) {
+ protected String createPerson(String firstName, String surName, String shortId, String authRefName ) throws Exception {
Map<String, String> personInfo = new HashMap<String,String>();
personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
personInfo.put(PersonJAXBSchema.SUR_NAME, surName);
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
String acquisitionAuthorizer,
List<String> acquisitionFundingSources,
List<String> acqOwners,
- List<String> acquisitionSources) {
+ List<String> acquisitionSources) throws Exception {
AcquisitionsCommon acquisition = new AcquisitionsCommon();
StructuredDateGroup accessionDateGroup = new StructuredDateGroup();
import org.collectionspace.services.acquisition.AcquisitionSourceList;
import org.collectionspace.services.acquisition.OwnerList;
import org.collectionspace.services.acquisition.StructuredDateGroup;
-
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new AcquisitionClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new AcquisitionClient(clientPropertiesFilename);
}
// ---------------------------------------------------------------
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
return createAcquisitionInstance(identifier);
}
*
* @param identifier the identifier
* @return the multipart output
+ * @throws Exception
*/
- private PoxPayloadOut createAcquisitionInstance(String identifier) {
+ private PoxPayloadOut createAcquisitionInstance(String identifier) throws Exception {
AcquisitionsCommon acquisition = new AcquisitionsCommon();
acquisition.setAcquisitionReferenceNumber("acquisitionReferenceNumber-" + identifier);
final static String DISPLAY_NAME = "displayName";
final static String REF_NAME = "refName";
final static String SHORT_IDENTIFIER = "shortIdentifier";
+ final static String REMOTECLIENT_CONFIG_NAME = "remoteClientConfigName";
final static String VOCAB_TYPE = "vocabType";
final static String CSID = "csid";
final static String REV = "rev";
package org.collectionspace.services.common.vocabulary;
+import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.collectionspace.services.client.AuthorityClient;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.PoxPayloadIn;
-import org.collectionspace.services.common.api.RefNameUtils.AuthorityTermInfo;
+import org.collectionspace.services.common.ServiceMain;
+import org.collectionspace.services.common.api.Tools;
import org.collectionspace.services.common.context.MultipartServiceContextImpl;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthorityItemSpecifier;
import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier;
-import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.SpecifierForm;
import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityIdentifierUtils;
+import org.collectionspace.services.config.service.ServiceBindingType;
+import org.collectionspace.services.config.tenant.RemoteClientConfig;
+import org.collectionspace.services.config.tenant.RemoteClientConfigurations;
+import org.collectionspace.services.config.tenant.TenantBindingType;
import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.dom4j.DocumentException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@SuppressWarnings("rawtypes")
public class AuthorityServiceUtils {
private static final Logger logger = LoggerFactory.getLogger(AuthorityIdentifierUtils.class);
//
// Used to keep track if an authority item's is deprecated
+ public static final String DEFAULT_REMOTECLIENT_CONFIG_NAME = "default";
public static final String IS_DEPRECATED_PROPERTY = "IS_DEPRECATED_PROPERTY";
public static final Boolean DEPRECATED = true;
public static final Boolean NOT_DEPRECATED = !DEPRECATED;
public static final Boolean NO_CHANGE = null;
+ /*
+ * Try to find a named remote client configuration in the current tenant bindings. If the value of the incoming param 'remoteClientConfigName' is
+ * blank or null, we'll try to find a name in the authority service's bindings. If we can't find a name there, we'll try using the default name.
+ *
+ * If the incoming param 'remoteClientConfigName' is not null, we'll look through all the named remote client configurations in the tenant's binding
+ * to find the configuration. If we can't find the named configuration, we'll throw an exception.
+ *
+ * If there are no remote client configurations in the tenant's bindings, we'll throw an exception.
+ */
+ public static final RemoteClientConfig getRemoteClientConfig(ServiceContext ctx, String remoteClientConfigName) throws Exception {
+ RemoteClientConfig result = null;
+
+ TenantBindingType tenantBinding = ServiceMain.getInstance().getTenantBindingConfigReader().getTenantBinding(ctx.getTenantId());
+ RemoteClientConfigurations remoteClientConfigurations = tenantBinding.getRemoteClientConfigurations();
+ if (remoteClientConfigurations != null) {
+ if (Tools.isEmpty(remoteClientConfigName) == true) {
+ // Since the authority instance didn't specify a remote client config name, let's see if the authority type's service bindings specifies one
+ ServiceBindingType serviceBindingType =
+ ServiceMain.getInstance().getTenantBindingConfigReader().getServiceBinding(ctx.getTenantId(), ctx.getServiceName());
+ remoteClientConfigName = serviceBindingType.getRemoteClientConfigName();
+ }
+ //
+ // If we still don't have a remote client config name, let's use the default value.
+ //
+ if (Tools.isEmpty(remoteClientConfigName) == true) {
+ remoteClientConfigName = DEFAULT_REMOTECLIENT_CONFIG_NAME;
+ }
+
+ List<RemoteClientConfig> remoteClientConfigList = remoteClientConfigurations.getRemoteClientConfig();
+ for (RemoteClientConfig config : remoteClientConfigList) {
+ if (config.getName().equalsIgnoreCase(remoteClientConfigName)) {
+ result = config;
+ break;
+ }
+ }
+ } else {
+ String errMsg = String.format("No remote client configurations could be found in the tenant bindings for tenant named '%s'.",
+ ctx.getTenantName());
+ logger.error(errMsg);
+ throw new Exception(errMsg);
+ }
+
+ if (result == null) {
+ String errMsg = String.format("Could not find a remote client configuration named '%s' in the tenant bindings for tenant named '%s'",
+ remoteClientConfigName, ctx.getTenantName());
+ logger.error(errMsg);
+ throw new Exception(errMsg);
+ }
+
+ return result;
+ }
+
/**
* Make a request to the SAS Server for an authority payload.
*
* @return
* @throws Exception
*/
- static public PoxPayloadIn requestPayloadIn(ServiceContext ctx, Specifier specifier, Class responseType) throws Exception {
+ static public PoxPayloadIn requestPayloadInFromRemoteServer(ServiceContext ctx, String remoteClientConfigName, Specifier specifier, Class responseType) throws Exception {
PoxPayloadIn result = null;
- AuthorityClient client = (AuthorityClient) ctx.getClient(CollectionSpaceClient.SAS_CLIENT_PROPERTIES_FILENAME);
+ RemoteClientConfig remoteClientConfig = getRemoteClientConfig(ctx, remoteClientConfigName);
+ AuthorityClient client = (AuthorityClient) ctx.getClient(remoteClientConfig);
+
Response res = client.read(specifier.getURNValue());
try {
int statusCode = res.getStatus();
}
//
- // Makes a call to the SAS server for a authority item payload
+ // Makes a call to the remote SAS server for a authority item payload
//
- static public PoxPayloadIn requestPayloadIn(AuthorityItemSpecifier specifier, String serviceName, Class responseType, boolean syncHierarchicalRelationships) throws Exception {
+ static public PoxPayloadIn requestPayloadInFromRemoteServer(
+ AuthorityItemSpecifier specifier,
+ String remoteClientConfigName,
+ String serviceName,
+ Class responseType,
+ boolean syncHierarchicalRelationships) throws Exception {
PoxPayloadIn result = null;
- ServiceContext parentCtx = new MultipartServiceContextImpl(serviceName);
- AuthorityClient client = (AuthorityClient) parentCtx.getClient(CollectionSpaceClient.SAS_CLIENT_PROPERTIES_FILENAME);
+ ServiceContext authorityCtx = new MultipartServiceContextImpl(serviceName);
+ RemoteClientConfig remoteClientConfig = getRemoteClientConfig(authorityCtx, remoteClientConfigName);
+ AuthorityClient client = (AuthorityClient) authorityCtx.getClient(remoteClientConfig);
Response res = client.readItem(specifier.getParentSpecifier().getURNValue(), specifier.getItemSpecifier().getURNValue(),
AuthorityClient.INCLUDE_DELETED_ITEMS, syncHierarchicalRelationships);
import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.AuthorityClient;
-import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.PayloadInputPart;
-import org.collectionspace.services.client.VocabularyClient;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.XmlTools;
import org.collectionspace.services.client.workflow.WorkflowClient;
import org.collectionspace.services.common.ResourceMap;
-import org.collectionspace.services.common.api.CommonAPI;
import org.collectionspace.services.common.api.RefName;
import org.collectionspace.services.common.api.RefName.Authority;
import org.collectionspace.services.common.api.RefNameUtils;
-import org.collectionspace.services.common.api.RefNameUtils.AuthorityInfo;
import org.collectionspace.services.common.api.RefNameUtils.AuthorityTermInfo;
import org.collectionspace.services.common.api.Tools;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.document.DocumentException;
-import org.collectionspace.services.common.document.DocumentHandler;
import org.collectionspace.services.common.document.DocumentNotFoundException;
import org.collectionspace.services.common.document.DocumentReferenceException;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
-import org.dom4j.Document;
+
import org.dom4j.Element;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.DocumentModel;
* $LastChangedRevision: $
* $LastChangedDate: $
*/
+@SuppressWarnings("rawtypes")
public abstract class AuthorityDocumentModelHandler<AuthCommon>
extends NuxeoDocumentModelHandler<AuthCommon> {
return payloadInputPart;
}
- @Override
+ @Override
public boolean handleSync(DocumentWrapper<Object> wrapDoc) throws Exception {
boolean result = false;
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = getServiceContext();
if (docModel != null) {
Long localRev = (Long) NuxeoUtils.getProperyValue(docModel, AuthorityJAXBSchema.REV);
String shortId = (String) NuxeoUtils.getProperyValue(docModel, AuthorityJAXBSchema.SHORT_IDENTIFIER);
+ String remoteClientConfigName = (String) NuxeoUtils.getProperyValue(docModel, AuthorityJAXBSchema.REMOTECLIENT_CONFIG_NAME); // If set, contains the name of the remote client configuration (remoteClientConfigName) from the tenant bindings
//
// Using the short ID of the local authority, create a URN specifier to retrieve the SAS authority
//
Specifier sasSpecifier = new Specifier(SpecifierForm.URN_NAME, shortId);
- PoxPayloadIn sasPayloadIn = AuthorityServiceUtils.requestPayloadIn(ctx, sasSpecifier, getEntityResponseType());
+ PoxPayloadIn sasPayloadIn = AuthorityServiceUtils.requestPayloadInFromRemoteServer(ctx, remoteClientConfigName, sasSpecifier, getEntityResponseType());
//
// If the authority on the SAS is newer, synch all the items and then the authority record as well
//
* @return
* @throws Exception
*/
- @SuppressWarnings("rawtypes")
private long deleteOrDeprecateItems(ServiceContext ctx, Specifier authoritySpecifier, ArrayList<String> itemShortIdList) throws Exception {
long result = 0;
AuthorityItemSpecifier authorityItemSpecificer = null;
Specifier itemSpecifier = Specifier.getSpecifier(itemIdentifier);
AuthorityItemSpecifier sasAuthorityItemSpecifier = new AuthorityItemSpecifier(authoritySpecifier, itemSpecifier);
//
+ // Get the remote client configuration name
+ //
+ DocumentModel docModel = NuxeoUtils.getDocFromSpecifier(ctx, getRepositorySession(), authorityCommonSchemaName, authoritySpecifier);
+ String remoteClientConfigName = (String) NuxeoUtils.getProperyValue(docModel, AuthorityJAXBSchema.REMOTECLIENT_CONFIG_NAME); // If set, contains the name of the remote client configuration (remoteClientConfigName) from the tenant bindings
+ //
// Get the remote payload
//
- PoxPayloadIn sasPayloadIn = AuthorityServiceUtils.requestPayloadIn(sasAuthorityItemSpecifier,
+ PoxPayloadIn sasPayloadIn = AuthorityServiceUtils.requestPayloadInFromRemoteServer(sasAuthorityItemSpecifier, remoteClientConfigName,
ctx.getServiceName(), getEntityResponseType(), syncHierarchicalRelationships);
sasPayloadIn = AuthorityServiceUtils.filterRefnameDomains(ctx, sasPayloadIn); // We need to filter domain name part of any and all refnames in the payload
//
//
DocumentModel authorityDocModel = NuxeoUtils.getDocFromSpecifier(ctx, getRepositorySession(), authorityCommonSchemaName,
authorityItemSpecifier.getParentSpecifier());
- String authorityShortId = (String) NuxeoUtils.getProperyValue(authorityDocModel, AuthorityJAXBSchema.SHORT_IDENTIFIER);
+ String authorityShortId = (String)NuxeoUtils.getProperyValue(authorityDocModel, AuthorityJAXBSchema.SHORT_IDENTIFIER);
String localParentCsid = authorityDocModel.getName();
+ String remoteClientConfigName = (String)NuxeoUtils.getProperyValue(authorityDocModel, AuthorityJAXBSchema.REMOTECLIENT_CONFIG_NAME);
//
// Using the short IDs of the local authority and item, create URN specifiers and retrieve the SAS authority item
//
AuthorityItemSpecifier sasAuthorityItemSpecifier = new AuthorityItemSpecifier(SpecifierForm.URN_NAME, authorityShortId, itemShortId);
// Get the shared authority server's copy
- PoxPayloadIn sasPayloadIn = AuthorityServiceUtils.requestPayloadIn(sasAuthorityItemSpecifier,
- getAuthorityServicePath(), getEntityResponseType(), AuthorityClient.INCLUDE_RELATIONS);
- Long sasRev = getRevision(sasPayloadIn);
- String sasWorkflowState = getWorkflowState(sasPayloadIn);
+ PoxPayloadIn sasPayloadIn = AuthorityServiceUtils.requestPayloadInFromRemoteServer(sasAuthorityItemSpecifier,
+ remoteClientConfigName, getAuthorityServicePath(), getEntityResponseType(), AuthorityClient.INCLUDE_RELATIONS);
//
// Get the RelationsCommonList and remove the CSIDs since they are for remote items only. We'll use
authorityItemSpecifier.getParentSpecifier());
String authorityShortId = (String) NuxeoUtils.getProperyValue(authorityDocModel, AuthorityJAXBSchema.SHORT_IDENTIFIER);
String localParentCsid = authorityDocModel.getName();
+ String remoteClientConfigName = (String)NuxeoUtils.getProperyValue(authorityDocModel, AuthorityJAXBSchema.REMOTECLIENT_CONFIG_NAME);
+
//
// Using the short IDs of the local authority and item, create URN specifiers and retrieve the SAS authority item
//
AuthorityItemSpecifier sasAuthorityItemSpecifier = new AuthorityItemSpecifier(SpecifierForm.URN_NAME, authorityShortId, itemShortId);
// Get the shared authority server's copy
- PoxPayloadIn sasPayloadIn = AuthorityServiceUtils.requestPayloadIn(sasAuthorityItemSpecifier,
- getAuthorityServicePath(), getEntityResponseType(), AuthorityClient.DONT_INCLUDE_RELATIONS);
+ PoxPayloadIn sasPayloadIn = AuthorityServiceUtils.requestPayloadInFromRemoteServer(sasAuthorityItemSpecifier,
+ remoteClientConfigName, getAuthorityServicePath(), getEntityResponseType(), AuthorityClient.DONT_INCLUDE_RELATIONS);
Long sasRev = getRevision(sasPayloadIn);
String sasWorkflowState = getWorkflowState(sasPayloadIn);
//
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
- public PermissionClient() {
+ public PermissionClient() throws Exception {
super();
}
- public PermissionClient(String clientPropertiesFilename) {
+ public PermissionClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
*/
public class PermissionRoleClient extends AbstractServiceClientImpl<PermissionRole, PermissionRole, PermissionRole, PermissionRoleProxy> {
- public PermissionRoleClient() {
+ public PermissionRoleClient() throws Exception {
super();
}
- public PermissionRoleClient(String clientPropertiesFilename) {
+ public PermissionRoleClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
+
+
+
+
import org.apache.http.HttpStatus;
import org.collectionspace.services.authorization.AccountRole;
import org.collectionspace.services.authorization.Role;
public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
public final static String IMMUTABLE = "immutable";
- public RoleClient() {
+ public RoleClient() throws Exception {
super();
}
- public RoleClient(String clientPropertiesFilename) {
+ public RoleClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
*/
public class RolePermissionClient extends AbstractServiceClientImpl<PermissionRole, PermissionRole, PermissionRole, RolePermissionProxy> {
- public RolePermissionClient() {
+ public RolePermissionClient() throws Exception {
super();
}
- public RolePermissionClient(String clientPropertiesFilename) {
+ public RolePermissionClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.client.RoleClient;
import org.collectionspace.services.client.RoleFactory;
import org.collectionspace.services.client.test.AbstractServiceTestImpl;
-
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
* @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
*/
@Override
- protected String getServicePathComponent() {
+ protected String getServicePathComponent() throws Exception {
return new PermissionRoleClient().getServicePathComponent();
}
/**
* Seed data.
+ * @throws Exception
*/
@BeforeClass(alwaysRun = true)
- public void seedData() {
+ public void seedData() throws Exception {
String ra = TEST_SERVICE_NAME + TEST_MARKER;
String accPermId = createPermission(ra, EffectType.PERMIT);
PermissionValue pva = new PermissionValue();
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new PermissionRoleClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new PermissionRoleClient(clientPropertiesFilename);
}
/**
* Clean up.
+ * @throws Exception
*/
@AfterClass(alwaysRun = true)
@Override
- public void cleanUp() {
+ public void cleanUp() throws Exception {
setupDelete();
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
* @param resName the res name
* @param effect the effect
* @return the string
+ * @throws Exception
*/
- private String createPermission(String resName, EffectType effect) {
+ private String createPermission(String resName, EffectType effect) throws Exception {
if (logger.isDebugEnabled()) {
logger.debug(getTestBanner("createPermission"));
}
* Delete permission.
*
* @param permId the perm id
+ * @throws Exception
*/
- private void deletePermission(String permId) {
+ private void deletePermission(String permId) throws Exception {
if (logger.isDebugEnabled()) {
logger.debug(getTestBanner("deletePermission"));
}
*
* @param roleName the role name
* @return the string
+ * @throws Exception
*/
- private String createRole(String roleName) {
+ private String createRole(String roleName) throws Exception {
if (logger.isDebugEnabled()) {
logger.debug(getTestBanner("createRole"));
}
* Delete role.
*
* @param roleId the role id
+ * @throws Exception
*/
- private void deleteRole(String roleId) {
+ private void deleteRole(String roleId) throws Exception {
if (logger.isDebugEnabled()) {
logger.debug(getTestBanner("deleteRole"));
}
import javax.ws.rs.core.Response;
+
+
//import org.collectionspace.services.authorization.ActionType;
import org.collectionspace.services.authorization.perms.EffectType;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.authorization.perms.PermissionsList;
import org.collectionspace.services.client.PermissionFactory;
import org.collectionspace.services.client.test.AbstractServiceTestImpl;
-
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new PermissionClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new PermissionClient(clientPropertiesFilename);
}
import org.collectionspace.services.client.RoleFactory;
import org.collectionspace.services.client.test.AbstractServiceTestImpl;
import org.collectionspace.services.client.test.ServiceRequestType;
-
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
* @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
*/
@Override
- protected String getServicePathComponent() {
+ protected String getServicePathComponent() throws Exception {
return new RolePermissionClient().getServicePathComponent();
}
/**
* Seed data.
+ * @throws Exception
*/
@BeforeClass(alwaysRun = true)
- public void seedData() {
+ public void seedData() throws Exception {
String rn1 = getRoleName();
String r1RoleId = createRole(rn1);
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new RolePermissionClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new RolePermissionClient(clientPropertiesFilename);
}
/**
* Clean up.
+ * @throws Exception
*/
@AfterClass(alwaysRun = true)
@Override
- public void cleanUp() {
+ public void cleanUp() throws Exception {
setupDelete();
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
* @param resName the res name
* @param effect the effect
* @return the string
+ * @throws Exception
*/
- private String createPermission(String resName, EffectType effect) {
+ private String createPermission(String resName, EffectType effect) throws Exception {
setupCreate();
PermissionClient permClient = new PermissionClient();
List<PermissionAction> actions = PermissionFactory.createDefaultActions();
* Delete permission.
*
* @param permId the perm id
+ * @throws Exception
*/
- private void deletePermission(String permId) {
+ private void deletePermission(String permId) throws Exception {
setupDelete();
PermissionClient permClient = new PermissionClient();
*
* @param roleName the role name
* @return the string
+ * @throws Exception
*/
- private String createRole(String roleName) {
+ private String createRole(String roleName) throws Exception {
setupCreate();
RoleClient roleClient = new RoleClient();
* Delete role.
*
* @param roleId the role id
+ * @throws Exception
*/
- private void deleteRole(String roleId) {
+ private void deleteRole(String roleId) throws Exception {
setupDelete();
RoleClient roleClient = new RoleClient();
Response res = null;
}
@Override
- protected String getServicePathComponent() {
+ protected String getServicePathComponent() throws Exception {
return new RoleClient().getServicePathComponent();
}
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new RoleClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new RoleClient(clientPropertiesFilename);
}
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
- public BatchClient() {
+ public BatchClient() throws Exception {
super();
}
- public BatchClient(String clientPropertiesFilename) {
+ public BatchClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.batch.BatchCommon;
-
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
* $LastChangedRevision: $
* $LastChangedDate: $
*/
+@SuppressWarnings("rawtypes")
public class BatchServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, BatchCommon> {
private final String CLASS_NAME = BatchServiceTest.class.getName();
return BatchClient.SERVICE_NAME;
}
- @Override
- protected CollectionSpaceClient getClientInstance() {
+ @Override
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new BatchClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new BatchClient(clientPropertiesFilename);
}
// ---------------------------------------------------------------
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
return createBatchInstance(identifier);
}
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
PoxPayloadOut result = createBatchInstance(identifier);
return result;
}
- private PoxPayloadOut createBatchInstance(String exitNumber) {
+ private PoxPayloadOut createBatchInstance(String exitNumber) throws Exception {
String identifier = "batchNumber-" + exitNumber;
BatchCommon batch = new BatchCommon();
batch.setName(identifier);
public static final String IMAGE_WIDTH_LABEL = "width";
public static final String IMAGE_HEIGHT_LABEL = "height";
- public BlobClient() {
+ public BlobClient() throws Exception {
super();
}
- public BlobClient(String clientPropertiesFilename) {
+ public BlobClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.blob.BlobsCommon;
import org.collectionspace.services.person.PersonTermGroup;
-
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
- private PoxPayloadOut createBlobInstance(String depositorRefName) {
+ private PoxPayloadOut createBlobInstance(String depositorRefName) throws Exception {
BlobClient blobClient = new BlobClient();
this.depositorRefName = depositorRefName;
this.blobName = "testblob-"+createIdentifier();
}
}
- protected void createPersonRefs() {
+ protected void createPersonRefs() throws Exception {
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
// 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());
}
}
- protected String createPerson(String firstName, String surName, String shortId, String authRefName) {
+ protected String createPerson(String firstName, String surName, String shortId, String authRefName) throws Exception {
String result = null;
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun = true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
logger.debug("Skipping Cleanup phase ...");
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
+@SuppressWarnings("rawtypes")
public class BlobScaleTest extends BaseServiceTest<AbstractCommonList> {
private final Logger logger = LoggerFactory.getLogger(BlobScaleTest.class);
private static Random generator = new Random(System.currentTimeMillis());
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new BlobClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new BlobClient(clientPropertiesFilename);
}
}
@Test(dataProvider = "testName", dependsOnMethods = {"scaleTest"})
- public void scaleGETTest(String testName) throws MalformedURLException, InterruptedException {
+ public void scaleGETTest(String testName) throws Exception {
this.setupRead();
BlobClient client = new BlobClient();
}
@Test(dataProvider = "testName")
- public void scaleTest(String testName) throws MalformedURLException {
+ public void scaleTest(String testName) throws Exception {
this.createDirectory(GENERATED_IMAGES);
setupCreate();
int imagesToCreate = getImagesToCreate();
import org.collectionspace.services.blob.BlobsCommon;
import org.collectionspace.services.blob.DimensionSubGroup;
import org.collectionspace.services.blob.MeasuredPartGroup;
-
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput;
import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
* $LastChangedRevision: $
* $LastChangedDate: $
*/
+@SuppressWarnings("rawtypes")
public class BlobServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, BlobsCommon> {
private final String CLASS_NAME = BlobServiceTest.class.getName();
}
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new BlobClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new BlobClient(clientPropertiesFilename);
}
// ---------------------------------------------------------------
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
return createBlobInstance(identifier);
}
- private PoxPayloadOut createBlobInstance(String exitNumber) {
+ private PoxPayloadOut createBlobInstance(String exitNumber) throws Exception {
BlobClient client = new BlobClient();
String identifier = "blobNumber-" + exitNumber;
BlobsCommon blob = new BlobsCommon();
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
return createInstance(identifier);
}
//
// Constructors
//
- public CitationAuthorityClient() {
+ public CitationAuthorityClient() throws Exception {
super();
}
- public CitationAuthorityClient(String clientPropertiesFilename) {
+ public CitationAuthorityClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.client.CitationAuthorityClientUtils;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.jaxb.AbstractCommonList;
-
import org.dom4j.DocumentException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* $LastChangedRevision: 753 $ $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed,
* 23 Sep 2009) $
*/
+@SuppressWarnings("rawtypes")
public class CitationAuthorityServiceTest extends AbstractAuthorityServiceTest<CitationauthoritiesCommon, CitationsCommon> {
/**
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new CitationAuthorityClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new CitationAuthorityClient(clientPropertiesFilename);
}
*
* @param vcsid the vcsid
* @param name the name
+ * @throws Exception
*/
- private void readItemList(String vcsid, String shortId) {
+ private void readItemList(String vcsid, String shortId) throws Exception {
String testName = "readItemList";
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun = true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
//
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
CitationAuthorityClient client = new CitationAuthorityClient();
String shortId = identifier;
String displayName = "displayName-" + shortId;
// All clients returning AbstractCommonList types should extend this class.
//
- public AbstractCommonListPoxServiceClientImpl() {
+ public AbstractCommonListPoxServiceClientImpl() throws Exception {
super();
}
- public AbstractCommonListPoxServiceClientImpl(String clientPropertiesFilename) {
+ public AbstractCommonListPoxServiceClientImpl(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
}
protected List<String> allResourceIdsCreated = new ArrayList<String>();
- public AbstractPoxServiceClientImpl(String clientPropertiesFilename) {
+ public AbstractPoxServiceClientImpl(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
- public AbstractPoxServiceClientImpl() {
+ public AbstractPoxServiceClientImpl() throws Exception {
super();
}
package org.collectionspace.services.client;
import java.io.IOException;
-import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
-import javax.ws.rs.PathParam;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.client.ClientRequestFilter;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.commons.httpclient.auth.AuthScope; //import org.collectionspace.services.collectionobject.CollectionobjectsCommonList;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.collectionspace.services.common.authorityref.AuthorityRefList;
+import org.apache.commons.httpclient.auth.AuthScope;
+
+import org.collectionspace.services.common.api.Tools;
import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.jboss.resteasy.client.ClientResponse; //import org.collectionspace.services.common.context.ServiceContext;
-import org.jboss.resteasy.client.ProxyFactory;
-import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor;
+
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
-//import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor;
+import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor;
import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+// FIXME: Deprecated classes that need to be updated
+import org.jboss.resteasy.client.ProxyFactory;
+import org.apache.http.impl.client.DefaultHttpClient;
+
/**
* Private class for JAX-RS authentication
implements CollectionSpaceClient<CLT, REQUEST_PT, RESPONSE_PT, P> {
/** The logger. */
- protected final Logger logger = LoggerFactory.getLogger(AbstractServiceClientImpl.class);
+ static protected final Logger logger = LoggerFactory.getLogger(AbstractServiceClientImpl.class);
/**
* The character used to separate the words in a part label
*/
* Instantiates a new abstract service client impl.
* @throws Exception
*/
- public AbstractServiceClientImpl() {
+ public AbstractServiceClientImpl() throws Exception {
this(CollectionSpaceClient.DEFAULT_CLIENT_PROPERTIES_FILENAME);
}
* Instantiates a new abstract service client impl.
* @throws Exception
*/
- public AbstractServiceClientImpl(String propertiesFileName) {
+ public AbstractServiceClientImpl(String propertiesFileName) throws Exception {
setClientProperties(propertiesFileName);
}
* @throws Exception
*/
public AbstractServiceClientImpl(Properties properties) {
- setClientProperties(properties);
+ setClientProperties(properties, false);
}
/**
/**
* readProperties reads properties from system class path as well as it
* overrides properties made available using command line
+ * @throws Exception
*
* @exception RuntimeException
*/
@Override
- public void setClientProperties(String clientPropertiesFilename) {
- Properties inProperties = new Properties();
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- InputStream is = null;
- try {
- is = cl.getResourceAsStream(clientPropertiesFilename);
- inProperties.load(is);
- setClientProperties(inProperties);
- } catch (Exception e) {
- logger.debug("Caught exception while reading properties", e);
- throw new RuntimeException(e);
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (Exception e) {
- if (logger.isDebugEnabled() == true) {
- e.printStackTrace();
- }
- }
- }
- }
+ public void setClientProperties(String clientPropertiesFilename) throws Exception {
+ Properties inProperties = Tools.loadProperties(clientPropertiesFilename, true);
+ setClientProperties(inProperties, true);
}
+ @Override
+ public void setClientProperties(Properties inProperties) {
+ setClientProperties(inProperties, false);
+ }
+
/**
- * Set our instance's properties to the in coming value. But only if the values don't already
- * existing as System properties.
+ * Set our instance's properties to the in coming values. But if 'overrideWithSyste' param is set to true then
+ * only use the incoming values if the values don't already exist as System properties.
*
* @param inProperties
* @throws Exception
*/
- protected void setClientProperties(Properties inProperties) {
+ protected void setClientProperties(Properties inProperties, boolean overrideWithSystemValues) {
properties = inProperties;
- if (logger.isDebugEnabled()) {
- System.getenv();
- System.getenv("An environment variable name");
- printProperties();
- }
-
- String spec = System.getProperty(URL_PROPERTY);
- if (spec != null && !"".equals(spec)) {
- properties.setProperty(URL_PROPERTY, spec);
+ if (overrideWithSystemValues == true) {
+ String spec = System.getProperty(URL_PROPERTY);
+ if (spec != null && !"".equals(spec)) {
+ properties.setProperty(URL_PROPERTY, spec);
+ }
+
+ String auth = System.getProperty(AUTH_PROPERTY);
+ if (auth != null && !"".equals(auth)) {
+ properties.setProperty(AUTH_PROPERTY, auth);
+ }
+ String ssl = System.getProperty(SSL_PROPERTY);
+ if (ssl != null && !"".equals(ssl)) {
+ properties.setProperty(AUTH_PROPERTY, ssl);
+ }
+ String user = System.getProperty(USER_PROPERTY);
+ if (user != null && !"".equals(user)) {
+ properties.setProperty(USER_PROPERTY, user);
+ }
+ String password = System.getProperty(PASSWORD_PROPERTY);
+ if (password != null && !"".equals(password)) {
+ properties.setProperty(PASSWORD_PROPERTY, password);
+ }
+ String tenant = System.getProperty(TENANT_NAME_PROPERTY);
+ if (tenant != null && !"".equals(tenant)) {
+ properties.setProperty(TENANT_NAME_PROPERTY, tenant);
+ }
}
-
- spec = properties.getProperty(URL_PROPERTY);
+ //
+ // Verify the URL is well formed.
+ //
+ String urlString = properties.getProperty(URL_PROPERTY);
try {
- url = new URL(spec);
- logger.debug("readProperties() using url=" + url);
+ url = new URL(urlString);
+ logger.debug("Client properties using url=" + url);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
- e.printStackTrace();
+ logger.error(String.format("Found malformed URL property value of '%s' for client URL settings.", urlString));
throw new RuntimeException(e.getMessage());
}
-
- String auth = System.getProperty(AUTH_PROPERTY);
- if (auth != null && !"".equals(auth)) {
- properties.setProperty(AUTH_PROPERTY, auth);
- }
- String ssl = System.getProperty(SSL_PROPERTY);
- if (ssl != null && !"".equals(ssl)) {
- properties.setProperty(AUTH_PROPERTY, ssl);
- }
- String user = System.getProperty(USER_PROPERTY);
- if (user != null && !"".equals(user)) {
- properties.setProperty(USER_PROPERTY, user);
- }
- String password = System.getProperty(PASSWORD_PROPERTY);
- if (password != null && !"".equals(password)) {
- properties.setProperty(PASSWORD_PROPERTY, password);
- }
- String tenant = System.getProperty(TENANT_PROPERTY);
- if (tenant != null && !"".equals(tenant)) {
- properties.setProperty(TENANT_PROPERTY, tenant);
- }
if (logger.isDebugEnabled()) {
printProperties();
}
//
- // How use the properties to initialize the HTTP client
+ // Now setup the connection.
//
init();
}
@Override
public String getTenantName() {
- return this.getProperty(TENANT_NAME_PROPERTY);
+ return this.getProperty(TENANT_ID_PROPERTY);
}
}
* Basic CRUD proxied methods
*/
- public AuthorityClientImpl(String clientPropertiesFilename) {
+ public AuthorityClientImpl(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
- public AuthorityClientImpl() {
+ public AuthorityClientImpl() throws Exception {
super();
}
*/
package org.collectionspace.services.client;
+import java.util.Properties;
+
import javax.ws.rs.core.Response;
import org.apache.commons.httpclient.HttpClient;
public static final String DEFAULT_CLIENT_PROPERTIES_FILENAME = "collectionspace-client.properties";
public static final String SAS_CLIENT_PROPERTIES_FILENAME = "sas-collectionspace-client.properties";
- public static final String AUTH_PROPERTY = "cspace.auth";
- public static final String PASSWORD_PROPERTY = "cspace.password";
- public static final String SSL_PROPERTY = "cspace.ssl";
+
public static final String URL_PROPERTY = "cspace.url";
public static final String USER_PROPERTY = "cspace.user";
- public static final String TENANT_PROPERTY = "cspace.tenant";
- public static final String TENANT_NAME_PROPERTY = "cspace.tenantID";
+ public static final String PASSWORD_PROPERTY = "cspace.password";
+ public static final String SSL_PROPERTY = "cspace.ssl";
+ public static final String AUTH_PROPERTY = "cspace.auth";
+ public static final String TENANT_NAME_PROPERTY = "cspace.tenant";
+ public static final String TENANT_ID_PROPERTY = "cspace.tenantID";
// JAX-RS path for getting service description meta information
public static final String SERVICE_DESCRIPTION_PATH = "description";
* Uses a properties files to set the url and credentials for an HTTP connection.
*
* @param clientPropertiesFilename
+ * @throws Exception
*/
- public void setClientProperties(String clientPropertiesFilename);
+ public void setClientProperties(String clientPropertiesFilename) throws Exception;
+
+ public void setClientProperties(Properties clientProperties);
public String getTenantName();
}
public class GenericAuthorityClientImpl extends
AuthorityClientImpl<Object, Object, AuthorityProxy> {
+ public GenericAuthorityClientImpl() throws Exception {
+ super();
+ }
+
@Override
public String getItemCommonPartName() {
// TODO Auto-generated method stub
public static final String SERVICE_COMMON_LIST_NAME = "relations-common-list";
public static final String SERVICE_COMMONPART_NAME = IRelationsManager.SERVICE_COMMONPART_NAME;
- public RelationClient() {
+ public RelationClient() throws Exception {
super();
}
- public RelationClient(String clientPropertiesFilename) {
+ public RelationClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
public final class TestServiceClient extends AbstractServiceClientImpl<AbstractCommonList, Object, Object, TestServiceProxy> {
- /**
+ public TestServiceClient() throws Exception {
+ super();
+ }
+
+ /**
*
* Returning NULL since this class is a base-level client, used (only)
* to obtain the base service URL.
*
*/
public class IndexClient extends AbstractCommonListPoxServiceClientImpl<IndexProxy, IndexCommon> {
+
public static final String SERVICE_NAME = "index";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
public static final String SERVICE_AUTHZ_SUFFIX = "/*/" + SERVICE_PATH_COMPONENT + "/";
public static final String INDEX_ID_PARAM = "indexid";
+ public IndexClient() throws Exception {
+ super();
+ }
+
@Override
public String getServiceName() {
return SERVICE_NAME;
* @param client
* @param vcsid
* @return
+ * @throws Exception
*/
- abstract protected String createItemInAuthority(AuthorityClient client, String vcsid, String shortId);
+ abstract protected String createItemInAuthority(AuthorityClient client, String vcsid, String shortId) throws Exception;
/**
* Gets a client to the SAS (Shared Authority Server)
*
* @return the client
+ * @throws Exception
*/
- protected AuthorityClient getSASClientInstance() {
+ protected AuthorityClient getSASClientInstance() throws Exception {
return (AuthorityClient) this.getClientInstance(CollectionSpaceClient.SAS_CLIENT_PROPERTIES_FILENAME);
}
}
@Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
- public void createItem(String testName) {
+ public void createItem(String testName) throws Exception {
// Perform setup.
setupCreate();
/**
* Verify that we can test synchronization with this authority. Otherwise, we skip the test.
+ * @throws Exception
*/
- private void assertSupportsSync() {
+ private void assertSupportsSync() throws Exception {
//
// Test to see if the authority on our locally tenant supports sync
//
/**
* Check to make sure the sync with the SAS returned the correct number of items as well as items
* with the correct short IDs.
+ * @throws Exception
*
*/
@Test(dataProvider = "testName", dependsOnMethods = {"syncWithSAS", "CRUDTests"})
- public void veryifySyncWithSAS(String testName) {
+ public void veryifySyncWithSAS(String testName) throws Exception {
//
// First check to see if we support sync.
//
}
@Test(dataProvider = "testName", dependsOnMethods = {"syncWithSASWithRelations", "CRUDTests"})
- public void veryifySyncWithSASWithRelations(String testName) {
+ public void veryifySyncWithSASWithRelations(String testName) throws Exception {
//
// First check to see if we support sync.
//
* @param subjectShortId
* @param objectShortId
* @param authorityItemDocumentType
+ * @throws Exception
*/
- private void verifyBroaderRelationship(AuthorityClient authorityClient, String authorityShortId, String subjectShortId, String objectShortId, String authorityItemDocumentType) {
+ private void verifyBroaderRelationship(AuthorityClient authorityClient, String authorityShortId, String subjectShortId, String objectShortId, String authorityItemDocumentType) throws Exception {
setupReadList();
RelationClient relationClient = new RelationClient();
Response res = relationClient.readList(getCsidFromShortId(authorityClient, authorityShortId, subjectShortId),
/**
* SAS - Create a new authority on the SAS server.
* @param testName
+ * @throws Exception
*/
@Test(dataProvider = "testName", dependsOnMethods = {"createItem", "CRUDTests"})
- public void createSASAuthority(String testName) {
+ public void createSASAuthority(String testName) throws Exception {
//
// First check to see if the authority supports synchronization.
//
}
@Test(dataProvider = "testName", dependsOnMethods = {"deleteLocalItemWithSync", "CRUDTests"})
- public void createSASAuthorityWithRelations(String testName) {
+ public void createSASAuthorityWithRelations(String testName) throws Exception {
//
// First check to see if the authority supports synchronization.
//
/**
* SAS - Create an item in the SAS authority on the SAS server.
* @param testName
+ * @throws Exception
*/
@Test(dataProvider = "testName", dependsOnMethods = {"createSASAuthority", "CRUDTests"})
- public void createSASItemList(String testName) {
+ public void createSASItemList(String testName) throws Exception {
//
// First check to see if the authority supports synchronization.
//
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
dependsOnMethods = {"readItem"})
- public void readItemNonExistent(String testName) {
+ public void readItemNonExistent(String testName) throws Exception {
// Perform setup.
setupReadNonExistent();
Assert.assertEquals(statusCode, testExpectedStatusCode);
}
- protected void readItemListInt(String vcsid, String shortId, String testName) {
+ protected void readItemListInt(String vcsid, String shortId, String testName) throws Exception {
// Perform setup.
setupReadList();
}
@Test(dataProvider = "testName", dependsOnMethods = {"createItemList"})
- public void readItemList(String testName) {
+ public void readItemList(String testName) throws Exception {
readItemListInt(knownAuthorityWithItems, null, testName);
}
@Test(dataProvider = "testName", dependsOnMethods = {"readItemList"})
- public void readItemListByName(String testName) {
+ public void readItemListByName(String testName) throws Exception {
readItemListInt(null, knownAuthorityWithItemsIdentifier, testName);
}
@Test(dataProvider = "testName",
dependsOnMethods = {"deleteItem"})
- public void deleteNonExistentItem(String testName) {
+ public void deleteNonExistentItem(String testName) throws Exception {
// Perform setup.
setupDeleteNonExistent();
return AuthorityClient.ITEMS;
}
- public PoxPayloadOut createItemRequestTypeInstance(AUTHORITY_ITEM_TYPE itemTypeInstance) {
+ public PoxPayloadOut createItemRequestTypeInstance(AUTHORITY_ITEM_TYPE itemTypeInstance) throws Exception {
PoxPayloadOut result = null;
AuthorityClient client = (AuthorityClient) getClientInstance();
}
@Override
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
}
@Override
- public PoxPayloadOut createRequestTypeInstance(CPT commonPartTypeInstance) {
+ public PoxPayloadOut createRequestTypeInstance(CPT commonPartTypeInstance) throws Exception {
PoxPayloadOut result = null;
CollectionSpaceClient client = this.getClientInstance();
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.workflow.WorkflowClient;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.Test;
+
import javax.ws.rs.core.Response;
/**
* $LastChangedDate$
*/
// FIXME: http://issues.collectionspace.org/browse/CSPACE-1685
+@SuppressWarnings("rawtypes")
public abstract class AbstractServiceTestImpl<CLT, CPT, REQUEST_TYPE, RESPONSE_TYPE>
extends BaseServiceTest<CLT> implements ServiceTest {
/** The logger. */
/*
* Sub-classes can override for the workflow tests.
*/
- protected REQUEST_TYPE createInstance(String identifier) {
+ protected REQUEST_TYPE createInstance(String identifier) throws Exception {
String commonPartName = getClientInstance().getCommonPartName();
return createInstance(commonPartName, identifier);
}
/**
* Sub-classes must override this method for the "Create" tests to work properly
+ * @throws Exception
*/
- protected abstract REQUEST_TYPE createInstance(String commonPartName, String identifier);
+ protected abstract REQUEST_TYPE createInstance(String commonPartName, String identifier) throws Exception;
- protected REQUEST_TYPE createNonExistenceInstance(String commonPartName, String identifier) {
+ protected REQUEST_TYPE createNonExistenceInstance(String commonPartName, String identifier) throws Exception {
return createInstance(commonPartName, identifier);
}
abstract public Class<RESPONSE_TYPE> getEntityResponseType();
- @SuppressWarnings("unchecked")
@Override
@Test(dataProvider = "testName", dependsOnMethods = {"create"})
public void read(String testName) throws Exception {
return (CPT)req;
}
- public REQUEST_TYPE createRequestTypeInstance(CPT commonPartTypeInstance) {
+ public REQUEST_TYPE createRequestTypeInstance(CPT commonPartTypeInstance) throws Exception {
return (REQUEST_TYPE)commonPartTypeInstance;
}
Assert.assertEquals(updatedWorkflowCommons.getCurrentLifeCycleState(), lifeCycleState);
}
- private CollectionSpacePoxClient assertPoxClient() {
- CollectionSpaceClient clientCandidate = this.getClientInstance();
+ private CollectionSpacePoxClient assertPoxClient() throws Exception {
+ CollectionSpaceClient clientCandidate = this.getClientInstance();
if (CollectionSpacePoxClient.class.isInstance(clientCandidate) != true) { //FIXME: REM - We should remove this check and instead make CollectionSpaceClient support the readIncludeDeleted() method.
String clientCandidateName = "Unknown";
if (clientCandidate != null) {
/*
* Return the number of items including those soft-deleted.
*/
- protected long readIncludeDeleted(String testName, Boolean includeDeleted) {
+ protected long readIncludeDeleted(String testName, Boolean includeDeleted) throws Exception {
long result = 0;
// Perform setup.
setupReadList();
return result;
}
- protected long readItemsIncludeDeleted(String testName, String parentCsid, Boolean includeDeleted) {
+ protected long readItemsIncludeDeleted(String testName, String parentCsid, Boolean includeDeleted) throws Exception {
long result = 0;
// Perform setup.
setupReadList();
return result;
}
- protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) {
+ protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) throws Exception {
logger.warn("Sub-class test clients should override this method");
throw new UnsupportedOperationException();
}
}
}
- @SuppressWarnings("unchecked")
- protected void updateItemLifeCycleState(String testName, String parentCsid, String itemCsid, String workflowTransition, String lifeCycleState) throws Exception {
+ protected void updateItemLifeCycleState(String testName, String parentCsid, String itemCsid, String workflowTransition, String lifeCycleState) throws Exception {
//
// Read the existing object
//
/*
* <CLT> - Common list type
*/
+@SuppressWarnings("rawtypes")
public abstract class BaseServiceTest<CLT> {
//A default MIME type result
static protected final String DEFAULT_MIME = "application/octet-stream; charset=ISO-8859-1";
protected static final String MAVEN_BASEDIR_PROPERTY = "maven.basedir";
/** The Constant logger. */
private static final Logger logger = LoggerFactory.getLogger(BaseServiceTest.class);
- /** The Constant serviceClient. */
- protected static final TestServiceClient serviceClient = new TestServiceClient();
+
+ /** The static serviceClient for all instances */
+ protected static TestServiceClient serviceClient;
+ static {
+ try {
+ serviceClient = new TestServiceClient();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
protected String knownResourceIdentifier = null;
/** Use this to keep track of a single known resource */
//
// Status constants
//
- protected static final int STATUS_BAD_REQUEST =
- Response.Status.BAD_REQUEST.getStatusCode();
- protected static final int STATUS_CREATED =
- Response.Status.CREATED.getStatusCode();
- protected static final int STATUS_INTERNAL_SERVER_ERROR =
- Response.Status.INTERNAL_SERVER_ERROR.getStatusCode();
- protected static final int STATUS_NOT_FOUND =
- Response.Status.NOT_FOUND.getStatusCode();
- protected static final int STATUS_OK =
- Response.Status.OK.getStatusCode();
- protected static final int STATUS_FORBIDDEN =
- Response.Status.FORBIDDEN.getStatusCode();
+ protected static final int STATUS_BAD_REQUEST = Response.Status.BAD_REQUEST.getStatusCode();
+ protected static final int STATUS_CREATED = Response.Status.CREATED.getStatusCode();
+ protected static final int STATUS_INTERNAL_SERVER_ERROR = Response.Status.INTERNAL_SERVER_ERROR.getStatusCode();
+ protected static final int STATUS_NOT_FOUND = Response.Status.NOT_FOUND.getStatusCode();
+ protected static final int STATUS_OK = Response.Status.OK.getStatusCode();
+ protected static final int STATUS_FORBIDDEN = Response.Status.FORBIDDEN.getStatusCode();
//
// "Global flag to cancel cleanup() method
//
private static boolean cancelCleanup = false;
-
+
+ /**
+ * Instantiates a new base service test.
+ * @throws Exception
+ */
+ public BaseServiceTest() {
+ super();
+ }
+
//
// Decide if cleanup should happen
//
cancelCleanup = true;
}
- /**
- * Instantiates a new base service test.
- */
- public BaseServiceTest() {
- super();
- }
-
/*
* A getter for retrieving the tests logger
*/
* Gets the client.
*
* @return the client
+ * @throws Exception
*/
- abstract protected CollectionSpaceClient getClientInstance();
+ abstract protected CollectionSpaceClient getClientInstance() throws Exception;
/**
* Gets the client.
*
* @return the client
+ * @throws Exception
*/
- abstract protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename);
+ abstract protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception;
/*
* Subclasses can override this method to return their AbstractCommonList subclass
* base path, if any.
*
* @return The URL path component of the service.
+ * @throws Exception
*/
- protected abstract String getServicePathComponent();
+ protected abstract String getServicePathComponent() throws Exception;
protected abstract String getServiceName();
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun = true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
if (cleanupCancelled() == true) {
if (logger.isDebugEnabled()) {
logger.debug("Skipping Cleanup phase ...");
*
*/
public class WorkflowClient extends AbstractCommonListPoxServiceClientImpl<WorkflowProxy, WorkflowCommon> {
+
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;
statesMappedToTransitions.put(WORKFLOWSTATE_DELETED, WORKFLOWTRANSITION_DELETE);
statesMappedToTransitions.put("c", "d");
}
+
+ public WorkflowClient() throws Exception {
+ super();
+ }
@Override
public String getServiceName() {
@Override
public Class<WorkflowProxy> getProxyClass() {
- // TODO Auto-generated method stub
return WorkflowProxy.class;
}
#
# URL of the CollectionSpace server and user credentials
#
-cspace.url=http://qa.collectionspace.org:8180/cspace-services/
+cspace.url=http://localhost:8180/cspace-services/
cspace.ssl=false
cspace.auth=true
-cspace.user=admin@materials.collectionspace.org
+cspace.user=admin@testsci.collectionspace.org
cspace.password=Administrator
#
# default tenant information
#
-cspace.tenant=2000
-cspace.tenantID=materials.collectionspace.org
\ No newline at end of file
+cspace.tenant=2
+cspace.tenantID=testsci.collectionspace.org
\ No newline at end of file
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
public static final String SERVICE_COMMON_PART_NAME = SERVICE_NAME + PART_LABEL_SEPARATOR + PART_COMMON_LABEL;
- public CollectionObjectClient() {
+ public CollectionObjectClient() throws Exception {
super();
}
- public CollectionObjectClient(String clientPropertiesFilename) {
+ public CollectionObjectClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.organization.OrgTermGroup;
import org.collectionspace.services.person.PersonTermGroup;
-
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
*
* @param displayName the display name of the authority
* @param shortIdentifier the short identifier for the authority
+ * @throws Exception
*/
- private void createPersonAuthority(String displayName, String shortIdentifier) {
+ private void createPersonAuthority(String displayName, String shortIdentifier) throws Exception {
testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
* @param surName the person's surname
* @param shortIdentifier the short identifier for the item
* @return the CSID of the newly-created person record
+ * @throws Exception
*/
- protected String createPerson(String firstName, String surName, String shortIdentifier ) {
+ protected String createPerson(String firstName, String surName, String shortIdentifier ) throws Exception {
String result = null;
Map<String, String> personInfo = new HashMap<String,String>();
/**
* Creates multiple Person items within a Person Authority,
* and stores the refNames referring to each.
+ * @throws Exception
*/
- protected void createPersonRefs(){
+ protected void createPersonRefs() throws Exception{
createPersonAuthority(PERSON_AUTHORITY_NAME_DISPLAY, PERSON_AUTHORITY_NAME);
*
* @param displayName the display name of the authority
* @param shortIdentifier the short identifier for the authority
+ * @throws Exception
*/
- private void createOrgAuthority(String displayName, String shortIdentifier) {
+ private void createOrgAuthority(String displayName, String shortIdentifier) throws Exception {
testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance(
* @param foundingPlace the organization's founding place
* @param shortIdentifier the short identifier for the item
* @return the CSID of the newly-created organization record
+ * @throws Exception
*/
- protected String createOrganization(String shortName, String foundingPlace, String shortIdentifier ) {
+ protected String createOrganization(String shortName, String foundingPlace, String shortIdentifier ) throws Exception {
String result = null;
Map<String, String> orgInfo = new HashMap<String,String>();
/**
* Creates multiple Organization items within an Organization Authority,
* and stores the refNames referring to each.
+ * @throws Exception
*/
- private void createOrganizationRefs() {
-
+ private void createOrganizationRefs() throws Exception {
createOrgAuthority(ORG_AUTHORITY_NAME, ORG_AUTHORITY_NAME);
-
String csid = "";
-
csid = createOrganization("Content Org", "Content Org Town", "contentOrg");
contentOrganizationRefName = OrgAuthorityClientUtils.getOrgRefName(orgAuthCSID, csid, null);
orgIdsCreated.add(csid);
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
* @param contentPerson the content person
* @param inscriber the inscriber
* @return the multipart output
+ * @throws Exception
*/
private PoxPayloadOut createCollectionObjectInstance(
String title,
String assocEventPerson,
String owner,
String fieldCollectionSource,
- String fieldCollector ) {
+ String fieldCollector ) throws Exception {
CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
TitleGroupList titleGroupList = new TitleGroupList();
List<TitleGroup> titleGroups = titleGroupList.getTitleGroup();
@Override
protected String getServiceName() {
- throw new UnsupportedOperationException(); // FIXME: REM - See
- // http://issues.collectionspace.org/browse/CSPACE-3498
+ throw new UnsupportedOperationException(); // FIXME: REM - See // http://issues.collectionspace.org/browse/CSPACE-3498
}
@Override
protected String getServicePathComponent() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException(); // FIXME: REM - See
- // http://issues.collectionspace.org/browse/CSPACE-3498
+ throw new UnsupportedOperationException(); // FIXME: REM - See // http://issues.collectionspace.org/browse/CSPACE-3498
}
- // /* (non-Javadoc)
- // * @see
- // org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
- // */
- // @Override
- // protected String getServicePathComponent() {
- // return new CollectionObjectClient().getServicePathComponent(); //FIXME:
- // REM = Remove all refs to this method.
- // }
-
/*
* (non-Javadoc)
*
* ()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new CollectionObjectClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new CollectionObjectClient(clientPropertiesFilename);
}
* database-specific constraint or otherwise, if the number of records
* containing a particular keyword represent too high a proportion of the
* total number of records.
+ * @throws Exception
*/
@BeforeClass(alwaysRun = true)
- public void setup() {
+ public void setup() throws Exception {
if (logger.isDebugEnabled()) {
logger.debug("Creating " + numNoiseWordResources
+ " 'noise word' resources ...");
// }
// }
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, groups = { "utf8" })
- public void searchWithUTF8Keyword(String testName) {
+ public void searchWithUTF8Keyword(String testName) throws Exception {
// Create one or more keyword retrievable resources, each containing
// two specified keywords.
long numKeywordRetrievableResources = 2;
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun = true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
- private void createCollectionObjects(long numToCreate, String keyword) {
+ private void createCollectionObjects(long numToCreate, String keyword) throws Exception {
List keywords = new ArrayList<String>();
keywords.add(keyword);
boolean keywordsInSameField = true;
}
private void createCollectionObjects(long numToCreate,
- List<String> keywords, boolean keywordsInSameField) {
+ List<String> keywords, boolean keywordsInSameField) throws Exception {
testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
CollectionObjectClient client = new CollectionObjectClient();
for (long i = 0; i < numToCreate; i++) {
}
private PoxPayloadOut createCollectionObjectInstance(long i,
- List<String> keywords, boolean keywordsInSameField) {
+ List<String> keywords, boolean keywordsInSameField) throws Exception {
CollectionobjectsCommon collectionObject = new CollectionobjectsCommon();
collectionObject.setObjectNumber(createIdentifier());
if (keywordsInSameField) {
return sb.toString();
}
- private Response doSearch(List<String> keywords) {
+ private Response doSearch(List<String> keywords) throws Exception {
String searchParamValue = listToString(keywords, KEYWORD_SEPARATOR);
return doSearch(searchParamValue);
}
private Response doAdvancedSearch(
- String propertyName, String propertyValue, String operator) {
+ String propertyName, String propertyValue, String operator) throws Exception {
if (logger.isDebugEnabled()) {
logger.debug("Searching on property: " + propertyName + "="
+ "'" + propertyValue + "'");
return res;
}
- private Response doSearch(String keyword) {
+ private Response doSearch(String keyword) throws Exception {
String searchParamValue = keyword;
if (logger.isDebugEnabled()) {
logger.debug("Searching on keyword(s): " + searchParamValue
import javax.ws.rs.core.Response;
+
+
+
+
+
+
+
+
+
+
+
+
//import org.collectionspace.services.client.AbstractServiceClientImpl;
import org.collectionspace.services.client.CollectionObjectClient;
import org.collectionspace.services.client.CollectionObjectFactory;
import org.collectionspace.services.collectionobject.TitleGroup;
import org.collectionspace.services.collectionobject.TitleGroupList;
import org.collectionspace.services.jaxb.AbstractCommonList;
-
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new CollectionObjectClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new CollectionObjectClient(clientPropertiesFilename);
}
* @param testName the test name
* @param id the id
* @return the client response
+ * @throws Exception
*/
- private Response updateRetrieve(String testName, String id) {
+ private Response updateRetrieve(String testName, String id) throws Exception {
setupRead();
CollectionObjectClient client = new CollectionObjectClient();
Response res = client.read(knownResourceId);
* @param testName the test name
* @param id the id
* @return the client response
+ * @throws Exception
*/
private Response updateSend(String testName, String id,
- CollectionobjectsCommon collectionObjectCommon) {
+ CollectionobjectsCommon collectionObjectCommon) throws Exception {
setupUpdate();
PoxPayloadOut output = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
PayloadOutputPart commonPart = output.addPart(collectionObjectCommon, MediaType.APPLICATION_XML_TYPE);
// Utility methods used by tests above
// ---------------------------------------------------------------
- private Response newCollectionObject() {
+ private Response newCollectionObject() throws Exception {
Response result = null;
CollectionObjectClient client = new CollectionObjectClient();
return result;
}
- private String newCollectionObject(boolean assertStatus) {
+ private String newCollectionObject(boolean assertStatus) throws Exception {
String result = null;
Response res = newCollectionObject();
package org.collectionspace.services.common.api;
import java.io.File;
+import java.io.InputStream;
+import java.util.Properties;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
return s;
}
+ /**
+ * Return a set of properties from a properties file.
+ *
+ * @param clientPropertiesFilename
+ * @return
+ */
+ static public Properties loadProperties(String clientPropertiesFilename) {
+ Properties inProperties = new Properties();
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ InputStream is = null;
+
+ try {
+ is = cl.getResourceAsStream(clientPropertiesFilename);
+ inProperties.load(is);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return inProperties;
+ }
+
+ static public Properties loadProperties(String clientPropertiesFilename, boolean filterPasswords) throws Exception {
+ Properties result = loadProperties(clientPropertiesFilename);
+
+ if (filterPasswords) {
+ result = filterPasswordsWithEnvVars(result);
+ }
+
+ return result;
+ }
+
+ static public Properties filterPasswordsWithEnvVars(Properties inProperties) throws Exception {
+ Properties result = inProperties;
+
+ if (inProperties != null && inProperties.size() > 0) {
+ for (String key : inProperties.stringPropertyNames()) {
+ String propertyValue = inProperties.getProperty(key);
+ String newPropertyValue = Tools.getPasswordFromEnv(propertyValue);
+ if (newPropertyValue != null) { // non-null result means the property value was the name of an environment variable
+ inProperties.setProperty(key, newPropertyValue);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Try to find the value of a password variable in the system or JVM environment. This code substitutes only environment variables formed
+ * like ${cspace.password.mysecret} or ${cspace_password_mysecret_secret}. The corresponding environment variables would
+ * be "cspace.password.mysecret" and "cspace.password.mysecret.secret".
+ *
+ * Returns null if the passed in propertyValue is not a password variable -i.e., not something of the form {$cspace.password.foo}
+ *
+ * Throws an exception if the passed in propertyValue has a valid variable form but the corresponding environment variable is not
+ * set.
+ *
+ * @param propertyValue
+ * @return
+ * @throws Exception
+ */
+ static private String getPasswordFromEnv(String propertyValue) throws Exception {
+ String result = null;
+ //
+ // Replace things like ${cspace.password.cow} with values from either the environment
+ // or from the JVM system properties.
+ //
+ Pattern pattern = Pattern.compile("\\$\\{([A-Za-z0-9_\\.]+)\\}"); // For example, "${cspace.password.mysecret}" or "${password_strong_longpassword}"
+ Matcher matcher = pattern.matcher(propertyValue);
+ String key = null;
+ if (matcher.find()) {
+ key = matcher.group(1); // Gets the string inside the ${} enclosure. For example, gets "cspace.password.mysecret" from "${cspace.password.mysecret}"
+ result = System.getenv(key);
+ if (result == null || result.isEmpty()) {
+ // If we couldn't find a value in the environment, check the JVM system properties
+ result = System.getProperty(key);
+ }
+ if (result == null || result.isEmpty()) {
+ String errMsg = String.format("Could find neither an environment variable nor a systen variable named '%s'", key);
+ throw new Exception(errMsg);
+ }
+ }
+
+ return result;
+ }
}
package org.collectionspace.services.client.test;
import java.io.IOException;
+
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.TraceMethod;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.TestServiceClient;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
private final String CLASS_NAME = ServiceLayerTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
- private TestServiceClient serviceClient = new TestServiceClient();
- private HttpClient httpClient = serviceClient.getHttpClient();
+ private TestServiceClient serviceClient;
+ private HttpClient httpClient;
@BeforeSuite
void printServiceClientProperties() {
+ serviceClient.getProperty(CollectionSpaceClient.PASSWORD_PROPERTY));
}
}
+
+ public ServiceLayerTest() throws Exception {
+ serviceClient = new TestServiceClient();
+ httpClient = serviceClient.getHttpClient();
+ }
@Test
public void servicesExist() {
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriInfo;
import org.collectionspace.services.client.IQueryManager;
import org.collectionspace.services.client.workflow.WorkflowClient;
import org.collectionspace.services.common.ServiceMain;
+import org.collectionspace.services.common.api.Tools;
import org.collectionspace.services.common.authorization_mgt.AuthorizationCommon;
import org.collectionspace.services.common.config.PropertyItemUtils;
import org.collectionspace.services.common.config.ServiceConfigUtils;
import org.collectionspace.services.config.ClientType;
import org.collectionspace.services.config.service.ObjectPartType;
import org.collectionspace.services.config.service.ServiceBindingType;
+import org.collectionspace.services.config.tenant.RemoteClientConfig;
import org.collectionspace.services.config.tenant.RepositoryDomainType;
import org.collectionspace.services.config.tenant.TenantBindingType;
import org.collectionspace.services.config.types.PropertyItemType;
* @param <IT>
* @param <OT>
*/
+@SuppressWarnings("rawtypes")
public abstract class AbstractServiceContextImpl<IT, OT>
implements ServiceContext<IT, OT> {
* (non-Javadoc)
* @see org.collectionspace.services.common.context.ServiceContext#getClient(java.lang.String)
*/
- @Override
+ @Override
public AuthorityClient getClient(String clientPropertiesFilename) throws Exception {
AuthorityClient result = null;
+ Properties inProperties = Tools.loadProperties(clientPropertiesFilename, true);
+ result = getClient(inProperties);
+
+ return result;
+ }
+
+ public AuthorityClient getClient(Properties inProperties) throws Exception {
+ AuthorityClient result = null;
+
String authorityClientClazz = getServiceBinding().getClientHandler();
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
authorityClientClazz = authorityClientClazz.trim();
Class<?> c = tccl.loadClass(authorityClientClazz);
if (AuthorityClient.class.isAssignableFrom(c)) {
result = authorityClient = ((AuthorityClient) c.newInstance());
- result.setClientProperties(clientPropertiesFilename);
+ result.setClientProperties(inProperties);
} else {
logger.error(String.format("The service binding clientHandler class '%s' for '%s' service was not of type AuthorityClient.",
authorityClientClazz, this.getServiceName()));
}
return result;
- }
+ }
+
+ @Override
+ public AuthorityClient getClient(RemoteClientConfig remoteClientConfig) throws Exception {
+ AuthorityClient result = null;
+
+ Properties properties = new Properties();
+ properties.setProperty(AuthorityClient.URL_PROPERTY, remoteClientConfig.getUrl());
+ properties.setProperty(AuthorityClient.USER_PROPERTY, remoteClientConfig.getUser());
+ properties.setProperty(AuthorityClient.PASSWORD_PROPERTY, remoteClientConfig.getPassword());
+ properties.setProperty(AuthorityClient.SSL_PROPERTY, remoteClientConfig.getSsl());
+ properties.setProperty(AuthorityClient.AUTH_PROPERTY, remoteClientConfig.getAuth());
+ properties.setProperty(AuthorityClient.TENANT_ID_PROPERTY, remoteClientConfig.getTenantId());
+ properties.setProperty(AuthorityClient.TENANT_NAME_PROPERTY, remoteClientConfig.getTenantName());
+
+ result = getClient(properties);
+ return result;
+ }
@Override
public void addValidatorHandler(ValidatorHandler<IT, OT> validator) throws Exception {
import org.collectionspace.services.config.ClientType;
import org.collectionspace.services.config.service.ObjectPartType;
import org.collectionspace.services.config.service.ServiceBindingType;
+import org.collectionspace.services.config.tenant.RemoteClientConfig;
import org.collectionspace.services.config.tenant.RepositoryDomainType;
/**
public CollectionSpaceClient getClient() throws Exception;
public CollectionSpaceClient getClient(String clientProperitesFilename) throws Exception;
+
+ public CollectionSpaceClient getClient(RemoteClientConfig remoteClientConfig) throws Exception;
/**
* @return the JAX-RS resource of service for the current context.
import java.util.Map;
import java.util.StringTokenizer;
-import org.collectionspace.services.client.PoxPayloadIn;
-import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.common.api.RefName;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.query.QueryContext;
-import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package org.collectionspace.services.nuxeo.client.java;
import java.util.Hashtable;
+import java.util.List;
import javax.security.auth.login.LoginContext;
import org.collectionspace.services.config.ClientType;
import org.collectionspace.services.config.RepositoryClientConfigType;
import org.collectionspace.services.config.service.ServiceBindingType;
+import org.collectionspace.services.config.tenant.RemoteClientConfig;
+import org.collectionspace.services.config.tenant.RemoteClientConfigurations;
import org.collectionspace.services.config.tenant.RepositoryDomainType;
import org.collectionspace.services.config.tenant.TenantBindingType;
+
import org.nuxeo.runtime.api.Framework;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//
// Constructors
//
- public ConceptAuthorityClient() {
+ public ConceptAuthorityClient() throws Exception {
super();
}
- public ConceptAuthorityClient(String clientPropertiesFilename) {
+ public ConceptAuthorityClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.concept.ConceptsCommon;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.dom4j.DocumentException;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new ConceptAuthorityClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new ConceptAuthorityClient(clientPropertiesFilename);
}
*
* @param vcsid the vcsid
* @param name the name
+ * @throws Exception
*/
- private void readItemList(String vcsid, String shortId) {
+ private void readItemList(String vcsid, String shortId) throws Exception {
String testName = "readItemList";
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
ConceptAuthorityClient client = new ConceptAuthorityClient();
String shortId = identifier;
String displayName = "displayName-" + shortId;
public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
- public ConditioncheckClient() {
+ public ConditioncheckClient() throws Exception {
super();
}
- public ConditioncheckClient(String clientPropertiesFilename) {
+ public ConditioncheckClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.conditioncheck.ConditionchecksCommon;
import org.collectionspace.services.person.PersonTermGroup;
-
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
}
}
- protected void createPersonRefs(){
+ protected void createPersonRefs() throws Exception{
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
// Create a temporary PersonAuthority resource, and its corresponding
// refName by which it can be identified.
conditionCheckerRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
}
- protected String createPerson(String firstName, String surName, String shortId, String authRefName ) {
+ protected String createPerson(String firstName, String surName, String shortId, String authRefName ) throws Exception {
String result = null;
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
}
private PoxPayloadOut createConditioncheckInstance(String conditionCheckRefNumber,
- String conditionChecker) {
+ String conditionChecker) throws Exception {
ConditionchecksCommon conditioncheckCommon = new ConditionchecksCommon();
conditioncheckCommon.setConditionCheckRefNumber(conditionCheckRefNumber);
import org.collectionspace.services.conditioncheck.ConditionchecksCommon;
import org.collectionspace.services.conditioncheck.HazardGroupList;
import org.collectionspace.services.conditioncheck.HazardGroup;
-
import org.testng.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new ConditioncheckClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new ConditioncheckClient(clientPropertiesFilename);
}
}
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
return createConditioncheckInstance(identifier);
}
*
* @param conditioncheckRefNumber the conditioncheck number
* @return the multipart output
+ * @throws Exception
*/
- private PoxPayloadOut createConditioncheckInstance(String conditionCheckRefNumber) {
+ private PoxPayloadOut createConditioncheckInstance(String conditionCheckRefNumber) throws Exception {
ConditionchecksCommon conditioncheckCommon = new ConditionchecksCommon();
conditioncheckCommon.setConditionCheckRefNumber(conditionCheckRefNumber);
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
PoxPayloadOut result = createConditioncheckInstance(identifier);
return result;
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<tenant:TenantBindingConfig xmlns:types="http://collectionspace.org/services/config/types"
+ xmlns:service="http://collectionspace.org/services/config/service"
+ xmlns:remoteclientconfig="http://collectionspace.org/services/config/remoteclientconfig"
+ xmlns:tenant="http://collectionspace.org/services/config/tenant"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://collectionspace.org/services/config/tenant file:/C:/dev/src/cspace/services/services/config/src/main/resources/tenant.xsd">
+ <tenant:tenantBinding id="ID000" name="name0" displayName="displayName0" version="0.1" createDisabled="false">
+ <tenant:repositoryDomain name="name1" storageName="storageName0" repositoryName="default" repositoryClient="nuxeo-java"/>
+ <tenant:repositoryDomain name="name2" storageName="storageName1" repositoryName="default" repositoryClient="nuxeo-java"/>
+ <tenant:binaryStorePath>123</tenant:binaryStorePath>
+ <tenant:properties>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ </tenant:properties>
+ <tenant:properties>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ </tenant:properties>
+ <tenant:remoteClientConfigurations>
+ <tenant:remoteClientConfig>
+ <tenant:name>123</tenant:name>
+ <tenant:url>123</tenant:url>
+ <tenant:user>123</tenant:user>
+ <tenant:password>123</tenant:password>
+ <tenant:tenantId>123</tenant:tenantId>
+ <tenant:tenantName>123</tenant:tenantName>
+ <tenant:ssl>123</tenant:ssl>
+ <tenant:auth>123</tenant:auth>
+ </tenant:remoteClientConfig>
+ <tenant:remoteClientConfig>
+ <tenant:name>123</tenant:name>
+ <tenant:url>123</tenant:url>
+ <tenant:user>123</tenant:user>
+ <tenant:password>123</tenant:password>
+ <tenant:tenantId>123</tenant:tenantId>
+ <tenant:tenantName>123</tenant:tenantName>
+ <tenant:ssl>123</tenant:ssl>
+ <tenant:auth>123</tenant:auth>
+ </tenant:remoteClientConfig>
+ </tenant:remoteClientConfigurations>
+ <tenant:serviceBindings name="name3" type="type0" version="0.1" supportsReplicating="false" requiresUniqueShortId="false">
+ <service:uriPath>123</service:uriPath>
+ <service:uriPath>123</service:uriPath>
+ <service:object name="name4" version="0.1">
+ <service:property>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ </service:property>
+ <service:property>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ </service:property>
+ <service:part id="ID001" control_group="External" versionable="false" auditable="false" label="label0" updated="2006-05-04T18:13:51.0" order="0">
+ <service:properties>
+ </service:properties>
+ <service:properties>
+ </service:properties>
+ <service:content contentType="contentType0">
+<!-- <service:xmlContent schemaLocation="schemaLocation0" namespaceURI="namespaceURI0">
+ </service:xmlContent>-->
+<!-- <service:contentLocation type="internalId" ref="http://www.oxygenxml.com/"/>-->
+ <service:binaryContent>123</service:binaryContent>
+ </service:content>
+ </service:part>
+ <service:part id="ID002" control_group="External" versionable="false" auditable="false" label="label1" updated="2006-05-04T18:13:51.0" order="0">
+ <service:properties>
+ </service:properties>
+ <service:properties>
+ </service:properties>
+ <service:content contentType="contentType1">
+<!-- <service:xmlContent schemaLocation="schemaLocation1" namespaceURI="namespaceURI1">
+ </service:xmlContent>-->
+ <service:contentLocation type="internalId" ref="http://www.oxygenxml.com/"/>
+<!-- <service:binaryContent>123</service:binaryContent>-->
+ </service:content>
+ </service:part>
+ <service:serviceHandler>123</service:serviceHandler>
+ </service:object>
+ <service:documentHandler>123</service:documentHandler>
+ <service:DocHandlerParams>
+ <service:classname>123</service:classname>
+ <service:params>
+ <service:SchemaName>123</service:SchemaName>
+ <service:RefnameDisplayNameField>
+ <service:setter>123</service:setter>
+ <service:element>123</service:element>
+ <service:schema>123</service:schema>
+ <service:xpath>123</service:xpath>
+ </service:RefnameDisplayNameField>
+ <service:SupportsHierarchy>123</service:SupportsHierarchy>
+ <service:SupportsVersioning>123</service:SupportsVersioning>
+ <service:DublinCoreTitle>123</service:DublinCoreTitle>
+ <service:SummaryFields>123</service:SummaryFields>
+ <service:AbstractCommonListClassname>123</service:AbstractCommonListClassname>
+ <service:CommonListItemClassname>123</service:CommonListItemClassname>
+ <service:ListResultsItemMethodName>123</service:ListResultsItemMethodName>
+ <service:ListResultsFields>
+ <service:Extended>123</service:Extended>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler>123</service:validatorHandler>
+ <service:validatorHandler>123</service:validatorHandler>
+ <service:clientHandler>123</service:clientHandler>
+ <service:disableAsserts>123</service:disableAsserts>
+ <service:initHandler>
+ <service:classname>123</service:classname>
+ <service:params>
+ <service:field>
+ </service:field>
+ <service:field>
+ </service:field>
+ <service:property>
+ <service:key>123</service:key>
+ <service:value>123</service:value>
+ </service:property>
+ <service:property>
+ <service:key>123</service:key>
+ <service:value>123</service:value>
+ </service:property>
+ </service:params>
+ </service:initHandler>
+ <service:initHandler>
+ <service:classname>123</service:classname>
+ <service:params>
+ <service:field>
+ </service:field>
+ <service:field>
+ </service:field>
+ <service:property>
+ <service:key>123</service:key>
+ <service:value>123</service:value>
+ </service:property>
+ <service:property>
+ <service:key>123</service:key>
+ <service:value>123</service:value>
+ </service:property>
+ </service:params>
+ </service:initHandler>
+ <service:repositoryDomain>123</service:repositoryDomain>
+ <service:repositoryWorkspaceId>123</service:repositoryWorkspaceId>
+ <service:properties>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ </service:properties>
+ <service:properties>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ </service:properties>
+ </tenant:serviceBindings>
+ <tenant:serviceBindings name="name5" type="type3" version="0.1" supportsReplicating="false" requiresUniqueShortId="false">
+ <service:uriPath>123</service:uriPath>
+ <service:uriPath>123</service:uriPath>
+ <service:object name="name6" version="0.1">
+ <service:property>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ </service:property>
+ <service:property>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ </service:property>
+ <service:part id="ID003" control_group="External" versionable="false" auditable="false" label="label2" updated="2006-05-04T18:13:51.0" order="0">
+ <service:properties>
+ </service:properties>
+ <service:properties>
+ </service:properties>
+ <service:content contentType="contentType2">
+<!-- <service:xmlContent schemaLocation="schemaLocation2" namespaceURI="namespaceURI2">
+ </service:xmlContent>-->
+<!-- <service:contentLocation type="internalId" ref="http://www.oxygenxml.com/"/>-->
+ <service:binaryContent>123</service:binaryContent>
+ </service:content>
+ </service:part>
+ <service:part id="ID004" control_group="External" versionable="false" auditable="false" label="label3" updated="2006-05-04T18:13:51.0" order="0">
+ <service:properties>
+ </service:properties>
+ <service:properties>
+ </service:properties>
+ <service:content contentType="contentType3">
+ <service:xmlContent schemaLocation="schemaLocation3" namespaceURI="namespaceURI3">
+ </service:xmlContent>
+<!-- <service:contentLocation type="internalId" ref="http://www.oxygenxml.com/"/>-->
+<!-- <service:binaryContent>123</service:binaryContent>-->
+ </service:content>
+ </service:part>
+ <service:serviceHandler>123</service:serviceHandler>
+ </service:object>
+ <service:documentHandler>123</service:documentHandler>
+ <service:DocHandlerParams>
+ <service:classname>123</service:classname>
+ <service:params>
+ <service:SchemaName>123</service:SchemaName>
+ <service:RefnameDisplayNameField>
+ <service:setter>123</service:setter>
+ <service:element>123</service:element>
+ <service:schema>123</service:schema>
+ <service:xpath>123</service:xpath>
+ </service:RefnameDisplayNameField>
+ <service:SupportsHierarchy>123</service:SupportsHierarchy>
+ <service:SupportsVersioning>123</service:SupportsVersioning>
+ <service:DublinCoreTitle>123</service:DublinCoreTitle>
+ <service:SummaryFields>123</service:SummaryFields>
+ <service:AbstractCommonListClassname>123</service:AbstractCommonListClassname>
+ <service:CommonListItemClassname>123</service:CommonListItemClassname>
+ <service:ListResultsItemMethodName>123</service:ListResultsItemMethodName>
+ <service:ListResultsFields>
+ <service:Extended>123</service:Extended>
+ </service:ListResultsFields>
+ </service:params>
+ </service:DocHandlerParams>
+ <service:validatorHandler>123</service:validatorHandler>
+ <service:validatorHandler>123</service:validatorHandler>
+ <service:clientHandler>123</service:clientHandler>
+ <service:disableAsserts>123</service:disableAsserts>
+ <service:initHandler>
+ <service:classname>123</service:classname>
+ <service:params>
+ <service:field>
+ </service:field>
+ <service:field>
+ </service:field>
+ <service:property>
+ <service:key>123</service:key>
+ <service:value>123</service:value>
+ </service:property>
+ <service:property>
+ <service:key>123</service:key>
+ <service:value>123</service:value>
+ </service:property>
+ </service:params>
+ </service:initHandler>
+ <service:initHandler>
+ <service:classname>123</service:classname>
+ <service:params>
+ <service:field>
+ </service:field>
+ <service:field>
+ </service:field>
+ <service:property>
+ <service:key>123</service:key>
+ <service:value>123</service:value>
+ </service:property>
+ <service:property>
+ <service:key>123</service:key>
+ <service:value>123</service:value>
+ </service:property>
+ </service:params>
+ </service:initHandler>
+ <service:repositoryDomain>123</service:repositoryDomain>
+ <service:repositoryWorkspaceId>123</service:repositoryWorkspaceId>
+ <service:properties>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ </service:properties>
+ <service:properties>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ <types:item>
+ <types:key>123</types:key>
+ <types:value>123</types:value>
+ </types:item>
+ </service:properties>
+ </tenant:serviceBindings>
+ </tenant:tenantBinding>
+</tenant:TenantBindingConfig>
<xs:attribute name="type" type="xs:string" use="optional"/>
<xs:attribute name="version" type="types:VersionType" use="required"/>
<xs:attribute name="supportsReplicating" type="xs:boolean" default="false"/>
+ <xs:attribute name="remoteClientConfigName" type="xs:string"/>
<xs:attribute name="requiresUniqueShortId" type="xs:boolean" default="false"/>
</xs:complexType>
xmlns="http://collectionspace.org/services/config/tenant"
xmlns:types="http://collectionspace.org/services/config/types"
xmlns:service="http://collectionspace.org/services/config/service"
+ xmlns:remoteclientconfig="http://collectionspace.org/services/config/remoteclientconfig"
targetNamespace="http://collectionspace.org/services/config/tenant"
version="0.1"
elementFormDefault="qualified">
<xs:import namespace="http://collectionspace.org/services/config/types" schemaLocation="types.xsd" />
- <xs:import namespace="http://collectionspace.org/services/config/service" schemaLocation="service.xsd" />
-
+ <xs:import namespace="http://collectionspace.org/services/config/service" schemaLocation="service.xsd" />
+
<xs:element name="TenantBindingConfig">
<xs:annotation>
<xs:documentation/>
<xs:element name="repositoryDomain" type="RepositoryDomainType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="binaryStorePath" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="properties" type="types:PropertyType" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element name="remoteClientConfigurations" type="RemoteClientConfigurations" minOccurs="0" maxOccurs="1"/>
<xs:element name="serviceBindings" type="service:ServiceBindingType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<!-- tenant id, a UUID -->
<xs:attribute name="repositoryClient" type="xs:string" use="optional" default="nuxeo-java"/>
</xs:complexType>
+ <xs:complexType name="RemoteClientConfigurations">
+ <xs:sequence>
+ <xs:element name="remoteClientConfig" type="RemoteClientConfig" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="RemoteClientConfig">
+ <xs:annotation>
+ <xs:documentation>Connection details for a remote CollectionSpace instance. Used for things like the Share Authority Server</xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1"/>
+ <xs:element name="url" type="xs:string" minOccurs="1" maxOccurs="1"/>
+ <xs:element name="user" type="xs:string" minOccurs="1" maxOccurs="1"/>
+ <xs:element name="password" type="xs:string" minOccurs="1" maxOccurs="1"/>
+ <xs:element name="tenantId" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="tenantName" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="ssl" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="auth" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+
</xs:schema>
public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
- public ConservationClient() {
+ public ConservationClient() throws Exception {
super();
}
- public ConservationClient(String clientPropertiesFilename) {
+ public ConservationClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.conservation.OtherPartyGroup;
import org.collectionspace.services.conservation.OtherPartyGroupList;
import org.collectionspace.services.person.PersonTermGroup;
-
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
}
}
- protected void createPersonRefs(){
+ protected void createPersonRefs() throws Exception{
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
// Create a temporary PersonAuthority resource, and its corresponding
// refName by which it can be identified.
sampleByRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
}
- protected String createPerson(String firstName, String surName, String shortId, String authRefName ) {
+ protected String createPerson(String firstName, String surName, String shortId, String authRefName ) throws Exception {
String result = null;
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
String examinationStaffRefName,
String approvedByRefName,
String researcherRefName,
- String sampleByRefName) {
+ String sampleByRefName) throws Exception {
ConservationCommon conservationCommon = new ConservationCommon();
conservationCommon.setConservationNumber(conservationNumber);
import org.collectionspace.services.conservation.ConservatorsList;
import org.collectionspace.services.conservation.ConservationStatusGroup;
import org.collectionspace.services.conservation.ConservationStatusGroupList;
-
import org.testng.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new ConservationClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new ConservationClient(clientPropertiesFilename);
}
}
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
return createConservationInstance(identifier);
}
* @param conservationNumber the conservation number
* @param returnDate the return date
* @return the multipart output
+ * @throws Exception
*/
- private PoxPayloadOut createConservationInstance(String identifier) {
+ private PoxPayloadOut createConservationInstance(String identifier) throws Exception {
ConservationCommon conservationCommon = new ConservationCommon();
conservationCommon.setConservationNumber("conservationNumber-" + identifier);
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
PoxPayloadOut result = createConservationInstance(identifier);
return result;
}
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
-import org.collectionspace.services.jaxb.AbstractCommonList;
-
/*
* LT - List type
* ILT - Authority item list type
extends AuthorityClientImpl<AUTHORITY_COMMON_TYPE, AUTHORITY_ITEM_TYPE, P>
implements AuthorityWithContactsClient<AUTHORITY_COMMON_TYPE, AUTHORITY_ITEM_TYPE, P> {
- public AuthorityWithContactsClientImpl(String clientPropertiesFilename) {
+ public AuthorityWithContactsClientImpl(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
- public AuthorityWithContactsClientImpl() {
+ public AuthorityWithContactsClientImpl() throws Exception {
super();
}
public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
- public ContactClient() {
+ public ContactClient() throws Exception {
super();
}
- public ContactClient(String clientPropertiesFilename) {
+ public ContactClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.jaxb.AbstractCommonList;
import java.util.List;
+
import javax.ws.rs.core.Response;
+
import org.testng.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*/
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";
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new ContactClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new ContactClient(clientPropertiesFilename);
}
public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
- public DimensionClient() {
+ public DimensionClient() throws Exception {
super();
}
- public DimensionClient(String clientPropertiesFilename) {
+ public DimensionClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.dimension.DimensionsCommon;
import org.collectionspace.services.jaxb.AbstractCommonList;
-
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new DimensionClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new DimensionClient(clientPropertiesFilename);
}
}
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
DimensionClient client = new DimensionClient();
return createInstance(client.getCommonPartName(), identifier);
}
public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
- public ExhibitionClient() {
+ public ExhibitionClient() throws Exception {
super();
}
- public ExhibitionClient(String clientPropertiesFilename) {
+ public ExhibitionClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.exhibition.ExhibitionsCommon;
import javax.ws.rs.core.Response;
+
import org.testng.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new ExhibitionClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new ExhibitionClient(clientPropertiesFilename);
}
}
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
return createExhibitionInstance(identifier);
}
*
* @param exhibitionNumber the exhibition number
* @return the multipart output
+ * @throws Exception
*/
- private PoxPayloadOut createExhibitionInstance(String exhibitionNumber) {
+ private PoxPayloadOut createExhibitionInstance(String exhibitionNumber) throws Exception {
ExhibitionsCommon exhibitionCommon = new ExhibitionsCommon();
exhibitionCommon.setExhibitionNumber(exhibitionNumber);
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
PoxPayloadOut result = createExhibitionInstance(identifier);
return result;
}
public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
- public GroupClient() {
+ public GroupClient() throws Exception {
super();
}
- public GroupClient(String clientPropertiesFilename) {
+ public GroupClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.group.GroupsCommon;
-
import org.testng.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
@Override
- protected CollectionSpaceClient<AbstractCommonList, PoxPayloadOut, String, GroupProxy> getClientInstance() {
+ protected CollectionSpaceClient<AbstractCommonList, PoxPayloadOut, String, GroupProxy> getClientInstance() throws Exception {
return new GroupClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new GroupClient(clientPropertiesFilename);
}
// ---------------------------------------------------------------
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
GroupClient client = new GroupClient();
return createInstance(client.getCommonPartName(), identifier);
}
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
return createGroupInstance(identifier);
}
- private PoxPayloadOut createGroupInstance(String uid) {
+ private PoxPayloadOut createGroupInstance(String uid) throws Exception {
String identifier = "title-" + uid;
GroupsCommon group = new GroupsCommon();
group.setTitle(identifier);
public static final String SERVICE_NAME = "idgenerators";
- public IdClient() {
+ public IdClient() throws Exception {
super();
}
- public IdClient(String clientPropertiesFilename) {
+ public IdClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import java.util.ArrayList;
import java.util.List;
+
import javax.ws.rs.core.Response;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.id.NumericIDGeneratorPart;
import org.collectionspace.services.id.SettableIDGenerator;
import org.collectionspace.services.id.StringIDGeneratorPart;
-
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new IdClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new IdClient(clientPropertiesFilename);
}
* @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
*/
@Override
- public String getServicePathComponent() {
+ public String getServicePathComponent() throws Exception {
return new IdClient().getServicePathComponent();
}
public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
- public IntakeClient() {
+ public IntakeClient() throws Exception {
super();
}
- public IntakeClient(String clientPropertiesFilename) {
+ public IntakeClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.intake.InsurerList;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.person.PersonTermGroup;
-
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
intakeIdsCreated.add(newId);
}
- protected void createPersonRefs() {
+ protected void createPersonRefs() throws Exception {
//
// First, create a new person authority
//
personIdsCreated.add(csid);
}
- protected String createPerson(String firstName, String surName, String shortId, String authRefName ) {
+ protected String createPerson(String firstName, String surName, String shortId, String authRefName ) throws Exception {
String result = null;
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
String depositor,
String conditionCheckerAssessor,
String insurer,
- String Valuer ) {
+ String Valuer ) throws Exception {
IntakesCommon intake = new IntakesCommon();
intake.setEntryNumber(entryNumber);
intake.setEntryDate(entryDate);
import org.collectionspace.services.intake.CurrentLocationGroupList;
import org.collectionspace.services.intake.IntakesCommon;
import org.collectionspace.services.jaxb.AbstractCommonList;
-
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
GregorianCalendarDateTimeUtils.currentDateUTC();
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new IntakeClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new IntakeClient(clientPropertiesFilename);
}
*
* @param identifier the identifier
* @return the multipart output
+ * @throws Exception
*/
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
return createIntakeInstance(
"entryNumber-" + identifier,
CURRENT_DATE_UTC,
* @param entryDate the entry date
* @param depositor the depositor
* @return the multipart output
+ * @throws Exception
*/
private PoxPayloadOut createIntakeInstance(String entryNumber,
String entryDate,
- String depositor) {
+ String depositor) throws Exception {
IntakesCommon intake = new IntakesCommon();
intake.setEntryNumber(entryNumber);
intake.setEntryDate(entryDate);
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
return this.createInstance(identifier);
}
import org.collectionspace.services.intake.InsurerList;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.organization.OrgTermGroup;
-
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
/**
* Creates the organization refs.
+ * @throws Exception
*/
- protected void createOrgRefs(){
+ protected void createOrgRefs() throws Exception{
OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
//orgAuthRefName =
// OrgAuthorityClientUtils.createOrgAuthRefName(ORGANIZATION_AUTHORITY_NAME, null);
orgIdsCreated.add(newOrgCSID);
}
- protected String createOrganization(String shortId, String shortName, String longName) {
+ protected String createOrganization(String shortId, String shortName, String longName) throws Exception {
String result = null;
OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
String depositor,
String conditionCheckerAssessor,
String insurer,
- String Valuer ) {
+ String Valuer ) throws Exception {
IntakesCommon intake = new IntakesCommon();
intake.setEntryNumber(entryNumber);
intake.setEntryDate(entryDate);
import org.collectionspace.services.intake.InsurerList;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.person.PersonTermGroup;
-
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
/**
* Creates the person refs.
+ * @throws Exception
*/
- protected void createPersonRefs() {
+ protected void createPersonRefs() throws Exception {
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
personIdsCreated.add(csid);
}
- protected String createPerson(String firstName, String surName, String shortId, String authRefName) {
+ protected String createPerson(String firstName, String surName, String shortId, String authRefName) throws Exception {
String result = null;
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun = true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
String depositor,
String conditionCheckerAssessor,
String insurer,
- String Valuer) {
+ String Valuer) throws Exception {
IntakesCommon intake = new IntakesCommon();
intake.setEntryNumber(entryNumber);
intake.setEntryDate(entryDate);
public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
- public LoaninClient() {
+ public LoaninClient() throws Exception {
super();
}
- public LoaninClient(String clientPropertiesFilename) {
+ public LoaninClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.loanin.LenderGroupList;
import org.collectionspace.services.loanin.LoansinCommon;
import org.collectionspace.services.person.PersonTermGroup;
-
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
loaninIdsCreated.add(newId);
}
- protected void createPersonRefs(){
+ protected void createPersonRefs() throws Exception{
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
// Create a temporary PersonAuthority resource, and its corresponding
// repeatable / multivalued authority reference fields. Be sure to
}
- protected String createPerson(String firstName, String surName, String shortId, String authRefName ) {
+ protected String createPerson(String firstName, String surName, String shortId, String authRefName ) throws Exception {
String result = null;
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
String lendersAuthorizer,
String lendersContact,
String borrowersContact,
- String borrowersAuthorizer) {
+ String borrowersAuthorizer) throws Exception {
LoansinCommon loaninCommon = new LoansinCommon();
loaninCommon.setLoanInNumber(loaninNumber);
loaninCommon.setLoanInNumber(returnDate);
import org.collectionspace.services.loanin.LenderGroup;
import org.collectionspace.services.loanin.LenderGroupList;
import org.collectionspace.services.loanin.LoansinCommon;
-
import org.testng.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new LoaninClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new LoaninClient(clientPropertiesFilename);
}
}
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
return createLoaninInstance(identifier);
}
*
* @param identifier the identifier
* @return the multipart output
+ * @throws Exception
*/
- private PoxPayloadOut createLoaninInstance(String identifier) {
+ private PoxPayloadOut createLoaninInstance(String identifier) throws Exception {
return createLoaninInstance(
"loaninNumber-" + identifier,
"returnDate-" + identifier);
* @param loaninNumber the loanin number
* @param returnDate the return date
* @return the multipart output
+ * @throws Exception
*/
private PoxPayloadOut createLoaninInstance(String loaninNumber,
- String returnDate) {
+ String returnDate) throws Exception {
LoansinCommon loaninCommon = new LoansinCommon();
loaninCommon.setLoanInNumber(loaninNumber);
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
PoxPayloadOut result = createLoaninInstance(identifier);
return result;
}
public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
- public LoanoutClient() {
+ public LoanoutClient() throws Exception {
super();
}
- public LoanoutClient(String clientPropertiesFilename) {
+ public LoanoutClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.loanout.LoansoutCommon;
import org.collectionspace.services.person.PersonTermGroup;
-
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
loanoutIdsCreated.add(newId);
}
- protected void createPersonRefs(){
+ protected void createPersonRefs() throws Exception{
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
// Create a temporary PersonAuthority resource, and its corresponding
lendersContactRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
}
- protected String createPerson(String firstName, String surName, String shortId, String authRefName ) {
+ protected String createPerson(String firstName, String surName, String shortId, String authRefName ) throws Exception {
String result = null;
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
String borrower,
String borrowersContact,
String lendersAuthorizer,
- String lendersContact) {
+ String lendersContact) throws Exception {
LoansoutCommon loanoutCommon = new LoansoutCommon();
loanoutCommon.setLoanOutNumber(loanoutNumber);
loanoutCommon.setLoanReturnDate(returnDate);
import org.collectionspace.services.loanout.LoanStatusGroup;
import org.collectionspace.services.loanout.LoanStatusGroupList;
import org.collectionspace.services.loanout.LoansoutCommon;
-
import org.testng.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new LoanoutClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new LoanoutClient(clientPropertiesFilename);
}
}
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
return createLoanoutInstance(identifier);
}
*
* @param identifier the identifier
* @return the multipart output
+ * @throws Exception
*/
- private PoxPayloadOut createLoanoutInstance(String identifier) {
+ private PoxPayloadOut createLoanoutInstance(String identifier) throws Exception {
return createLoanoutInstance(
"loanoutNumber-" + identifier,
CURRENT_DATE_UTC);
* @param loanOutNumber the loan out number
* @param returnDate the return date
* @return the multipart output
+ * @throws Exception
*/
private PoxPayloadOut createLoanoutInstance(String loanOutNumber,
- String returnDate) {
+ String returnDate) throws Exception {
LoansoutCommon loanoutCommon = new LoansoutCommon();
loanoutCommon.setLoanOutNumber(loanOutNumber);
loanoutCommon.setLoanReturnDate(returnDate);
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
PoxPayloadOut result = createLoanoutInstance(identifier);
return result;
}
//
// Constructors
//
- public LocationAuthorityClient() {
+ public LocationAuthorityClient() throws Exception {
super();
}
- public LocationAuthorityClient(String clientPropertiesFilename) {
+ public LocationAuthorityClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import javax.ws.rs.core.Response;
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.LocationAuthorityClient;
import org.collectionspace.services.client.LocationAuthorityClientUtils;
import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.location.LocTermGroup;
import org.collectionspace.services.location.LocTermGroupList;
import org.collectionspace.services.location.LocationauthoritiesCommon;
import org.collectionspace.services.location.LocationsCommon;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new LocationAuthorityClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new LocationAuthorityClient(clientPropertiesFilename);
}
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
//
// Constructors
//
- public MaterialAuthorityClient() {
+ public MaterialAuthorityClient() throws Exception {
super();
}
- public MaterialAuthorityClient(String clientPropertiesFilename) {
+ public MaterialAuthorityClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.material.MaterialTermGroupList;
import org.collectionspace.services.material.MaterialauthoritiesCommon;
import org.collectionspace.services.material.MaterialsCommon;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new MaterialAuthorityClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new MaterialAuthorityClient(clientPropertiesFilename);
}
* 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.
+ * @throws Exception
*/
@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 ...");
- }
- String parentResourceId;
- String itemResourceId;
- // Clean up contact resources.
- MaterialAuthorityClient client = new MaterialAuthorityClient();
- parentResourceId = knownResourceId;
- // Clean up item resources.
- 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.
- client.deleteItem(parentResourceId, itemResourceId).close();
- }
- // Clean up parent resources.
- for (String resourceId : allResourceIdsCreated) {
- // Note: Any non-success responses from the delete operation
- // below are ignored and not reported.
- client.delete(resourceId).close();
- }
- }
+ public void cleanUp() throws Exception {
+ 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 ...");
+ }
+ String parentResourceId;
+ String itemResourceId;
+ // Clean up contact resources.
+ MaterialAuthorityClient client = new MaterialAuthorityClient();
+ parentResourceId = knownResourceId;
+ // Clean up item resources.
+ 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.
+ client.deleteItem(parentResourceId, itemResourceId).close();
+ }
+ // Clean up parent resources.
+ for (String resourceId : allResourceIdsCreated) {
+ // Note: Any non-success responses from the delete operation
+ // below are ignored and not reported.
+ client.delete(resourceId).close();
+ }
+ }
// ---------------------------------------------------------------
// Utility methods used by tests above
package org.collectionspace.services.client;
import javax.ws.rs.core.Response;
+
import org.collectionspace.services.media.MediaCommon;
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
- public MediaClient() {
+ public MediaClient() throws Exception {
super();
}
- public MediaClient(String clientPropertiesFilename) {
+ public MediaClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.media.MediaCommon;
import org.collectionspace.services.person.PersonTermGroup;
-
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
- private PoxPayloadOut createMediaInstance(String depositorRefName, String title) {
+ private PoxPayloadOut createMediaInstance(String depositorRefName, String title) throws Exception {
this.title = title;
this.depositorRefName = depositorRefName;
MediaCommon media = new MediaCommon();
}
}
- protected void createPersonRefs() {
+ protected void createPersonRefs() throws Exception {
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
// Create a temporary PersonAuthority resource, and its corresponding refName by which it can be identified.
PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
depositorRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
}
- protected String createPerson(String firstName, String surName, String shortId, String authRefName) {
+ protected String createPerson(String firstName, String surName, String shortId, String authRefName) throws Exception {
String result = null;
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun = true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
logger.debug("Skipping Cleanup phase ...");
import org.collectionspace.services.media.LanguageList;
import org.collectionspace.services.media.MediaCommon;
import org.collectionspace.services.media.SubjectList;
-
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput;
import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.testng.Assert;
}
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new MediaClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new MediaClient(clientPropertiesFilename);
}
// ---------------------------------------------------------------
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
return createMediaInstance(identifier);
}
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
- private PoxPayloadOut createMediaInstance(String title) {
+ private PoxPayloadOut createMediaInstance(String title) throws Exception {
String identifier = "media.title-" + title;
MediaCommon media = new MediaCommon();
media.setTitle(identifier);
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
return createMediaInstance(identifier);
}
import org.collectionspace.services.blob.BlobResource;
import org.collectionspace.services.client.BlobClient;
import org.collectionspace.services.client.CollectionSpaceClientUtils;
-import org.collectionspace.services.client.IQueryManager;
import org.collectionspace.services.client.MediaClient;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.common.blob.BlobUtil;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.nuxeo.client.java.CommonList;
+
import org.jboss.resteasy.util.HttpResponseCodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Consumes("application/xml")
@Produces("application/xml")
public class MediaResource extends NuxeoBasedResource {
- final Logger logger = LoggerFactory.getLogger(MediaResource.class);
- final static MediaClient mediaClient = new MediaClient();
+ final static Logger logger = LoggerFactory.getLogger(MediaResource.class);
+ final static MediaClient mediaClient = createMediaClient();
+
+ private static MediaClient createMediaClient() {
+ MediaClient result = null;
+
+ try {
+ result = new MediaClient();
+ } catch (Exception e) {
+ String errMsg = "Could not create a new media client for the Media resource.";
+ logger.error(errMsg, e);
+ throw new RuntimeException();
+ }
+
+ return result;
+ }
@Override
public String getServiceName(){
*
*/
public class MovementClient extends AbstractCommonListPoxServiceClientImpl<MovementProxy, MovementsCommon> {
- public static final String SERVICE_NAME = "movements";
+ public static final String SERVICE_NAME = "movements";
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;
+ public MovementClient() throws Exception {
+ super();
+ }
+
@Override
public String getServiceName() {
return SERVICE_NAME;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.movement.MovementsCommon;
import org.collectionspace.services.person.PersonTermGroup;
-
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
movementIdsCreated.add(newId);
}
- protected void createPersonRefs(){
+ protected void createPersonRefs() throws Exception{
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
// Create a temporary PersonAuthority resource, and its corresponding
// refName by which it can be identified.
movementContactRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
}
- protected String createPerson(String firstName, String surName, String shortId, String authRefName ) {
+ protected String createPerson(String firstName, String surName, String shortId, String authRefName ) throws Exception {
String result = null;
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
private PoxPayloadOut createMovementInstance(String movementReferenceNumber,
String locationDate,
- String movementContact) {
+ String movementContact) throws Exception {
MovementsCommon movementCommon = new MovementsCommon();
movementCommon.setMovementReferenceNumber(movementReferenceNumber);
movementCommon.setLocationDate(locationDate);
import org.collectionspace.services.movement.MovementMethodsList;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
-
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
* ()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new MovementClient();
}
* @param identifier
* the identifier
* @return the multipart output
+ * @throws Exception
*/
- private PoxPayloadOut createMovementInstance(String identifier) {
+ private PoxPayloadOut createMovementInstance(String identifier) throws Exception {
return createInstance("movementReferenceNumber-" + identifier);
}
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
PoxPayloadOut result = createMovementInstance(identifier);
return result;
}
* A movement reference number.
* @return Multipart output suitable for use as a payload in a create or
* update request.
+ * @throws Exception
*/
@Override
- protected PoxPayloadOut createInstance(String movementReferenceNumber) {
+ protected PoxPayloadOut createInstance(String movementReferenceNumber) throws Exception {
MovementsCommon movementCommon = new MovementsCommon();
// FIXME: Values of currentLocation, normalLocation,
// and movementContact should be refNames.
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.movement.MovementsCommon;
import org.collectionspace.services.jaxb.AbstractCommonList;
-
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.DataProvider;
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun = true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
private PoxPayloadOut createMovementInstance(
String movementReferenceNumber,
String movementNote,
- String locationDate) {
+ String locationDate) throws Exception {
MovementsCommon movementCommon = new MovementsCommon();
movementCommon.setMovementReferenceNumber(movementReferenceNumber);
movementCommon.setMovementNote(movementNote);
public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
- public ObjectExitClient() {
+ public ObjectExitClient() throws Exception {
super();
}
- public ObjectExitClient(String clientPropertiesFilename) {
+ public ObjectExitClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.objectexit.StructuredDateGroup;
import org.collectionspace.services.objectexit.ObjectexitCommon;
import org.collectionspace.services.person.PersonTermGroup;
-
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
- private PoxPayloadOut createObjectExitInstance(String depositorRefName, String exitNumber, String exitDateDisplayDate) {
+ private PoxPayloadOut createObjectExitInstance(String depositorRefName, String exitNumber, String exitDateDisplayDate) throws Exception {
this.exitNumber = exitNumber;
this.depositorRefName = depositorRefName;
this.exitDateGroup.setDateDisplayDate(exitDateDisplayDate);
objectexitIdsCreated.add(newId);// Store the IDs from every resource created; delete on cleanup
}
- protected void createPersonRefs() {
+ protected void createPersonRefs() throws Exception {
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
// Create a temporary PersonAuthority resource, and its corresponding refName by which it can be identified.
PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
depositorRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
}
- protected String createPerson(String firstName, String surName, String shortId, String authRefName) {
+ protected String createPerson(String firstName, String surName, String shortId, String authRefName) throws Exception {
String result = null;
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun = true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
logger.debug("Skipping Cleanup phase ...");
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.objectexit.ObjectexitCommon;
-
import org.testng.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new ObjectExitClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new ObjectExitClient(clientPropertiesFilename);
}
// ---------------------------------------------------------------
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
ObjectExitClient client = new ObjectExitClient();
return createObjectExitInstance(identifier);
}
- private PoxPayloadOut createObjectExitInstance(String exitNumber) {
+ private PoxPayloadOut createObjectExitInstance(String exitNumber) throws Exception {
String identifier = "objectexitNumber-" + exitNumber;
ObjectexitCommon objectexit = new ObjectexitCommon();
objectexit.setExitNumber(identifier);
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
PoxPayloadOut result = createObjectExitInstance(createIdentifier());
return result;
}
//
// Constructors
//
- public OrgAuthorityClient() {
+ public OrgAuthorityClient() throws Exception {
super();
}
- public OrgAuthorityClient(String clientPropertiesFilename) {
+ public OrgAuthorityClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
+
import org.collectionspace.services.OrganizationJAXBSchema;
import org.collectionspace.services.client.test.ServiceRequestType;
import org.collectionspace.services.common.api.Tools;
import org.jboss.resteasy.client.ClientResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import org.collectionspace.services.organization.StructuredDateGroup;
/**
* @param csid the id of the OrgAuthority
* @param client if null, creates a new client
* @return
+ * @throws Exception
*/
- public static String getAuthorityRefName(String csid, OrgAuthorityClient client){
+ public static String getAuthorityRefName(String csid, OrgAuthorityClient client) throws Exception{
if (client==null) {
client = new OrgAuthorityClient();
}
* @param csid the ID of the Organization
* @param client if null, creates a new client
* @return
+ * @throws Exception
*/
- public static String getOrgRefName(String inAuthority, String csid, OrgAuthorityClient client){
+ public static String getOrgRefName(String inAuthority, String csid, OrgAuthorityClient client) throws Exception{
if (client == null) {
client = new OrgAuthorityClient();
}
import org.collectionspace.services.organization.OrganizationsCommon;
import org.collectionspace.services.organization.OrgTermGroup;
import org.collectionspace.services.person.PersonTermGroup;
-
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
/**
* Creates the person refs.
+ * @throws Exception
*/
- protected void createPersonRefs() {
+ protected void createPersonRefs() throws Exception {
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
// Create a temporary PersonAuthority resource, and its corresponding
// refName by which it can be identified.
* @param shortId
* @param authRefName
* @return the string
+ * @throws Exception
*/
- protected String createPerson(String personAuthCSID, String firstName, String surName, String shortId, String authRefName ) {
+ protected String createPerson(String personAuthCSID, String firstName, String surName, String shortId, String authRefName ) throws Exception {
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
Map<String, String> personInfo = new HashMap<String,String>();
personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
import org.collectionspace.services.organization.OrganizationsCommon;
import org.collectionspace.services.organization.OrgTermGroup;
import org.collectionspace.services.organization.OrgTermGroupList;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new OrgAuthorityClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new OrgAuthorityClient(clientPropertiesFilename);
}
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
OrgAuthorityClient client = new OrgAuthorityClient();
String displayName = "displayName-" + identifier;
PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance(
}
@Override
- protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) {
+ protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) throws Exception {
String headerLabel = new OrgAuthorityClient().getItemCommonPartName();
String shortId = TEST_SHORTID + identifier;
* Creates the contact.
*
* @param testName the test name
+ * @throws Exception
*/
@Test(dataProvider = "testName", groups = {"create"},
dependsOnMethods = {"createItem"})
- public void createContact(String testName) {
+ public void createContact(String testName) throws Exception {
setupCreate();
String newID = createContactInItem(knownResourceId, knownItemResourceId);
}
* @param parentcsid the parentcsid
* @param itemcsid the itemcsid
* @return the string
+ * @throws Exception
*/
- private String createContactInItem(String parentcsid, String itemcsid) {
+ private String createContactInItem(String parentcsid, String itemcsid) throws Exception {
final String testName = "createContactInItem";
if (logger.isDebugEnabled()) {
readInternal(testName, null, knownResourceShortIdentifer);
}
- protected void readInternal(String testName, String CSID, String shortId) {
+ protected void readInternal(String testName, String CSID, String shortId) throws Exception {
// Perform setup.
setupRead();
* Read contact non existent.
*
* @param testName the test name
+ * @throws Exception
*/
@Test(dataProvider = "testName", groups = {"readItem"},
dependsOnMethods = {"readContact"})
- public void readContactNonExistent(String testName) {
+ public void readContactNonExistent(String testName) throws Exception {
// Perform setup.
setupReadNonExistent();
/**
* Read item list.
+ * @throws Exception
*/
@Override
// @Test(groups = {"readList"}, dependsOnMethods = {"readList"})
- public void readItemList(String testName) {
+ public void readItemList(String testName) throws Exception {
readItemList(knownAuthorityWithItems, null);
}
/**
* Read item list by authority name.
+ * @throws Exception
*/
@Override
// @Test(dataProvider = "testName",
// dependsOnMethods = {"readItem"})
- public void readItemListByName(String testName) {
+ public void readItemListByName(String testName) throws Exception {
readItemList(null, READITEMS_SHORT_IDENTIFIER);
}
*
* @param vcsid the vcsid
* @param name the name
+ * @throws Exception
*/
- private void readItemList(String vcsid, String name) {
+ private void readItemList(String vcsid, String name) throws Exception {
final String testName = "readItemList";
// Perform setup.
/**
* Read contact list.
+ * @throws Exception
*/
@Test(groups = {"readList"},
dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.readItemList"})
- public void readContactList() {
+ public void readContactList() throws Exception {
readContactList(knownResourceId, knownItemResourceId);
}
*
* @param parentcsid the parentcsid
* @param itemcsid the itemcsid
+ * @throws Exception
*/
- private void readContactList(String parentcsid, String itemcsid) {
+ private void readContactList(String parentcsid, String itemcsid) throws Exception {
final String testName = "readContactList";
// Perform setup.
setupReadList();
* Delete non existent contact.
*
* @param testName the test name
+ * @throws Exception
*/
@Test(dataProvider = "testName", groups = {"delete"},
dependsOnMethods = {"deleteContact"})
- public void deleteNonExistentContact(String testName) {
+ public void deleteNonExistentContact(String testName) throws Exception {
// Perform setup.
setupDeleteNonExistent();
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun = true)
@Override
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
//
// Constructors
//
- public PersonAuthorityClient() {
+ public PersonAuthorityClient() throws Exception {
super();
}
- public PersonAuthorityClient(String clientPropertiesFilename) {
+ public PersonAuthorityClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.person.PersonauthoritiesCommon;
import org.collectionspace.services.person.SchoolOrStyleList;
import org.collectionspace.services.person.StructuredDateGroup;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @param csid the id of the PersonAuthority
* @param client if null, creates a new client
* @return
+ * @throws Exception
*/
- public static String getAuthorityRefName(String csid, PersonAuthorityClient client){
+ public static String getAuthorityRefName(String csid, PersonAuthorityClient client) throws Exception{
if (client == null) {
client = new PersonAuthorityClient();
}
* @param csid the id of the PersonAuthority
* @param client if null, creates a new client
* @return
+ * @throws Exception
*/
- public static String getPersonRefName(String inAuthority, String csid, PersonAuthorityClient client){
+ public static String getPersonRefName(String inAuthority, String csid, PersonAuthorityClient client) throws Exception{
if ( client == null) {
client = new PersonAuthorityClient();
}
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.person.PersonTermGroup;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new PersonAuthorityClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new PersonAuthorityClient(clientPropertiesFilename);
}
/**
* Reads an item list by partial term.
+ * @throws Exception
*/
@Test(dataProvider="testName", groups = {"readListByPartialTerm"})
- public void partialTermMatch(String testName) {
+ public void partialTermMatch(String testName) throws Exception {
int numMatchesFound = 0;
String partialTerm = getPartialTermCommon();
if (logger.isDebugEnabled()) {
* Reads an item list by partial term, with a partial term that consists
* of an all-lowercase variation of the expected match, to test case-insensitive
* matching.
+ * @throws Exception
*/
@Test(dataProvider="testName", groups = {"readListByPartialTerm"},
dependsOnMethods = {"partialTermMatch"})
- public void partialTermMatchCaseInsensitiveLowerCase(String testName) {
+ public void partialTermMatchCaseInsensitiveLowerCase(String testName) throws Exception {
int numMatchesFound = 0;
final String partialTerm = getPartialTermCommon().toLowerCase();
* Reads an item list by partial term, with a partial term that consists
* of an all-uppercase variation of the expected match, to test case-insensitive
* matching.
+ * @throws Exception
*/
@Test(dataProvider="testName",
groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
- public void partialTermMatchCaseInsensitiveUpperCase(String testName) {
+ public void partialTermMatchCaseInsensitiveUpperCase(String testName) throws Exception {
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.
+ * @throws Exception
*/
@Test(dataProvider="testName",
groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
- public void partialTermMatchMinimumLength(String testName) {
+ public void partialTermMatchMinimumLength(String testName) throws Exception {
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).
+ * @throws Exception
*/
@Test(dataProvider="testName",
groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
- public void partialTermMatchUTF8(String testName) {
+ public void partialTermMatchUTF8(String testName) throws Exception {
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).
+ * @throws Exception
*/
@Test(dataProvider="testName",
groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
- public void partialTermMatchQuote(String testName) {
+ public void partialTermMatchQuote(String testName) throws Exception {
int numMatchesFound = 0;
String partialTerm = getPartialTermQuote();
if (logger.isDebugEnabled()) {
/**
* Finds terms by keywords.
+ * @throws Exception
*/
@Test(dataProvider="testName", groups = {"readListByKwdTerm"})
- public void keywordTermMatch(String testName) {
+ public void keywordTermMatch(String testName) throws Exception {
int numMatchesFound = 0;
String kwdTerm = getKwdTerm();
if (logger.isDebugEnabled()) {
/**
* Finds terms by keywords.
+ * @throws Exception
*/
@Test(dataProvider="testName",
groups = {"readListByKwdTerm"}, dependsOnMethods = {"keywordTermMatch"})
- public void keywordTermMatchUTF8(String testName) {
+ public void keywordTermMatchUTF8(String testName) throws Exception {
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.
+ * @throws Exception
*/
@Test(dataProvider="testName",
groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
- public void partialTermMatchOnNonexistentTerm(String testName) {
+ public void partialTermMatchOnNonexistentTerm(String testName) throws Exception {
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.
+ * @throws Exception
*/
@Test(dataProvider="testName", groups = {"readListByKwdTerm"},
dependsOnMethods = {"keywordTermMatch"})
- public void keywordTermMatchOnNonexistentTerm(String testName) {
+ public void keywordTermMatchOnNonexistentTerm(String testName) throws Exception {
int numMatchesFound = 0;
int ZERO_MATCHES_EXPECTED = 0;
String kwdTerm = getKwdTermNonExistent();
* @param partialTerm A partial term to match item resources.
* @param partialTerm A keyword list to match item resources.
* @return The number of item resources matched by the partial term.
+ * @throws Exception
*/
private int readItemListWithFilters(String testName,
- String authorityCsid, String partialTerm, String keywords) {
+ String authorityCsid, String partialTerm, String keywords) throws Exception {
// Perform setup.
int expectedStatusCode = Response.Status.OK.getStatusCode();
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.person.PersonTermGroup;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new PersonAuthorityClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new PersonAuthorityClient(clientPropertiesFilename);
}
/**
* Reads an item list by partial term.
+ * @throws Exception
*/
@Test(dataProvider="testName")
- public void partialTermMatch(String testName) {
+ public void partialTermMatch(String testName) throws Exception {
for(int i=0; i<partialTerms.length; i++) {
long startTime = System.currentTimeMillis();
int numMatchesFound = readItemListWithFilters(testName, authId,
* @param partialTerm A partial term to match item resources.
* @param partialTerm A keyword list to match item resources.
* @return The number of item resources matched by the partial term.
+ * @throws Exception
*/
private int readItemListWithFilters(String testName,
- String authorityCsid, String partialTerm, String keywords) {
+ String authorityCsid, String partialTerm, String keywords) throws Exception {
// Perform setup.
int expectedStatusCode = Response.Status.OK.getStatusCode();
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new PersonAuthorityClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new PersonAuthorityClient(clientPropertiesFilename);
}
}
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
PersonAuthorityClient client = new PersonAuthorityClient();
String displayName = "displayName-" + identifier;
}
@Override
- protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) {
+ protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) throws Exception {
String headerLabel = new PersonAuthorityClient().getItemCommonPartName();
HashMap<String, String> personInfo = new HashMap<String, String>();
* @param vcsid the vcsid
* @param authRefName the auth ref name
* @return the string
+ * @throws Exception
*/
@Override
- protected String createItemInAuthority(AuthorityClient client, String vcsid, String shortId) {
+ protected String createItemInAuthority(AuthorityClient client, String vcsid, String shortId) throws Exception {
final String testName = "createItemInAuthority";
if (logger.isDebugEnabled()) {
* @param itemFieldProperties a set of properties specifying the values of fields.
* @param itemRepeatableFieldProperties a set of properties specifying the values of repeatable fields.
* @return the string
+ * @throws Exception
*/
private String createItemInAuthority(AuthorityClient client, String vcsid, String authRefName, String shortId,
- Map<String, String> itemFieldProperties, List<PersonTermGroup> terms, Map<String, List<String>> itemRepeatableFieldProperties) {
+ Map<String, String> itemFieldProperties, List<PersonTermGroup> terms, Map<String, List<String>> itemRepeatableFieldProperties) throws Exception {
final String testName = "createItemInAuthority";
if (logger.isDebugEnabled()) {
* Creates the contact.
*
* @param testName the test name
+ * @throws Exception
*/
- @Test(dataProvider = "testName", groups = {"create"},
- dependsOnMethods = {"createItem"})
- public void createContact(String testName) {
+ @Test(dataProvider = "testName", groups = {"create"}, dependsOnMethods = {"createItem"})
+ public void createContact(String testName) throws Exception {
setupCreate();
createContactInItem(knownResourceId, knownItemResourceId);
}
* @param parentcsid the parentcsid
* @param itemcsid the itemcsid
* @return the string
+ * @throws Exception
*/
- private String createContactInItem(String parentcsid, String itemcsid) {
+ private String createContactInItem(String parentcsid, String itemcsid) throws Exception {
final String testName = "createContactInItem";
if (logger.isDebugEnabled()) {
* non-word characters.
*
* @param testName the test name
+ * @throws Exception
*/
@Test(dataProvider = "testName", groups = {"create", "nonWordCharsInShortId"},
dependsOnMethods = {"org.collectionspace.services.client.test.AbstractServiceTestImpl.create"})
- public void createItemWithShortIdNonWordChars(String testName) {
+ public void createItemWithShortIdNonWordChars(String testName) throws Exception {
testExpectedStatusCode = STATUS_BAD_REQUEST;
testRequestType = ServiceRequestType.CREATE;
testSetup(testExpectedStatusCode, testRequestType);
readInternal(testName, null, knownResourceShortIdentifer);
}
- protected void readInternal(String testName, String CSID, String shortId) {
+ protected void readInternal(String testName, String CSID, String shortId) throws Exception {
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
Response res = null;
* Read contact non existent.
*
* @param testName the test name
+ * @throws Exception
*/
@Test(dataProvider = "testName", groups = {"readItem"}, dependsOnMethods = {"readContact"})
- public void readContactNonExistent(String testName) {
+ public void readContactNonExistent(String testName) throws Exception {
// Perform setup.
setupReadNonExistent();
/**
* Read contact list.
+ * @throws Exception
*/
@Test(groups = {"readList"},
dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.readItemList"})
- public void readContactList() {
+ public void readContactList() throws Exception {
readContactList(knownResourceId, knownItemResourceId);
}
*
* @param parentcsid the parentcsid
* @param itemcsid the itemcsid
+ * @throws Exception
*/
- private void readContactList(String parentcsid, String itemcsid) {
+ private void readContactList(String parentcsid, String itemcsid) throws Exception {
final String testName = "readContactList";
// Perform setup.
* Delete non existent contact.
*
* @param testName the test name
+ * @throws Exception
*/
@Test(dataProvider = "testName", groups = {"delete"},
dependsOnMethods = {"deleteContact"})
- public void deleteNonExistentContact(String testName) {
+ public void deleteNonExistentContact(String testName) throws Exception {
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
setupDeleteNonExistent();
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun = true)
@Override
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
//
// Constructors
//
- public PlaceAuthorityClient() {
+ public PlaceAuthorityClient() throws Exception {
super();
}
- public PlaceAuthorityClient(String clientPropertiesFilename) {
+ public PlaceAuthorityClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.place.PlaceTermGroupList;
import org.collectionspace.services.place.PlaceauthoritiesCommon;
import org.collectionspace.services.place.PlacesCommon;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new PlaceAuthorityClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new PlaceAuthorityClient(clientPropertiesFilename);
}
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
public static final String PUBLICITEMS_CONTENT_SUFFIX = "content";
- public PublicItemClient() {
+ public PublicItemClient() throws Exception {
super();
}
- public PublicItemClient(String clientPropertiesFilename) {
+ public PublicItemClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.publicitem.PublicitemsCommon;
-
import org.testng.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* ()
*/
@Override
- protected PublicItemClient getClientInstance() {
+ protected PublicItemClient getClientInstance() throws Exception {
return new PublicItemClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new PublicItemClient(clientPropertiesFilename);
}
}
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
return createPublicItemInstance(identifier);
}
* @param identifier
* the identifier
* @return the multipart output
+ * @throws Exception
*/
- private PoxPayloadOut createPublicItemInstance(String identifier) {
+ private PoxPayloadOut createPublicItemInstance(String identifier) throws Exception {
return createPublicItemInstance("itemNumber-" + identifier,
"contentCreationJobId-" + identifier);
}
* @param contentCreationJobId
* the publicitem asynch job ID
* @return the multipart output
+ * @throws Exception
*/
private PoxPayloadOut createPublicItemInstance(String itemNumber,
- String itemJobId) {
+ String itemJobId) throws Exception {
PublicitemsCommon publicItemsCommon = new PublicitemsCommon();
publicItemsCommon.setItemNumber(itemNumber);
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
PoxPayloadOut result = createPublicItemInstance(identifier);
return result;
}
import org.collectionspace.services.relation.RelationsCommon;
import org.collectionspace.services.relation.RelationsCommonList;
import org.collectionspace.services.relation.RelationshipType;
-
import org.testng.Assert;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new RelationClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new RelationClient(clientPropertiesFilename);
}
/**
* Creates the person refs as a precondition for running the tests in this class.
+ * @throws Exception
*/
@BeforeSuite
- private void createPersonRefs() {
+ private void createPersonRefs() throws Exception {
setupCreate();
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
}
@AfterSuite
- private void deletePersonRefs() {
+ private void deletePersonRefs() throws Exception {
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
for (String csid:personIdsCreated) {
Response res = personAuthClient.deleteItem(personAuthCSID, csid);
}
- private String createPerson(String firstName, String surName, String shortId, String authRefName) {
+ private String createPerson(String firstName, String surName, String shortId, String authRefName) throws Exception {
String result = null;
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
return relationCommon;
}
- private PoxPayloadOut createRelationInstance(RelationsCommon relation) {
+ private PoxPayloadOut createRelationInstance(RelationsCommon relation) throws Exception {
PoxPayloadOut result = new PoxPayloadOut(this.getServicePathComponent());
PayloadOutputPart commonPart =
result.addPart(new RelationClient().getCommonPartName(), relation);
*
* @param identifier the identifier
* @return the multipart output
+ * @throws Exception
*/
- private PoxPayloadOut createRelationInstance(String identifier) {
+ private PoxPayloadOut createRelationInstance(String identifier) throws Exception {
RelationsCommon relation = createRelationsCommon(identifier);
PoxPayloadOut result = createRelationInstance(relation);
return result;
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
return createRelationInstance(identifier);
}
public static final String COMPILED_REPORT_EXTENSION = ".jasper";
public static final String REPORT_DECSRIPTION_EXTENSION = ".jrxml";
- public ReportClient() {
+ public ReportClient() throws Exception {
super();
}
- public ReportClient(String clientPropertiesFilename) {
+ public ReportClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.report.ReportsCommon;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.client.AcquisitionClient;
-
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
// Instance variables specific to this test.
private String testDocType = "Acquisition";
- private String createAquisitionResource() {
+ private String createAquisitionResource() throws Exception {
String result = null;
AcquisitionClient acquisitionClient = new AcquisitionClient();
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new ReportClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new ReportClient(clientPropertiesFilename);
}
*
* @param identifier the identifier
* @return the multipart output
+ * @throws Exception
*/
- private PoxPayloadOut createReportInstance(String identifier) {
+ private PoxPayloadOut createReportInstance(String identifier) throws Exception {
List<String> docTypes = new ArrayList<String>();
docTypes.add(testDocType);
return createReportInstance(
* @param filename the relative path to the report
* @param outputMIME the MIME type we will return for this report
* @return the multipart output
+ * @throws Exception
*/
private PoxPayloadOut createReportInstance(String name,
List<String> forDocTypeList,
boolean supportsSingle, boolean supportsList,
boolean supportsGroup, boolean supportsNoContext,
String filename,
- String outputMIME) {
+ String outputMIME) throws Exception {
ReportsCommon reportCommon = new ReportsCommon();
reportCommon.setName(name);
ReportsCommon.ForDocTypes forDocTypes = new ReportsCommon.ForDocTypes();
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
PoxPayloadOut result = createReportInstance(identifier);
return result;
}
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.account.Status;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new AccountClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new AccountClient(clientPropertiesFilename);
}
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTest#create()
*/
- @Test(dataProvider = "testName",
- dependsOnMethods = {"createActiveAccount"})
- public void create(String testName) {
+ @Test(dataProvider = "testName", dependsOnMethods = {"createActiveAccount"})
+ public void create(String testName) throws Exception {
setupCreate();
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
}
- @Test(dataProvider = "testName",
- dependsOnMethods = {"createActiveAccount"})
- public void createWithoutAuthn(String testName) {
+ @Test(dataProvider = "testName", dependsOnMethods = {"createActiveAccount"})
+ public void createWithoutAuthn(String testName) throws Exception {
setupCreate();
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
}
}
- @Test(dataProvider = "testName",
- dependsOnMethods = {"createInactiveAccount"})
- public void createWithInactiveAccount(String testName) {
+ @Test(dataProvider = "testName", dependsOnMethods = {"createInactiveAccount"})
+ public void createWithInactiveAccount(String testName) throws Exception {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
collectionObjectClient.setAuth(true, "george", true, "george08", true);
String identifier = createIdentifier();
/**
* Creates the collection object instance without password.
+ * @throws Exception
*/
- @Test(dataProvider = "testName",
- dependsOnMethods = {"createActiveAccount"})
- public void createWithoutPassword(String testName) {
+ @Test(dataProvider = "testName", dependsOnMethods = {"createActiveAccount"})
+ public void createWithoutPassword(String testName) throws Exception {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
String user = collectionObjectClient.getProperty(collectionObjectClient.USER_PROPERTY);
collectionObjectClient.setAuth(true, user, true, "", false);
/**
* Creates the collection object with unknown user
+ * @throws Exception
*/
- @Test(dataProvider = "testName",
- dependsOnMethods = {"createActiveAccount"})
- public void createWithUnknownUser(String testName) {
+ @Test(dataProvider = "testName", dependsOnMethods = {"createActiveAccount"})
+ public void createWithUnknownUser(String testName) throws Exception {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
collectionObjectClient.setAuth(true, "foo", true, "bar", true);
String identifier = createIdentifier();
/**
* Creates the collection object instance with incorrect password.
+ * @throws Exception
*/
- @Test(dataProvider = "testName",
- dependsOnMethods = {"createActiveAccount"})
- public void createWithIncorrectPassword(String testName) {
+ @Test(dataProvider = "testName", dependsOnMethods = {"createActiveAccount"})
+ public void createWithIncorrectPassword(String testName) throws Exception {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
String user = collectionObjectClient.getProperty(collectionObjectClient.USER_PROPERTY);
collectionObjectClient.setAuth(true, user, true, "bar", true);
/**
* Creates the collection object instance with incorrect user password.
+ * @throws Exception
*/
@Test(dataProvider = "testName", dependsOnMethods = {"createActiveAccount"})
- public void createWithIncorrectUserPassword(String testName) {
+ public void createWithIncorrectUserPassword(String testName) throws Exception {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
collectionObjectClient.setAuth(true, "foo", true, "bar", true);
String identifier = createIdentifier();
/**
* Creates the collection object instance with incorrect user password.
+ * @throws Exception
*/
@Test(dataProvider = "testName", dependsOnMethods = {"createActiveAccount"})
- public void createWithoutTenant(String testName) {
+ public void createWithoutTenant(String testName) throws Exception {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
collectionObjectClient.setAuth(true, "babybop", true, "babybop09", true);
String identifier = createIdentifier();
import org.slf4j.LoggerFactory;
/**
- * AuthorizationServiceTest, carries out tests against a
- * deployed and running Permission, Role, AccountRole, PermissionRole and
- * CollectionObject Services.
+ * AuthorizationServiceTest, carries out tests against a deployed and running
+ * Permission, Role, AccountRole, PermissionRole and CollectionObject Services.
*
- * Pre-requisite : authorization-mgt/client tests seed some permissions used
- * by this test
+ * Pre-requisite : authorization-mgt/client tests seed some permissions used by
+ * this test
*
- * $LastChangedRevision: 917 $
- * $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
+ * $LastChangedRevision: 917 $ $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri,
+ * 06 Nov 2009) $
*/
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 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>();
- //key for roleValues is roleName
- private Hashtable<String, RoleValue> roleValues = new Hashtable<String, RoleValue>();
- private String bigbirdPermId;
- private String elmoPermId;
- private final static String TEST_SERVICE_NAME = "dimensions";
- private boolean accountRolesFlipped = false;
- /*
- * This method is called only by the parent class, AbstractServiceTestImpl
- */
-
- @Override
+ private final String CLASS_NAME = AuthorizationServiceTest.class.getName();
+ private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
+ // Instance variables specific to this test.
+ 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>();
+ // key for roleValues is roleName
+ private Hashtable<String, RoleValue> roleValues = new Hashtable<String, RoleValue>();
+ private String bigbirdPermId;
+ private String elmoPermId;
+ private final static String TEST_SERVICE_NAME = "dimensions";
+ private boolean accountRolesFlipped = false;
+
+ /*
+ * This method is called only by the parent class, AbstractServiceTestImpl
+ */
+
+ @Override
protected String getServiceName() {
- // no need to return anything but null since no auth resources are
- // accessed
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected String getServicePathComponent() {
- // no need to return anything but null since no auth resources are
- // accessed
- throw new UnsupportedOperationException();
- }
-
- @BeforeClass(alwaysRun = true)
- public void seedData() {
- seedPermissions();
- seedRoles();
- seedAccounts();
- seedAccountRoles();
- seedPermissionRoles();
- }
-
- private void seedPermissions() {
- String res = TEST_SERVICE_NAME;
-
- PermissionAction pac = new PermissionAction();
- pac.setName(ActionType.CREATE);
- PermissionAction par = new PermissionAction();
- par.setName(ActionType.READ);
- PermissionAction pau = new PermissionAction();
- pau.setName(ActionType.UPDATE);
-
-
- //bigbird can create, read and update but not delete
- List<PermissionAction> bbactions = new ArrayList<PermissionAction>();
- bbactions.add(pac);
- bbactions.add(par);
- bbactions.add(pau);
- bigbirdPermId = createPermission(res, bbactions, EffectType.PERMIT);
- PermissionValue bbpv = new PermissionValue();
- bbpv.setResourceName(res);
- bbpv.setPermissionId(bigbirdPermId);
- permValues.put(bbpv.getPermissionId(), bbpv);
-
- //elmo can only read
- List<PermissionAction> eactions = new ArrayList<PermissionAction>();
- eactions.add(par);
- elmoPermId = createPermission(res, eactions, EffectType.PERMIT);
- PermissionValue epv = new PermissionValue();
- epv.setResourceName(res);
- epv.setPermissionId(elmoPermId);
- permValues.put(epv.getPermissionId(), epv);
- }
-
- private void seedRoles() {
- String rn1 = "ROLE_TEST_CM";
- String r1RoleId = createRole(rn1);
- RoleValue rv1 = new RoleValue();
- rv1.setRoleId(r1RoleId);
- rv1.setRoleName(rn1);
- roleValues.put(rv1.getRoleName(), rv1);
-
- String rn2 = "ROLE_TEST_INTERN";
- String r2RoleId = createRole(rn2);
- RoleValue rv2 = new RoleValue();
- rv2.setRoleId(r2RoleId);
- rv2.setRoleName(rn2);
- roleValues.put(rv2.getRoleName(), rv2);
- }
-
- private void seedAccounts() {
- String userId1 = "bigbird2010";
- String accId1 = createAccount(userId1, "bigbird@cspace.org");
- AccountValue av1 = new AccountValue();
- av1.setScreenName(userId1);
- av1.setUserId(userId1);
- av1.setAccountId(accId1);
- accValues.put(av1.getUserId(), av1);
-
- String userId2 = "elmo2010";
- String accId2 = createAccount(userId2, "elmo@cspace.org");
- AccountValue av2 = new AccountValue();
- av2.setScreenName(userId2);
- av2.setUserId(userId2);
- av2.setAccountId(accId2);
- accValues.put(av2.getUserId(), av2);
-
- String userId3 = "lockedOut";
- String accId3 = createAccount(userId3, "lockedOut@cspace.org");
- AccountValue av3 = new AccountValue();
- av3.setScreenName(userId3);
- av3.setUserId(userId3);
- av3.setAccountId(accId3);
- accValues.put(av3.getUserId(), av3);
- }
-
- private void seedAccountRoles() {
-
- List<RoleValue> bigbirdRoleValues = new ArrayList<RoleValue>();
- bigbirdRoleValues.add(roleValues.get("ROLE_TEST_CM"));
- createAccountRole(accValues.get("bigbird2010"), bigbirdRoleValues);
-
- List<RoleValue> elmoRoleValues = new ArrayList<RoleValue>();
- elmoRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
- createAccountRole(accValues.get("elmo2010"), elmoRoleValues);
- }
-
- private void seedPermissionRoles() {
-
- List<RoleValue> bigbirdRoleValues = new ArrayList<RoleValue>();
- bigbirdRoleValues.add(roleValues.get("ROLE_TEST_CM"));
- createPermissionRole(permValues.get(bigbirdPermId), bigbirdRoleValues);
-
- List<RoleValue> elmoRoleValues = new ArrayList<RoleValue>();
- elmoRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
- createPermissionRole(permValues.get(elmoPermId), elmoRoleValues);
-
- }
-
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
- */
- @Override
- protected CollectionSpaceClient getClientInstance() {
- // This method is meaningless to this test.
- return null;
- }
+ // no need to return anything but null since no auth resources are
+ // accessed
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected String getServicePathComponent() {
+ // no need to return anything but null since no auth resources are
+ // accessed
+ throw new UnsupportedOperationException();
+ }
+
+ @BeforeClass(alwaysRun = true)
+ public void seedData() throws Exception {
+ seedPermissions();
+ seedRoles();
+ seedAccounts();
+ seedAccountRoles();
+ seedPermissionRoles();
+ }
+
+ private void seedPermissions() throws Exception {
+ String res = TEST_SERVICE_NAME;
+
+ PermissionAction pac = new PermissionAction();
+ pac.setName(ActionType.CREATE);
+ PermissionAction par = new PermissionAction();
+ par.setName(ActionType.READ);
+ PermissionAction pau = new PermissionAction();
+ pau.setName(ActionType.UPDATE);
+
+ // bigbird can create, read and update but not delete
+ List<PermissionAction> bbactions = new ArrayList<PermissionAction>();
+ bbactions.add(pac);
+ bbactions.add(par);
+ bbactions.add(pau);
+ bigbirdPermId = createPermission(res, bbactions, EffectType.PERMIT);
+ PermissionValue bbpv = new PermissionValue();
+ bbpv.setResourceName(res);
+ bbpv.setPermissionId(bigbirdPermId);
+ permValues.put(bbpv.getPermissionId(), bbpv);
+
+ // elmo can only read
+ List<PermissionAction> eactions = new ArrayList<PermissionAction>();
+ eactions.add(par);
+ elmoPermId = createPermission(res, eactions, EffectType.PERMIT);
+ PermissionValue epv = new PermissionValue();
+ epv.setResourceName(res);
+ epv.setPermissionId(elmoPermId);
+ permValues.put(epv.getPermissionId(), epv);
+ }
+
+ private void seedRoles() throws Exception {
+ String rn1 = "ROLE_TEST_CM";
+ String r1RoleId = createRole(rn1);
+ RoleValue rv1 = new RoleValue();
+ rv1.setRoleId(r1RoleId);
+ rv1.setRoleName(rn1);
+ roleValues.put(rv1.getRoleName(), rv1);
+
+ String rn2 = "ROLE_TEST_INTERN";
+ String r2RoleId = createRole(rn2);
+ RoleValue rv2 = new RoleValue();
+ rv2.setRoleId(r2RoleId);
+ rv2.setRoleName(rn2);
+ roleValues.put(rv2.getRoleName(), rv2);
+ }
+
+ private void seedAccounts() throws Exception {
+ String userId1 = "bigbird2010";
+ String accId1 = createAccount(userId1, "bigbird@cspace.org");
+ AccountValue av1 = new AccountValue();
+ av1.setScreenName(userId1);
+ av1.setUserId(userId1);
+ av1.setAccountId(accId1);
+ accValues.put(av1.getUserId(), av1);
+
+ String userId2 = "elmo2010";
+ String accId2 = createAccount(userId2, "elmo@cspace.org");
+ AccountValue av2 = new AccountValue();
+ av2.setScreenName(userId2);
+ av2.setUserId(userId2);
+ av2.setAccountId(accId2);
+ accValues.put(av2.getUserId(), av2);
+
+ String userId3 = "lockedOut";
+ String accId3 = createAccount(userId3, "lockedOut@cspace.org");
+ AccountValue av3 = new AccountValue();
+ av3.setScreenName(userId3);
+ av3.setUserId(userId3);
+ av3.setAccountId(accId3);
+ accValues.put(av3.getUserId(), av3);
+ }
+
+ private void seedAccountRoles() throws Exception {
+
+ List<RoleValue> bigbirdRoleValues = new ArrayList<RoleValue>();
+ bigbirdRoleValues.add(roleValues.get("ROLE_TEST_CM"));
+ createAccountRole(accValues.get("bigbird2010"), bigbirdRoleValues);
+
+ List<RoleValue> elmoRoleValues = new ArrayList<RoleValue>();
+ elmoRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
+ createAccountRole(accValues.get("elmo2010"), elmoRoleValues);
+ }
+
+ private void seedPermissionRoles() throws Exception {
+
+ List<RoleValue> bigbirdRoleValues = new ArrayList<RoleValue>();
+ bigbirdRoleValues.add(roleValues.get("ROLE_TEST_CM"));
+ createPermissionRole(permValues.get(bigbirdPermId), bigbirdRoleValues);
+
+ List<RoleValue> elmoRoleValues = new ArrayList<RoleValue>();
+ elmoRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
+ createPermissionRole(permValues.get(elmoPermId), elmoRoleValues);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.collectionspace.services.client.test.BaseServiceTest#getClientInstance
+ * ()
+ */
+ @Override
+ protected CollectionSpaceClient getClientInstance() {
+ // This method is meaningless to this test.
+ return null;
+ }
@Override
protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
return null;
}
- // ---------------------------------------------------------------
- // CRUD tests : CREATE tests
- // ---------------------------------------------------------------
- // Success outcomes
-
- @Test(dataProvider = "testName")
- public void create(String testName) throws Exception {
- int statusCode;
- setupCreate();
-
- // Submit the request to the service and store the response.
- DimensionClient client = new DimensionClient();
- //bigbird allowed to create
- client.setAuth(true, "bigbird2010", true, "bigbird2010", true);
- String identifier = createIdentifier();
- DimensionsCommon dimension = new DimensionsCommon();
- dimension.setDimension("dimensionType");
- dimension.setMeasurementUnit("measurementUnit-" + identifier);
- dimension.setValueDate(new Date().toString());
- PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(client.getCommonPartName(),
- dimension);
- Response res = client.create(multipart);
- try {
- statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.CREATED.getStatusCode());
- knownResourceId = extractId(res);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
- } finally {
- res.close();
- }
-
- // Now verify that elmo cannot create
- client = new DimensionClient();
- client.setAuth(true, "elmo2010", true, "elmo2010", true);
- res = client.create(multipart);
- try {
- statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug(testName + " (verify not allowed): status = " + statusCode);
- }
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
- } finally {
- res.close();
- }
-
- //Finally, verify that elmo has no access to Intakes
- // Submit the request to the service and store the response.
- IntakeClient iclient = new IntakeClient();
- iclient.setAuth(true, "elmo2010", true, "elmo2010", true);
- multipart = createIntakeInstance(
- "entryNumber-" + identifier,
- "entryDate-" + identifier,
- "depositor-" + identifier);
- res = iclient.create(multipart);
- try {
- if (logger.isDebugEnabled()) {
- logger.debug(testName + " (verify create intake not allowed): status = " + statusCode);
- }
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
- } finally {
- res.close();
- }
- }
-
- /**
- * Creates the intake instance.
- *
- * @param entryNumber the entry number
- * @param entryDate the entry date
- * @param depositor the depositor
- * @return the multipart output
- */
- private PoxPayloadOut createIntakeInstance(String entryNumber,
- String entryDate,
- String depositor) {
- IntakesCommon intake = new IntakesCommon();
- intake.setEntryNumber(entryNumber);
- intake.setEntryDate(entryDate);
- intake.setDepositor(depositor);
-
- PoxPayloadOut multipart = new PoxPayloadOut(IntakeClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
- commonPart.setLabel(new IntakeClient().getCommonPartName());
-
- if(logger.isDebugEnabled()){
- logger.debug("to be created, intake common");
- logger.debug(objectAsXmlString(intake, IntakesCommon.class));
- }
-
- return multipart;
- }
-
- @Test(dataProvider = "testName",
- dependsOnMethods = {"delete"})
- public void verifyCreateWithFlippedRoles(String testName) throws Exception {
- int statusCode;
- setupCreate();
-
- // Submit the request to the service and store the response.
- DimensionClient client = new DimensionClient();
- flipInitialAccountRoles();
-
- // Now verify that elmo can create
- client.setAuth(true, "elmo2010", true, "elmo2010", true);
- client = new DimensionClient();
-
- String identifier = createIdentifier();
- DimensionsCommon dimension = new DimensionsCommon();
- dimension.setDimension("dimensionType");
- dimension.setMeasurementUnit("measurementUnit-" + identifier);
- dimension.setValueDate(new Date().toString());
- PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(client.getCommonPartName(),
- dimension);
- Response res = client.create(multipart);
- try {
- statusCode = res.getStatus();
-
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.CREATED.getStatusCode());
- knownResourceId = extractId(res);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
- }
- } finally {
- res.close();
- }
-
- //bigbird no longer allowed to create
- client.setAuth(true, "bigbird2010", true, "bigbird2010", true);
- res = client.create(multipart);
- try {
- statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug(testName + " (verify not allowed): status = " + statusCode);
- }
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
- } finally {
- res.close();
- }
-
- restoreInitialAccountRoles();
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : READ tests
- // ---------------------------------------------------------------
- // Success outcomes
- @Test(dataProvider = "testName",
- dependsOnMethods = {"create"})
- public void read(String testName) throws Exception {
- // Perform setup.
- setupRead();
-
- // Submit the request to the service and store the response.
- DimensionClient client = new DimensionClient();
- //elmo allowed to read
- client.setAuth(true, "elmo2010", true, "elmo2010", true);
- Response res = client.read(knownResourceId);
- try {
- assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
- DimensionsCommon dimension = (DimensionsCommon) extractPart(input,
- client.getCommonPartName(), DimensionsCommon.class);
- Assert.assertNotNull(dimension);
- } finally {
- if (res != null) {
- res.close();
- }
- }
- }
-
- @Test(dataProvider = "testName",
- dependsOnMethods = {"read"})
- public void readLockedOut(String testName) throws Exception {
- // Perform setup.
- 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);
- Response res = client.read(knownResourceId);
- try {
- assertStatusCode(res, testName);
- } finally {
- if (res != null) {
- res.close();
- }
- }
- }
-
- @Test(dataProvider = "testName",
- dependsOnMethods = {"read"})
- public void updateNotAllowed(String testName) throws Exception {
- setupForbidden();
-
- // 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());
- //
- // Create and submit the request to the service and store the response.
- //
- PoxPayloadOut output = new PoxPayloadOut(DimensionClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), dimension);
- Response res = client.update(knownResourceId, output);
- try {
- assertStatusCode(res, testName);
- } finally {
- if (res != null) {
- res.close();
- }
- }
- //
- // 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);
- try {
- assertStatusCode(res, testName);
- } finally {
- if (res != null) {
- res.close();
- }
- }
-
- }
-
- // ---------------------------------------------------------------
- // CRUD tests : DELETE tests
- // ---------------------------------------------------------------
- // Success outcomes
- @Test(dataProvider = "testName",
- dependsOnMethods = {"updateNotAllowed"})
- public void deleteNotAllowed(String testName) throws Exception {
- // Perform setup.
- 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
- //
- Response res = client.delete(knownResourceId);
- try {
- assertStatusCode(res, testName);
- } finally {
- if (res != null) {
- res.close();
- }
- }
- }
-
- @Test(dataProvider = "testName",
- dependsOnMethods = {"deleteNotAllowed"})
- public void delete(String testName) throws Exception {
- // Perform setup.
- setupDelete();
-
- // Submit the request to the service and store the response.
- DimensionClient client = new DimensionClient();
-
- Response res = client.delete(knownResourceId);
- try {
- assertStatusCode(res, testName);
- } finally {
- if (res != null) {
- res.close();
- }
- }
- }
-
- // ---------------------------------------------------------------
- // Utility methods used by tests above
- // ---------------------------------------------------------------
- @AfterClass(alwaysRun = true)
- public void cleanUp() {
- setupDelete();
- 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 ...");
- }
-
- deletePermissionRoles();
- deleteAccountRoles();
- //FIXME delete on permission deletes all associations with roles
- //this would delete association with ROLE_ADMINISTRATOR too
- //deletePermissions();
- deleteRoles();
- deleteAccounts();
- }
-
- 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() {
- List<RoleValue> bigbirdRoleValues = new ArrayList<RoleValue>();
- bigbirdRoleValues.add(roleValues.get("ROLE_TEST_CM"));
-
- List<RoleValue> elmoRoleValues = new ArrayList<RoleValue>();
- elmoRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
- if(!accountRolesFlipped) {
- deleteAccountRole(accValues.get("bigbird2010"), bigbirdRoleValues);
- deleteAccountRole(accValues.get("elmo2010"), elmoRoleValues);
- } else {
- deleteAccountRole(accValues.get("bigbird2010"), elmoRoleValues);
- deleteAccountRole(accValues.get("elmo2010"),bigbirdRoleValues );
- }
- }
-
- private void flipInitialAccountRoles() {
- if(!accountRolesFlipped) {
- List<RoleValue> cmRoleValues = new ArrayList<RoleValue>();
- List<RoleValue> internRoleValues = new ArrayList<RoleValue>();
- cmRoleValues.add(roleValues.get("ROLE_TEST_CM"));
- internRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
-
- deleteAccountRole(accValues.get("bigbird2010"), cmRoleValues);
- deleteAccountRole(accValues.get("elmo2010"), internRoleValues);
-
- createAccountRole(accValues.get("bigbird2010"), internRoleValues);
- createAccountRole(accValues.get("elmo2010"), cmRoleValues);
-
- accountRolesFlipped = true;
- }
- }
-
- private void restoreInitialAccountRoles() {
- if(accountRolesFlipped) {
- List<RoleValue> cmRoleValues = new ArrayList<RoleValue>();
- List<RoleValue> internRoleValues = new ArrayList<RoleValue>();
- cmRoleValues.add(roleValues.get("ROLE_TEST_CM"));
- internRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
-
- deleteAccountRole(accValues.get("bigbird2010"), internRoleValues);
- deleteAccountRole(accValues.get("elmo2010"), cmRoleValues);
-
- createAccountRole(accValues.get("bigbird2010"), internRoleValues);
- createAccountRole(accValues.get("elmo2010"), cmRoleValues);
- accountRolesFlipped = false;
- }
- }
-
- private void deletePermissions() {
- //delete entities
- for (PermissionValue pv : permValues.values()) {
- deletePermission(pv.getPermissionId());
- }
- }
-
- private void deleteRoles() {
- for (RoleValue rv : roleValues.values()) {
- deleteRole(rv.getRoleId());
- }
- }
-
- private void deleteAccounts() {
-
- for (AccountValue av1 : accValues.values()) {
- deleteAccount(av1.getAccountId());
- }
- }
-
- private String createPermission(String resName, EffectType effect) {
- List<PermissionAction> actions = PermissionFactory.createDefaultActions();
- return createPermission(resName, actions, effect);
- }
-
- 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);
- Response res = permClient.create(permission);
- try {
- assertStatusCode(res, "CreatePermission");
- result = extractId(res);
- } finally {
- if (res != null) {
- res.close();
- }
- }
-
- return result;
- }
-
- private void deletePermission(String permId) {
- setupDelete();
- PermissionClient permClient = new PermissionClient();
- Response res = permClient.delete(permId);
- try {
- assertStatusCode(res, "DeletePermission");
- } finally {
- if (res != null) {
- res.close();
- }
- }
- }
-
- 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);
- Response res = roleClient.create(role);
- try {
- assertStatusCode(res, "CreateRole");
- result = extractId(res);
- } finally {
- if (res != null) {
- res.close();
- }
- }
-
- return result;
- }
-
- private void deleteRole(String roleId) {
- setupDelete();
- RoleClient roleClient = new RoleClient();
- Response res = roleClient.delete(roleId);
- try {
- assertStatusCode(res, "DeleteRole");
- } finally {
- if (res != null) {
- res.close();
- }
- }
- }
-
- 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);
- Response res = accountClient.create(account);
- try {
- assertStatusCode(res, "CreateAccount");
- result = extractId(res);
- } finally {
- if (res != null) {
- res.close();
- }
- }
-
- return result;
- }
-
- private void deleteAccount(String accId) {
- setupDelete();
- AccountClient accClient = new AccountClient();
- Response res = accClient.delete(accId);
- try {
- assertStatusCode(res, "DeleteAccount");
- } finally {
- if (res != null) {
- res.close();
- }
- }
- }
-
- 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();
- Response res = client.create(av.getAccountId(), accRole);
- try {
- assertStatusCode(res, "CreateAccountRole");
- result = extractId(res);
- } finally {
- if (res != null) {
- res.close();
- }
- }
-
- return result;
- }
-
- private void deleteAccountRole(AccountValue av,
- Collection<RoleValue> rvs) {
- // Perform setup.
- setupDelete();
-
- // Submit the request to the service and store the response.
- AccountRoleClient client = new AccountRoleClient();
- AccountRole accRole = AccountRoleFactory.createAccountRoleInstance(
- av, rvs, true, true);
- Response res = client.delete(av.getAccountId());
- try {
- assertStatusCode(res, "DeleteAccountRole");
- } finally {
- if (res != null) {
- res.close();
- }
- }
- }
-
- private String createPermissionRole(PermissionValue pv, Collection<RoleValue> rvs) {
- String result = null;
-
- setupCreate();
- List<RoleValue> rvls = new ArrayList<RoleValue>();
- rvls.addAll(rvs);
- PermissionRole permRole = PermissionRoleFactory.createPermissionRoleInstance(
- pv, rvls, true, true);
- PermissionRoleClient client = new PermissionRoleClient();
- Response res = client.create(pv.getPermissionId(), permRole);
- try {
- assertStatusCode(res, "CreatePermissionRole");
- result = extractId(res);
- } finally {
- if (res != null) {
- res.close();
- }
- }
-
- return result;
- }
-
- private void deletePermissionRole(PermissionValue pv,
- Collection<RoleValue> rvs) {
- List<RoleValue> rvls = new ArrayList<RoleValue>();
- rvls.addAll(rvs);
-
- // Perform setup.
- setupDelete();
-
- // Submit the request to the service and store the response.
- PermissionRoleClient client = new PermissionRoleClient();
- PermissionRole permRole = PermissionRoleFactory.createPermissionRoleInstance(
- pv, rvls, true, true);
- Response res = client.delete(pv.getPermissionId());
- try {
- assertStatusCode(res, "DeletePermissionRole");
- } finally {
- if (res != null) {
- res.close();
- }
- }
- }
+ // ---------------------------------------------------------------
+ // CRUD tests : CREATE tests
+ // ---------------------------------------------------------------
+ // Success outcomes
+
+ @Test(dataProvider = "testName")
+ public void create(String testName) throws Exception {
+ int statusCode;
+ setupCreate();
+
+ // Submit the request to the service and store the response.
+ DimensionClient client = new DimensionClient();
+ // bigbird allowed to create
+ client.setAuth(true, "bigbird2010", true, "bigbird2010", true);
+ String identifier = createIdentifier();
+ DimensionsCommon dimension = new DimensionsCommon();
+ dimension.setDimension("dimensionType");
+ dimension.setMeasurementUnit("measurementUnit-" + identifier);
+ dimension.setValueDate(new Date().toString());
+ PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(client.getCommonPartName(), dimension);
+ Response res = client.create(multipart);
+ try {
+ statusCode = res.getStatus();
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.CREATED.getStatusCode());
+ knownResourceId = extractId(res);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": knownResourceId=" + knownResourceId);
+ }
+ } finally {
+ res.close();
+ }
+
+ // Now verify that elmo cannot create
+ client = new DimensionClient();
+ client.setAuth(true, "elmo2010", true, "elmo2010", true);
+ res = client.create(multipart);
+ try {
+ statusCode = res.getStatus();
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + " (verify not allowed): status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
+ } finally {
+ res.close();
+ }
+
+ // Finally, verify that elmo has no access to Intakes
+ // Submit the request to the service and store the response.
+ IntakeClient iclient = new IntakeClient();
+ iclient.setAuth(true, "elmo2010", true, "elmo2010", true);
+ multipart = createIntakeInstance("entryNumber-" + identifier, "entryDate-" + identifier, "depositor-"
+ + identifier);
+ res = iclient.create(multipart);
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + " (verify create intake not allowed): status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
+ } finally {
+ res.close();
+ }
+ }
+
+ /**
+ * Creates the intake instance.
+ *
+ * @param entryNumber
+ * the entry number
+ * @param entryDate
+ * the entry date
+ * @param depositor
+ * the depositor
+ * @return the multipart output
+ * @throws Exception
+ */
+ private PoxPayloadOut createIntakeInstance(String entryNumber, String entryDate, String depositor) throws Exception {
+ IntakesCommon intake = new IntakesCommon();
+ intake.setEntryNumber(entryNumber);
+ intake.setEntryDate(entryDate);
+ intake.setDepositor(depositor);
+
+ PoxPayloadOut multipart = new PoxPayloadOut(IntakeClient.SERVICE_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
+ commonPart.setLabel(new IntakeClient().getCommonPartName());
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("to be created, intake common");
+ logger.debug(objectAsXmlString(intake, IntakesCommon.class));
+ }
+
+ return multipart;
+ }
+
+ @Test(dataProvider = "testName", dependsOnMethods = { "delete" })
+ public void verifyCreateWithFlippedRoles(String testName) throws Exception {
+ int statusCode;
+ setupCreate();
+
+ // Submit the request to the service and store the response.
+ DimensionClient client = new DimensionClient();
+ flipInitialAccountRoles();
+
+ // Now verify that elmo can create
+ client.setAuth(true, "elmo2010", true, "elmo2010", true);
+ client = new DimensionClient();
+
+ String identifier = createIdentifier();
+ DimensionsCommon dimension = new DimensionsCommon();
+ dimension.setDimension("dimensionType");
+ dimension.setMeasurementUnit("measurementUnit-" + identifier);
+ dimension.setValueDate(new Date().toString());
+ PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(client.getCommonPartName(), dimension);
+ Response res = client.create(multipart);
+ try {
+ statusCode = res.getStatus();
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.CREATED.getStatusCode());
+ knownResourceId = extractId(res);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": knownResourceId=" + knownResourceId);
+ }
+ } finally {
+ res.close();
+ }
+
+ // bigbird no longer allowed to create
+ client.setAuth(true, "bigbird2010", true, "bigbird2010", true);
+ res = client.create(multipart);
+ try {
+ statusCode = res.getStatus();
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + " (verify not allowed): status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
+ } finally {
+ res.close();
+ }
+
+ restoreInitialAccountRoles();
+ }
+
+ // ---------------------------------------------------------------
+ // CRUD tests : READ tests
+ // ---------------------------------------------------------------
+ // Success outcomes
+ @Test(dataProvider = "testName", dependsOnMethods = { "create" })
+ public void read(String testName) throws Exception {
+ // Perform setup.
+ setupRead();
+
+ // Submit the request to the service and store the response.
+ DimensionClient client = new DimensionClient();
+ // elmo allowed to read
+ client.setAuth(true, "elmo2010", true, "elmo2010", true);
+ Response res = client.read(knownResourceId);
+ try {
+ assertStatusCode(res, testName);
+ PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
+ DimensionsCommon dimension = (DimensionsCommon) extractPart(input, client.getCommonPartName(),
+ DimensionsCommon.class);
+ Assert.assertNotNull(dimension);
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+ }
+
+ @Test(dataProvider = "testName", dependsOnMethods = { "read" })
+ public void readLockedOut(String testName) throws Exception {
+ // Perform setup.
+ 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);
+ Response res = client.read(knownResourceId);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+ }
+
+ @Test(dataProvider = "testName", dependsOnMethods = { "read" })
+ public void updateNotAllowed(String testName) throws Exception {
+ setupForbidden();
+
+ // 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());
+ //
+ // Create and submit the request to the service and store the response.
+ //
+ PoxPayloadOut output = new PoxPayloadOut(DimensionClient.SERVICE_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), dimension);
+ Response res = client.update(knownResourceId, output);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+ //
+ // 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);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+
+ }
+
+ // ---------------------------------------------------------------
+ // CRUD tests : DELETE tests
+ // ---------------------------------------------------------------
+ // Success outcomes
+ @Test(dataProvider = "testName", dependsOnMethods = { "updateNotAllowed" })
+ public void deleteNotAllowed(String testName) throws Exception {
+ // Perform setup.
+ 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
+ //
+ Response res = client.delete(knownResourceId);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+ }
+
+ @Test(dataProvider = "testName", dependsOnMethods = { "deleteNotAllowed" })
+ public void delete(String testName) throws Exception {
+ // Perform setup.
+ setupDelete();
+
+ // Submit the request to the service and store the response.
+ DimensionClient client = new DimensionClient();
+
+ Response res = client.delete(knownResourceId);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+ }
+
+ // ---------------------------------------------------------------
+ // Utility methods used by tests above
+ // ---------------------------------------------------------------
+ @AfterClass(alwaysRun = true)
+ public void cleanUp() throws Exception {
+ setupDelete();
+ 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 ...");
+ }
+
+ deletePermissionRoles();
+ deleteAccountRoles();
+ // FIXME delete on permission deletes all associations with roles
+ // this would delete association with ROLE_ADMINISTRATOR too
+ // deletePermissions();
+ deleteRoles();
+ deleteAccounts();
+ }
+
+ private void deletePermissionRoles() throws Exception {
+ 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() throws Exception {
+ List<RoleValue> bigbirdRoleValues = new ArrayList<RoleValue>();
+ bigbirdRoleValues.add(roleValues.get("ROLE_TEST_CM"));
+
+ List<RoleValue> elmoRoleValues = new ArrayList<RoleValue>();
+ elmoRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
+ if (!accountRolesFlipped) {
+ deleteAccountRole(accValues.get("bigbird2010"), bigbirdRoleValues);
+ deleteAccountRole(accValues.get("elmo2010"), elmoRoleValues);
+ } else {
+ deleteAccountRole(accValues.get("bigbird2010"), elmoRoleValues);
+ deleteAccountRole(accValues.get("elmo2010"), bigbirdRoleValues);
+ }
+ }
+
+ private void flipInitialAccountRoles() throws Exception {
+ if (!accountRolesFlipped) {
+ List<RoleValue> cmRoleValues = new ArrayList<RoleValue>();
+ List<RoleValue> internRoleValues = new ArrayList<RoleValue>();
+ cmRoleValues.add(roleValues.get("ROLE_TEST_CM"));
+ internRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
+
+ deleteAccountRole(accValues.get("bigbird2010"), cmRoleValues);
+ deleteAccountRole(accValues.get("elmo2010"), internRoleValues);
+
+ createAccountRole(accValues.get("bigbird2010"), internRoleValues);
+ createAccountRole(accValues.get("elmo2010"), cmRoleValues);
+
+ accountRolesFlipped = true;
+ }
+ }
+
+ private void restoreInitialAccountRoles() throws Exception {
+ if (accountRolesFlipped) {
+ List<RoleValue> cmRoleValues = new ArrayList<RoleValue>();
+ List<RoleValue> internRoleValues = new ArrayList<RoleValue>();
+ cmRoleValues.add(roleValues.get("ROLE_TEST_CM"));
+ internRoleValues.add(roleValues.get("ROLE_TEST_INTERN"));
+
+ deleteAccountRole(accValues.get("bigbird2010"), internRoleValues);
+ deleteAccountRole(accValues.get("elmo2010"), cmRoleValues);
+
+ createAccountRole(accValues.get("bigbird2010"), internRoleValues);
+ createAccountRole(accValues.get("elmo2010"), cmRoleValues);
+ accountRolesFlipped = false;
+ }
+ }
+
+ private void deletePermissions() throws Exception {
+ // delete entities
+ for (PermissionValue pv : permValues.values()) {
+ deletePermission(pv.getPermissionId());
+ }
+ }
+
+ private void deleteRoles() throws Exception {
+ for (RoleValue rv : roleValues.values()) {
+ deleteRole(rv.getRoleId());
+ }
+ }
+
+ private void deleteAccounts() throws Exception {
+
+ for (AccountValue av1 : accValues.values()) {
+ deleteAccount(av1.getAccountId());
+ }
+ }
+
+ private String createPermission(String resName, EffectType effect) throws Exception {
+ List<PermissionAction> actions = PermissionFactory.createDefaultActions();
+ return createPermission(resName, actions, effect);
+ }
+
+ private String createPermission(String resName, List<PermissionAction> actions, EffectType effect) throws Exception {
+ String result = null;
+
+ setupCreate();
+ PermissionClient permClient = new PermissionClient();
+ Permission permission = PermissionFactory.createPermissionInstance(resName, "default permissions for "
+ + resName, actions, effect, true, true, true);
+ Response res = permClient.create(permission);
+ try {
+ assertStatusCode(res, "CreatePermission");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+
+ return result;
+ }
+
+ private void deletePermission(String permId) throws Exception {
+ setupDelete();
+ PermissionClient permClient = new PermissionClient();
+ Response res = permClient.delete(permId);
+ try {
+ assertStatusCode(res, "DeletePermission");
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+ }
+
+ private String createRole(String roleName) throws Exception {
+ String result = null;
+
+ setupCreate();
+ RoleClient roleClient = new RoleClient();
+ Role role = RoleFactory.createRoleInstance(roleName, roleName, // the
+ // display
+ // name
+ "role for " + roleName, true);
+ Response res = roleClient.create(role);
+ try {
+ assertStatusCode(res, "CreateRole");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+
+ return result;
+ }
+
+ private void deleteRole(String roleId) throws Exception {
+ setupDelete();
+ RoleClient roleClient = new RoleClient();
+ Response res = roleClient.delete(roleId);
+ try {
+ assertStatusCode(res, "DeleteRole");
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+ }
+
+ private String createAccount(String userName, String email) throws Exception {
+ String result = null;
+
+ setupCreate();
+ AccountClient accountClient = new AccountClient();
+ AccountsCommon account = AccountFactory.createAccountInstance(userName, userName, userName, email,
+ accountClient.getTenantId(), true, false, true, true);
+ Response res = accountClient.create(account);
+ try {
+ assertStatusCode(res, "CreateAccount");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+
+ return result;
+ }
+
+ private void deleteAccount(String accId) throws Exception {
+ setupDelete();
+ AccountClient accClient = new AccountClient();
+ Response res = accClient.delete(accId);
+ try {
+ assertStatusCode(res, "DeleteAccount");
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+ }
+
+ private String createAccountRole(AccountValue av, Collection<RoleValue> rvs) throws Exception {
+ 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();
+ Response res = client.create(av.getAccountId(), accRole);
+ try {
+ assertStatusCode(res, "CreateAccountRole");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+
+ return result;
+ }
+
+ private void deleteAccountRole(AccountValue av, Collection<RoleValue> rvs) throws Exception {
+ // Perform setup.
+ setupDelete();
+
+ // Submit the request to the service and store the response.
+ AccountRoleClient client = new AccountRoleClient();
+ AccountRole accRole = AccountRoleFactory.createAccountRoleInstance(av, rvs, true, true);
+ Response res = client.delete(av.getAccountId());
+ try {
+ assertStatusCode(res, "DeleteAccountRole");
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+ }
+
+ private String createPermissionRole(PermissionValue pv, Collection<RoleValue> rvs) throws Exception {
+ String result = null;
+
+ setupCreate();
+ List<RoleValue> rvls = new ArrayList<RoleValue>();
+ rvls.addAll(rvs);
+ PermissionRole permRole = PermissionRoleFactory.createPermissionRoleInstance(pv, rvls, true, true);
+ PermissionRoleClient client = new PermissionRoleClient();
+ Response res = client.create(pv.getPermissionId(), permRole);
+ try {
+ assertStatusCode(res, "CreatePermissionRole");
+ result = extractId(res);
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+
+ return result;
+ }
+
+ private void deletePermissionRole(PermissionValue pv, Collection<RoleValue> rvs) throws Exception {
+ List<RoleValue> rvls = new ArrayList<RoleValue>();
+ rvls.addAll(rvs);
+
+ // Perform setup.
+ setupDelete();
+
+ // Submit the request to the service and store the response.
+ PermissionRoleClient client = new PermissionRoleClient();
+ PermissionRole permRole = PermissionRoleFactory.createPermissionRoleInstance(pv, rvls, true, true);
+ Response res = client.delete(pv.getPermissionId());
+ try {
+ assertStatusCode(res, "DeletePermissionRole");
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+ }
@Override
protected Class<AbstractCommonList> getCommonListType() {
}
@BeforeClass(alwaysRun = true)
- public void seedData() {
+ public void seedData() throws Exception {
//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));
seedPermissionRoles();
}
- private void seedAccounts() {
+ private void seedAccounts() throws Exception {
seedAccount(TENANT_1, TENANT_1_USER);
seedAccount(TENANT_2, TENANT_2_USER);
}
- private void seedAccount(String tenantId, String userId) {
+ private void seedAccount(String tenantId, String userId) throws Exception {
//create account using default user in admin role but assign tenant id
//create username, email and password same for simplicity
String accId = createAccount(tenantId, userId, userId);
}
}
- private void seedPermissions() {
+ private void seedPermissions() throws Exception {
String resource = TEST_SERVICE_A;
PermissionAction pac = new PermissionAction();
}
private void seedPermission(String tenantId,
- String resource, List<PermissionAction> testActions, EffectType effect) {
+ String resource, List<PermissionAction> testActions, EffectType effect) throws Exception {
//create permission using default user in admin role but assign tenant id
String id = createPermission(tenantId, resource, testActions, effect);
PermissionValue pv = new PermissionValue();
}
}
- private void seedRoles() {
+ private void seedRoles() throws Exception {
//create role using default user in admin role but assign tenant id
//use the same role name to check constraints
seedRole(TENANT_1, TEST_ROLE_NAME);
seedRole(TENANT_2, TEST_ROLE_NAME);
}
- private void seedRole(String tenantId, String roleName) {
+ private void seedRole(String tenantId, String roleName) throws Exception {
String rid = createRole(tenantId, roleName);
RoleValue rv = new RoleValue();
rv.setRoleId(rid);
}
}
- private void seedAccountRoles() {
+ private void seedAccountRoles() throws Exception {
for (String tenantId : tenantAccounts.keySet()) {
AccountValue av = (AccountValue) tenantAccounts.get(tenantId);
seedAccountRole(tenantId, av.getUserId());
}
}
- private void seedAccountRole(String tenantId, String userId) {
+ private void seedAccountRole(String tenantId, String userId) throws Exception {
List<RoleValue> tenantRoleValues = new ArrayList<RoleValue>();
tenantRoleValues.add(tenantRoles.get(tenantId));
createAccountRole(tenantId, userAccounts.get(userId), tenantRoleValues);
}
}
- private void seedPermissionRoles() {
+ private void seedPermissionRoles() throws Exception {
for (String tenantId : tenantPermissions.keySet()) {
PermissionValue pv = tenantPermissions.get(tenantId);
seedPermissionRole(tenantId, pv.getPermissionId());
}
}
- private void seedPermissionRole(String tenantId, String permId) {
+ private void seedPermissionRole(String tenantId, String permId) throws Exception {
List<RoleValue> tenantRoleValues = new ArrayList<RoleValue>();
tenantRoleValues.add(tenantRoles.get(tenantId));
PermissionValue pv = permValues.get(permId);
}
}
- private String create(String testName, String userName, String tenatnId) {
+ private String create(String testName, String userName, String tenatnId) throws Exception {
String result = null;
setupCreate();
// Utility methods used by tests above
// ---------------------------------------------------------------
@AfterClass(alwaysRun = true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
setupDelete();
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
deleteAccounts();
}
- private void deletePermissionRoles() {
+ private void deletePermissionRoles() throws Exception {
for (String tenantId : tenantPermissions.keySet()) {
List<RoleValue> tenantRoleValues = new ArrayList<RoleValue>();
tenantRoleValues.add(tenantRoles.get(tenantId));
}
}
- private void deleteAccountRoles() {
+ private void deleteAccountRoles() throws Exception {
for (String tenantId : tenantAccounts.keySet()) {
List<RoleValue> tenantRoleValues = new ArrayList<RoleValue>();
tenantRoleValues.add(tenantRoles.get(tenantId));
}
}
- private void deletePermissions() {
+ private void deletePermissions() throws Exception {
for (String tenantId : tenantPermissions.keySet()) {
PermissionValue pv = tenantPermissions.get(tenantId);
deletePermission(tenantId, pv.getPermissionId());
}
}
- private void deleteRoles() {
+ private void deleteRoles() throws Exception {
for (String tenantId : tenantRoles.keySet()) {
RoleValue rv = tenantRoles.get(tenantId);
deleteRole(tenantId, rv.getRoleId());
}
}
- private void deleteAccounts() {
+ private void deleteAccounts() throws Exception {
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) {
+ List<PermissionAction> actions, EffectType effect) throws Exception {
String result = null;
setupCreate();
return result;
}
- private void deletePermission(String tenantId, String permId) {
+ private void deletePermission(String tenantId, String permId) throws Exception {
setupDelete();
PermissionClient permClient = new PermissionClient();
UserInfo ui = tenantAdminUsers.get(tenantId);
}
}
- private String createRole(String tenantId, String roleName) {
+ private String createRole(String tenantId, String roleName) throws Exception {
String result = null;
setupCreate();
return result;
}
- private void deleteRole(String tenantId, String roleId) {
+ private void deleteRole(String tenantId, String roleId) throws Exception {
setupDelete();
RoleClient roleClient = new RoleClient();
UserInfo ui = tenantAdminUsers.get(tenantId);
}
}
- private String createAccount(String tenantId, String userName, String email) {
+ private String createAccount(String tenantId, String userName, String email) throws Exception {
String result = null;
setupCreate();
return result;
}
- private void deleteAccount(String tenantId, String accId) {
+ private void deleteAccount(String tenantId, String accId) throws Exception {
setupDelete();
AccountClient accClient = new AccountClient();
UserInfo ui = tenantAdminUsers.get(tenantId);
}
private String createAccountRole(String tenantId, AccountValue av,
- Collection<RoleValue> rvs) {
+ Collection<RoleValue> rvs) throws Exception {
String result = null;
setupCreate();
}
private void deleteAccountRole(String tenantId, AccountValue av,
- List<RoleValue> rvs) {
+ List<RoleValue> rvs) throws Exception {
// Perform setup.
setupDelete();
}
private String createPermissionRole(String tenantId, PermissionValue pv,
- Collection<RoleValue> rvs) {
+ Collection<RoleValue> rvs) throws Exception {
String result = null;
setupCreate();
return result;
}
- private void deletePermissionRole(String tenantId, PermissionValue pv, List<RoleValue> rvls) {
+ private void deletePermissionRole(String tenantId, PermissionValue pv, List<RoleValue> rvls) throws Exception {
// Perform setup.
setupDelete();
public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
- public ServiceGroupClient() {
+ public ServiceGroupClient() throws Exception {
super();
}
- public ServiceGroupClient(String clientPropertiesFilename) {
+ public ServiceGroupClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.servicegroup.ServicegroupsCommon;
import javax.ws.rs.core.Response;
+
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
}
@Override
- protected CollectionSpaceClient<AbstractCommonList, PoxPayloadOut, String, ServiceGroupProxy> getClientInstance() {
+ protected CollectionSpaceClient<AbstractCommonList, PoxPayloadOut, String, ServiceGroupProxy> getClientInstance() throws Exception {
return new ServiceGroupClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new ServiceGroupClient(clientPropertiesFilename);
}
//
// Constructors
//
- public TaxonomyAuthorityClient() {
+ public TaxonomyAuthorityClient() throws Exception {
super();
}
- public TaxonomyAuthorityClient(String clientPropertiesFilename) {
+ public TaxonomyAuthorityClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.client.TaxonomyAuthorityClientUtils;
import org.collectionspace.services.client.TaxonomyAuthorityProxy;
import org.collectionspace.services.jaxb.AbstractCommonList;
-
import org.collectionspace.services.taxonomy.CommonNameGroup;
import org.collectionspace.services.taxonomy.CommonNameGroupList;
import org.collectionspace.services.taxonomy.TaxonAuthorGroup;
* org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient<AbstractCommonList, PoxPayloadOut, String, TaxonomyAuthorityProxy> getClientInstance() {
+ protected CollectionSpaceClient<AbstractCommonList, PoxPayloadOut, String, TaxonomyAuthorityProxy> getClientInstance() throws Exception {
return new TaxonomyAuthorityClient();
}
@Override
- protected CollectionSpaceClient<AbstractCommonList, PoxPayloadOut, String, TaxonomyAuthorityProxy> getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient<AbstractCommonList, PoxPayloadOut, String, TaxonomyAuthorityProxy> getClientInstance(String clientPropertiesFilename) throws Exception {
return new TaxonomyAuthorityClient(clientPropertiesFilename);
}
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun = true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
- public ValuationcontrolClient() {
+ public ValuationcontrolClient() throws Exception {
super();
}
- public ValuationcontrolClient(String clientPropertiesFilename) {
+ public ValuationcontrolClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.valuationcontrol.ValuationcontrolsCommon;
import javax.ws.rs.core.Response;
+
import org.testng.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final String SERVICE_PATH_COMPONENT = "valuationcontrols";
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new ValuationcontrolClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new ValuationcontrolClient(clientPropertiesFilename);
}
}
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
return createValuationcontrolInstance(identifier);
}
*
* @param valuationcontrolRefNumber the valuationcontrol number
* @return the multipart output
+ * @throws Exception
*/
- private PoxPayloadOut createValuationcontrolInstance(String valuationcontrolRefNumber) {
+ private PoxPayloadOut createValuationcontrolInstance(String valuationcontrolRefNumber) throws Exception {
ValuationcontrolsCommon valuationcontrolCommon = new ValuationcontrolsCommon();
valuationcontrolCommon.setValuationcontrolRefNumber(valuationcontrolRefNumber);
@Override
protected PoxPayloadOut createInstance(String commonPartName,
- String identifier) {
+ String identifier) throws Exception {
PoxPayloadOut result = createValuationcontrolInstance(identifier);
return result;
}
//
// Constructors
//
- public VocabularyClient() {
+ public VocabularyClient() throws Exception {
super();
}
- public VocabularyClient(String clientPropertiesFilename) {
+ public VocabularyClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new VocabularyClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new VocabularyClient(clientPropertiesFilename);
}
}
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
VocabularyClient client = new VocabularyClient();
return createInstance(client.getCommonPartName(), identifier);
}
//
@Override
- protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) {
+ protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) throws Exception {
String headerLabel = new VocabularyClient().getItemCommonPartName();
HashMap<String, String> vocabItemInfo = new HashMap<String, String>();
String shortId = identifier;
@AfterClass(alwaysRun = true)
@Override
- public void cleanUp() {
+ public void cleanUp() throws Exception {
super.cleanUp();
}
}
//
// Constructors
//
- public WorkAuthorityClient() {
+ public WorkAuthorityClient() throws Exception {
super();
}
- public WorkAuthorityClient(String clientPropertiesFilename) {
+ public WorkAuthorityClient(String clientPropertiesFilename) throws Exception {
super(clientPropertiesFilename);
}
import org.collectionspace.services.work.WorkTermGroupList;
import org.collectionspace.services.work.WorkauthoritiesCommon;
import org.collectionspace.services.work.WorksCommon;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new WorkAuthorityClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new WorkAuthorityClient(clientPropertiesFilename);
}
* 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.
+ * @throws Exception
*/
@AfterClass(alwaysRun=true)
- public void cleanUp() {
+ public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
if (logger.isDebugEnabled()) {
}
@Override
- protected CollectionSpaceClient getClientInstance() {
+ protected CollectionSpaceClient getClientInstance() throws Exception {
return new DimensionClient();
}
@Override
- protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
+ protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
return new DimensionClient(clientPropertiesFilename);
}
// ---------------------------------------------------------------
@Override
- protected PoxPayloadOut createInstance(String identifier) {
+ protected PoxPayloadOut createInstance(String identifier) throws Exception {
String dimensionsCommonPartName = new DimensionClient().getCommonPartName();
return createInstance(identifier, dimensionsCommonPartName);
}
/*
* We're using a DimensionsCommon instance to test the workflow service.
*/
- private PoxPayloadOut createDimensionInstance(String dimensionValue) {
+ private PoxPayloadOut createDimensionInstance(String dimensionValue) throws Exception {
String commonPartName = new DimensionClient().getCommonPartName();
return createDimensionInstance(commonPartName, dimensionValue);
}