jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r654542 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/test: java/org/apache/jackrabbit/jcr2spi/UpdateTest.java resources/repositoryStubImpl.properties
Date Thu, 08 May 2008 14:53:32 GMT
Author: angela
Date: Thu May  8 07:53:32 2008
New Revision: 654542

URL: http://svn.apache.org/viewvc?rev=654542&view=rev
Log:
JCR-1578: Jcr2Spi: UpdateTest#testUpdateRemovesExtraProperty and #testUpdateAddsMissingSubtree
fail occasionally

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/UpdateTest.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/resources/repositoryStubImpl.properties

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/UpdateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/UpdateTest.java?rev=654542&r1=654541&r2=654542&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/UpdateTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/UpdateTest.java
Thu May  8 07:53:32 2008
@@ -30,6 +30,7 @@
 import javax.jcr.ItemExistsException;
 import javax.jcr.Session;
 import javax.jcr.Property;
+import javax.jcr.PathNotFoundException;
 import javax.jcr.version.VersionException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
@@ -45,17 +46,16 @@
     private static Logger log = LoggerFactory.getLogger(UpdateTest.class);
 
     private String currentWorkspace;
-    private String[] accessibleWorkspaces;
 
     protected void setUp() throws Exception {
         super.setUp();
 
         currentWorkspace = testRootNode.getSession().getWorkspace().getName();
-        accessibleWorkspaces = testRootNode.getSession().getWorkspace().getAccessibleWorkspaceNames();
     }
 
     public void testInvalidSrcWorkspace() throws RepositoryException, InvalidItemStateException,
AccessDeniedException {
         String nonExistingWorkspace = "nonExistingWorkspace";
+        String[] accessibleWorkspaces = testRootNode.getSession().getWorkspace().getAccessibleWorkspaceNames();
         List l = Arrays.asList(accessibleWorkspaces);
         while (l.contains(nonExistingWorkspace)) {
             nonExistingWorkspace = nonExistingWorkspace + "_";
@@ -73,14 +73,16 @@
         testRootNode.save();
 
         String srcWorkspace = null;
-        for (int i = 0; i < accessibleWorkspaces.length; i++) {
-            if (!accessibleWorkspaces[i].equals(currentWorkspace)) {
-                try {
-                    n.getCorrespondingNodePath(accessibleWorkspaces[i]);
-                } catch (ItemNotFoundException e) {
-                    srcWorkspace = accessibleWorkspaces[i];
-                }
-            }
+        String wspName = helper.getProperty("org.apache.jackrabbit.jcr2spi.workspace2.name");
+        if (wspName == null) {
+            throw new NotExecutableException("Cannot run update. Missing config param.");
+        }
+        try {
+            n.getCorrespondingNodePath(wspName);
+        } catch (ItemNotFoundException e) {
+            srcWorkspace = wspName;
+        } catch (RepositoryException e) {
+            throw new NotExecutableException("Cannot run update. Workspace " + srcWorkspace
+ " does not exist or is not accessible.");
         }
         if (srcWorkspace == null) {
             throw new NotExecutableException("Cannot run update. No workspace found, that
misses the corresponding node.");
@@ -132,8 +134,8 @@
             if (root.isSame(testRootNode)) {
                 throw new NotExecutableException();
             }
-            if (root.canAddMixin("mixLockable")) {
-                root.addMixin("mixLockable");
+            if (root.canAddMixin(mixLockable)) {
+                root.addMixin(mixLockable);
             } else {
                 root.setProperty(propertyName1, "anyValue");
             }
@@ -170,6 +172,10 @@
 
             // ok first check if node has no longer propertis
             assertFalse("Node updated with Node.update() should have property removed", testRootNode.hasProperty(propertyName2));
+        } catch (PathNotFoundException e) {
+            throw new NotExecutableException();
+        } catch (ItemNotFoundException e) {
+            throw new NotExecutableException();
         } finally {
             session2.logout();
         }
@@ -199,21 +205,27 @@
                     testRootNode.hasProperty(nodeName1+"/"+propertyName2) &&
                     testRootNode.hasProperty(propertyName1);
             assertTrue("Node updated with Node.update() should have received childrens",
allPresent);
+        } catch (PathNotFoundException e) {
+            throw new NotExecutableException();
+        } catch (ItemNotFoundException e) {
+            throw new NotExecutableException();
         } finally {
             session2.logout();
         }
     }
 
-    private String getAnotherWorkspace() throws NotExecutableException {
-        String srcWorkspace = null;
-        for (int i = 0; i < accessibleWorkspaces.length; i++) {
-            if (!accessibleWorkspaces[i].equals(currentWorkspace)) {
-                srcWorkspace = accessibleWorkspaces[i];
-            }
+    private String getAnotherWorkspace() throws NotExecutableException, RepositoryException
{
+        String srcWorkspace = helper.getProperty("org.apache.jackrabbit.jcr2spi.workspace2.name");;
+        if (srcWorkspace == null || srcWorkspace.equals(currentWorkspace)) {
+            throw new NotExecutableException("no alternative workspace configured");
         }
-        if (srcWorkspace == null) {
-            throw new NotExecutableException("Cannot run update. No workspace found, that
misses the corresponding node.");
+
+        String[] accessible = testRootNode.getSession().getWorkspace().getAccessibleWorkspaceNames();
+        for (int i = 0; i < accessible.length; i++) {
+            if (accessible[i].equals(srcWorkspace)) {
+                return srcWorkspace;
+            }
         }
-        return srcWorkspace;
+        throw new NotExecutableException("configured workspace does not exist.");
     }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/resources/repositoryStubImpl.properties
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/resources/repositoryStubImpl.properties?rev=654542&r1=654541&r2=654542&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/resources/repositoryStubImpl.properties (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/resources/repositoryStubImpl.properties Thu
May  8 07:53:32 2008
@@ -37,7 +37,11 @@
 
 # config for JCR2SPIRepositoryStub (SPI2DAV)
 org.apache.jackrabbit.jcr2spi.repository.url=http://localhost:4302/jackrabbit/server/
+
+# name of the default workspace
 org.apache.jackrabbit.jcr2spi.workspace.name=default
+# alternative workspace used for update tests etc.
+org.apache.jackrabbit.jcr2spi.workspace2.name=test
 
 # config for jackrabbit repository implementation when testing SPI2JCR
 org.apache.jackrabbit.repository.config=src/test/resources/repository.xml



Mime
View raw message