--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>\r
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>\r
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>\r
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+ <classpathentry kind="output" path="target/classes"/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.collectionspace.services.PerformanceTests</name>\r
+ <comment></comment>\r
+ <projects>\r
+ <project>org.collectionspace.services.client</project>\r
+ <project>org.collectionspace.services.collectionobject.client</project>\r
+ <project>org.collectionspace.services.collectionobject.jaxb</project>\r
+ <project>org.collectionspace.services.common</project>\r
+ <project>org.collectionspace.services.intake.client</project>\r
+ <project>org.collectionspace.services.intake.jaxb</project>\r
+ <project>org.collectionspace.services.relation.client</project>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.maven.ide.eclipse.maven2Builder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+#Wed Jan 20 14:09:34 PST 2010\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.source=1.6\r
--- /dev/null
+#Fri Sep 11 17:00:31 PDT 2009\r
+activeProfiles=\r
+eclipse.preferences.version=1\r
+fullBuildGoals=process-test-resources\r
+includeModules=false\r
+resolveWorkspaceProjects=true\r
+resourceFilterGoals=process-resources resources\:testResources\r
+skipCompilerPlugin=true\r
+version=1\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
+ <parent>\r
+ <artifactId>org.collectionspace.services.main</artifactId>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <version>1.0</version>\r
+ </parent>\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.PerformanceTests</artifactId>\r
+ <packaging>jar</packaging>\r
+ <version>1.0</version>\r
+ <name>services.PerformanceTests</name>\r
+\r
+ <dependencies>\r
+ <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
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.client</artifactId>\r
+ <version>1.0</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.testng</groupId>\r
+ <artifactId>testng</artifactId>\r
+ <version>5.6</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-jaxrs</artifactId>\r
+ <version>1.0.2.GA</version>\r
+ <!-- filter out unwanted jars -->\r
+ <exclusions>\r
+ <exclusion>\r
+ <groupId>tjws</groupId>\r
+ <artifactId>webserver</artifactId>\r
+ </exclusion>\r
+ </exclusions>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-jaxb-provider</artifactId>\r
+ <version>1.0.2.GA</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-multipart-provider</artifactId>\r
+ <version>1.0.2.GA</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>commons-httpclient</groupId>\r
+ <artifactId>commons-httpclient</artifactId>\r
+ <version>3.1</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.common</artifactId>\r
+ <version>1.0</version>\r
+ </dependency> \r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.collectionobject.jaxb</artifactId>\r
+ <version>1.0</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.collectionobject.client</artifactId>\r
+ <version>1.0</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.intake.jaxb</artifactId>\r
+ <version>1.0</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.intake.client</artifactId>\r
+ <version>1.0</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.relation.client</artifactId>\r
+ <version>1.0</version>\r
+ </dependency>\r
+ </dependencies>\r
+ \r
+ <build>\r
+ <finalName>collectionspace-services-PerformanceTests</finalName>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-surefire-plugin</artifactId>\r
+ <configuration>\r
+ <systemProperties>\r
+ <property>\r
+ <name>log4j.configuration</name>\r
+ <value>file:target/test-classes/log4j.properties</value>\r
+ </property>\r
+ </systemProperties>\r
+ </configuration>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-compiler-plugin</artifactId>\r
+ <configuration>\r
+ <source>1.6</source>\r
+ <target>1.6</target>\r
+ </configuration>\r
+ </plugin>\r
+ </plugins>\r
+ </build>\r
+</project>\r
+\r
--- /dev/null
+/** \r
+ * CollectionSpacePerformanceTest.java\r
+ *\r
+ * {Purpose of This Class}\r
+ *\r
+ * {Other Notes Relating to This Class (Optional)}\r
+ *\r
+ * $LastChangedBy: $\r
+ * $LastChangedRevision: $\r
+ * $LastChangedDate: $\r
+ *\r
+ * This document is a part of the source code and related artifacts\r
+ * for CollectionSpace, an open source collections management system\r
+ * for museums and related institutions:\r
+ *\r
+ * http://www.collectionspace.org\r
+ * http://wiki.collectionspace.org\r
+ *\r
+ * Copyright © 2009 {Contributing Institution}\r
+ *\r
+ * Licensed under the Educational Community License (ECL), Version 2.0.\r
+ * You may not use this file except in compliance with this License.\r
+ *\r
+ * You may obtain a copy of the ECL 2.0 License at\r
+ * https://source.collectionspace.org/collection-space/LICENSE.txt\r
+ */\r
+package org.collectionspace.services.PerformanceTests.test;\r
+\r
+import java.util.ArrayList;\r
+\r
+import javax.ws.rs.core.MultivaluedMap;\r
+import javax.ws.rs.core.Response;\r
+import javax.xml.bind.JAXBContext;\r
+import javax.xml.bind.Marshaller;\r
+\r
+import org.collectionspace.services.collectionobject.CollectionobjectsCommon;\r
+import org.collectionspace.services.intake.IntakesCommon;\r
+import org.collectionspace.services.relation.RelationsCommon;\r
+import org.collectionspace.services.relation.RelationshipType;\r
+import org.jboss.resteasy.client.ClientResponse;\r
+import org.jboss.resteasy.plugins.providers.multipart.InputPart;\r
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;\r
+\r
+/**\r
+ * The Class CollectionSpacePerformanceTests.\r
+ */\r
+public abstract class CollectionSpacePerformanceTest {\r
+\r
+ /*\r
+ * Package scoped methods.\r
+ */\r
+\r
+ /**\r
+ * Fill collection object.\r
+ * \r
+ * @param co the co\r
+ * @param identifier the identifier\r
+ */\r
+ void fillCollectionObject(CollectionobjectsCommon co, String identifier) {\r
+ fillCollectionObject(co, "objectNumber-" + identifier, "objectName-"\r
+ + identifier);\r
+ }\r
+\r
+ /**\r
+ * Fill collection object.\r
+ * \r
+ * @param co the co\r
+ * @param objectNumber the object number\r
+ * @param objectName the object name\r
+ */\r
+ void fillCollectionObject(CollectionobjectsCommon co, String objectNumber,\r
+ String objectName) {\r
+ co.setObjectNumber(objectNumber);\r
+ co.setObjectName(objectName);\r
+ }\r
+\r
+ /**\r
+ * Fill intake.\r
+ * \r
+ * @param theIntake the the intake\r
+ * @param identifier the identifier\r
+ */\r
+ void fillIntake(IntakesCommon theIntake, String identifier) {\r
+ fillIntake(theIntake, "entryNumber-" + identifier, "entryDate-"\r
+ + identifier);\r
+ }\r
+\r
+ /**\r
+ * Fill intake.\r
+ * \r
+ * @param theIntake the the intake\r
+ * @param entryNumber the entry number\r
+ * @param entryDate the entry date\r
+ */\r
+ void fillIntake(IntakesCommon theIntake, String entryNumber, String entryDate) {\r
+ theIntake.setEntryNumber(entryNumber);\r
+ theIntake.setEntryDate(entryDate);\r
+ }\r
+\r
+ /**\r
+ * Fill relation.\r
+ * \r
+ * @param relation the relation\r
+ * @param documentId1 the document id1\r
+ * @param documentType1 the document type1\r
+ * @param documentId2 the document id2\r
+ * @param documentType2 the document type2\r
+ * @param rt the rt\r
+ */\r
+ void fillRelation(RelationsCommon relation, String documentId1, String documentType1,\r
+ String documentId2, String documentType2, RelationshipType rt)\r
+ {\r
+ relation.setDocumentId1(documentId1);\r
+ relation.setDocumentType1(documentType1);\r
+ relation.setDocumentId2(documentId2);\r
+ relation.setDocumentType2(documentType2);\r
+ \r
+ relation.setRelationshipType(rt);\r
+ }\r
+ \r
+ /**\r
+ * Creates the identifier.\r
+ * \r
+ * @return the string\r
+ */\r
+ String createIdentifier() {\r
+ long identifier = System.currentTimeMillis();\r
+ return Long.toString(identifier);\r
+ }\r
+\r
+ /**\r
+ * Extract id.\r
+ * \r
+ * @param res the res\r
+ * \r
+ * @return the string\r
+ */\r
+ String extractId(ClientResponse<Response> res) {\r
+ String result = null;\r
+ \r
+ MultivaluedMap mvm = res.getMetadata();\r
+ String uri = (String) ((ArrayList) mvm.get("Location")).get(0);\r
+ verbose("extractId:uri=" + uri);\r
+ String[] segments = uri.split("/");\r
+ result = segments[segments.length - 1];\r
+ verbose("id=" + result);\r
+ \r
+ return result;\r
+ }\r
+\r
+ /**\r
+ * Extract part.\r
+ * \r
+ * @param input\r
+ * the input\r
+ * @param label\r
+ * the label\r
+ * @param clazz\r
+ * the clazz\r
+ * \r
+ * @return the object\r
+ * \r
+ * @throws Exception\r
+ * the exception\r
+ */\r
+ static Object extractPart(MultipartInput input, String label, Class clazz) {\r
+ Object obj = null;\r
+ \r
+ try {\r
+ for (InputPart part : input.getParts()) {\r
+ String partLabel = part.getHeaders().getFirst("label");\r
+ if (label.equalsIgnoreCase(partLabel)) {\r
+ String partStr = part.getBodyAsString();\r
+ obj = part.getBody(clazz, null);\r
+ break;\r
+ }\r
+ }\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ return obj;\r
+ }\r
+ \r
+ /**\r
+ * Verbose.\r
+ * \r
+ * @param msg the msg\r
+ */\r
+ void verbose(String msg) {\r
+// System.out.println(msg);\r
+ }\r
+\r
+ /**\r
+ * Verbose.\r
+ * \r
+ * @param msg the msg\r
+ * @param o the o\r
+ * @param clazz the clazz\r
+ */\r
+ void verbose(String msg, Object o, Class clazz) {\r
+ try {\r
+ verbose(msg);\r
+ JAXBContext jc = JAXBContext.newInstance(clazz);\r
+ Marshaller m = jc.createMarshaller();\r
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);\r
+ m.marshal(o, System.out);\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Verbose map.\r
+ * \r
+ * @param map the map\r
+ */\r
+ void verboseMap(MultivaluedMap map) {\r
+ for (Object entry : map.entrySet()) {\r
+ MultivaluedMap.Entry mentry = (MultivaluedMap.Entry) entry;\r
+ verbose(" name=" + mentry.getKey() + " value=" + mentry.getValue());\r
+ }\r
+ }\r
+\r
+}\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 (c) 2009 Regents of the University of California
+ *
+ * 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.PerformanceTests.test;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Date;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.HeadMethod;
+import org.apache.commons.httpclient.methods.OptionsMethod;
+import org.apache.commons.httpclient.methods.TraceMethod;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
+
+import org.collectionspace.services.client.TestServiceClient;
+
+import org.collectionspace.services.CollectionObjectJAXBSchema;
+import org.collectionspace.services.client.CollectionObjectClient;
+import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
+import org.collectionspace.services.collectionobject.CollectionobjectsCommonList;
+
+import org.collectionspace.services.IntakeJAXBSchema;
+import org.collectionspace.services.client.IntakeClient;
+import org.collectionspace.services.intake.IntakesCommon;
+import org.collectionspace.services.intake.IntakesCommonList;
+
+import org.collectionspace.services.common.relation.RelationJAXBSchema;
+import org.collectionspace.services.client.RelationClient;
+import org.collectionspace.services.relation.RelationsCommon;
+import org.collectionspace.services.relation.RelationsCommonList;
+import org.collectionspace.services.relation.RelationshipType;
+
+/**
+ * A ServiceTest.
+ *
+ * @version $Revision:$
+ */
+public class PerformanceTest extends CollectionSpacePerformanceTest {
+
+ final Logger logger = LoggerFactory
+ .getLogger(PerformanceTest.class);
+ //
+ // Get clients for the CollectionSpace services
+ //
+ private RelationClient relationClient = new RelationClient();
+ private IntakeClient intakeClient = new IntakeClient();
+ private static int MAX_RECORDS = 100;
+
+ private String createCollectionObject(CollectionObjectClient collectionObjectClient) {
+ String result = null;
+ //
+ // First create a CollectionObject
+ //
+ CollectionobjectsCommon co = new CollectionobjectsCommon();
+ fillCollectionObject(co, createIdentifier());
+
+ // Next, create a part object
+ MultipartOutput multipart = new MultipartOutput();
+ OutputPart commonPart = multipart.addPart(co, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", collectionObjectClient.getCommonPartName());
+ // Make the create call and check the response
+ ClientResponse<Response> response = collectionObjectClient.create(multipart);
+ Assert.assertEquals(response.getStatus(), Response.Status.CREATED
+ .getStatusCode());
+ result = extractId(response);
+
+ return result;
+ }
+
+ @Test
+ public void createCollectionObjects() {
+ CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
+ String[] coList = new String[MAX_RECORDS];
+
+ Date startTime = new Date();
+ for (int i = 0; i < MAX_RECORDS; i++) {
+ coList[i] = createCollectionObject(collectionObjectClient);
+ }
+ Date stopTime = new Date();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Created " + MAX_RECORDS + " CollectionObjects" +
+ " in " + (stopTime.getTime() - startTime.getTime())/1000.0 + " seconds.");
+ }
+
+ startTime = new Date();
+ for (int i = 0; i < MAX_RECORDS; i++) {
+ deleteCollectionObject(collectionObjectClient, coList[i]);
+ }
+ stopTime = new Date();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Deleted " + MAX_RECORDS + " CollectionObjects" +
+ " in " + (stopTime.getTime() - startTime.getTime())/1000.0 + " seconds.");
+ }
+ }
+
+ private void deleteCollectionObject(CollectionObjectClient collectionObjectClient,
+ String resourceId) {
+ ClientResponse<Response> res = collectionObjectClient.delete(resourceId);
+ }
+
+ @Test
+ public void relateCollectionObjectToIntake() {
+
+ //
+ // First create a CollectionObject
+ //
+ CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
+ CollectionobjectsCommon co = new CollectionobjectsCommon();
+ fillCollectionObject(co, createIdentifier());
+
+ // Next, create a part object
+ MultipartOutput multipart = new MultipartOutput();
+ OutputPart commonPart = multipart.addPart(co, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", collectionObjectClient.getCommonPartName());
+ // Make the create call and check the response
+ ClientResponse<Response> response = collectionObjectClient.create(multipart);
+ Assert.assertEquals(response.getStatus(), Response.Status.CREATED
+ .getStatusCode());
+ String collectionObjectCsid = extractId(response);
+
+
+ // Next, create an Intake object
+ IntakesCommon intake = new IntakesCommon();
+ fillIntake(intake, createIdentifier());
+ // Create the a part object
+ multipart = new MultipartOutput();
+ commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", intakeClient.getCommonPartName());
+ // Make the call to create and check the response
+ response = intakeClient.create(multipart);
+ Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
+ String intakeCsid = extractId(response);
+
+ // Lastly, relate the two entities, by creating a new relation object
+ RelationsCommon relation = new RelationsCommon();
+ fillRelation(relation, collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(),
+ intakeCsid, IntakesCommon.class.getSimpleName(),
+ RelationshipType.COLLECTIONOBJECT_INTAKE);
+ // Create the part and fill it with the relation object
+ multipart = new MultipartOutput();
+ commonPart = multipart.addPart(relation, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", relationClient.getCommonPartName());
+ // Make the call to crate
+ response = relationClient.create(multipart);
+ Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
+ String relationCsid = extractId(response);
+ }
+
+ /*
+ * Private Methods
+ */
+
+}
--- /dev/null
+log4j.rootLogger=debug, stdout, R\r
+\r
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender\r
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout\r
+\r
+# Pattern to output the caller's file name and line number.\r
+log4j.appender.stdout.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n\r
+\r
+log4j.appender.R=org.apache.log4j.RollingFileAppender\r
+log4j.appender.R.File=target/test-client.log\r
+\r
+log4j.appender.R.MaxFileSize=100KB\r
+# Keep one backup file\r
+log4j.appender.R.MaxBackupIndex=1\r
+\r
+log4j.appender.R.layout=org.apache.log4j.PatternLayout\r
+log4j.appender.R.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n\r
+\r
+#packages\r
+log4j.logger.org.collectionspace=DEBUG\r
+log4j.logger.org.apache=INFO\r
+log4j.logger.httpclient=INFO\r
+log4j.logger.org.jboss.resteasy=INFO\r