jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r677917 - in /jackrabbit/sandbox/spi/client: ./ src/test/java/org/apache/jackrabbit/client/ src/test/java/org/apache/jackrabbit/jcr2spi/ src/test/resources/
Date Fri, 18 Jul 2008 14:38:22 GMT
Author: angela
Date: Fri Jul 18 07:38:21 2008
New Revision: 677917

URL: http://svn.apache.org/viewvc?rev=677917&view=rev
Log:
JCR-1684: SPI sandbox: use tests-jars introduced with JCR-1629 and JCR-1683

Added:
    jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/
    jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/DefaultRepositoryStub.java   (with props)
    jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPI2JCROverRMIRepositoryStub.java   (with props)
    jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPI2JCRRepositoryStub.java   (with props)
    jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIOverRMIRepositoryStub.java   (with props)
    jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIRepositoryStub.java   (with props)
    jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/RMIRepositoryStub.java   (with props)
    jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/RepositorySetup.java   (with props)
    jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/SPIServer.java   (with props)
    jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/ServiceStubImpl.java   (with props)
    jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/TestAll.java   (with props)
    jackrabbit/sandbox/spi/client/src/test/resources/repositoryServiceStubImpl.properties   (with props)
Removed:
    jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/jcr2spi/
Modified:
    jackrabbit/sandbox/spi/client/pom.xml
    jackrabbit/sandbox/spi/client/src/test/resources/repositoryStubImpl.properties

Modified: jackrabbit/sandbox/spi/client/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/client/pom.xml?rev=677917&r1=677916&r2=677917&view=diff
==============================================================================
--- jackrabbit/sandbox/spi/client/pom.xml (original)
+++ jackrabbit/sandbox/spi/client/pom.xml Fri Jul 18 07:38:21 2008
@@ -49,6 +49,14 @@
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-spi</artifactId>
+      <version>${project.parent.version}</version>
+      <classifier>tests</classifier>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-spi</artifactId>
+      <version>${project.parent.version}</version>
+      <classifier></classifier>
     </dependency>
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
@@ -57,6 +65,14 @@
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-jcr2spi</artifactId>
+      <version>${project.parent.version}</version>
+      <classifier>tests</classifier>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-jcr2spi</artifactId>
+      <version>${project.parent.version}</version>
+      <classifier></classifier>
     </dependency>
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>

Added: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/DefaultRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/DefaultRepositoryStub.java?rev=677917&view=auto
==============================================================================
--- jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/DefaultRepositoryStub.java (added)
+++ jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/DefaultRepositoryStub.java Fri Jul 18 07:38:21 2008
@@ -0,0 +1,127 @@
+/*
+ * 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.client;
+
+import org.apache.jackrabbit.test.RepositoryStub;
+import org.apache.jackrabbit.test.RepositoryStubException;
+import org.apache.jackrabbit.core.jndi.RegistryHelper;
+
+import javax.jcr.Repository;
+import javax.jcr.Session;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+import java.util.Hashtable;
+
+/**
+ * Implements the <code>RepositoryStub</code> for the JCR Reference Implementation.
+ * TODO: copied from jackrabbit/core test classes
+ */
+public class DefaultRepositoryStub extends RepositoryStub {
+
+    /**
+     * Property for the repository name (used for jndi lookup)
+     */
+    public static final String PROP_REPOSITORY_NAME = "org.apache.jackrabbit.repository.name";
+
+    /**
+     * Property for the repository configuration file (used for repository instantiation)
+     */
+    public static final String PROP_REPOSITORY_CONFIG = "org.apache.jackrabbit.repository.config";
+
+    /**
+     * Property for the repository home directory (used for repository instantiation)
+     */
+    public static final String PROP_REPOSITORY_HOME = "org.apache.jackrabbit.repository.home";
+
+    /**
+     * Property for the jaas config path. If the system property
+     * <code>java.security.auth.login.config</code> is not set this repository
+     * stub will try to read this property from the environment and use the
+     * value retrieved as the value for the system property.
+     */
+    public static final String PROP_JAAS_CONFIG = "org.apache.jackrabbit.repository.jaas.config";
+
+    /**
+     * The name of the jaas config system property.
+     */
+    private static final String SYS_JAAS_CONFIG = "java.security.auth.login.config";
+
+    /**
+     * The repository instance
+     */
+    private Repository repository;
+
+    /**
+     * Constructor as required by the JCR TCK.
+     *
+     * @param env environment properties.
+     */
+    public DefaultRepositoryStub(Properties env) {
+        super(env);
+        // set some attributes on the sessions
+        superuser.setAttribute("jackrabbit", "jackrabbit");
+        readwrite.setAttribute("jackrabbit", "jackrabbit");
+        readonly.setAttribute("jackrabbit", "jackrabbit");
+    }
+
+    /**
+     * Returns the configured <code>Repository</code> instance.
+     * <br>
+     * The default repository name is 'repo'.
+     *
+     * @return the configured <code>Repository</code> instance.
+     * @throws RepositoryStubException if an error occurs while
+     *                                 obtaining the Repository instance.
+     */
+    public synchronized Repository getRepository() throws RepositoryStubException {
+        if (repository == null) {
+            try {
+                String repName = environment.getProperty(PROP_REPOSITORY_NAME, "repo");
+                String repConfig = environment.getProperty(PROP_REPOSITORY_CONFIG);
+                String repHome = environment.getProperty(PROP_REPOSITORY_HOME);
+                String jaasConfig = environment.getProperty(PROP_JAAS_CONFIG);
+
+                // set jaas config from stub properties if system property is
+                // not set.
+                if (System.getProperty(SYS_JAAS_CONFIG) == null && jaasConfig != null) {
+                    System.setProperty(SYS_JAAS_CONFIG, jaasConfig);
+                }
+
+                // register repository instance
+                Hashtable env = new Hashtable();
+                env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
+                env.put(Context.PROVIDER_URL, "localhost");
+                InitialContext ctx = new InitialContext(env);
+                RegistryHelper.registerRepository(ctx, repName, repConfig, repHome, true);
+
+                repository = (Repository) ctx.lookup(repName);
+
+                // setup repository
+                Session s = repository.login(getSuperuserCredentials());
+                try {
+                    RepositorySetup.run(s);
+                } finally {
+                    s.logout();
+                }
+            } catch (Exception e) {
+                throw new RepositoryStubException(e.toString());
+            }
+        }
+        return repository;
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/DefaultRepositoryStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/DefaultRepositoryStub.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPI2JCROverRMIRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPI2JCROverRMIRepositoryStub.java?rev=677917&view=auto
==============================================================================
--- jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPI2JCROverRMIRepositoryStub.java (added)
+++ jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPI2JCROverRMIRepositoryStub.java Fri Jul 18 07:38:21 2008
@@ -0,0 +1,82 @@
+/*
+ * 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.client;
+
+import org.apache.jackrabbit.test.RepositoryStubException;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.rmi.server.ServerRepositoryService;
+import org.apache.jackrabbit.spi.rmi.remote.RemoteRepositoryService;
+import org.apache.jackrabbit.spi.rmi.client.ClientRepositoryService;
+import org.apache.jackrabbit.jcr2spi.RepositoryImpl;
+import org.apache.jackrabbit.jcr2spi.AbstractRepositoryConfig;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import java.util.Properties;
+import java.rmi.RemoteException;
+
+/**
+ * <code>JCR2SPI2JCROverRMIRepositoryStub</code> implements a repository stub that
+ * initializes a Jackrabbit repository and wraps it with a SPI2JCR layer,
+ * a SPI-RMI layer and a JCR2SPI layer.
+ */
+public class JCR2SPI2JCROverRMIRepositoryStub extends JCR2SPI2JCRRepositoryStub {
+
+    /**
+     * The Jackrabbit repository.
+     */
+    private Repository repo;
+
+    /**
+     * Constructor required by TCK.
+     *
+     * @param env the environment.
+     */
+    public JCR2SPI2JCROverRMIRepositoryStub(Properties env) {
+        super(env);
+    }
+
+    /**
+     * @return the repository instance to test.
+     * @throws RepositoryStubException if an error occurs while starting up the
+     *                                 repository.
+     */
+    public Repository getRepository() throws RepositoryStubException {
+        if (repo == null) {
+            RepositoryService spi2jcrRepoService = super.getRepositoryService();
+            try {
+                RemoteRepositoryService remoteRepoService = new ServerRepositoryService(spi2jcrRepoService);
+                final RepositoryService localRepoService = new ClientRepositoryService(remoteRepoService);
+
+                repo = RepositoryImpl.create(new AbstractRepositoryConfig() {
+                    public RepositoryService getRepositoryService() {
+                        return localRepoService;
+                    }
+                });
+            } catch (RepositoryException e) {
+                RepositoryStubException ex = new RepositoryStubException(e.getMessage());
+                ex.initCause(e);
+                throw ex;
+            } catch (RemoteException e) {
+                RepositoryStubException ex = new RepositoryStubException(e.getMessage());
+                ex.initCause(e);
+                throw ex;
+            }
+        }
+        return repo;
+    }
+}

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPI2JCROverRMIRepositoryStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPI2JCROverRMIRepositoryStub.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPI2JCRRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPI2JCRRepositoryStub.java?rev=677917&view=auto
==============================================================================
--- jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPI2JCRRepositoryStub.java (added)
+++ jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPI2JCRRepositoryStub.java Fri Jul 18 07:38:21 2008
@@ -0,0 +1,90 @@
+/*
+ * 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.client;
+
+import org.apache.jackrabbit.test.RepositoryStubException;
+import org.apache.jackrabbit.spi2jcr.RepositoryServiceImpl;
+import org.apache.jackrabbit.spi2jcr.BatchReadConfig;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.jcr2spi.RepositoryImpl;
+import org.apache.jackrabbit.jcr2spi.AbstractRepositoryConfig;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import java.util.Properties;
+
+/**
+ * <code>JCR2SPI2JCRRepositoryStub</code> implements a repository stub that
+ * initializes a Jackrabbit repository and wraps it with a SPI2JCR layer and
+ * a JCR2SPI layer.
+ */
+public class JCR2SPI2JCRRepositoryStub extends DefaultRepositoryStub {
+
+    /**
+     * The Jackrabbit repository.
+     */
+    private Repository repo;
+
+    /**
+     * Constructor required by TCK.
+     *
+     * @param env the environment.
+     */
+    public JCR2SPI2JCRRepositoryStub(Properties env) {
+        super(env);
+    }
+
+    /**
+     * @return the repository instance to test.
+     * @throws RepositoryStubException if an error occurs while starting up the
+     *                                 repository.
+     */
+    public Repository getRepository() throws RepositoryStubException {
+        if (repo == null) {
+            final RepositoryService service = getRepositoryService();
+            try {
+                repo = RepositoryImpl.create(new AbstractRepositoryConfig() {
+                    public RepositoryService getRepositoryService() {
+                        return service;
+                    }
+                });
+            } catch (RepositoryException e) {
+                RepositoryStubException ex = new RepositoryStubException(e.getMessage());
+                ex.initCause(e);
+                throw ex;
+            }
+        }
+        return repo;
+    }
+
+    /**
+     *
+     * @return
+     * @throws RepositoryStubException
+     */
+    public RepositoryService getRepositoryService() throws RepositoryStubException {
+        Repository jackrabbitRepo = super.getRepository();
+
+        // TODO: make configurable
+        BatchReadConfig brconfig = new BatchReadConfig();
+        brconfig.setDepth(NameConstants.NT_FILE, BatchReadConfig.DEPTH_INFINITE);
+        brconfig.setDepth(NameConstants.NT_RESOURCE, BatchReadConfig.DEPTH_INFINITE);
+
+        return new RepositoryServiceImpl(jackrabbitRepo, brconfig);
+    }
+}

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPI2JCRRepositoryStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPI2JCRRepositoryStub.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIOverRMIRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIOverRMIRepositoryStub.java?rev=677917&view=auto
==============================================================================
--- jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIOverRMIRepositoryStub.java (added)
+++ jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIOverRMIRepositoryStub.java Fri Jul 18 07:38:21 2008
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  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.client;
+
+import org.apache.jackrabbit.test.RepositoryStub;
+import org.apache.jackrabbit.test.RepositoryStubException;
+import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
+import org.apache.jackrabbit.jcr2spi.AbstractRepositoryConfig;
+import org.apache.jackrabbit.jcr2spi.RepositoryImpl;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.rmi.client.ClientRepositoryService;
+import org.apache.jackrabbit.spi.rmi.remote.RemoteRepositoryService;
+import org.apache.log4j.PropertyConfigurator;
+
+import javax.jcr.Repository;
+import java.util.Properties;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+/**
+ * <code>JCR2SPIRepositoryStub</code> implements a repository stub that returns
+ * a JCR2SPI Client that works on a SPI-RMI transport.
+ */
+public class JCR2SPIOverRMIRepositoryStub extends RepositoryStub {
+
+    /**
+     * Property for the repository url
+     */
+    public static final String PROP_REPOSITORY_NAME = "org.apache.jackrabbit.spi.rmi.repository.name";
+
+    static {
+        PropertyConfigurator.configure(JCR2SPIOverRMIRepositoryStub.class.getClassLoader().getResource("log4j.properties"));
+    }
+
+    /**
+     * The repository instance
+     */
+    private Repository repository;
+
+    /**
+     * Overwritten constructor from base class.
+     */
+    public JCR2SPIOverRMIRepositoryStub(Properties env) {
+        super(env);
+    }
+
+    public synchronized Repository getRepository() throws RepositoryStubException {
+        if (repository == null) {
+            try {
+                String repName = environment.getProperty(PROP_REPOSITORY_NAME);
+
+                Registry reg = LocateRegistry.getRegistry(Registry.REGISTRY_PORT);
+                RemoteRepositoryService remoteService = (RemoteRepositoryService) reg.lookup(repName);
+                final RepositoryService rmiService = new ClientRepositoryService(remoteService);
+
+                RepositoryConfig config = new AbstractRepositoryConfig() {
+                    public RepositoryService getRepositoryService() {
+                        return rmiService;
+                    }
+                };
+
+                repository = RepositoryImpl.create(config);
+            } catch (Exception e) {
+                throw new RepositoryStubException(e.toString());
+            }
+        }
+        return repository;
+    }
+}

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIOverRMIRepositoryStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIOverRMIRepositoryStub.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIRepositoryStub.java?rev=677917&view=auto
==============================================================================
--- jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIRepositoryStub.java (added)
+++ jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIRepositoryStub.java Fri Jul 18 07:38:21 2008
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  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.client;
+
+import org.apache.jackrabbit.spi.commons.identifier.IdFactoryImpl;
+import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
+import org.apache.jackrabbit.jcr2spi.AbstractRepositoryConfig;
+import org.apache.jackrabbit.jcr2spi.RepositoryImpl;
+import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi2dav.RepositoryServiceImpl;
+import org.apache.jackrabbit.test.RepositoryStub;
+import org.apache.jackrabbit.test.RepositoryStubException;
+import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
+import org.apache.log4j.PropertyConfigurator;
+
+import javax.jcr.Repository;
+import java.util.Properties;
+
+/**
+ * <code>JCR2SPIRepositoryStub</code> implements a repository stub that returns
+ * a JCR2SPI Client that works on a SPI2DAV implementation which in turn
+ * connects to an JCR WebDAV Server.
+ */
+public class JCR2SPIRepositoryStub extends RepositoryStub {
+
+    /**
+     * Property for the repository url
+     */
+    public static final String PROP_REPOSITORY_URL = "org.apache.jackrabbit.jcr2spi.repository.url";
+    /**
+     * Property for the default workspace name
+     */
+    public static final String PROP_WORKSPACE_NAME = "org.apache.jackrabbit.jcr2spi.workspace.name";
+
+    static {
+        PropertyConfigurator.configure(JCR2SPIRepositoryStub.class.getClassLoader().getResource("log4j.properties"));
+    }
+
+    /**
+     * The repository instance
+     */
+    private Repository repository;
+
+    /**
+     * Overwritten constructor from base class.
+     */
+    public JCR2SPIRepositoryStub(Properties env) {
+        super(env);
+    }
+
+    public synchronized Repository getRepository() throws RepositoryStubException {
+        if (repository == null) {
+            try {
+                String url = environment.getProperty(PROP_REPOSITORY_URL);
+
+                final IdFactory idFactory = IdFactoryImpl.getInstance();
+                final NameFactory nFactory = NameFactoryImpl.getInstance();
+                final PathFactory pFactory = PathFactoryImpl.getInstance();
+                final QValueFactory vFactory = QValueFactoryImpl.getInstance();
+                final RepositoryServiceImpl webdavRepoService = new RepositoryServiceImpl(url, idFactory, nFactory, pFactory, vFactory);
+
+                RepositoryConfig config = new AbstractRepositoryConfig() {
+                    public RepositoryService getRepositoryService() {
+                        return webdavRepoService;
+                    }
+
+                    public String getDefaultWorkspaceName() {
+                        String name = environment.getProperty(PROP_WORKSPACE_NAME);
+                        return name;
+                    }
+                };
+
+                repository = RepositoryImpl.create(config);
+            } catch (Exception e) {
+                throw new RepositoryStubException(e.toString());
+            }
+        }
+        return repository;
+    }
+}

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIRepositoryStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIRepositoryStub.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/RMIRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/RMIRepositoryStub.java?rev=677917&view=auto
==============================================================================
--- jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/RMIRepositoryStub.java (added)
+++ jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/RMIRepositoryStub.java Fri Jul 18 07:38:21 2008
@@ -0,0 +1,118 @@
+/*
+ * 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.client;
+
+import org.apache.jackrabbit.rmi.client.ClientRepositoryFactory;
+import org.apache.jackrabbit.test.RepositoryStubException;
+import org.apache.log4j.PropertyConfigurator;
+
+import javax.jcr.Repository;
+import java.util.Properties;
+import java.rmi.RemoteException;
+import java.rmi.NotBoundException;
+import java.net.MalformedURLException;
+
+/**
+ * <code>RMIRepositoryStub</code> implements a repository stub that initializes
+ * a Jackrabbit RMI client.
+ */
+public class RMIRepositoryStub extends DefaultRepositoryStub {
+
+    /**
+     * Property for the repository url
+     */
+    public static final String PROP_REPOSITORY_URI = "org.apache.jackrabbit.rmi.repository.uri";
+
+    static {
+        PropertyConfigurator.configure(RMIRepositoryStub.class.getClassLoader().getResource("log4j.properties"));
+    }
+
+    /**
+     * The Jackrabbit repository.
+     */
+    private Repository repo;
+
+    /**
+     * Constructor required by TCK.
+     *
+     * @param env the environment.
+     */
+    public RMIRepositoryStub(Properties env) {
+        super(env);
+    }
+
+    /**
+     * @return the repository instance to test.
+     * @throws RepositoryStubException if an error occurs while starting up the
+     *                                 repository.
+     */
+    public Repository getRepository() throws RepositoryStubException {
+        if (repo == null) {
+            repo = getRepositoryFromRMI();
+        }
+        return repo;
+    }
+
+    private Repository getRepositoryFromRMI() throws RepositoryStubException {
+        try {
+            Class clazz = Class.forName(getServerFactoryDelegaterClass());
+            ClientFactoryDelegater cfd = (ClientFactoryDelegater) clazz.newInstance();
+
+            String repositoryURI = environment.getProperty(PROP_REPOSITORY_URI);
+            Repository r = cfd.getRepository(repositoryURI);
+            //log.info("Acquired repository via RMI.");
+            return r;
+        } catch (Exception e) {
+            //log.error("Error while retrieving repository using RMI: " + e);
+            throw new RepositoryStubException(e.getMessage());
+        }
+    }
+
+    /**
+     * Return the fully qualified name of the class providing the client
+     * repository. The class whose name is returned must implement the
+     * {@link ClientFactoryDelegater} interface.
+     *
+     * @return the qfn of the factory class.
+     */
+    protected String getServerFactoryDelegaterClass() {
+        return getClass().getName() + "$RMIClientFactoryDelegater";
+    }
+
+    /**
+     * optional class for RMI, will only be used, if RMI client is present
+     */
+    protected static abstract class ClientFactoryDelegater {
+
+        public abstract Repository getRepository(String uri)
+                throws RemoteException, MalformedURLException, NotBoundException;
+    }
+
+    /**
+     * optional class for RMI, will only be used, if RMI server is present
+     */
+    protected static class RMIClientFactoryDelegater extends ClientFactoryDelegater {
+
+        // only used to enforce linking upon Class.forName()
+        static String FactoryClassName = ClientRepositoryFactory.class.getName();
+
+        public Repository getRepository(String uri) throws MalformedURLException, NotBoundException, RemoteException {
+            System.setProperty("java.rmi.server.useCodebaseOnly", "true");
+            return new ClientRepositoryFactory().getRepository(uri);
+        }
+    }
+}

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/RMIRepositoryStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/RMIRepositoryStub.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/RepositorySetup.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/RepositorySetup.java?rev=677917&view=auto
==============================================================================
--- jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/RepositorySetup.java (added)
+++ jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/RepositorySetup.java Fri Jul 18 07:38:21 2008
@@ -0,0 +1,267 @@
+/*
+ * 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.client;
+
+import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.WorkspaceImpl;
+import org.apache.jackrabbit.core.nodetype.xml.NodeTypeReader;
+import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
+import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
+import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.ImportUUIDBehavior;
+import javax.jcr.Node;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import java.io.InputStream;
+import java.io.IOException;
+import java.util.Properties;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * <code>RepositorySetup</code> initializes the test candidate with required
+ * namespaces, node types and test content.
+ */
+public class RepositorySetup {
+
+    private static final String NAMESPACES_RESOURCE = "namespaces.properties";
+
+    private static final String NODETYPES_RESOURCE = "custom_nodetypes.xml";
+
+    private static final String TEST_CONTENT_RESOURCE = "testdata.xml";
+
+    private static final String TEST_WORKSPACE_NAME = "test";
+
+    /**
+     * The setup tasks to run.
+     */
+    private final Task[] TASKS = {
+        new RegisterNamespaces(),
+        new RegisterNodeTypes(),
+        new ImportTestContent(),
+        new CreateTestWorkspace()
+    };
+
+    /**
+     * The session to the repository to setup.
+     */
+    private final SessionImpl session;
+
+    /**
+     * Private constructor.
+     */
+    private RepositorySetup(SessionImpl session) {
+        this.session = session;
+    }
+
+    /**
+     * Executes the repository setup tasks.
+     *
+     * @throws RepositoryException if an error occurs while running the tasks.
+     */
+    private void execute() throws RepositoryException {
+        for (int i = 0; i < TASKS.length; i++) {
+            TASKS[i].execute();
+        }
+    }
+
+    /**
+     * Runs the repository setup.
+     *
+     * @param session the session of the repository to setup.
+     * @throws RepositoryException      if an error occurs while running the
+     *                                  tasks.
+     * @throws IllegalArgumentException if <code>session</code> is not a jackrabbit
+     *                                  session.
+     */
+    public static void run(Session session) throws RepositoryException {
+        if (session instanceof SessionImpl) {
+            new RepositorySetup((SessionImpl) session).execute();
+        } else {
+            throw new IllegalArgumentException("not a Jackrabbit session");
+        }
+    }
+
+    /**
+     * Returns an input stream for reading the specified resource.
+     *
+     * @param name the resource name.
+     * @return An input stream for reading the resource, or <code>null</code> if
+     *         the resource could not be found
+     */
+    private static InputStream getResource(String name) {
+        return RepositorySetup.class.getClassLoader().getResourceAsStream(name);
+    }
+
+    /**
+     * Registers the <code>namespaces</code>.
+     *
+     * @param namespaces the namespaces to register.
+     * @param session the session to register the namespaces.
+     */
+    private static void registerNamespaces(Properties namespaces,
+                                           Session session)
+            throws RepositoryException {
+        NamespaceRegistry nsReg = session.getWorkspace().getNamespaceRegistry();
+        for (Iterator it = namespaces.keySet().iterator(); it.hasNext();) {
+            String prefix = (String) it.next();
+            String uri = namespaces.getProperty(prefix);
+            try {
+                nsReg.registerNamespace(prefix, uri);
+            } catch (RepositoryException e) {
+                // then this namespace is already registered.
+            }
+        }
+    }
+
+    private interface Task {
+
+        /**
+         * Executes this task.
+         *
+         * @throws RepositoryException if an error occurs while running this
+         *                             tasks.
+         */
+        public void execute() throws RepositoryException;
+    }
+
+    /**
+     * Registers namespaces that are needed to run the test cases.
+     */
+    private final class RegisterNamespaces implements Task {
+
+        /**
+         * @inheritDoc
+         */
+        public void execute() throws RepositoryException {
+            InputStream is = getResource(NAMESPACES_RESOURCE);
+            if (is != null) {
+                try {
+                    Properties namespaces = new Properties();
+                    namespaces.load(is);
+
+                    registerNamespaces(namespaces, session);
+                } catch (IOException e) {
+                    throw new RepositoryException(e.getMessage());
+                } finally {
+                    try {
+                        is.close();
+                    } catch (IOException e1) {
+                        // ignore
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Registers node types that are needed to run the test cases.
+     */
+    private final class RegisterNodeTypes implements Task {
+
+        /**
+         * @inheritDoc
+         */
+        public void execute() throws RepositoryException {
+            InputStream is = getResource(NODETYPES_RESOURCE);
+            if (is != null) {
+                try {
+                    NodeTypeReader ntReader = new NodeTypeReader(is);
+                    registerNamespaces(ntReader.getNamespaces(), session);
+
+                    NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
+                    NodeTypeDef[] nodeTypes = ntReader.getNodeTypeDefs();
+                    List unregisteredNTs = new ArrayList();
+                    for (int i = 0; i < nodeTypes.length; i++) {
+                        try {
+                            ntMgr.getNodeType(nodeTypes[i].getName());
+                        } catch (NoSuchNodeTypeException e) {
+                            // register the node type
+                            unregisteredNTs.add(nodeTypes[i]);
+                        }
+                    }
+                    ntMgr.getNodeTypeRegistry().registerNodeTypes(unregisteredNTs);
+                } catch (IOException e) {
+                    throw new RepositoryException(e.getMessage());
+                } catch (InvalidNodeTypeDefException e) {
+                    throw new RepositoryException(e.getMessage());
+                } finally {
+                    try {
+                        is.close();
+                    } catch (IOException e1) {
+                        // ignore
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Imports test content into the repository if the repository is empty.
+     */
+    private final class ImportTestContent implements Task {
+
+        /**
+         * @inheritDoc
+         */
+        public void execute() throws RepositoryException {
+            InputStream is = getResource(TEST_CONTENT_RESOURCE);
+            if (is != null) {
+                try {
+                    Node rootNode = session.getRootNode();
+                    if (!rootNode.hasNode("testdata")) {
+                        session.getWorkspace().importXML("/", is,
+                                ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
+                    }
+                    if (!rootNode.hasNode("testroot")) {
+                        rootNode.addNode("testroot");
+                        session.save();
+                    }
+                } catch (IOException e) {
+                    throw new RepositoryException(e.getMessage());
+                } finally {
+                    try {
+                        is.close();
+                    } catch (IOException e1) {
+                        // ignore
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Creates a workspace with name 'test' if it is not yet present.
+     */
+    private final class CreateTestWorkspace implements Task {
+
+        /**
+         * @inheritDoc
+         */
+        public void execute() throws RepositoryException {
+            List workspaces = Arrays.asList(session.getWorkspace().getAccessibleWorkspaceNames());
+            if (!workspaces.contains(TEST_WORKSPACE_NAME)) {
+                ((WorkspaceImpl) session.getWorkspace()).createWorkspace(TEST_WORKSPACE_NAME);
+            }
+        }
+    }
+}

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/RepositorySetup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/RepositorySetup.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/SPIServer.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/SPIServer.java?rev=677917&view=auto
==============================================================================
--- jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/SPIServer.java (added)
+++ jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/SPIServer.java Fri Jul 18 07:38:21 2008
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  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.client;
+
+import org.apache.jackrabbit.core.config.RepositoryConfig;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.rmi.remote.RemoteRepositoryService;
+import org.apache.jackrabbit.spi.rmi.server.ServerRepositoryService;
+import org.apache.jackrabbit.spi2jcr.RepositoryServiceImpl;
+import org.apache.jackrabbit.spi2jcr.BatchReadConfig;
+import org.apache.log4j.PropertyConfigurator;
+
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.RemoteException;
+import java.rmi.NotBoundException;
+
+/**
+ * <code>SPIServer</code> starts a jackrabbit repository and wraps it with
+ * a SPI2JCR layer and finally makes it available over RMI.
+ */
+public class SPIServer {
+
+    private static final String REPO_CONFIG = "src/test/resources/repository.xml";
+
+    private static final String REPO_HOME = "target/repo-home";
+
+    private final org.apache.jackrabbit.core.RepositoryImpl repo;
+
+    private final RemoteRepositoryService remoteService;
+
+    private final Registry reg;
+
+    static {
+        PropertyConfigurator.configure(SPIServer.class.getClassLoader().getResource("log4j.properties"));
+    }
+
+    private SPIServer() throws Exception {
+        // start a jackrabbit repository
+        System.out.println("Starting Jackrabbit...");
+        RepositoryConfig config = RepositoryConfig.create(REPO_CONFIG, REPO_HOME);
+        repo = org.apache.jackrabbit.core.RepositoryImpl.create(config);
+        System.out.println("Jackrabbit started");
+        // try to setup test data
+        Session s = repo.login(new SimpleCredentials("user", "pass".toCharArray()));
+        try {
+            RepositorySetup.run(s);
+        } finally {
+            s.logout();
+        }
+        // wrap with spi2jcr
+        // TODO: make BatchReadConfig configurable
+        RepositoryService repoService = new RepositoryServiceImpl(repo, new BatchReadConfig());
+        System.out.println("Wrapped with SPI2JCR");
+        // create spi server
+        remoteService = new ServerRepositoryService(repoService);
+        System.out.println("Wrapped with SPI-RMI");
+        // register server
+        reg = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
+        reg.bind("spi-server", remoteService);
+        System.out.println("Bound to RMI Registry");
+    }
+
+    private void shutdown() {
+        System.out.println("Shutting down...");
+        try {
+            reg.unbind("spi-server");
+        } catch (RemoteException e) {
+            e.printStackTrace();
+        } catch (NotBoundException e) {
+            e.printStackTrace();
+        }
+        repo.shutdown();
+        System.out.println("Jackrabbit stopped");
+    }
+
+    public static void main(String[] args) {
+        try {
+            SPIServer server = new SPIServer();
+            // wait for console input, then terminate
+            while (System.in.read() != 'q') {
+                // read again
+            }
+            server.shutdown();
+            System.exit(0);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+}

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/SPIServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/SPIServer.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/ServiceStubImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/ServiceStubImpl.java?rev=677917&view=auto
==============================================================================
--- jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/ServiceStubImpl.java (added)
+++ jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/ServiceStubImpl.java Fri Jul 18 07:38:21 2008
@@ -0,0 +1,142 @@
+/*
+ * 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.client;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.spi.RepositoryServiceStub;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.rmi.remote.RemoteRepositoryService;
+import org.apache.jackrabbit.spi.rmi.server.ServerRepositoryService;
+import org.apache.jackrabbit.spi.rmi.client.ClientRepositoryService;
+import org.apache.jackrabbit.core.jndi.RegistryHelper;
+import org.apache.jackrabbit.spi2jcr.BatchReadConfig;
+import org.apache.jackrabbit.spi2jcr.RepositoryServiceImpl;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Repository;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.Credentials;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+import java.util.Hashtable;
+import java.rmi.RemoteException;
+
+/** <code>ServiceStubImpl</code>... */
+public class ServiceStubImpl extends RepositoryServiceStub {
+
+    private static Logger log = LoggerFactory.getLogger(ServiceStubImpl.class);
+
+    /**
+     * Property for the repository name (used for jndi lookup)
+     */
+    public static final String PROP_REPOSITORY_NAME = "org.apache.jackrabbit.client.name";
+
+    /**
+     * Property for the repository configuration file (used for repository instantiation)
+     */
+    public static final String PROP_REPOSITORY_CONFIG = "org.apache.jackrabbit.client.config";
+
+    /**
+     * Property for the repository home directory (used for repository instantiation)
+     */
+    public static final String PROP_REPOSITORY_HOME = "org.apache.jackrabbit.client.home";
+
+    /**
+     * Property for the jaas config path. If the system property
+     * <code>java.security.auth.login.config</code> is not set this repository
+     * stub will try to read this property from the environment and use the
+     * value retrieved as the value for the system property.
+     */
+    public static final String PROP_JAAS_CONFIG = "org.apache.jackrabbit.client.jaas.config";
+
+    /**
+     * The name of the jaas config system property.
+     */
+    private static final String SYS_JAAS_CONFIG = "java.security.auth.login.config";
+
+
+    private RepositoryService service;
+    private Credentials adminCredentials;
+    private Credentials readOnlyCredentials;
+
+    /**
+     * Implementations of this class must overwrite this constructor.
+     *
+     * @param env the environment variables. This parameter must not be null.
+     */
+    public ServiceStubImpl(Properties env) {
+        super(env);
+    }
+
+    public RepositoryService getRepositoryService() throws RepositoryException {
+        if (service == null) {
+            Repository repository;
+            try {
+                String repName = environment.getProperty(PROP_REPOSITORY_NAME);
+                String repConfig = environment.getProperty(PROP_REPOSITORY_CONFIG);
+                String repHome = environment.getProperty(PROP_REPOSITORY_HOME);
+                String jaasConfig = environment.getProperty(PROP_JAAS_CONFIG);
+
+                // set jaas config from stub properties if system property is
+                // not set.
+                if (System.getProperty(SYS_JAAS_CONFIG) == null && jaasConfig != null) {
+                    System.setProperty(SYS_JAAS_CONFIG, jaasConfig);
+                }
+
+                // register repository instance
+                Hashtable env = new Hashtable();
+                env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
+                env.put(Context.PROVIDER_URL, "localhost");
+                InitialContext ctx = new InitialContext(env);
+                RegistryHelper.registerRepository(ctx, repName, repConfig, repHome, true);
+
+                repository = (Repository) ctx.lookup(repName);
+            } catch (Exception e) {
+                throw new RepositoryException(e.toString());
+            }
+
+            RepositoryService spi2jcrservice = new RepositoryServiceImpl(repository, new BatchReadConfig());
+            try {
+                RemoteRepositoryService remoteRepoService = new ServerRepositoryService(spi2jcrservice);
+                service = new ClientRepositoryService(remoteRepoService);
+            } catch (RemoteException e) {
+                RepositoryException ex = new RepositoryException(e.getMessage());
+                ex.initCause(e);
+                throw ex;
+            }
+        }
+        return service;
+    }
+
+    public Credentials getAdminCredentials() {
+        if (adminCredentials == null) {
+            adminCredentials = new SimpleCredentials(getProperty(PROP_PREFIX + "." + PROP_ADMIN_NAME),
+                    getProperty(PROP_PREFIX + "." + PROP_ADMIN_PWD).toCharArray());
+        }
+        return adminCredentials;
+    }
+
+    public Credentials getReadOnlyCredentials() {
+        if (readOnlyCredentials == null) {
+            readOnlyCredentials = new SimpleCredentials(getProperty(PROP_PREFIX + "." + PROP_READONLY_NAME),
+                getProperty(PROP_PREFIX + "." + PROP_READONLY_PWD).toCharArray());
+        }
+        return readOnlyCredentials;
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/ServiceStubImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/ServiceStubImpl.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/TestAll.java?rev=677917&view=auto
==============================================================================
--- jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/TestAll.java (added)
+++ jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/TestAll.java Fri Jul 18 07:38:21 2008
@@ -0,0 +1,48 @@
+/*
+ * 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.client;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * <code>TestAll</code>...
+ */
+public class TestAll extends TestCase {
+
+    private static Logger log = LoggerFactory.getLogger(TestAll.class);
+
+    public static Test suite() {
+
+        TestSuite suite = new TestSuite("jcr2spi and spi tests");
+
+        suite.addTest(org.apache.jackrabbit.jcr2spi.TestAll.suite());
+        suite.addTest(org.apache.jackrabbit.jcr2spi.lock.TestAll.suite());
+        suite.addTest(org.apache.jackrabbit.jcr2spi.name.TestAll.suite());
+        suite.addTest(org.apache.jackrabbit.jcr2spi.nodetype.TestAll.suite());
+        suite.addTest(org.apache.jackrabbit.jcr2spi.query.TestAll.suite());
+        suite.addTest(org.apache.jackrabbit.jcr2spi.version.TestAll.suite());
+        suite.addTest(org.apache.jackrabbit.jcr2spi.xml.TestAll.suite());
+
+        suite.addTest(org.apache.jackrabbit.spi.TestAll.suite());
+
+        return suite;
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/TestAll.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/TestAll.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/sandbox/spi/client/src/test/resources/repositoryServiceStubImpl.properties
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/client/src/test/resources/repositoryServiceStubImpl.properties?rev=677917&view=auto
==============================================================================
--- jackrabbit/sandbox/spi/client/src/test/resources/repositoryServiceStubImpl.properties (added)
+++ jackrabbit/sandbox/spi/client/src/test/resources/repositoryServiceStubImpl.properties Fri Jul 18 07:38:21 2008
@@ -0,0 +1,34 @@
+#  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.
+
+#
+# This is the configuration file for the jackrabbit repositoryservice test stub.
+#
+
+# the ServiceStubImpl used for SPI tests.
+org.apache.jackrabbit.spi.repository_service_stub_impl=org.apache.jackrabbit.client.ServiceStubImpl
+
+org.apache.jackrabbit.spi.admin.pwd=admin
+org.apache.jackrabbit.spi.admin.name=admin
+org.apache.jackrabbit.spi.readonly.pwd=anonymous
+org.apache.jackrabbit.spi.readonly.name=
+org.apache.jackrabbit.spi.workspacename=default
+
+
+# config for jackrabbit repository implementation when testing SPI2JCR
+org.apache.jackrabbit.client.config=src/test/resources/repository.xml
+org.apache.jackrabbit.client.name=repo
+org.apache.jackrabbit.client.home=target/client-home
+org.apache.jackrabbit.client.jaas.config=src/test/resources/jaas.config

Propchange: jackrabbit/sandbox/spi/client/src/test/resources/repositoryServiceStubImpl.properties
------------------------------------------------------------------------------
    svn = 

Propchange: jackrabbit/sandbox/spi/client/src/test/resources/repositoryServiceStubImpl.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/sandbox/spi/client/src/test/resources/repositoryStubImpl.properties
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/client/src/test/resources/repositoryStubImpl.properties?rev=677917&r1=677916&r2=677917&view=diff
==============================================================================
--- jackrabbit/sandbox/spi/client/src/test/resources/repositoryStubImpl.properties (original)
+++ jackrabbit/sandbox/spi/client/src/test/resources/repositoryStubImpl.properties Fri Jul 18 07:38:21 2008
@@ -18,22 +18,22 @@
 #
 
 # Stub implementation class for testing JCR2SPI on spi2dav
-#javax.jcr.tck.repository_stub_impl=org.apache.jackrabbit.jcr2spi.JCR2SPIRepositoryStub
+#javax.jcr.tck.repository_stub_impl=org.apache.jackrabbit.client.JCR2SPIRepositoryStub
 
 # Use this stub implementation instead for testing SPI2JCR on Jackrabbit
-#javax.jcr.tck.repository_stub_impl=org.apache.jackrabbit.jcr2spi.JCR2SPI2JCRRepositoryStub
+#javax.jcr.tck.repository_stub_impl=org.apache.jackrabbit.client.JCR2SPI2JCRRepositoryStub
 
 # Use this stub implementation instead for testing SPI-RMI on Jackrabbit with SPI2JCR
-javax.jcr.tck.repository_stub_impl=org.apache.jackrabbit.jcr2spi.JCR2SPI2JCROverRMIRepositoryStub
+javax.jcr.tck.repository_stub_impl=org.apache.jackrabbit.client.JCR2SPI2JCROverRMIRepositoryStub
 
 # Use this stub implementation instead for testing SPI-RMI using a stand-alone server
-#javax.jcr.tck.repository_stub_impl=org.apache.jackrabbit.jcr2spi.JCR2SPIOverRMIRepositoryStub
+#javax.jcr.tck.repository_stub_impl=org.apache.jackrabbit.client.JCR2SPIOverRMIRepositoryStub
 
 # Use this stub implementation for test the JCR api via RMI
-#javax.jcr.tck.repository_stub_impl=org.apache.jackrabbit.jcr2spi.RMIRepositoryStub
+#javax.jcr.tck.repository_stub_impl=org.apache.jackrabbit.client.RMIRepositoryStub
 
 # Use this stub implementation for testing Jackrabbit-Core over JNDI without intermediate SPI
-# javax.jcr.tck.repository_stub_impl=org.apache.jackrabbit.jcr2spi.DefaultRepositoryStub
+# javax.jcr.tck.repository_stub_impl=org.apache.jackrabbit.client.DefaultRepositoryStub
 
 # config for JCR2SPIRepositoryStub (SPI2DAV)
 org.apache.jackrabbit.jcr2spi.repository.url=http://localhost:4302/jackrabbit/server/



Mime
View raw message