jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r125412 - in incubator/jackrabbit/trunk: applications/test src/test/org/apache/jackrabbit/test
Date Mon, 17 Jan 2005 13:46:41 GMT
Author: mreutegg
Date: Mon Jan 17 05:46:38 2005
New Revision: 125412

URL: http://svn.apache.org/viewcvs?view=rev&rev=125412
Log:
Extended RepositoryHelper to retrieve sessions for a specific named workspace
Modified:
   incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties
   incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java
   incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryHelper.java
   incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryStub.java

Modified: incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties?view=diff&rev=125412&p1=incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties&r1=125411&p2=incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties&r2=125412
==============================================================================
--- incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties	(original)
+++ incubator/jackrabbit/trunk/applications/test/repositoryStubImpl.properties	Mon Jan 17
05:46:38 2005
@@ -19,6 +19,7 @@
 javax.jcr.tck.nodename1=foo
 javax.jcr.tck.nodename2=bar
 javax.jcr.tck.nodename3=foobar
+javax.jcr.tck.workspacename=default
 
 # sample for per test case config overriding
 # Test class: AddNodeText

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java?view=diff&rev=125412&p1=incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java&r1=125411&p2=incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java&r2=125412
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java	(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java	Mon
Jan 17 05:46:38 2005
@@ -71,6 +71,11 @@
     protected String nodeName3;
 
     /**
+     * Name of a workspace to use instead of the default workspace.
+     */
+    protected String workspaceName;
+
+    /**
      * The superuser session
      */
     protected Session superuser;
@@ -101,6 +106,10 @@
         nodeName3 = getProperty(RepositoryStub.PROP_NODE_NAME3);
         if (nodeName3 == null) {
             fail("Property '" + RepositoryStub.PROP_NODE_NAME3 + "' is not defined.");
+        }
+        workspaceName = getProperty(RepositoryStub.PROP_WORKSPACE_NAME);
+        if (workspaceName == null) {
+            fail("Property '" + RepositoryStub.PROP_WORKSPACE_NAME + "' is not defined.");
         }
 
         superuser = helper.getSuperuserSession();

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryHelper.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryHelper.java?view=diff&rev=125412&p1=incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryHelper.java&r1=125411&p2=incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryHelper.java&r2=125412
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryHelper.java	(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryHelper.java	Mon
Jan 17 05:46:38 2005
@@ -21,10 +21,15 @@
 import javax.jcr.Session;
 
 /**
- *
+ * Utility class to get access to {@link javax.jcr.Session} instances.
  */
 public class RepositoryHelper {
 
+    /**
+     * Returns the repository instance to test.
+     * @return the repository instance to test.
+     * @throws RepositoryException if the repository could not be obtained.
+     */
     public Repository getRepository() throws RepositoryException {
         try {
             RepositoryStub repStub = RepositoryStub.getInstance();
@@ -34,33 +39,95 @@
         }
     }
 
+    /**
+     * Returns a superuser <code>Session</code> of the default workspace. The
+     * returned <code>Session</code> has read and write access to the whole
+     * workspace.
+     * @return a superuser <code>Session</code>.
+     * @throws RepositoryException if login to the repository failed.
+     */
     public Session getSuperuserSession() throws RepositoryException {
+        return getSuperuserSession(null);
+    }
+
+    /**
+     * Returns a superuser <code>Session</code> of the workspace with name
+     * <code>workspaceName</code>. The returned <code>Session</code>
has read
+     * and write access to the whole workspace.
+     * @return a superuser <code>Session</code>.
+     * @throws RepositoryException if login to the repository failed.
+     */
+    public Session getSuperuserSession(String workspaceName) throws RepositoryException {
         try {
             RepositoryStub repStub = RepositoryStub.getInstance();
-            return repStub.getRepository().login(repStub.getSuperuserCredentials(), null);
+            return repStub.getRepository().login(repStub.getSuperuserCredentials(), workspaceName);
         } catch (RepositoryStubException e) {
             throw new RepositoryException("Failed to login to Repository.", e);
         }
     }
 
+    /**
+     * Returns a <code>Session</code> of the default workspace with read and
+     * write access to the workspace.
+     * @return a <code>Session</code> with read and write access.
+     * @throws RepositoryException if login to the repository failed.
+     */
     public Session getReadWriteSession() throws RepositoryException {
+        return getReadWriteSession(null);
+    }
+
+    /**
+     * Returns a <code>Session</code> of the workspace with name
+     * <code>workspaceName</code> with read and write access to the workspace.
+     * @return a <code>Session</code> with read and write access.
+     * @throws RepositoryException if login to the repository failed.
+     */
+    public Session getReadWriteSession(String workspaceName) throws RepositoryException {
         try {
             RepositoryStub repStub = RepositoryStub.getInstance();
-            return repStub.getRepository().login(repStub.getReadWriteCredentials(), null);
+            return repStub.getRepository().login(repStub.getReadWriteCredentials(), workspaceName);
         } catch (RepositoryStubException e) {
             throw new RepositoryException("Failed to login to Repository.", e);
         }
     }
 
+    /**
+     * Returns a <code>Session</code> of the default workspace with read only
+     * access to the workspace.
+     * @return a <code>Session</code> with read only.
+     * @throws RepositoryException if login to the repository failed.
+     */
     public Session getReadOnlySession() throws RepositoryException {
+        return getReadOnlySession(null);
+    }
+
+    /**
+     * Returns a <code>Session</code> of the workspace with name
+     * <code>workspaceName</code> with read only access to the workspace.
+     * @return a <code>Session</code> with read only access.
+     * @throws RepositoryException if login to the repository failed.
+     */
+    public Session getReadOnlySession(String workspaceName) throws RepositoryException {
         try {
             RepositoryStub repStub = RepositoryStub.getInstance();
-            return repStub.getRepository().login(repStub.getReadOnlyCredentials(), null);
+            return repStub.getRepository().login(repStub.getReadOnlyCredentials(), workspaceName);
         } catch (RepositoryStubException e) {
             throw new RepositoryException("Failed to login to Repository.", e);
         }
     }
 
+    /**
+     * Returns the value of the configuration property with specified
+     * <code>name</code>. If the property does not exist <code>null</code>
is
+     * returned.
+     * <p/>
+     * Configuration properties are defined in the file:
+     * <code>repositoryStubImpl.properties</code>.
+     *
+     * @param name the name of the property to retrieve.
+     * @return the value of the property or <code>null</code> if non existent.
+     * @throws RepositoryException if the configuration file cannot be found.
+     */
     public String getProperty(String name) throws RepositoryException {
         try {
             return RepositoryStub.getInstance().getProperty(name);

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryStub.java
Url: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryStub.java?view=diff&rev=125412&p1=incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryStub.java&r1=125411&p2=incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryStub.java&r2=125412
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryStub.java	(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/RepositoryStub.java	Mon
Jan 17 05:46:38 2005
@@ -66,6 +66,8 @@
 
     public static final String PROP_NODE_NAME3 = "nodename3";
 
+    public static final String PROP_WORKSPACE_NAME = "workspacename";
+
     protected static RepositoryStub instance;
 
     protected final Properties environment;

Mime
View raw message