refactoring of collectionobject, accountrole and permissionrole tests, extracted out factories
added releaseConnection on the test in this checkin
test: security/client
M services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java
A services/collectionobject/client/src/main/java/org/collectionspace/services/client/CollectionObjectFactory.java
M services/collectionobject/client/pom.xml
M services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RoleServiceTest.java
M services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionServiceTest.java
M services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionRoleServiceTest.java
A services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionRoleFactory.java
M services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountRoleServiceTest.java
A services/account/client/src/main/java/org/collectionspace/services/client/AccountRoleFactory.java
D services/security/client/src/test/java/org/collectionspace/services/authentication/client/test/AuthenticationServiceTest.java
A services/security/client/src/test/java/org/collectionspace/services/security
A services/security/client/src/test/java/org/collectionspace/services/security/client
A services/security/client/src/test/java/org/collectionspace/services/security/client/test
A + services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthenticationServiceTest.java
M services/security/client/src/test/resources/log4j.properties
M services/security/client/pom.xml
--- /dev/null
+/**
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+
+ * Copyright 2009 University of California at Berkeley
+
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+
+ * You may obtain a copy of the ECL 2.0 License at
+
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.collectionspace.services.client;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.collectionspace.services.authorization.AccountRole;
+import org.collectionspace.services.authorization.AccountValue;
+import org.collectionspace.services.authorization.RoleValue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author
+ */
+public class AccountRoleFactory {
+ static private final Logger logger = LoggerFactory.getLogger(AccountRoleFactory.class);
+
+ /**
+ * Creates the account role instance.
+ *
+ * @param pv the pv
+ * @param rvs the rvs
+ * @param usePermId the use perm id
+ * @param useRoleId the use role id
+ * @return the account role
+ */
+ static public AccountRole createAccountRoleInstance(AccountValue pv,
+ Collection<RoleValue> rvs,
+ boolean usePermId,
+ boolean useRoleId) {
+
+ AccountRole accRole = new AccountRole();
+ //service consume is not required to provide subject as it is determined
+ //from URI used
+// accRole.setSubject(SubjectType.ROLE);
+ if (usePermId) {
+ ArrayList<AccountValue> pvs = new ArrayList<AccountValue>();
+ pvs.add(pv);
+ accRole.setAccounts(pvs);
+ }
+ if (useRoleId) {
+ //FIXME is there a better way?
+ ArrayList<RoleValue> rvas = new ArrayList<RoleValue>();
+ for (RoleValue rv : rvs) {
+ rvas.add(rv);
+ }
+ accRole.setRoles(rvas);
+ }
+
+ return accRole;
+ }
+
+
+}
import org.collectionspace.services.client.AccountClient;
import org.collectionspace.services.client.AccountFactory;
import org.collectionspace.services.client.AccountRoleClient;
+import org.collectionspace.services.client.AccountRoleFactory;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.RoleClient;
import org.collectionspace.services.client.RoleFactory;
@BeforeClass(alwaysRun = true)
public void seedData() {
- String ra = "acc-role-user1";
- String accId = createAccount(ra, "acc-role-test@cspace.org");
+ String userId = "acc-role-user1";
+ String accId = createAccount(userId, "acc-role-test@cspace.org");
AccountValue ava = new AccountValue();
- ava.setScreenName(ra);
- ava.setUserId(ra);
+ ava.setScreenName(userId);
+ ava.setUserId(userId);
ava.setAccountId(accId);
accValues.put(ava.getScreenName(), ava);
- String rc = "acc-role-user2";
- String coAccId = createAccount(rc, "acc-role-test@cspace.org");
+ String userId2 = "acc-role-user2";
+ String coAccId = createAccount(userId2, "acc-role-test@cspace.org");
AccountValue avc = new AccountValue();
- avc.setScreenName(rc);
- avc.setUserId(rc);
+ avc.setScreenName(userId2);
+ avc.setUserId(userId2);
avc.setAccountId(coAccId);
accValues.put(avc.getScreenName(), avc);
*/
@Override
protected CollectionSpaceClient getClientInstance() {
- return new AccountRoleClient();
+ return new AccountRoleClient();
}
-
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
- throw new UnsupportedOperationException();
+ protected AbstractCommonList getAbstractCommonList(
+ ClientResponse<AbstractCommonList> response) {
+ //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
+ throw new UnsupportedOperationException();
}
-
- @Test(dataProvider = "testName")
- @Override
+
+ @Test(dataProvider = "testName")
+ @Override
public void readPaginatedList(String testName) throws Exception {
- //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
- }
-
+ //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
+ }
+
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
if (logger.isDebugEnabled()) {
logger.debug(testName + ": knownResourceId=" + knownResourceId);
}
+ res.releaseConnection();
}
//to not cause uniqueness violation for accRole, createList is removed
dependsOnMethods = {"create"})
@Override
public void createList(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
+ //FIXME: Should this test really be empty? If so, please comment accordingly.
}
// Failure outcomes
// See Issue CSPACE-401.
@Override
public void createWithEmptyEntityBody(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
+ //FIXME: Should this test really be empty? If so, please comment accordingly.
}
@Override
public void createWithMalformedXml(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
+ //FIXME: Should this test really be empty? If so, please comment accordingly.
}
@Override
public void createWithWrongXmlSchema(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
+ //FIXME: Should this test really be empty? If so, please comment accordingly.
}
// ---------------------------------------------------------------
AccountRole output = (AccountRole) res.getEntity();
Assert.assertNotNull(output);
+ res.releaseConnection();
}
// Failure outcomes
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ res.releaseConnection();
}
// ---------------------------------------------------------------
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
dependsOnMethods = {"createList", "read"})
public void readList(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
+ //FIXME: Should this test really be empty? If so, please comment accordingly.
}
// Failure outcomes
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
dependsOnMethods = {"read", "readList", "readNonExistent"})
public void update(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
+ //FIXME: Should this test really be empty? If so, please comment accordingly.
}
// Failure outcomes
// See Issue CSPACE-401.
@Override
public void updateWithEmptyEntityBody(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
+ //FIXME: Should this test really be empty? If so, please comment accordingly.
}
@Override
public void updateWithMalformedXml(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
+ //FIXME: Should this test really be empty? If so, please comment accordingly.
}
@Override
public void updateWithWrongXmlSchema(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
+ //FIXME: Should this test really be empty? If so, please comment accordingly.
}
@Override
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
public void updateNonExistent(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
+ //FIXME: Should this test really be empty? If so, please comment accordingly.
}
// ---------------------------------------------------------------
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ res.releaseConnection();
}
// Failure outcomes
boolean usePermId,
boolean useRoleId) {
- AccountRole accRole = new AccountRole();
- //service consume is not required to provide subject as it is determined
- //from URI used
-// accRole.setSubject(SubjectType.ROLE);
- if (usePermId) {
- ArrayList<AccountValue> pvs = new ArrayList<AccountValue>();
- pvs.add(pv);
- accRole.setAccounts(pvs);
- }
- if (useRoleId) {
- //FIXME is there a better way?
- ArrayList<RoleValue> rvas = new ArrayList<RoleValue>();
- for (RoleValue rv : rvs) {
- rvas.add(rv);
- }
- accRole.setRoles(rvas);
- }
+ AccountRole accRole = AccountRoleFactory.createAccountRoleInstance(
+ pv, rvs, usePermId, useRoleId);
if (logger.isDebugEnabled()) {
logger.debug("to be created, accRole common");
public void cleanUp() {
setupDelete("delete");
String noTest = System.getProperty("noTestCleanup");
- if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
+ 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 ...");
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ res.releaseConnection();
}
for (AccountValue pv : accValues.values()) {
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ res.releaseConnection();
return extractId(res);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ res.releaseConnection();
}
private String createRole(String roleName) {
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ res.releaseConnection();
return extractId(res);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ res.releaseConnection();
}
}
--- /dev/null
+/**
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+
+ * Copyright 2009 University of California at Berkeley
+
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+
+ * You may obtain a copy of the ECL 2.0 License at
+
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.collectionspace.services.client;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.collectionspace.services.authorization.PermissionRole;
+import org.collectionspace.services.authorization.PermissionValue;
+import org.collectionspace.services.authorization.RoleValue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author
+ */
+public class PermissionRoleFactory {
+
+ static private final Logger logger = LoggerFactory.getLogger(PermissionRoleFactory.class);
+ /**
+ * create permRolerole instance
+ * @param permId
+ * @param roleValues array of role ids
+ * @param userPermId
+ * @param useRoleId
+ * @return
+ */
+ public static PermissionRole createPermissionRoleInstance(PermissionValue pv,
+ Collection<RoleValue> rvs,
+ boolean usePermId,
+ boolean useRoleId) {
+
+ PermissionRole permRole = new PermissionRole();
+ //service consume is not required to provide subject as it is determined
+ //from URI used
+// permRole.setSubject(SubjectType.ROLE);
+ if (usePermId) {
+ ArrayList<PermissionValue> pvs = new ArrayList<PermissionValue>();
+ pvs.add(pv);
+ permRole.setPermissions(pvs);
+ }
+ if (useRoleId) {
+ //FIXME is there a better way?
+ ArrayList<RoleValue> rvas = new ArrayList<RoleValue>();
+ for (RoleValue rv : rvs) {
+ rvas.add(rv);
+ }
+ permRole.setRoles(rvas);
+ }
+
+ return permRole;
+ }
+}
import org.collectionspace.services.client.PermissionClient;
import org.collectionspace.services.client.PermissionFactory;
import org.collectionspace.services.client.PermissionRoleClient;
+import org.collectionspace.services.client.PermissionRoleFactory;
import org.collectionspace.services.client.RoleClient;
import org.collectionspace.services.client.RoleFactory;
import org.collectionspace.services.client.test.AbstractServiceTestImpl;
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+ res.releaseConnection();
// Store the ID returned from this create operation
// for additional tests below.
//this is is not important in case of this relationship
PermissionRole output = (PermissionRole) res.getEntity();
Assert.assertNotNull(output);
+ res.releaseConnection();
}
// Failure outcomes
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ res.releaseConnection();
}
// ---------------------------------------------------------------
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ res.releaseConnection();
}
// Failure outcomes
}
Assert.assertEquals(statusCode, EXPECTED_STATUS);
+
}
// ---------------------------------------------------------------
boolean usePermId,
boolean useRoleId) {
- PermissionRole permRole = new PermissionRole();
- //service consume is not required to provide subject as it is determined
- //from URI used
-// permRole.setSubject(SubjectType.ROLE);
- if (usePermId) {
- ArrayList<PermissionValue> pvs = new ArrayList<PermissionValue>();
- pvs.add(pv);
- permRole.setPermissions(pvs);
- }
- if (useRoleId) {
- //FIXME is there a better way?
- ArrayList<RoleValue> rvas = new ArrayList<RoleValue>();
- for (RoleValue rv : rvs) {
- rvas.add(rv);
- }
- permRole.setRoles(rvas);
- }
-
+ PermissionRole permRole = PermissionRoleFactory.createPermissionRoleInstance(
+ pv, rvs, usePermId, useRoleId);
if (logger.isDebugEnabled()) {
- logger.debug("to be created, permRole common");
+ logger.debug("to be created, permRole");
logger.debug(objectAsXmlString(permRole, PermissionRole.class));
}
return permRole;
setupCreate();
PermissionClient permClient = new PermissionClient();
List<PermissionAction> actions = PermissionFactory.createDefaultActions();
- Permission permission = PermissionServiceTest.createPermissionInstance(resName,
+ Permission permission = PermissionFactory.createPermissionInstance(resName,
"default permissions for " + resName,
actions, effect, true, true, true);
ClientResponse<Response> res = permClient.create(permission);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ res.releaseConnection();
return extractId(res);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ res.releaseConnection();
}
private String createRole(String roleName) {
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ res.releaseConnection();
return extractId(res);
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ res.releaseConnection();
}
}
useResourceName, useAction, useEffect);
if (logger.isDebugEnabled()) {
- logger.debug("to be created, permission common");
+ logger.debug("to be created, permission");
logger.debug(objectAsXmlString(permission, Permission.class));
}
return permission;
Role role = RoleFactory.createRoleInstance(roleName, description,
useRoleName);
if (logger.isDebugEnabled()) {
- logger.debug("to be created, role common");
+ logger.debug("to be created, role");
logger.debug(objectAsXmlString(role, Role.class));
}
return role;
<dependency>\r
<groupId>org.slf4j</groupId>\r
<artifactId>slf4j-api</artifactId>\r
- <scope>test</scope>\r
</dependency>\r
<dependency>\r
<groupId>org.slf4j</groupId>\r
<artifactId>slf4j-log4j12</artifactId>\r
- <scope>test</scope>\r
</dependency>\r
<!-- CollectionSpace dependencies -->\r
<dependency>\r
--- /dev/null
+/**
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+
+ * Copyright 2009 University of California at Berkeley
+
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+
+ * You may obtain a copy of the ECL 2.0 License at
+
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.collectionspace.services.client;
+
+import javax.ws.rs.core.MediaType;
+import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
+import org.collectionspace.services.collectionobject.domain.naturalhistory.CollectionobjectsNaturalhistory;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author
+ */
+public class CollectionObjectFactory {
+ static private final Logger logger = LoggerFactory.getLogger(CollectionObjectFactory.class);
+
+ /**
+ * create account instance
+ * @param screenName
+ * @param userName
+ * @param passwd
+ * @param email
+ * @param useScreenName
+ * @param addTenant
+ * @param invalidTenant
+ * @param useUser
+ * @param usePassword
+ * @return
+ */
+
+ /**
+ * Creates the collection object instance.
+ *
+ * @param commonPartName the common part name
+ * @param collectionObject the collection object
+ * @param nhPartname natural history part name
+ * @param conh the conh
+ * @return the multipart output
+ */
+ public static MultipartOutput createCollectionObjectInstance(String commonPartName,
+ CollectionobjectsCommon collectionObject,
+ String nhPartName, CollectionobjectsNaturalhistory conh) {
+
+ MultipartOutput multipart = new MultipartOutput();
+ OutputPart commonPart = multipart.addPart(collectionObject,
+ MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", commonPartName);
+
+ if (conh != null) {
+ OutputPart nhPart = multipart.addPart(conh, MediaType.APPLICATION_XML_TYPE);
+ nhPart.getHeaders().add("label", nhPartName);
+ }
+ return multipart;
+
+ }
+
+
+}
//import org.collectionspace.services.client.AbstractServiceClientImpl;
import org.collectionspace.services.client.CollectionObjectClient;
+import org.collectionspace.services.client.CollectionObjectFactory;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
import org.collectionspace.services.collectionobject.domain.naturalhistory.CollectionobjectsNaturalhistory;
private MultipartOutput createCollectionObjectInstance(String commonPartName,
CollectionobjectsCommon collectionObject, CollectionobjectsNaturalhistory conh) {
- MultipartOutput multipart = new MultipartOutput();
- OutputPart commonPart = multipart.addPart(collectionObject,
- MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", commonPartName);
-
+ MultipartOutput multipart = CollectionObjectFactory.createCollectionObjectInstance(
+ commonPartName, collectionObject, getNHPartName(), conh);
if (logger.isDebugEnabled()) {
logger.debug("to be created, collectionobject common");
logger.debug(objectAsXmlString(collectionObject,
}
if (conh != null) {
- OutputPart nhPart = multipart.addPart(conh, MediaType.APPLICATION_XML_TYPE);
- nhPart.getHeaders().add("label", getNHPartName());
-
if (logger.isDebugEnabled()) {
logger.debug("to be created, collectionobject nhistory");
logger.debug(objectAsXmlString(conh,
<groupId>org.collectionspace.services</groupId>\r
<artifactId>org.collectionspace.services.security.client</artifactId>\r
<name>services.security.client</name>\r
- \r
+\r
<dependencies>\r
<!-- keep slf4j dependencies on the top -->\r
<dependency>\r
<!-- authentication tests use CollectionObject service and Account service -->\r
<dependency>\r
<groupId>org.collectionspace.services</groupId>\r
- <artifactId>org.collectionspace.services.authentication.client</artifactId>\r
+ <artifactId>org.collectionspace.services.account.client</artifactId>\r
<version>${project.version}</version>\r
</dependency>\r
<dependency>\r
<groupId>org.collectionspace.services</groupId>\r
- <artifactId>org.collectionspace.services.account.client</artifactId>\r
+ <artifactId>org.collectionspace.services.authorization-mgt.client</artifactId>\r
<version>${project.version}</version>\r
</dependency>\r
<dependency>\r
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.collectionspace.services.authentication.client.test;
+package org.collectionspace.services.security.client.test;
import java.util.List;
-import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
//import org.apache.commons.codec.binary.Base64;
import org.jboss.resteasy.client.ClientResponse;
import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.collectionspace.services.client.AccountFactory;
import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
import org.collectionspace.services.client.CollectionObjectClient;
+import org.collectionspace.services.client.CollectionObjectFactory;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.test.AbstractServiceTestImpl;
import org.collectionspace.services.client.test.BaseServiceTest;
if (logger.isDebugEnabled()) {
logger.debug(testName + ": barneyAccountId=" + barneyAccountId);
}
+ res.releaseConnection();
}
if (logger.isDebugEnabled()) {
logger.debug(testName + ": georgeAccountId=" + georgeAccountId);
}
-
+ res.releaseConnection();
//deactivate
setupUpdate(testName);
account.setStatus(Status.INACTIVE);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ res1.releaseConnection();
}
// Store the ID returned from this create operation for additional tests
// below.
knownResourceId = extractId(res);
+ res.releaseConnection();
+
}
@Test(dataProvider = "testName", dependsOnMethods = {"createInactiveAccount"})
Assert.assertEquals(res.getStatus(),
Response.Status.FORBIDDEN.getStatusCode(), "expected "
+ Response.Status.FORBIDDEN.getStatusCode());
+ res.releaseConnection();
}
/**
logger.debug(testName + ": status = " + res.getStatus());
}
Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "expected " + Response.Status.UNAUTHORIZED.getStatusCode());
+ res.releaseConnection();
}
/**
logger.debug(testName + ": status = " + res.getStatus());
}
Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "expected " + Response.Status.UNAUTHORIZED.getStatusCode());
+ res.releaseConnection();
}
/**
logger.debug(testName + ": status = " + res.getStatus());
}
Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "expected " + Response.Status.UNAUTHORIZED.getStatusCode());
+ res.releaseConnection();
}
/**
+ res.getStatus());
}
Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "expected " + Response.Status.UNAUTHORIZED.getStatusCode());
+ res.releaseConnection();
}
/**
+ res.getStatus());
}
Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "expected " + Response.Status.UNAUTHORIZED.getStatusCode());
+ res.releaseConnection();
}
/* (non-Javadoc)
}
Assert.assertEquals(res.getStatus(),
Response.Status.OK.getStatusCode(), "expected " + Response.Status.OK.getStatusCode());
+ res.releaseConnection();
}
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
}
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ res.releaseConnection();
}
// ---------------------------------------------------------------
collectionObject.setObjectNumber(objectNumber);
collectionObject.setObjectName(objectName);
- MultipartOutput multipart = new MultipartOutput();
- OutputPart commonPart = multipart.addPart(collectionObject,
- MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", commonPartName);
+ MultipartOutput multipart =
+ CollectionObjectFactory.createCollectionObjectInstance(
+ commonPartName, collectionObject, null, null);
if (logger.isDebugEnabled()) {
logger.debug("to be created, collectionobject common ",
log4j.logger.org.collectionspace=DEBUG\r
log4j.logger.org.apache=INFO\r
log4j.logger.httpclient=INFO\r
-log4j.logger.org.jboss.resteasy=WARN\r
+log4j.logger.org.jboss.resteasy=INFO\r