Author: fguillaume
Date: Fri Jun 5 17:10:47 2009
New Revision: 782068
URL: http://svn.apache.org/viewvc?rev=782068&view=rev
Log:
Improved code a bit, added start of test plugging together AtomPub client and
server
Added:
incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/
incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/
incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/
incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/
incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/
incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/
incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java
(with props)
Modified:
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/BaseType.java
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ContentStreamPresence.java
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/JoinCapability.java
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/QueryCapability.java
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RelationshipDirection.java
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ReturnVersion.java
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Unfiling.java
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Updatability.java
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/VersioningState.java
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPConnection.java
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepository.java
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPType.java
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/AbstractObjectReader.java
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/ServiceDocumentReader.java
incubator/chemistry/trunk/chemistry/chemistry-tests/pom.xml
Modified:
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/BaseType.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/BaseType.java?rev=782068&r1=782067&r2=782068&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/BaseType.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/BaseType.java
Fri Jun 5 17:10:47 2009
@@ -16,6 +16,9 @@
*/
package org.apache.chemistry;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* The CMIS base types.
*/
@@ -51,6 +54,21 @@
this.value = value;
}
+ private static final Map<String, BaseType> all = new HashMap<String,
BaseType>();
+ static {
+ for (BaseType o : values()) {
+ all.put(o.value, o);
+ }
+ }
+
+ public static BaseType get(String value) {
+ BaseType o = all.get(value);
+ if (o == null) {
+ throw new IllegalArgumentException(value);
+ }
+ return o;
+ }
+
@Override
public String toString() {
return value;
Modified:
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ContentStreamPresence.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ContentStreamPresence.java?rev=782068&r1=782067&r2=782068&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ContentStreamPresence.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ContentStreamPresence.java
Fri Jun 5 17:10:47 2009
@@ -16,6 +16,9 @@
*/
package org.apache.chemistry;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* The presence status for a content stream.
*/
@@ -42,6 +45,21 @@
this.value = value;
}
+ private static final Map<String, ContentStreamPresence> all = new
HashMap<String, ContentStreamPresence>();
+ static {
+ for (ContentStreamPresence o : values()) {
+ all.put(o.value, o);
+ }
+ }
+
+ public static ContentStreamPresence get(String value) {
+ ContentStreamPresence o = all.get(value);
+ if (o == null) {
+ throw new IllegalArgumentException(value);
+ }
+ return o;
+ }
+
@Override
public String toString() {
return value;
Modified:
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/JoinCapability.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/JoinCapability.java?rev=782068&r1=782067&r2=782068&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/JoinCapability.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/JoinCapability.java
Fri Jun 5 17:10:47 2009
@@ -16,6 +16,9 @@
*/
package org.apache.chemistry;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* Support for inner and outer join in query.
*/
@@ -42,6 +45,21 @@
this.value = value;
}
+ private static final Map<String, JoinCapability> all = new HashMap<String,
JoinCapability>();
+ static {
+ for (JoinCapability o : values()) {
+ all.put(o.value, o);
+ }
+ }
+
+ public static JoinCapability get(String value) {
+ JoinCapability o = all.get(value);
+ if (o == null) {
+ throw new IllegalArgumentException(value);
+ }
+ return o;
+ }
+
@Override
public String toString() {
return value;
Modified:
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/QueryCapability.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/QueryCapability.java?rev=782068&r1=782067&r2=782068&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/QueryCapability.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/QueryCapability.java
Fri Jun 5 17:10:47 2009
@@ -16,6 +16,9 @@
*/
package org.apache.chemistry;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* Support for query on full-text or metadata.
*/
@@ -52,6 +55,21 @@
this.value = value;
}
+ private static final Map<String, QueryCapability> all = new
HashMap<String, QueryCapability>();
+ static {
+ for (QueryCapability o : values()) {
+ all.put(o.value, o);
+ }
+ }
+
+ public static QueryCapability get(String value) {
+ QueryCapability o = all.get(value);
+ if (o == null) {
+ throw new IllegalArgumentException(value);
+ }
+ return o;
+ }
+
@Override
public String toString() {
return value;
Modified:
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RelationshipDirection.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RelationshipDirection.java?rev=782068&r1=782067&r2=782068&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RelationshipDirection.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RelationshipDirection.java
Fri Jun 5 17:10:47 2009
@@ -16,6 +16,9 @@
*/
package org.apache.chemistry;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* The choice of which relationships having a given document as source or
target
* are to be included in a list of objects.
@@ -44,6 +47,21 @@
this.value = value;
}
+ private static final Map<String, RelationshipDirection> all = new
HashMap<String, RelationshipDirection>();
+ static {
+ for (RelationshipDirection o : values()) {
+ all.put(o.value, o);
+ }
+ }
+
+ public static RelationshipDirection get(String value) {
+ RelationshipDirection o = all.get(value);
+ if (o == null) {
+ throw new IllegalArgumentException(value);
+ }
+ return o;
+ }
+
@Override
public String toString() {
return value;
Modified:
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ReturnVersion.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ReturnVersion.java?rev=782068&r1=782067&r2=782068&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ReturnVersion.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ReturnVersion.java
Fri Jun 5 17:10:47 2009
@@ -16,6 +16,9 @@
*/
package org.apache.chemistry;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* Flag specifying what version of a given document is to be returned.
*/
@@ -42,6 +45,21 @@
this.value = value;
}
+ private static final Map<String, ReturnVersion> all = new HashMap<String,
ReturnVersion>();
+ static {
+ for (ReturnVersion o : values()) {
+ all.put(o.value, o);
+ }
+ }
+
+ public static ReturnVersion get(String value) {
+ ReturnVersion o = all.get(value);
+ if (o == null) {
+ throw new IllegalArgumentException(value);
+ }
+ return o;
+ }
+
@Override
public String toString() {
return value;
Modified:
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Unfiling.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Unfiling.java?rev=782068&r1=782067&r2=782068&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Unfiling.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Unfiling.java
Fri Jun 5 17:10:47 2009
@@ -16,6 +16,9 @@
*/
package org.apache.chemistry;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* Flag specifying how to unfile non-folder objects when a tree of objects is
* deleted through {...@link Connection#deleteTree}.
@@ -46,6 +49,21 @@
this.value = value;
}
+ private static final Map<String, Unfiling> all = new HashMap<String,
Unfiling>();
+ static {
+ for (Unfiling o : values()) {
+ all.put(o.value, o);
+ }
+ }
+
+ public static Unfiling get(String value) {
+ Unfiling o = all.get(value);
+ if (o == null) {
+ throw new IllegalArgumentException(value);
+ }
+ return o;
+ }
+
@Override
public String toString() {
return value;
Modified:
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Updatability.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Updatability.java?rev=782068&r1=782067&r2=782068&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Updatability.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Updatability.java
Fri Jun 5 17:10:47 2009
@@ -16,6 +16,9 @@
*/
package org.apache.chemistry;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* The Updatability of a property.
*/
@@ -61,6 +64,21 @@
this.value = value;
}
+ private static final Map<String, Updatability> all = new HashMap<String,
Updatability>();
+ static {
+ for (Updatability o : values()) {
+ all.put(o.value, o);
+ }
+ }
+
+ public static Updatability get(String value) {
+ Updatability o = all.get(value);
+ if (o == null) {
+ throw new IllegalArgumentException(value);
+ }
+ return o;
+ }
+
@Override
public String toString() {
return value;
Modified:
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/VersioningState.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/VersioningState.java?rev=782068&r1=782067&r2=782068&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/VersioningState.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/VersioningState.java
Fri Jun 5 17:10:47 2009
@@ -16,6 +16,9 @@
*/
package org.apache.chemistry;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* State of a document when it is created.
*/
@@ -42,6 +45,21 @@
this.value = value;
}
+ private static final Map<String, VersioningState> all = new
HashMap<String, VersioningState>();
+ static {
+ for (VersioningState o : values()) {
+ all.put(o.value, o);
+ }
+ }
+
+ public static VersioningState get(String value) {
+ VersioningState o = all.get(value);
+ if (o == null) {
+ throw new IllegalArgumentException(value);
+ }
+ return o;
+ }
+
@Override
public String toString() {
return value;
Modified:
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPConnection.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPConnection.java?rev=782068&r1=782067&r2=782068&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPConnection.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPConnection.java
Fri Jun 5 17:10:47 2009
@@ -25,6 +25,8 @@
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.apache.chemistry.BaseType;
import org.apache.chemistry.CMISObject;
@@ -218,15 +220,13 @@
if (returnVersion == null) {
returnVersion = ReturnVersion.THIS;
}
- String href = repository.getCollectionHref("root-children");
- int p = href.lastIndexOf("/");
- if (p == href.length() - 1) {
- p = href.lastIndexOf("/", href.length() - 1);
+ // TODO hardcoded URL pattern here...
+ String href = repository.getCollectionHref(CMIS.COL_ROOT_CHILDREN);
+ if (!href.matches(".*/children/[0-9a-f-]{36}")) {
+ throw new AssertionError(href);
}
- if (p > -1) {
- href = href.substring(0, p + 1);
- }
- href += "objects/" + objectId;
+ href = href.substring(0, href.length() - "/children/".length() - 36);
+ href += "/object/" + objectId;
Request req = new Request(href);
Response resp = connector.get(req);
if (!resp.isOk()) {
Modified:
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepository.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepository.java?rev=782068&r1=782067&r2=782068&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepository.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepository.java
Fri Jun 5 17:10:47 2009
@@ -150,9 +150,8 @@
throw new IllegalArgumentException(
"Invalid CMIS repository. No types children
collection defined");
}
- Request req = new Request(href);
// TODO lazy load property definition
- req.setHeader("CMIS-includePropertyDefinitions", "true");
+ Request req = new Request(href +
"?includePropertyDefinitions=true");
Response resp = cm.getConnector().get(req);
if (!resp.isOk()) {
throw new ContentManagerException(
Modified:
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPType.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPType.java?rev=782068&r1=782067&r2=782068&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPType.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPType.java
Fri Jun 5 17:10:47 2009
@@ -20,7 +20,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import org.apache.chemistry.BaseType;
@@ -64,7 +63,7 @@
public BaseType getBaseType() {
if (baseType == null) {
- baseType =
BaseType.valueOf(map.get(CMIS.BASE_TYPE.getLocalPart()));
+ baseType = BaseType.get(map.get(CMIS.BASE_TYPE.getLocalPart()));
}
return baseType;
}
@@ -86,9 +85,14 @@
return getTypeId();
}
+ @Override
+ public String getTypeId() {
+ return map.get(CMIS.TYPE_ID.getLocalPart());
+ }
+
public String getParentId() {
if (parentId == null) {
- parentId = map.get(CMIS.TYPE_ID.getLocalPart());
+ parentId = map.get(CMIS.PARENT_ID.getLocalPart());
}
return parentId;
}
@@ -104,27 +108,27 @@
}
public String getQueryName() {
- return map.get(CMIS.QUERY_NAME);
+ return map.get(CMIS.QUERY_NAME.getLocalPart());
}
public boolean isControllable() {
- return "true".equals(map.get(CMIS.CONTROLLABLE));
+ return "true".equals(map.get(CMIS.CONTROLLABLE.getLocalPart()));
}
public boolean isCreatable() {
- return "true".equals(map.get(CMIS.CREATABLE));
+ return "true".equals(map.get(CMIS.CREATABLE.getLocalPart()));
}
public boolean isFileable() {
- return "true".equals(map.get(CMIS.FILEABLE));
+ return "true".equals(map.get(CMIS.FILEABLE.getLocalPart()));
}
public boolean isQueryable() {
- return "true".equals(map.get(CMIS.QUERYABLE));
+ return "true".equals(map.get(CMIS.QUERYABLE.getLocalPart()));
}
public boolean isVersionable() {
- return "true".equals(map.get(CMIS.VERSIONABLE));
+ return "true".equals(map.get(CMIS.VERSIONABLE.getLocalPart()));
}
public boolean isIncludedInSuperTypeQuery() {
@@ -153,6 +157,6 @@
@Override
public String toString() {
- return getId();
+ return this.getClass().getSimpleName() + '(' + getId() + ')';
}
}
Modified:
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/AbstractObjectReader.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/AbstractObjectReader.java?rev=782068&r1=782067&r2=782068&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/AbstractObjectReader.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/AbstractObjectReader.java
Fri Jun 5 17:10:47 2009
@@ -76,12 +76,11 @@
prefetch = new ArrayList<XmlProperty>();
while (it.hasNext()) {
XmlProperty p = it.next();
- // System.out.println(" prefetch >>>>> "+reader.getName()+" ->
"+p.value);
if (Property.TYPE_ID.equals(p.value)) {
- entryType = ctx.getRepository().getType(
- (String) p.getXmlValue());
+ String v = (String) p.getXmlValue();
+ entryType = ctx.getRepository().getType(v);
if (entryType == null) {
- throw new ParseException("No such type: " + p.value);
+ throw new ParseException("No such type: " + v);
}
prefetch.add(p);
break;
Modified:
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/ServiceDocumentReader.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/ServiceDocumentReader.java?rev=782068&r1=782067&r2=782068&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/ServiceDocumentReader.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/common/atom/ServiceDocumentReader.java
Fri Jun 5 17:10:47 2009
@@ -107,9 +107,9 @@
} else if
(localName.equals(CMIS.CAPABILITY_VERSION_SPECIFIC_FILING.getLocalPart())) {
caps.setHasVersionSpecificFiling(Boolean.parseBoolean(reader.getElementText()));
} else if
(localName.equals(CMIS.CAPABILITY_QUERY.getLocalPart())) {
-
caps.setQueryCapability(QueryCapability.valueOf(reader.getElementText()));
+
caps.setQueryCapability(QueryCapability.get(reader.getElementText()));
} else if
(localName.equals(CMIS.CAPABILITY_JOIN.getLocalPart())) {
-
caps.setJoinCapability(JoinCapability.valueOf(reader.getElementText()));
+
caps.setJoinCapability(JoinCapability.get(reader.getElementText()));
}
}
} else if (localName.equals("repositorySpecificInformation")) {
@@ -144,9 +144,9 @@
} else if
(localName.equals(CMIS.CAPABILITY_VERSION_SPECIFIC_FILING.getLocalPart())) {
caps.setHasVersionSpecificFiling(Boolean.parseBoolean(el2.getText()));
} else if
(localName.equals(CMIS.CAPABILITY_QUERY.getLocalPart())) {
-
caps.setQueryCapability(QueryCapability.valueOf(el2.getText()));
+
caps.setQueryCapability(QueryCapability.get(el2.getText()));
} else if
(localName.equals(CMIS.CAPABILITY_JOIN.getLocalPart())) {
-
caps.setJoinCapability(JoinCapability.valueOf(el2.getText()));
+
caps.setJoinCapability(JoinCapability.get(el2.getText()));
}
}
} else if (localName.equals("repositorySpecificInformation")) {
Modified: incubator/chemistry/trunk/chemistry/chemistry-tests/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tests/pom.xml?rev=782068&r1=782067&r2=782068&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tests/pom.xml (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tests/pom.xml Fri Jun 5
17:10:47 2009
@@ -37,6 +37,10 @@
</dependency>
<dependency>
<groupId>org.apache.chemistry</groupId>
+ <artifactId>chemistry-atompub-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.chemistry</groupId>
<artifactId>chemistry-commons</artifactId>
</dependency>
Added:
incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java?rev=782068&view=auto
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java
(added)
+++
incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java
Fri Jun 5 17:10:47 2009
@@ -0,0 +1,103 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ * Authors:
+ * Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.test;
+
+import java.util.List;
+
+import javax.servlet.Servlet;
+
+import junit.framework.TestCase;
+
+import org.apache.chemistry.CMISObject;
+import org.apache.chemistry.Connection;
+import org.apache.chemistry.Folder;
+import org.apache.chemistry.Repository;
+import org.apache.chemistry.atompub.client.ContentManager;
+import org.apache.chemistry.atompub.client.app.APPContentManager;
+import org.apache.chemistry.atompub.client.app.model.APPRepository;
+import org.apache.chemistry.atompub.server.CMISServlet;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.bio.SocketConnector;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+/**
+ * Tests the AtomPub client with the AtomPub server.
+ */
+public class TestAtomPubClientServer extends TestCase {
+
+ private static final Log log = LogFactory.getLog(MainServlet.class);
+
+ public static final String HOST = "0.0.0.0";
+
+ public static final int PORT = 8080;
+
+ public static final String SERVLET_PATH = "/cmis";
+
+ public static final String CMIS_SERVICE = "/repository";
+
+ public Server server;
+
+ public String serverUrl;
+
+ public void startServer() throws Exception {
+ Repository repository = RepositoryCreationHelper.makeRepository(null);
+ server = new Server();
+ Connector connector = new SocketConnector();
+ connector.setHost(HOST);
+ connector.setPort(PORT);
+ server.setConnectors(new Connector[] { connector });
+ Servlet servlet = new CMISServlet(repository);
+ ServletHolder servletHolder = new ServletHolder(servlet);
+ Context context = new Context(server, SERVLET_PATH, Context.SESSIONS);
+ context.addServlet(servletHolder, "/*");
+ server.start();
+ serverUrl = "http://" + HOST + ':' + PORT + SERVLET_PATH +
CMIS_SERVICE;
+ log.info("CMIS server started, AtomPub service url: " + serverUrl);
+ }
+
+ public void stopServer() throws Exception {
+ // Thread.sleep(60 * MINUTES);
+ server.stop();
+ log.info("CMIS server stopped");
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ startServer();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ stopServer();
+ }
+
+ public void testBasic() {
+ ContentManager cm = new APPContentManager(serverUrl);
+
+ Repository repo = cm.getDefaultRepository();
+ Connection conn = ((APPRepository) repo).getConnection(null);
+
+ Folder root = conn.getRootFolder();
+ List<CMISObject> entries = root.getChildren(null);
+ assertEquals(1, entries.size());
+ }
+
+}
Propchange:
incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java
------------------------------------------------------------------------------
svn:keywords = Id