chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r889742 - in /incubator/chemistry/trunk/chemistry: chemistry-jcr/ chemistry-parent/ chemistry-tests/ chemistry-tests/src/main/java/org/apache/chemistry/test/ chemistry-tests/src/test/java/org/apache/chemistry/test/
Date Fri, 11 Dec 2009 18:19:27 GMT
Author: fguillaume
Date: Fri Dec 11 18:19:26 2009
New Revision: 889742

URL: http://svn.apache.org/viewvc?rev=889742&view=rev
Log:
CMIS-73: prepare unit test framework for JcrRepository tests (tests currently disabled)

Added:
    incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestJcrRepository.java
  (with props)
Modified:
    incubator/chemistry/trunk/chemistry/chemistry-jcr/pom.xml
    incubator/chemistry/trunk/chemistry/chemistry-parent/pom.xml
    incubator/chemistry/trunk/chemistry/chemistry-tests/pom.xml
    incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicHelper.java
    incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java
    incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java
    incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java
    incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestSimpleDirect.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/pom.xml?rev=889742&r1=889741&r2=889742&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/pom.xml (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/pom.xml Fri Dec 11 18:19:26 2009
@@ -29,39 +29,32 @@
   <artifactId>chemistry-jcr</artifactId>
   <name>Chemistry JCR Connector</name>
 
+  <properties>
+    <jackrabbit.version>1.6.0</jackrabbit.version>
+  </properties>
+
   <dependencies>
     <dependency>
       <groupId>org.apache.chemistry</groupId>
       <artifactId>chemistry-api</artifactId>
     </dependency>
-
     <dependency>
       <groupId>org.apache.chemistry</groupId>
       <artifactId>chemistry-commons</artifactId>
     </dependency>
-
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
-    </dependency>
-
     <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
     </dependency>
-
     <dependency>
       <groupId>javax.jcr</groupId>
       <artifactId>jcr</artifactId>
       <version>1.0</version>
     </dependency>
-
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-jcr-commons</artifactId>
-      <version>1.4.2</version>
+      <version>${jackrabbit.version}</version>
     </dependency>
-
   </dependencies>
 </project>

Modified: incubator/chemistry/trunk/chemistry/chemistry-parent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-parent/pom.xml?rev=889742&r1=889741&r2=889742&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-parent/pom.xml (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-parent/pom.xml Fri Dec 11 18:19:26 2009
@@ -121,6 +121,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.chemistry</groupId>
+        <artifactId>chemistry-jcr</artifactId>
+        <version>${version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.chemistry</groupId>
         <artifactId>chemistry-commons</artifactId>
         <version>${version}</version>
       </dependency>

Modified: incubator/chemistry/trunk/chemistry/chemistry-tests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tests/pom.xml?rev=889742&r1=889741&r2=889742&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tests/pom.xml (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tests/pom.xml Fri Dec 11 18:19:26 2009
@@ -23,9 +23,14 @@
     <artifactId>chemistry-parent</artifactId>
     <version>1.0-SNAPSHOT</version>
   </parent>
+
   <artifactId>chemistry-tests</artifactId>
   <name>Chemistry Tests</name>
 
+  <properties>
+    <jackrabbit.version>1.6.0</jackrabbit.version>
+  </properties>
+
   <dependencies>
     <dependency>
       <groupId>org.apache.chemistry</groupId>
@@ -83,6 +88,19 @@
       <artifactId>junit</artifactId>
       <scope>compile</scope> <!-- override -->
     </dependency>
+
+    <dependency>
+      <groupId>org.apache.chemistry</groupId>
+      <artifactId>chemistry-jcr</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-core</artifactId>
+      <version>${jackrabbit.version}</version>
+      <scope>test</scope>
+    </dependency>
+
   </dependencies>
 
   <build>
@@ -109,6 +127,15 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <excludes>
+            <!-- excluded until tests pass -->
+            <exclude>**/TestJcrRepository.java</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 

Modified: incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicHelper.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicHelper.java?rev=889742&r1=889741&r2=889742&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicHelper.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicHelper.java
Fri Dec 11 18:19:26 2009
@@ -45,7 +45,8 @@
 
     public static final String TEST_FILE_CONTENT = "This is a test file.\nTesting, testing...\n";
 
-    public static Repository makeRepository(String rootId) throws Exception {
+    public static Repository makeSimpleRepository(String rootId)
+            throws Exception {
         PropertyDefinition p1 = new SimplePropertyDefinition("title",
                 "def:title", null, "title", "Title", "", false,
                 PropertyType.STRING, false, null, false, false, "(no title)",
@@ -70,6 +71,10 @@
                         p1, p2));
         SimpleRepository repo = new SimpleRepository("test", Arrays.asList(dt,
                 ft), rootId);
+        return repo;
+    }
+
+    public static void populateRepository(Repository repo) throws Exception {
         Connection conn = repo.getConnection(null);
         Folder root = conn.getRootFolder();
 
@@ -115,7 +120,6 @@
         doc4.save();
 
         conn.close();
-        return repo;
     }
 
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java?rev=889742&r1=889741&r2=889742&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/BasicTestCase.java
Fri Dec 11 18:19:26 2009
@@ -58,14 +58,13 @@
 import org.apache.commons.io.IOUtils;
 
 /**
- * Basic test on a repository created with {@link BasicHelper#makeRepository}.
+ * Basic test on a repository populated with
+ * {@link BasicHelper#populateRepository}.
  * <p>
  * The {@link #setUp} method must initialize repository, conn and spi.
  */
 public abstract class BasicTestCase extends TestCase {
 
-    public static final String ROOT_TYPE_ID = "chemistry:root"; // not in spec
-
     public static final String ROOT_FOLDER_NAME = ""; // not in spec
 
     public Repository repository;
@@ -74,11 +73,36 @@
 
     public SPI spi;
 
-    public abstract void makeRepository() throws Exception;
+    public String expectedRepositoryId = "test";
+
+    public String expectedRepositoryName = "test";
+
+    public String expectedRepositoryDescription = "Repository test";
+
+    public String expectedRepositoryVendor = "Apache";
+
+    public String expectedRepositoryProductName = "Chemistry Simple Repository";
+
+    public String expectedRepositoryProductVersion = "1.0-SNAPSHOT";
+
+    public boolean expectedCapabilityHasGetDescendants = true;
+
+    public boolean expectedCapabilityHasMultifiling = false;
+
+    public CapabilityQuery expectedCapabilityQuery = CapabilityQuery.BOTH_COMBINED;
+
+    public boolean expectedCapabilityHasUnfiling = false;
+
+    public String expectedRootTypeId = "chemistry:root"; // not in spec
+
+    /**
+     * Must be implemented by actual testing classes.
+     */
+    public abstract Repository makeRepository() throws Exception;
 
     @Override
     public void setUp() throws Exception {
-        makeRepository();
+        repository = makeRepository();
         openConn();
     }
 
@@ -119,13 +143,13 @@
 
     public void testRepository() {
         assertNotNull(repository);
-        assertEquals("test", repository.getId());
-        assertEquals("test", repository.getName());
+        assertEquals(expectedRepositoryId, repository.getId());
+        assertEquals(expectedRepositoryName, repository.getName());
         RepositoryInfo info = repository.getInfo();
-        assertEquals("Repository test", info.getDescription());
-        assertEquals("Apache", info.getVendorName());
-        assertEquals("Chemistry Simple Repository", info.getProductName());
-        assertEquals("1.0-SNAPSHOT", info.getProductVersion());
+        assertEquals(expectedRepositoryDescription, info.getDescription());
+        assertEquals(expectedRepositoryVendor, info.getVendorName());
+        assertEquals(expectedRepositoryProductName, info.getProductName());
+        assertEquals(expectedRepositoryProductVersion, info.getProductVersion());
         // assertEquals(new SimpleObjectId("XYZ"), info.getRootFolderId());
         // assertEquals("", info.getLatestChangeLogToken());
         assertEquals("1.0", info.getVersionSupported());
@@ -140,14 +164,15 @@
         assertFalse(cap.isAllVersionsSearchable());
         assertEquals(CapabilityChange.NONE, cap.getChangeCapability());
         assertTrue(cap.isContentStreamUpdatableAnytime());
-        assertTrue(cap.hasGetDescendants());
+        assertEquals(expectedCapabilityHasGetDescendants,
+                cap.hasGetDescendants());
         assertFalse(cap.hasGetFolderTree());
-        assertFalse(cap.hasMultifiling());
+        assertEquals(expectedCapabilityHasMultifiling, cap.hasMultifiling());
         assertFalse(cap.isPWCSearchable());
         assertFalse(cap.isPWCUpdatable());
-        assertEquals(CapabilityQuery.BOTH_COMBINED, cap.getQueryCapability());
+        assertEquals(expectedCapabilityQuery, cap.getQueryCapability());
         assertEquals(CapabilityRendition.NONE, cap.getRenditionCapability());
-        assertFalse(cap.hasUnfiling());
+        assertEquals(expectedCapabilityHasUnfiling, cap.hasUnfiling());
         assertFalse(cap.hasVersionSpecificFiling());
         assertEquals(CapabilityJoin.NONE, cap.getJoinCapability());
     }
@@ -159,8 +184,8 @@
         assertNotNull(root);
         Type rootType = root.getType();
         assertNotNull(rootType);
-        assertEquals(ROOT_TYPE_ID, rootType.getId());
-        assertEquals(ROOT_TYPE_ID, root.getTypeId());
+        assertEquals(expectedRootTypeId, rootType.getId());
+        assertEquals(expectedRootTypeId, root.getTypeId());
         assertEquals(ROOT_FOLDER_NAME, root.getName());
         assertEquals(null, root.getParent());
         Map<String, Property> props = root.getProperties();
@@ -220,8 +245,8 @@
 
     public void testGetChildren() {
         Folder root = conn.getRootFolder();
-        ListPage<ObjectEntry> page = spi.getChildren(root, null, null, new Paging(20,
-                        0));
+        ListPage<ObjectEntry> page = spi.getChildren(root, null, null,
+                new Paging(20, 0));
         assertEquals(1, page.size());
         assertFalse(page.getHasMoreItems());
         assertEquals(1, page.getNumItems());

Modified: incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java?rev=889742&r1=889741&r2=889742&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java
Fri Dec 11 18:19:26 2009
@@ -46,7 +46,7 @@
     public static final int DEFAULT_PORT = 8080;
 
     public static void main(String[] args) throws Exception {
-        Repository repository = BasicHelper.makeRepository(ROOT_ID);
+        Repository repository = BasicHelper.makeSimpleRepository(ROOT_ID);
         MainServlet.run(args, repository, "/cmis", "/repository");
     }
 

Modified: 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=889742&r1=889741&r2=889742&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java
Fri Dec 11 18:19:26 2009
@@ -48,7 +48,10 @@
     public Server server;
 
     public String startServer() throws Exception {
-        Repository repository = BasicHelper.makeRepository(null);
+        Repository repository = BasicHelper.makeSimpleRepository(null);
+        // populate repository from the server side
+        // could also be done from the server side
+        BasicHelper.populateRepository(repository);
         server = new Server();
         Connector connector = new SocketConnector();
         connector.setHost(HOST);
@@ -74,10 +77,10 @@
     }
 
     @Override
-    public void makeRepository() throws Exception {
+    public Repository makeRepository() throws Exception {
         String serverUrl = startServer();
         ContentManager cm = new APPContentManager(serverUrl);
-        repository = cm.getDefaultRepository();
+        return cm.getDefaultRepository();
     }
 
     @Override

Added: incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestJcrRepository.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestJcrRepository.java?rev=889742&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestJcrRepository.java
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestJcrRepository.java
Fri Dec 11 18:19:26 2009
@@ -0,0 +1,75 @@
+/*
+ * 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.io.File;
+
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+
+import org.apache.chemistry.CapabilityQuery;
+import org.apache.chemistry.Repository;
+import org.apache.chemistry.jcr.JcrRepository;
+import org.apache.commons.io.FileUtils;
+import org.apache.jackrabbit.api.JackrabbitRepository;
+import org.apache.jackrabbit.core.TransientRepository;
+
+/**
+ * Test on a Jackrabbit repository.
+ */
+public class TestJcrRepository extends BasicTestCase {
+
+    private static final String DIRECTORY = "target/test/jackrabbit";
+
+    protected JackrabbitRepository jackrabbitRepo;
+
+    @Override
+    public Repository makeRepository() throws Exception {
+        File dir = new File(DIRECTORY);
+        FileUtils.deleteDirectory(dir);
+        dir.mkdirs();
+        String config = new File(dir, "repository.xml").toString();
+        String home = new File(dir, "repository").toString();
+
+        jackrabbitRepo = new TransientRepository(config, home);
+        Session session = jackrabbitRepo.login(new SimpleCredentials("userid",
+                "".toCharArray()));
+        String workspaceName = session.getWorkspace().getName();
+
+        expectedRepositoryId = "Jackrabbit";
+        expectedRepositoryName = "Jackrabbit";
+        expectedRepositoryDescription = "Jackrabbit";
+        expectedRepositoryVendor = "Apache Software Foundation";
+        expectedRepositoryProductName = "Jackrabbit";
+        expectedRepositoryProductVersion = "1.6.0";
+        expectedCapabilityHasGetDescendants = false;
+        expectedCapabilityHasMultifiling = true;
+        expectedCapabilityQuery = CapabilityQuery.BOTH_SEPARATE;
+        expectedCapabilityHasUnfiling = true;
+        expectedRootTypeId = "rep:root";
+        Repository repo = new JcrRepository(jackrabbitRepo, workspaceName);
+        BasicHelper.populateRepository(repo);
+        return repo;
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+        jackrabbitRepo.shutdown();
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestJcrRepository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestJcrRepository.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestSimpleDirect.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestSimpleDirect.java?rev=889742&r1=889741&r2=889742&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestSimpleDirect.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestSimpleDirect.java
Fri Dec 11 18:19:26 2009
@@ -16,14 +16,18 @@
  */
 package org.apache.chemistry.test;
 
+import org.apache.chemistry.Repository;
+
 /**
  * Tests the simple implementation directly (no client/server).
  */
 public class TestSimpleDirect extends BasicTestCase {
 
     @Override
-    public void makeRepository() throws Exception {
-        repository = BasicHelper.makeRepository(null);
+    public Repository makeRepository() throws Exception {
+        Repository repo = BasicHelper.makeSimpleRepository(null);
+        BasicHelper.populateRepository(repo);
+        return repo;
     }
 
 }



Mime
View raw message