jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r722807 - in /jackrabbit/sandbox/jcr-cmis/server/atompub/src: main/java/org/apache/jackrabbit/cmis/server/atompub/CMISRepositoryInfo.java test/java/org/apache/jackrabbit/cmis/server/atompub/RepositoryInfo.java
Date Wed, 03 Dec 2008 08:25:41 GMT
Author: dpfister
Date: Wed Dec  3 00:25:41 2008
New Revision: 722807

URL: http://svn.apache.org/viewvc?rev=722807&view=rev
Log:
- Add test case for getRepositoryInfo()

Added:
    jackrabbit/sandbox/jcr-cmis/server/atompub/src/main/java/org/apache/jackrabbit/cmis/server/atompub/CMISRepositoryInfo.java
  (with props)
    jackrabbit/sandbox/jcr-cmis/server/atompub/src/test/java/org/apache/jackrabbit/cmis/server/atompub/RepositoryInfo.java
  (with props)

Added: jackrabbit/sandbox/jcr-cmis/server/atompub/src/main/java/org/apache/jackrabbit/cmis/server/atompub/CMISRepositoryInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcr-cmis/server/atompub/src/main/java/org/apache/jackrabbit/cmis/server/atompub/CMISRepositoryInfo.java?rev=722807&view=auto
==============================================================================
--- jackrabbit/sandbox/jcr-cmis/server/atompub/src/main/java/org/apache/jackrabbit/cmis/server/atompub/CMISRepositoryInfo.java
(added)
+++ jackrabbit/sandbox/jcr-cmis/server/atompub/src/main/java/org/apache/jackrabbit/cmis/server/atompub/CMISRepositoryInfo.java
Wed Dec  3 00:25:41 2008
@@ -0,0 +1,22 @@
+package org.apache.jackrabbit.cmis.server.atompub;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+
+public class CMISRepositoryInfo extends ElementWrapper {
+
+    public static final QName NAME =
+        new QName(CMISExtensionFactory.CMIS_NS, "repositoryInfo");
+    private static final QName REPOSITORY_ID =
+        new QName(CMISExtensionFactory.CMIS_NS, "repositoryId");
+
+    public CMISRepositoryInfo(Element elem) {
+        super(elem);
+    }
+
+    public String getRepositoryId() {
+        return getFirstChild(REPOSITORY_ID).getText();
+    }
+}

Propchange: jackrabbit/sandbox/jcr-cmis/server/atompub/src/main/java/org/apache/jackrabbit/cmis/server/atompub/CMISRepositoryInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/jcr-cmis/server/atompub/src/main/java/org/apache/jackrabbit/cmis/server/atompub/CMISRepositoryInfo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: jackrabbit/sandbox/jcr-cmis/server/atompub/src/test/java/org/apache/jackrabbit/cmis/server/atompub/RepositoryInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jcr-cmis/server/atompub/src/test/java/org/apache/jackrabbit/cmis/server/atompub/RepositoryInfo.java?rev=722807&view=auto
==============================================================================
--- jackrabbit/sandbox/jcr-cmis/server/atompub/src/test/java/org/apache/jackrabbit/cmis/server/atompub/RepositoryInfo.java
(added)
+++ jackrabbit/sandbox/jcr-cmis/server/atompub/src/test/java/org/apache/jackrabbit/cmis/server/atompub/RepositoryInfo.java
Wed Dec  3 00:25:41 2008
@@ -0,0 +1,96 @@
+package org.apache.jackrabbit.cmis.server.atompub;
+
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Service;
+import org.apache.abdera.model.Workspace;
+import org.apache.abdera.protocol.Resolver;
+import org.apache.abdera.protocol.client.AbderaClient;
+import org.apache.abdera.protocol.client.ClientResponse;
+import org.apache.abdera.protocol.server.CollectionInfo;
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.Target;
+import org.apache.abdera.protocol.server.TargetBuilder;
+import org.apache.abdera.protocol.server.WorkspaceInfo;
+import org.apache.abdera.protocol.server.WorkspaceManager;
+import org.apache.abdera.protocol.server.impl.AbstractProvider;
+import org.apache.abdera.protocol.server.impl.DefaultProvider;
+import org.apache.abdera.protocol.server.impl.SimpleWorkspaceInfo;
+import org.apache.abdera.protocol.server.provider.basic.BasicProvider;
+import org.apache.jackrabbit.cmis.server.atompub.CMISRepositoryInfo;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import junit.framework.Assert;
+
+public class RepositoryInfo extends Assert {
+
+    private static JettyServer server;
+    private static Abdera abdera = Abdera.getInstance();
+    private static AbderaClient client = new AbderaClient();
+
+    @BeforeClass
+    public static void setUp() throws Exception {
+        if (server == null) {
+            server = new JettyServer();
+            server.start(MyProvider.class);
+        }
+    }
+
+    @AfterClass
+    public static void tearDown() throws Exception {
+    }
+
+    @Test
+    public void testGetService() throws Exception {
+        ClientResponse resp = client.get("http://localhost:9002/");
+
+        Service root = (Service) resp.getDocument().getRoot();
+        Workspace workspace = root.getWorkspaces().get(0);
+        System.out.println(workspace);
+
+        CMISRepositoryInfo info = workspace.getFirstChild(CMISRepositoryInfo.NAME);
+        System.out.println(info.getRepositoryId());
+        /*
+        InputStream in = getInputStream("Example-Service.xml");
+
+        Service root = (Service) abdera.getParser().parse(in).getRoot();
+        Workspace workspace = root.getWorkspaces().get(0);
+
+        CMISRepositoryInfo info = workspace.getFirstChild(CMISRepositoryInfo.NAME);
+        System.out.println(info.getRepositoryId());
+        */
+    }
+
+    private InputStream getInputStream(String name) {
+        return RepositoryInfo.class.getClassLoader().getResourceAsStream(name);
+    }
+
+}
+
+// does not work because the class must be public
+class MyProvider extends DefaultProvider {
+
+    public MyProvider() {
+        addWorkspace(new SimpleWorkspaceInfo());
+    }
+
+}
+
+class MyWorkspaceInfo extends SimpleWorkspaceInfo {
+
+    public String getTitle(RequestContext requsest) {
+        return "Repository 1";
+    }
+
+    @Override
+    public Workspace asWorkspaceElement(RequestContext request) {
+        Workspace workspace = super.asWorkspaceElement(request);
+        workspace.setAttributeValue("cmis:repositoryRelationship", "Self");
+        return workspace;
+    }
+}

Propchange: jackrabbit/sandbox/jcr-cmis/server/atompub/src/test/java/org/apache/jackrabbit/cmis/server/atompub/RepositoryInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/jcr-cmis/server/atompub/src/test/java/org/apache/jackrabbit/cmis/server/atompub/RepositoryInfo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url



Mime
View raw message