incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r728780 - in /incubator/sling/trunk/commons/testing: pom.xml src/main/java/org/apache/sling/commons/testing/jcr/RepositoryUtil.java src/main/resources/jackrabbit-test-config.xml
Date Mon, 22 Dec 2008 21:20:43 GMT
Author: fmeschbe
Date: Mon Dec 22 13:20:43 2008
New Revision: 728780

URL: http://svn.apache.org/viewvc?rev=728780&view=rev
Log:
SLING-794 Setup correct for transitive test dependencies and repository setup

Added:
    incubator/sling/trunk/commons/testing/src/main/resources/jackrabbit-test-config.xml  
(with props)
Modified:
    incubator/sling/trunk/commons/testing/pom.xml
    incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryUtil.java

Modified: incubator/sling/trunk/commons/testing/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/commons/testing/pom.xml?rev=728780&r1=728779&r2=728780&view=diff
==============================================================================
--- incubator/sling/trunk/commons/testing/pom.xml (original)
+++ incubator/sling/trunk/commons/testing/pom.xml Mon Dec 22 13:20:43 2008
@@ -37,34 +37,64 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/commons/testing</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/testing</developerConnection>
-        <url>http://svn.apache.org/viewvc/incubator/sling/trunk/commons/testing</url>
+        <connection>
+            scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/commons/testing
+        </connection>
+        <developerConnection>
+            scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/testing
+        </developerConnection>
+        <url>
+            http://svn.apache.org/viewvc/incubator/sling/trunk/commons/testing
+        </url>
     </scm>
 
     <dependencies>
         <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+
+        <!--
+            Dependencies required for testing and provided
+            transitively to modules using this artifact
+        -->
+        <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
             <version>2.0.2-incubator</version>
+            <scope>compile</scope>
         </dependency>
-
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.jcr.api</artifactId>
             <version>2.0.2-incubator</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-api</artifactId>
+            <version>1.5.0</version>
+            <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
             <artifactId>jackrabbit-core</artifactId>
+            <version>1.5.0</version>
+            <scope>compile</scope>
         </dependency>
-
         <dependency>
             <groupId>rhino</groupId>
             <artifactId>js</artifactId>
             <scope>compile</scope>
         </dependency>
-        
         <dependency>
             <groupId>commons-httpclient</groupId>
             <artifactId>commons-httpclient</artifactId>
@@ -82,24 +112,25 @@
             </exclusions>
         </dependency>
         
+        <!-- Logging for tests -->
         <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>servlet-api</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.osgi.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.osgi.compendium</artifactId>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>compile</scope>
         </dependency>
-
+        
+        <!-- Basic Test Controller JUnit -->
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <scope>provided</scope>
+            <scope>compile</scope>
+        </dependency>
+        
+        <!-- Provide for Test Mocks -->
+        <dependency>
+            <groupId>org.jmock</groupId>
+            <artifactId>jmock-junit4</artifactId>
+            <scope>compile</scope>
         </dependency>
     </dependencies>
 </project>

Modified: incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryUtil.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryUtil.java?rev=728780&r1=728779&r2=728780&view=diff
==============================================================================
--- incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryUtil.java
(original)
+++ incubator/sling/trunk/commons/testing/src/main/java/org/apache/sling/commons/testing/jcr/RepositoryUtil.java
Mon Dec 22 13:20:43 2008
@@ -16,6 +16,8 @@
  */
 package org.apache.sling.commons.testing.jcr;
 
+import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Hashtable;
@@ -38,8 +40,8 @@
 import org.apache.sling.jcr.api.SlingRepository;
 
 /**
- * Utility class for managing JCR repositories, used to
- * initialize temporary Jackrabbit repositories for testing.
+ * Utility class for managing JCR repositories, used to initialize temporary
+ * Jackrabbit repositories for testing.
  */
 public class RepositoryUtil {
 
@@ -53,7 +55,7 @@
 
     public static final String PROVIDER_URL = "localhost";
 
-    public static final String CONFIG_FILE = "src/test/test-config/jackrabbit-test-config.xml";
+    public static final String CONFIG_FILE = "jackrabbit-test-config.xml";
 
     public static final String HOME_DIR = "target/repository";
 
@@ -66,22 +68,63 @@
 
     /**
      * Start a new repository
-     *
+     * 
      * @throws RepositoryException when it is not possible to start the
      *             repository.
      * @throws NamingException
      */
     public static void startRepository() throws RepositoryException,
             NamingException {
+
+        // copy the repository configuration file to the repository HOME_DIR
+        InputStream ins = RepositoryUtil.class.getClassLoader().getResourceAsStream(
+            CONFIG_FILE);
+        if (ins == null) {
+            throw new RepositoryException("Cannot get " + CONFIG_FILE);
+        }
+
+        File configFile = new File(HOME_DIR, CONFIG_FILE);
+        configFile.getParentFile().mkdirs();
+        
+        FileOutputStream out = null;
+        try {
+            out = new FileOutputStream(configFile);
+            byte[] buf = new byte[1024];
+            int rd;
+            while ((rd = ins.read(buf)) >= 0) {
+                out.write(buf, 0, rd);
+            }
+        } catch (IOException ioe) {
+            throw new RepositoryException("Cannot copy configuration file to "
+                + configFile);
+        } finally {
+            try {
+                ins.close();
+            } catch (IOException ignore) {
+            }
+            if (out != null) {
+                try {
+                    out.close();
+                } catch (IOException ignore) {
+                }
+            }
+        }
+
+        // somewhat dirty hack to have the derby.log file in a sensible
+        // location, but don't overwrite anything already set
+        if (System.getProperty("derby.stream.error.file") == null) {
+            String derbyLog = HOME_DIR + "/derby.log";
+            System.setProperty("derby.stream.error.file", derbyLog);
+        }
+
         RegistryHelper.registerRepository(getInitialContext(), REPOSITORY_NAME,
-            CONFIG_FILE, HOME_DIR, true);
+            configFile.getPath(), HOME_DIR, true);
     }
 
     /**
      * Stop a repository.
-     *
-     * @throws NamingException when it is not possible to stop the
-     *             repository
+     * 
+     * @throws NamingException when it is not possible to stop the repository
      * @throws NamingException
      */
     public static void stopRepository() throws NamingException {
@@ -91,11 +134,11 @@
 
     /**
      * Get a repository
-     *
+     * 
      * @return a JCR repository reference
-     * @throws NamingException when it is not possible to get the
-     *             repository. Before calling this method, the repository has to
-     *             be registered (@see RepositoryUtil#registerRepository(String,
+     * @throws NamingException when it is not possible to get the repository.
+     *             Before calling this method, the repository has to be
+     *             registered (@see RepositoryUtil#registerRepository(String,
      *             String, String)
      * @throws NamingException
      */
@@ -115,7 +158,7 @@
      * <p>
      * This method is not synchronized. It is up to the calling method to
      * prevent paralell execution.
-     *
+     * 
      * @param session The <code>Session</code> providing the node type manager
      *            through which the node type is to be registered.
      * @param source The <code>InputStream</code> from which the CND file is
@@ -204,4 +247,4 @@
         }
 
     }
-}
\ No newline at end of file
+}

Added: incubator/sling/trunk/commons/testing/src/main/resources/jackrabbit-test-config.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/commons/testing/src/main/resources/jackrabbit-test-config.xml?rev=728780&view=auto
==============================================================================
--- incubator/sling/trunk/commons/testing/src/main/resources/jackrabbit-test-config.xml (added)
+++ incubator/sling/trunk/commons/testing/src/main/resources/jackrabbit-test-config.xml Mon
Dec 22 13:20:43 2008
@@ -0,0 +1,112 @@
+<?xml version="1.0"?>
+<!--
+   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.
+-->
+<!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 1.2//EN"
+                            "http://jackrabbit.apache.org/dtd/repository-1.2.dtd">
+<Repository>
+    <!--
+        virtual file system where the repository stores global state
+        (e.g. registered namespaces, custom node types, etc.)
+    -->
+    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+        <param name="path" value="${rep.home}/repository"/>
+    </FileSystem>
+
+    <!--
+        security configuration
+    -->
+    <Security appName="Jackrabbit">
+        <!--
+            access manager:
+            class: FQN of class implementing the AccessManager interface
+        -->
+        <AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager">
+            <!-- <param name="config" value="${rep.home}/access.xml"/> -->
+        </AccessManager>
+
+        <LoginModule class="org.apache.jackrabbit.core.security.SimpleLoginModule">
+           <!-- anonymous user name ('anonymous' is the default value) -->
+           <param name="anonymousId" value="anonymous"/>
+        </LoginModule>
+    </Security>
+
+    <!--
+        location of workspaces root directory and name of default workspace
+    -->
+    <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/>
+    <!--
+        workspace configuration template:
+        used to create the initial workspace if there's no workspace yet
+    -->
+    <Workspace name="Jackrabbit Core">
+        <!--
+            virtual file system of the workspace:
+            class: FQN of class implementing the FileSystem interface
+        -->
+        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${wsp.home}"/>
+        </FileSystem>
+        <!--
+            persistence manager of the workspace:
+            class: FQN of class implementing the PersistenceManager interface
+        -->
+        <PersistenceManager class="org.apache.jackrabbit.core.persistence.db.DerbyPersistenceManager">
+          <param name="url" value="jdbc:derby:${wsp.home}/db;create=true"/>
+          <param name="schemaObjectPrefix" value="Jackrabbit Core_"/>
+        </PersistenceManager>
+        <!--
+            Search index and the file system it uses.
+            class: FQN of class implementing the QueryHandler interface
+        -->
+        <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+            <param name="path" value="${wsp.home}/index"/>
+        </SearchIndex>
+    </Workspace>
+
+    <!--
+        Configures the versioning
+    -->
+    <Versioning rootPath="${rep.home}/version">
+        <!--
+            Configures the filesystem to use for versioning for the respective
+            persistence manager
+        -->
+        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${rep.home}/version" />
+        </FileSystem>
+
+        <!--
+            Configures the persistence manager to be used for persisting version state.
+            Please note that the current versioning implementation is based on
+            a 'normal' persistence manager, but this could change in future
+            implementations.
+        -->
+        <PersistenceManager class="org.apache.jackrabbit.core.persistence.db.DerbyPersistenceManager">
+          <param name="url" value="jdbc:derby:${rep.home}/version/db;create=true"/>
+          <param name="schemaObjectPrefix" value="version_"/>
+        </PersistenceManager>
+    </Versioning>
+
+    <!--
+        Search index for content that is shared repository wide
+        (/jcr:system tree, contains mainly versions)
+    -->
+    <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+        <param name="path" value="${rep.home}/repository/index"/>
+    </SearchIndex>
+</Repository>
+

Propchange: incubator/sling/trunk/commons/testing/src/main/resources/jackrabbit-test-config.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message