jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r901449 [2/2] - in /jackrabbit/sandbox/jackrabbit-spi2cmis: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/jackrabbit/ src/main/java/org/apache/jackrabbit/spi2cmis/ src/main/resources/...
Date Thu, 21 Jan 2010 00:03:48 GMT
Added: jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/ReadTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/ReadTest.java?rev=901449&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/ReadTest.java
(added)
+++ jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/ReadTest.java
Thu Jan 21 00:03:47 2010
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.jackrabbit.spi2cmis;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeIterator;
+import javax.jcr.nodetype.NodeTypeManager;
+
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl;
+import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.nodetype.compact.CompactNodeTypeDefWriter;
+import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
+
+public class ReadTest extends AbstractTestCase {
+
+    public void testLogin() throws RepositoryException {
+        Session session = repository.login();
+        session.logout();
+    }
+
+    public void testGetDescriptors() throws RepositoryException {
+        for (String key : repository.getDescriptorKeys()) {
+            Value value = repository.getDescriptorValue(key);
+            System.out.println(key + "=" + (value == null? "" : value.getString()));
+        }
+    }
+
+    public void testGetRoot() throws RepositoryException {
+        Session session = repository.login();
+        try {
+            Node root = session.getRootNode();
+            assertEquals("/", root.getPath());
+        }
+        finally {
+            session.logout();
+        }
+    }
+
+    public void testNodeTypes() throws RepositoryException, IOException {
+        Session session = repository.login();
+        try {
+            NodeTypeManager ntm = session.getWorkspace().getNodeTypeManager();
+            NodeTypeIterator nts = ntm.getAllNodeTypes();
+
+            Writer writer = new StringWriter();
+            List<QNodeTypeDefinition> ntds = new ArrayList<QNodeTypeDefinition>();
+            while (nts.hasNext()) {
+                NodeType nt = nts.nextNodeType();
+                NamePathResolver resolver = new DefaultNamePathResolver(session.getWorkspace().getNamespaceRegistry());
+                QNodeTypeDefinitionImpl ntd = new QNodeTypeDefinitionImpl(nt, resolver, QValueFactoryImpl.getInstance());
+                ntds.add(ntd);
+            }
+            CompactNodeTypeDefWriter cndWriter = new CompactNodeTypeDefWriter(writer, session,
true);
+            cndWriter.write(ntds);
+            cndWriter.close();
+            System.out.println(writer);
+        }
+        finally {
+            session.logout();
+        }
+    }
+
+    public void testGetNode() throws RepositoryException {
+        String paths[] = {
+//                "/Sites/Franki/gsrodes/DSC00517.JPG",
+//                "/default-domain/workspaces/demo-workspace",
+                "/folder 1/folder 2",
+        };
+
+        Session session = repository.login();
+        try {
+            for (String path : paths) {
+                Node node = session.getNode(path);
+                assertEquals(path, node.getPath());
+                dumpNode(node, false);
+            }
+        }
+        finally {
+            session.logout();
+        }
+    }
+
+    public void testGetProperty() throws RepositoryException {
+        String paths[] = {
+//                "/Sites/Franki/gsrodes/DSC00517.JPG/cmis:name",
+//                "/default-domain/workspaces/demo-workspace/dc:title",
+                "/folder 1/folder 2/title",
+        };
+
+        Session session = repository.login();
+        try {
+            for (String path : paths) {
+                Property property = session.getProperty(path);
+                assertEquals(path, property.getPath());
+                dumpProperty(property);
+            }
+        }
+        finally {
+            session.logout();
+        }
+    }
+
+    public void testTraverse() throws RepositoryException {
+        String paths[] = { "/" };
+
+        Session session = repository.login();
+        try {
+            for (String path : paths) {
+                Node node = session.getNode(path);
+                dumpNode(node, true);
+            }
+        }
+        finally {
+            session.logout();
+        }
+    }
+
+    // -----------------------------------------------------< private >---
+
+    private static void dumpNode(Node node, boolean recursive) throws RepositoryException
{
+        NodeType nt = node.getPrimaryNodeType();
+        System.out.println(node.getPath() + ": " + nt.getName());
+
+        dumpProperties(node);
+
+        NodeIterator nodes = node.getNodes();
+        while (recursive && nodes.hasNext()) {
+            dumpNode(nodes.nextNode(), recursive);
+        }
+    }
+
+    private static void dumpProperties(Node node) throws RepositoryException {
+        PropertyIterator props = node.getProperties();
+        while(props.hasNext()) {
+            dumpProperty(props.nextProperty());
+        }
+    }
+
+    private static void dumpProperty(Property property) throws RepositoryException {
+        String value;
+        if (property.isMultiple()) {
+            Value[] values = property.getValues();
+            value = "[";
+            for (Value v : values) {
+                value += (v.getString() + ", ");
+            }
+            value += "]";
+        }
+        else {
+            value = property.getString();
+        }
+        System.out.println(property.getPath() + ": " + PropertyType.nameFromValue(property.getType())
+                + " = " + value);
+    }
+
+}

Propchange: jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/ReadTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/Spi2cmisFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/Spi2cmisFactoryTest.java?rev=901449&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/Spi2cmisFactoryTest.java
(added)
+++ jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/Spi2cmisFactoryTest.java
Thu Jan 21 00:03:47 2010
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.jackrabbit.spi2cmis;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.Repository;
+
+import org.apache.jackrabbit.jcr2spi.Jcr2spiRepositoryFactory;
+import org.apache.jackrabbit.spi.RepositoryService;
+
+public class Spi2cmisFactoryTest extends AbstractTestCase {
+
+    public void testCreateRepositoryService() throws Exception {
+        Spi2cmisRepositoryServiceFactory factory = new Spi2cmisRepositoryServiceFactory();
+        Map<?, ?> parameters = Collections.singletonMap(
+                Spi2cmisRepositoryServiceFactory.PARAM_CMIS_REPOSITORY, createSimpleRepository());
+        RepositoryService service = factory.createRepositoryService(parameters);
+        assertNotNull(service);
+    }
+
+    public void testCreateRepository() throws Exception {
+        Map<String, Object> parameters = new HashMap<String, Object>();
+        parameters.put(
+                Jcr2spiRepositoryFactory.PARAM_REPOSITORY_SERVICE_FACTORY,
+                Spi2cmisRepositoryServiceFactory.class.getName());
+        parameters.put(
+                Spi2cmisRepositoryServiceFactory.PARAM_CMIS_REPOSITORY, createSimpleRepository());
+
+        Jcr2spiRepositoryFactory factory = new Jcr2spiRepositoryFactory();
+        Repository jcrRepository = factory.getRepository(parameters);
+        assertNotNull(jcrRepository);
+    }
+
+}

Propchange: jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/Spi2cmisFactoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/resources/log4j.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/resources/log4j.xml?rev=901449&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/resources/log4j.xml (added)
+++ jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/resources/log4j.xml Thu Jan 21 00:03:47
2010
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+    <appender name="sockethub" class="org.apache.log4j.net.SocketHubAppender">
+        <param name="Port" value="4560"/> 
+        <param name="LocationInfo" value="false"/>
+    </appender>
+
+    <appender name="console" class="org.apache.log4j.ConsoleAppender">
+        <layout class="org.apache.log4j.PatternLayout">
+            <param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* %c{1}:
%m (%F, line %L)%n"/>
+        </layout>
+    </appender>
+    
+    <root>
+        <level value="info" />
+        <appender-ref ref="sockethub"/>
+        <appender-ref ref="console"/>
+    </root>
+
+</log4j:configuration>



Mime
View raw message