You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2009/10/21 13:38:44 UTC

svn commit: r827966 [8/15] - in /jackrabbit/sandbox/JCR-1456: ./ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/...

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd Wed Oct 21 11:38:31 2009
@@ -92,7 +92,7 @@
  *
  * @since 1.0
  */
-[nt:resource] > mix:mimeType, mix:lastModified
+[nt:resource] > mix:mimeType, mix:lastModified, mix:referenceable
   primaryitem jcr:data
   - jcr:data (BINARY) mandatory
   
@@ -591,7 +591,6 @@
   + * (rep:Authorizable) = rep:Authorizable protected VERSION
   + * (rep:AuthorizableFolder) = rep:AuthorizableFolder protected VERSION
   - rep:principalName (STRING) protected mandatory
-  - rep:referees (STRING) protected multiple
   - rep:groups (WEAKREFERENCE) protected multiple < 'rep:Group'
   - * (UNDEFINED)
   - * (UNDEFINED) multiple
@@ -601,7 +600,6 @@
   - rep:impersonators (STRING) protected multiple
 
 [rep:User] > rep:Authorizable, rep:Impersonatable
-  - rep:userId (STRING) protected mandatory
   - rep:password (STRING) protected mandatory
 
 [rep:Group] > rep:Authorizable
@@ -617,4 +615,4 @@
 [rep:RetentionManageable]
   mixin
   - rep:hold (UNDEFINED) protected  multiple IGNORE
-  - rep:retentionPolicy (UNDEFINED) protected IGNORE
\ No newline at end of file
+  - rep:retentionPolicy (UNDEFINED) protected IGNORE

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/AuthorizableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/AuthorizableTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/AuthorizableTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/AuthorizableTest.java Wed Oct 21 11:38:31 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.api.security.user;
 
-import org.apache.jackrabbit.api.security.principal.PrincipalIterator;
 import org.apache.jackrabbit.test.NotExecutableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -54,32 +53,6 @@
         assertNotNull(gr.getPrincipal());
     }
 
-    public void testGetPrincipals() throws NotExecutableException, RepositoryException {
-        User user = getTestUser(superuser);
-        assertNotNull(user.getPrincipals());
-        assertTrue(user.getPrincipals().getSize() > 0);
-    }
-
-    public void testGroupGetPrincipals() throws NotExecutableException, RepositoryException {
-        Group gr = getTestGroup(superuser);
-        assertNotNull(gr.getPrincipals());
-        assertTrue(gr.getPrincipals().getSize() > 0);
-    }
-
-    public void testGetPrincipalsContainsPrincipal() throws RepositoryException, NotExecutableException {
-        Authorizable auth = getTestUser(superuser);
-        Principal p = auth.getPrincipal();
-        PrincipalIterator it = auth.getPrincipals();
-
-        while (it.hasNext()) {
-            if (it.nextPrincipal().equals(p)) {
-                // main principal is indeed present in the iterator.
-                return;
-            }
-        }
-        fail("Main principal (Authorizable.getPrincipal()) must be present in the iterator obtained by Authorizable.getPrincipals()");
-    }
-
     public void testSetProperty() throws NotExecutableException, RepositoryException {
         Authorizable auth = getTestUser(superuser);
 
@@ -204,156 +177,16 @@
         }
     }
 
-    public void testAddReferee() throws NotExecutableException, RepositoryException {
-        Authorizable auth = getTestUser(superuser);
-
-        Principal testPrincipal = getTestPrincipal();
-        try {
-            assertTrue(auth.addReferee(testPrincipal));
-        } catch (AuthorizableExistsException e) {
-            throw new NotExecutableException(e.getMessage());
-        } finally {
-            auth.removeReferee(testPrincipal);
-        }
-    }
-
-    public void testAddRefereeTwice() throws NotExecutableException, RepositoryException {
-        Authorizable auth = getTestUser(superuser);
-
-        Principal testPrincipal = getTestPrincipal();
-        try {
-            auth.addReferee(testPrincipal);
-            // adding same principal again must return false;
-            assertFalse(auth.addReferee(testPrincipal));
-        } finally {
-            auth.removeReferee(testPrincipal);
-        }
-    }
-
-    public void testGetPrincipalsExposeReferees() throws NotExecutableException, RepositoryException {
-        Authorizable auth = getTestUser(superuser);
-
-        Principal testPrincipal = getTestPrincipal();
-        try {
-            if (auth.addReferee(testPrincipal)) {
-                // make sure the referee is part of principals-set
-                boolean found = false;
-                for (PrincipalIterator it = auth.getPrincipals(); it.hasNext() && !found;) {
-                    found = testPrincipal.equals(it.nextPrincipal());
-                }
-                assertTrue("The referee added must be part of the 'getPrincipals()' iterator.", found);
-            } else {
-                throw new NotExecutableException();
-            }
-        } finally {
-            auth.removeReferee(testPrincipal);
-        }
-    }
-
-    public void testRemoveReferee() throws NotExecutableException, RepositoryException {
-        Authorizable auth = getTestUser(superuser);
-
-        Principal testPrincipal = getTestPrincipal();
-        try {
-            auth.addReferee(testPrincipal);
-            assertTrue(auth.removeReferee(testPrincipal));
-        } finally {
-            auth.removeReferee(testPrincipal);
-        }
-    }
-
-    public void testRefereeNotFoundByUserManager() throws NotExecutableException, RepositoryException {
-        Authorizable auth = getTestUser(superuser);
-        Principal testPrincipal = getTestPrincipal();
-
-        try {
-            assertTrue(auth.addReferee(testPrincipal));
-            Authorizable a = userMgr.getAuthorizable(testPrincipal);
-            assertNull(a);
-        } catch (RepositoryException e) {
-            auth.removeReferee(testPrincipal);
-        }
-    }
-
-    public void testAddExistingReferee() throws NotExecutableException, RepositoryException {
-        Authorizable auth = getTestUser(superuser);
-        Authorizable auth2 = getTestGroup(superuser);
-        Principal testPrincipal = getTestPrincipal();
-        try {
-            try {
-                assertTrue(auth.addReferee(testPrincipal));
-            } catch (AuthorizableExistsException e) {
-                throw new NotExecutableException(e.getMessage());
-            }
-
-            // adding same principal to another authorizable must fail
-            try {
-                auth2.addReferee(testPrincipal);
-                fail("Adding an existing referee-principal to another authorizable must fail.");
-            } catch (AuthorizableExistsException e) {
-                // success
-            }
-        } finally {
-            auth.removeReferee(testPrincipal);
-            auth2.removeReferee(testPrincipal);
-        }
-    }
-
-    public void testAddMainPrincipalAsReferee() throws NotExecutableException, RepositoryException {
-        Authorizable auth = getTestUser(superuser);
-        Principal mainPrinc = auth.getPrincipal();
-        try {
-            // adding main principal as referee to another authorizable must
-            // return false
-            assertFalse(auth.addReferee(mainPrinc));
-        } finally {
-            auth.removeReferee(mainPrinc);
-        }
-    }
-
-    public void testAddMainPrincipalAsOthersReferee() throws NotExecutableException, RepositoryException {
-        Authorizable auth = getTestUser(superuser);
-        Authorizable auth2 = getTestGroup(superuser);
-        Principal mainPrinc = auth.getPrincipal();
-        try {
-            // adding main principal as referee to another authorizable must fail
-            try {
-                auth2.addReferee(mainPrinc);
-                fail("Adding an existing main-principal as referee to another authorizable must fail.");
-            } catch (AuthorizableExistsException e) {
-                // success
-            }
-        } finally {
-            auth2.removeReferee(mainPrinc);
-        }
-    }
-
-    public void testRemoveNotExistingReferee() throws NotExecutableException, RepositoryException {
-        Authorizable auth = getTestUser(superuser);
-        Principal testPrincipal = getTestPrincipal();
-
-        if (userMgr.getAuthorizable(testPrincipal) != null) {
-            throw new NotExecutableException("test principal " + testPrincipal.getName() + " already associated with an authorizable.");
-        }
-        for (PrincipalIterator it = auth.getPrincipals(); it.hasNext();) {
-            if (it.nextPrincipal().getName().equals(testPrincipal.getName())) {
-                throw new NotExecutableException("test principal " + testPrincipal.getName() + " already referee.");
-            }
-        }
-        assertFalse(auth.removeReferee(testPrincipal));
-    }
-
     /**
      * Removing an authorizable that is still listed as member of a group.
      */
-    /*
     public void testRemoveListedAuthorizable() throws RepositoryException, NotExecutableException {
         String newUserId = null;
         Group newGroup = null;
 
         try {
             Principal uP = getTestPrincipal();
-            User newUser = userMgr.createUser(uP.getName(), buildCredentials(uP), uP);
+            User newUser = userMgr.createUser(uP.getName(), uP.getName());
             newUserId = newUser.getID();
 
             newGroup = userMgr.createGroup(getTestPrincipal());
@@ -376,5 +209,4 @@
             }
         }
     }
-    */
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerCreateUserTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerCreateUserTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerCreateUserTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerCreateUserTest.java Wed Oct 21 11:38:31 2009
@@ -109,7 +109,6 @@
 
     public void testCreateUserWithNullUserID() throws RepositoryException {
         try {
-            Principal p = getTestPrincipal();
             User user = userMgr.createUser(null, "anyPW");
             createdUsers.add(user);
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/NodeImplTest.java Wed Oct 21 11:38:31 2009
@@ -19,6 +19,7 @@
 import org.apache.jackrabbit.api.security.JackrabbitAccessControlList;
 import org.apache.jackrabbit.test.AbstractJCRTest;
 import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.test.api.nodetype.NodeTypeUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -26,7 +27,10 @@
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
 import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.security.AccessControlManager;
 import javax.jcr.security.AccessControlPolicy;
 import javax.jcr.security.AccessControlPolicyIterator;
@@ -34,6 +38,7 @@
 import java.security.Principal;
 import java.security.acl.Group;
 import java.util.Iterator;
+import java.util.Calendar;
 
 /** <code>NodeImplTest</code>... */
 public class NodeImplTest extends AbstractJCRTest {
@@ -153,4 +158,51 @@
         }
     }
 
+    /**
+     * Test case for JCR-2336. Setting jcr:data (of type BINARY) must convert
+     * the String value to a binary.
+     *
+     * @throws RepositoryException -
+     */
+    public void testSetPropertyConvertValue() throws RepositoryException {
+        Node content = testRootNode.addNode("jcr:content", "nt:resource");
+        content.setProperty("jcr:lastModified", Calendar.getInstance());
+        content.setProperty("jcr:mimeType", "text/plain");
+        content.setProperty("jcr:data", "Hello");
+        superuser.save();
+    }
+
+    public void testSetPropertyConvertToString() throws RepositoryException {
+        Node n = testRootNode.addNode(nodeName1, "nt:folder");
+        n.addMixin("mix:title");
+        // must convert to string there is no other definition for this property
+        Property p = n.setProperty("jcr:title", 123);
+        assertEquals(PropertyType.nameFromValue(PropertyType.STRING),
+                PropertyType.nameFromValue(p.getType()));
+    }
+
+    public void testSetPropertyExplicitType() throws RepositoryException {
+        Node n = testRootNode.addNode(nodeName1, ntUnstructured);
+        n.addMixin("mix:title");
+        Property p = n.setProperty("jcr:title", "foo");
+        assertEquals(PropertyType.nameFromValue(PropertyType.STRING),
+                PropertyType.nameFromValue(p.getType()));
+        assertEquals(PropertyType.nameFromValue(PropertyType.STRING),
+                PropertyType.nameFromValue(p.getDefinition().getRequiredType()));
+        p.remove();
+        // must use residual definition from nt:unstructured
+        p = n.setProperty("jcr:title", 123);
+        assertEquals(PropertyType.nameFromValue(PropertyType.LONG),
+                PropertyType.nameFromValue(p.getType()));
+        assertEquals(PropertyType.nameFromValue(PropertyType.UNDEFINED),
+                PropertyType.nameFromValue(p.getDefinition().getRequiredType()));
+    }
+
+    public void testSetPropertyConvertMultiValued() throws RepositoryException {
+        Node n = testRootNode.addNode(nodeName1, "test:canSetProperty");
+        // must convert to long there is no other definition for this property
+        Property p = n.setProperty("LongMultiple", new String[]{"123", "456"});
+        assertEquals(PropertyType.nameFromValue(PropertyType.LONG),
+                PropertyType.nameFromValue(p.getType()));
+    }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java Wed Oct 21 11:38:31 2009
@@ -44,6 +44,7 @@
         suite.addTestSuite(InvalidDateTest.class);
         suite.addTestSuite(SessionGarbageCollectedTest.class);
         suite.addTestSuite(ReferencesTest.class);
+        suite.addTestSuite(ReplaceTest.class);
 
         // test related to NodeStateMerger
         // temporarily disabled see JCR-2272 and JCR-2295

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/UserTransactionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/UserTransactionImpl.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/UserTransactionImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/UserTransactionImpl.java Wed Oct 21 11:38:31 2009
@@ -16,6 +16,10 @@
  */
 package org.apache.jackrabbit.core;
 
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 import javax.transaction.xa.XAException;
@@ -41,14 +45,9 @@
     private static byte counter = 0;
 
     /**
-     * XAResource
-     */
-    private final XAResource xares;
-
-    /**
-     * Xid
+     * The XAResources map
      */
-    private Xid xid;
+    private Map xaResources = new HashMap();
 
     /**
      * Status
@@ -75,7 +74,8 @@
      */
     public UserTransactionImpl(Session session, boolean distributedThreadAccess) {
         if (session instanceof XASession) {
-            xares = ((XASession) session).getXAResource();
+            counter++;
+            xaResources.put(((XASession) session).getXAResource(), new XidImpl(counter));
             this.distributedThreadAccess = distributedThreadAccess; 
         } else {
             throw new IllegalArgumentException("Session not of type XASession");
@@ -83,6 +83,14 @@
     }
 
     /**
+     * Enlists the given Session to this UserTransaction
+     * @param session
+     */
+    public void enlistXAResource(Session session) {
+        xaResources.put(session, new XidImpl(counter));
+    }
+
+    /**
      * @see javax.transaction.UserTransaction#begin
      */
     public void begin() throws NotSupportedException, SystemException {
@@ -91,8 +99,11 @@
         }
 
         try {
-            xid = new XidImpl(counter++);
-            xares.start(xid, XAResource.TMNOFLAGS);
+            for (Iterator it = xaResources.keySet().iterator(); it.hasNext(); ) {
+                XAResource resource = (XAResource) it.next();
+                XidImpl xid = (XidImpl) xaResources.get(resource);
+                resource.start(xid, XAResource.TMNOFLAGS);
+            }
             status = Status.STATUS_ACTIVE;
 
         } catch (XAException e) {
@@ -114,32 +125,47 @@
         }
 
         try {
-            xares.end(xid, XAResource.TMSUCCESS);
+            for (Iterator it = xaResources.keySet().iterator(); it.hasNext(); ) {
+                XAResource resource = (XAResource) it.next();
+                XidImpl xid = (XidImpl) xaResources.get(resource);
+                resource.end(xid, XAResource.TMSUCCESS);
+            }
 
             status = Status.STATUS_PREPARING;
-            xares.prepare(xid);
+            for (Iterator it = xaResources.keySet().iterator(); it.hasNext(); ) {
+                XAResource resource = (XAResource) it.next();
+                XidImpl xid = (XidImpl) xaResources.get(resource);
+                resource.prepare(xid);
+            }
             status = Status.STATUS_PREPARED;
 
             status = Status.STATUS_COMMITTING;
             if (distributedThreadAccess) {
-                try {
-                    Thread distributedThread = new Thread() {
-                        public void run() {
-                            try {
-                                xares.commit(xid, false);
-                            } catch (Exception e) {
-                                throw new RuntimeException(e.getMessage());
+                Thread distributedThread = new Thread() {
+                    public void run() {
+                        try {
+                            for (Iterator it = xaResources.keySet().iterator(); it.hasNext(); ) {
+                                XAResource resource = (XAResource) it.next();
+                                XidImpl xid = (XidImpl) xaResources.get(resource);
+                                resource.commit(xid, false);
                             }
+                        } catch (Exception e) {
+                            throw new RuntimeException(e.getMessage());
                         }
-                    };
-                    distributedThread.start();
-                    distributedThread.join(1000);
-                } catch (InterruptedException e) {
+                    }
+                };
+                distributedThread.start();
+                distributedThread.join(1000);
+                if (distributedThread.isAlive()) {
                     throw new SystemException(
                             "Commit from different thread but same XID must not block");
                 }
             } else {
-                xares.commit(xid, false);
+                for (Iterator it = xaResources.keySet().iterator(); it.hasNext(); ) {
+                    XAResource resource = (XAResource) it.next();
+                    XidImpl xid = (XidImpl) xaResources.get(resource);
+                    resource.commit(xid, false);
+                }
             }
             
             status = Status.STATUS_COMMITTED;
@@ -158,6 +184,8 @@
                 se.initCause(e.getCause());
                 throw se;
             }
+        } catch (InterruptedException e) {
+            throw new SystemException("Thread.join() interrupted");
         }
     }
 
@@ -181,10 +209,18 @@
         }
 
         try {
-            xares.end(xid, XAResource.TMFAIL);
+            for (Iterator it = xaResources.keySet().iterator(); it.hasNext(); ) {
+                XAResource resource = (XAResource) it.next();
+                XidImpl xid = (XidImpl) xaResources.get(resource);
+                resource.end(xid, XAResource.TMFAIL);
+            }
 
             status = Status.STATUS_ROLLING_BACK;
-            xares.rollback(xid);
+            for (Iterator it = xaResources.keySet().iterator(); it.hasNext(); ) {
+                XAResource resource = (XAResource) it.next();
+                XidImpl xid = (XidImpl) xaResources.get(resource);
+                resource.rollback(xid);
+            }
             status = Status.STATUS_ROLLEDBACK;
 
         } catch (XAException e) {
@@ -210,7 +246,9 @@
      */
     public void setTransactionTimeout(int seconds) throws SystemException {
         try {
-            xares.setTransactionTimeout(seconds);
+            for (Iterator it = xaResources.keySet().iterator(); it.hasNext(); ) {
+                ((XAResource) it.next()).setTransactionTimeout(seconds);
+            }
         } catch (XAException e) {
             SystemException se = new SystemException(
                     "Unable to set the TransactionTiomeout: XA_ERR=" + e.errorCode);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/XATest.java Wed Oct 21 11:38:31 2009
@@ -828,6 +828,79 @@
             other.logout();
         }
     }
+    
+    /**
+     * Test locking and unlocking behavior in transaction
+     * (see JCR-2356)
+     * @throws Exception
+     */
+    public void testCreateLockUnlockInDifferentTransactions() throws Exception {
+        // create new node and lock it
+        UserTransaction utx = new UserTransactionImpl(superuser);
+        utx.begin();
+
+        // add node that is both lockable and referenceable, save
+        Node rootNode = superuser.getRootNode(); 
+        Node n = rootNode.addNode(nodeName1);
+        n.addMixin(mixLockable);
+        n.addMixin(mixReferenceable);
+        rootNode.save();
+        
+        String uuid = n.getUUID();
+        
+        // commit
+        utx.commit();
+        
+        // start new Transaction and try to add lock token
+        utx = new UserTransactionImpl(superuser);
+        utx.begin();
+        
+        n = superuser.getNodeByUUID(uuid);
+        // lock this new node
+        Lock lock = n.lock(true, false);
+        
+        // verify node is locked
+        assertTrue("Node not locked", n.isLocked());
+        
+        String lockToken = lock.getLockToken();
+        // assert: session must get a non-null lock token
+        assertNotNull("session must get a non-null lock token", lockToken);
+        // assert: session must hold lock token
+        assertTrue("session must hold lock token", containsLockToken(superuser, lockToken));
+
+        n.save();
+
+        superuser.removeLockToken(lockToken);
+        assertNull("session must get a null lock token", lock.getLockToken());
+        assertFalse("session must not hold lock token", containsLockToken(superuser, lockToken));
+        
+        // commit
+        utx.commit();
+
+        assertFalse("session must not hold lock token", containsLockToken(superuser, lockToken));
+        assertNull("session must get a null lock token", lock.getLockToken());
+
+        // start new Transaction and try to unlock
+        utx = new UserTransactionImpl(superuser);
+        utx.begin();
+
+        n = superuser.getNodeByUUID(uuid);
+
+        // verify node is locked
+        assertTrue("Node not locked", n.isLocked());
+        // assert: session must not hold lock token
+        assertFalse("session must not hold lock token", containsLockToken(superuser, lockToken));
+        
+        superuser.addLockToken(lockToken);
+        
+        // assert: session must not hold lock token
+        assertTrue("session must hold lock token", containsLockToken(superuser, lockToken));
+
+        n.unlock();
+        
+        // commit
+        utx.commit();
+    }
 
     /**
      * Test locking a node in one session. Verify that node is not locked
@@ -1643,7 +1716,165 @@
             fail("Committed node not visible in this session");
         }
     }
+    
+    /**
+     * Tests two different Sessions in one Transaction
+     * (see JCR-769)
+     */
+    public void testTwoSessionsInOneTransaction() throws Exception {
+        Session otherSuperuser = getHelper().getSuperuserSession();
+        
+        // get user transaction object
+        UserTransactionImpl utx = new UserTransactionImpl(superuser, true);
+        utx.enlistXAResource(otherSuperuser);
+        
+        // start transaction
+        utx.begin();
+
+        Node rootNode = superuser.getRootNode();
+        // add node and save
+        Node n = rootNode.addNode(nodeName1, testNodeType);
+        n.addMixin(mixReferenceable);
+        rootNode.save();
+
+        // assertion: node exists in this session
+        try {
+            superuser.getNodeByUUID(n.getUUID());
+        } catch (ItemNotFoundException e) {
+            fail("New node not visible after save()");
+        }
+
+        // assertion: node does exist in other session
+        try {
+            otherSuperuser.getNodeByUUID(n.getUUID());
+            fail("Uncommitted node visible for other session");
+        } catch (ItemNotFoundException e) {
+            /* expected */
+        }
+
+        // add node with other session and save
+        rootNode = otherSuperuser.getRootNode();
+        Node n1 = rootNode.addNode(nodeName2, testNodeType);
+        n1.addMixin(mixReferenceable);
+        rootNode.save();
+
+        // assertion: node exists in this session
+        try {
+            otherSuperuser.getNodeByUUID(n1.getUUID());
+        } catch (ItemNotFoundException e) {
+            fail("New node not visible after save()");
+        }
+
+        // assertion: node does exist in other session
+        try {
+            superuser.getNodeByUUID(n1.getUUID());
+            fail("Uncommitted node visible for other session");
+        } catch (ItemNotFoundException e) {
+            /* expected */
+        }
+
+        
+        // commit
+        utx.commit();
+
+        // assertion: node exists in this session
+        try {
+            superuser.getNodeByUUID(n.getUUID());
+        } catch (ItemNotFoundException e) {
+            fail("Committed node not visible in this session");
+        }
+
+        // assertion: node also exists in other session
+        try {
+            otherSuperuser.getNodeByUUID(n.getUUID());
+        } catch (ItemNotFoundException e) {
+            fail("Committed node not visible in the other session");
+        }
+
+        // assertion: node1 exists in this session
+        try {
+            superuser.getNodeByUUID(n1.getUUID());
+        } catch (ItemNotFoundException e) {
+            fail("Committed node not visible in this session");
+        }
+
+        // assertion: node1 also exists in other session
+        try {
+            otherSuperuser.getNodeByUUID(n1.getUUID());
+        } catch (ItemNotFoundException e) {
+            fail("Committed node not visible in this session");
+        }
+
+        // logout
+        superuser.logout();
+        otherSuperuser.logout();
+    }
+    
+    /**
+     * Test add lock token and remove node in in a transaction
+     * (see JCR-2332) 
+     * @throws Exception
+     */
+    public void testAddLockTokenRemoveNode() throws Exception {
+        // create new node and lock it
+        UserTransaction utx = new UserTransactionImpl(superuser);
+        utx.begin();
+
+        // add node that is both lockable and referenceable, save
+        Node rootNode = superuser.getRootNode(); 
+        Node n = rootNode.addNode(nodeName1);
+        n.addMixin(mixLockable);
+        n.addMixin(mixReferenceable);
+        rootNode.save();
+
+        String uuid = n.getUUID();
+        
+        // lock this new node
+        Lock lock = n.lock(true, false);
+        String lockToken = lock.getLockToken();
+        
+        // assert: session must get a non-null lock token
+        assertNotNull("session must get a non-null lock token", lockToken);
+
+        // assert: session must hold lock token
+        assertTrue("session must hold lock token", containsLockToken(superuser, lockToken));
+
+        superuser.removeLockToken(lockToken);
+        assertNull("session must get a null lock token", lock.getLockToken());
+        
+        // commit
+        utx.commit();
+        
+        // refresh Lock Info
+        lock = n.getLock();
+
+        assertNull("session must get a null lock token", lock.getLockToken());
+
+        Session other = getHelper().getSuperuserSession();
+        // start new Transaction and try to add lock token unlock the node and then remove it
+        utx = new UserTransactionImpl(other);
+        utx.begin();
+        
+        Node otherNode = other.getNodeByUUID(uuid); 
+        assertTrue("Node not locked", otherNode.isLocked());
+        // add lock token
+        other.addLockToken(lockToken);
+      
+        // refresh Lock Info
+        lock = otherNode.getLock();
 
+        // assert: session must hold lock token
+        assertTrue("session must hold lock token", containsLockToken(other, lock.getLockToken()));        
+        
+        otherNode.unlock();
+        
+        assertFalse("Node is locked", otherNode.isLocked());
+        
+        otherNode.remove();
+        other.save();
+        utx.commit();
+    }
+    
     /**
      * Test setting the same property multiple times. Exposes an issue where
      * the same property instance got reused in subsequent transactions

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/ClusterRecordTest.java Wed Oct 21 11:38:31 2009
@@ -17,22 +17,26 @@
 package org.apache.jackrabbit.core.cluster;
 
 import java.util.ArrayList;
-import java.util.Properties;
 
-import org.apache.jackrabbit.core.id.NodeId;
+import javax.jcr.RepositoryException;
+
 import org.apache.jackrabbit.core.cluster.SimpleEventListener.LockEvent;
 import org.apache.jackrabbit.core.cluster.SimpleEventListener.NamespaceEvent;
 import org.apache.jackrabbit.core.cluster.SimpleEventListener.NodeTypeEvent;
 import org.apache.jackrabbit.core.cluster.SimpleEventListener.UnlockEvent;
 import org.apache.jackrabbit.core.cluster.SimpleEventListener.UpdateEvent;
-import org.apache.jackrabbit.core.config.BeanConfig;
 import org.apache.jackrabbit.core.config.ClusterConfig;
-import org.apache.jackrabbit.core.config.JournalConfig;
+import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.journal.Journal;
+import org.apache.jackrabbit.core.journal.JournalFactory;
 import org.apache.jackrabbit.core.journal.MemoryJournal;
-import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
+import org.apache.jackrabbit.core.journal.MemoryJournal.MemoryRecord;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+import org.apache.jackrabbit.spi.commons.nodetype.QNodeTypeDefinitionBuilder;
 import org.apache.jackrabbit.test.JUnitTest;
 
 /**
@@ -59,7 +63,7 @@
     /**
      * Records shared among multiple memory journals.
      */
-    private ArrayList records = new ArrayList();
+    private ArrayList<MemoryRecord> records = new ArrayList<MemoryRecord>();
 
     /**
      * Master.
@@ -175,12 +179,12 @@
      * @throws Exception
      */
     public void testNodeTypeRegistration() throws Exception {
-        NodeTypeDef ntd = new NodeTypeDef();
+        QNodeTypeDefinitionBuilder ntd = new QNodeTypeDefinitionBuilder();
         ntd.setName(NameFactoryImpl.getInstance().create("", "test"));
         ntd.setSupertypes(new Name[]{NameConstants.NT_BASE});
 
-        ArrayList list = new ArrayList();
-        list.add(ntd);
+        ArrayList<QNodeTypeDefinition> list = new ArrayList<QNodeTypeDefinition>();
+        list.add(ntd.build());
 
         NodeTypeEvent event = new NodeTypeEvent(NodeTypeEvent.REGISTER, list);
         master.registered(event.getCollection());
@@ -198,15 +202,15 @@
      * @throws Exception
      */
     public void testNodeTypeReregistration() throws Exception {
-        NodeTypeDef ntd = new NodeTypeDef();
+        QNodeTypeDefinitionBuilder ntd = new QNodeTypeDefinitionBuilder();
         ntd.setName(NameFactoryImpl.getInstance().create("", "test"));
         ntd.setSupertypes(new Name[]{NameConstants.NT_BASE});
 
-        ArrayList list = new ArrayList();
-        list.add(ntd);
+        ArrayList<QNodeTypeDefinition> list = new ArrayList<QNodeTypeDefinition>();
+        list.add(ntd.build());
 
         NodeTypeEvent event = new NodeTypeEvent(NodeTypeEvent.REREGISTER, list);
-        master.reregistered(ntd);
+        master.reregistered(ntd.build());
 
         SimpleEventListener listener = new SimpleEventListener();
         slave.setListener((NodeTypeEventListener) listener);
@@ -223,7 +227,7 @@
     public void testNodeTypeUnregistration() throws Exception {
         Name name = NameFactoryImpl.getInstance().create("", "test");
 
-        ArrayList list = new ArrayList();
+        ArrayList<Name> list = new ArrayList<Name>();
         list.add(name);
 
         NodeTypeEvent event = new NodeTypeEvent(NodeTypeEvent.UNREGISTER, list);
@@ -277,19 +281,26 @@
      * @param id cluster node id
      * @param records memory journal's list of records
      */
-    private ClusterNode createClusterNode(String id, ArrayList records)
-            throws ClusterException {
-
-        BeanConfig bc = new BeanConfig(MemoryJournal.class.getName(), new Properties());
-        JournalConfig jc = new JournalConfig(bc);
-        ClusterConfig cc = new ClusterConfig(id, SYNC_DELAY, jc);
+    private ClusterNode createClusterNode(
+            String id, ArrayList<MemoryRecord> records) throws Exception {
+        final MemoryJournal journal = new MemoryJournal();
+        JournalFactory jf = new JournalFactory() {
+            public Journal getJournal(NamespaceResolver resolver)
+                    throws RepositoryException {
+                return journal;
+            }
+        };
+        ClusterConfig cc = new ClusterConfig(id, SYNC_DELAY, jf);
         SimpleClusterContext context = new SimpleClusterContext(cc);
 
-        ClusterNode clusterNode = new ClusterNode();
-        clusterNode.init(context);
+        journal.setRepositoryHome(context.getRepositoryHome());
+        journal.init(id, context.getNamespaceResolver());
         if (records != null) {
-            ((MemoryJournal) clusterNode.getJournal()).setRecords(records);
+            journal.setRecords(records);
         }
+
+        ClusterNode clusterNode = new ClusterNode();
+        clusterNode.init(context);
         return clusterNode;
     }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/SimpleEventListener.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/SimpleEventListener.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/SimpleEventListener.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/SimpleEventListener.java Wed Oct 21 11:38:31 2009
@@ -29,9 +29,9 @@
 
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
-import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.state.ChangeLog;
 import org.apache.jackrabbit.core.state.ItemState;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 
 /**
  * Simple event listener that can be registered for all cluster event listener
@@ -206,7 +206,7 @@
     /**
      * {@inheritDoc}
      */
-    public void externalReregistered(NodeTypeDef ntDef)
+    public void externalReregistered(QNodeTypeDefinition ntDef)
             throws NoSuchNodeTypeException, InvalidNodeTypeDefException,
             RepositoryException {
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestAll.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestAll.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/cluster/TestAll.java Wed Oct 21 11:38:31 2009
@@ -38,7 +38,6 @@
         TestSuite suite = new TestSuite();
 
         suite.addTestSuite(ClusterRecordTest.class);
-        suite.addTestSuite(ClusterTest.class);
 
         return suite;
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java Wed Oct 21 11:38:31 2009
@@ -20,6 +20,7 @@
 import org.xml.sax.InputSource;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.input.ClosedInputStream;
+import org.apache.jackrabbit.core.cluster.ClusterNode;
 import org.apache.jackrabbit.core.security.authorization.WorkspaceAccessManager;
 
 import java.io.File;
@@ -259,16 +260,56 @@
         final String id = "testvalue";
         final long syncDelay = 11;
 
-        System.setProperty("cluster.id", id);
+        System.setProperty(ClusterNode.SYSTEM_PROPERTY_NODE_ID, id);
         System.setProperty("cluster.syncDelay", Long.toString(syncDelay));
+        try {
+            InputStream in = getClass().getResourceAsStream(
+                    "/org/apache/jackrabbit/core/cluster/repository.xml");
+            RepositoryConfig config = RepositoryConfig.create(in, DIR.getPath());
+
+            ClusterConfig clusterConfig = config.getClusterConfig();
+            assertEquals(id, clusterConfig.getId());
+            assertEquals(syncDelay, clusterConfig.getSyncDelay());
+        } finally {
+            System.clearProperty(ClusterNode.SYSTEM_PROPERTY_NODE_ID);
+            System.clearProperty("cluster.syncDelay");
+        }
+    }
+
+    public void testAutomaticClusterNodeIdCreation() throws Exception {
+        final long syncDelay = 12;
 
-        InputStream in = getClass().getResourceAsStream(
-                "/org/apache/jackrabbit/core/cluster/repository.xml");
-        RepositoryConfig config = RepositoryConfig.create(in, DIR.getPath());
-
-        ClusterConfig clusterConfig = config.getClusterConfig();
-        assertEquals(id, clusterConfig.getId());
-        assertEquals(syncDelay, clusterConfig.getSyncDelay());
+        System.setProperty("cluster.syncDelay", Long.toString(syncDelay));
+        try {
+            File file = new File(DIR, "cluster_node.id");
+            assertFalse(file.exists());
+
+            // Check that a new cluster node id is automatically persisted
+            InputStream in = getClass().getResourceAsStream(
+                    "/org/apache/jackrabbit/core/cluster/repository.xml");
+            RepositoryConfig config = RepositoryConfig.create(in, DIR.getPath());
+
+            assertTrue(file.exists());
+            String id = FileUtils.readFileToString(file);
+
+            ClusterConfig clusterConfig = config.getClusterConfig();
+            assertEquals(id, clusterConfig.getId());
+            assertEquals(syncDelay, clusterConfig.getSyncDelay());
+
+            // Check that the persisted cluster node id is used when it exists
+            in = getClass().getResourceAsStream(
+                    "/org/apache/jackrabbit/core/cluster/repository.xml");
+            config = RepositoryConfig.create(in, DIR.getPath());
+
+            assertTrue(file.exists());
+            assertEquals(id, FileUtils.readFileToString(file));
+
+            clusterConfig = config.getClusterConfig();
+            assertEquals(id, clusterConfig.getId());
+            assertEquals(syncDelay, clusterConfig.getSyncDelay());
+        } finally {
+            System.clearProperty("cluster.syncDelay");
+        }
     }
 
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/WorkspaceConfigTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/WorkspaceConfigTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/WorkspaceConfigTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/WorkspaceConfigTest.java Wed Oct 21 11:38:31 2009
@@ -58,15 +58,7 @@
                 pmc.getClassName());
         assertTrue(pmc.getParameters().isEmpty());
 
-        SearchConfig sc = config.getSearchConfig();
-        assertEquals(
-                "org.apache.jackrabbit.core.query.lucene.SearchIndex",
-                sc.getClassName());
-        assertEquals(4, sc.getParameters().size());
-        assertEquals("true", sc.getParameters().getProperty("useCompoundFile"));
-        assertEquals("1000", sc.getParameters().getProperty("minMergeDocs"));
-        assertEquals("10000", sc.getParameters().getProperty("maxMergeDocs"));
-        assertEquals("10", sc.getParameters().getProperty("mergeFactor"));
+        assertTrue(config.isSearchEnabled());
 
         WorkspaceSecurityConfig ws = config.getSecurityConfig();
         if (ws != null) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCConcurrentTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCConcurrentTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCConcurrentTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCConcurrentTest.java Wed Oct 21 11:38:31 2009
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.core.data;
 
+import org.apache.jackrabbit.api.management.DataStoreGarbageCollector;
+import org.apache.jackrabbit.api.management.MarkEventListener;
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.test.AbstractJCRTest;
@@ -52,22 +54,19 @@
         final String testNodeName = "testConcurrentDelete";
         node(root, testNodeName);
         session.save();
-        GarbageCollector gc = ((SessionImpl) session).createDataStoreGarbageCollector();
+        DataStoreGarbageCollector gc = ((SessionImpl) session).createDataStoreGarbageCollector();
         gc.setPersistenceManagerScan(false);
-        gc.setScanEventListener(new ScanEventListener() {
+        gc.setMarkEventListener(new MarkEventListener() {
             public void beforeScanning(Node n) throws RepositoryException {
                 if (n.getName().equals(testNodeName)) {
                     n.remove();
                     n.getSession().save();
                 }
             }
-            public void afterScanning(Node n) throws RepositoryException {
-            }
-            public void done() {
-            }
+
         });
-        gc.scan();
-        gc.stopScan();
+        gc.mark();
+        gc.close();
     }
 
     public void testGC() throws Exception {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCEventListenerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCEventListenerTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCEventListenerTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCEventListenerTest.java Wed Oct 21 11:38:31 2009
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.core.data;
 
+import org.apache.jackrabbit.api.management.DataStoreGarbageCollector;
+import org.apache.jackrabbit.api.management.MarkEventListener;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.test.AbstractJCRTest;
 import org.slf4j.Logger;
@@ -35,17 +37,17 @@
  *
  * @author Thomas Mueller
  */
-public class GCEventListenerTest extends AbstractJCRTest implements ScanEventListener {
+public class GCEventListenerTest extends AbstractJCRTest implements MarkEventListener {
 
     /** logger instance */
     private static final Logger LOG = LoggerFactory.getLogger(GCEventListenerTest.class);
 
+    private static final String TEST_NODE_NAME = "testGCEventListener";
+
     private boolean gotNullNode;
     private boolean gotNode;
     private int count;
 
-    private static final String TEST_NODE_NAME = "testGCEventListener";
-
     public void testEventListener() throws Exception {
         doTestEventListener(true);
         doTestEventListener(false);
@@ -74,16 +76,16 @@
         }
         session.save();
         SessionImpl si = (SessionImpl) session;
-        GarbageCollector gc = si.createDataStoreGarbageCollector();
-        if (gc.getDataStore() != null) {
-            gc.getDataStore().clearInUse();
-            boolean pmScan = gc.getPersistenceManagerScan();
+        DataStoreGarbageCollector gc = si.createDataStoreGarbageCollector();
+        DataStore ds = ((GarbageCollector) gc).getDataStore();
+        if (ds != null) {
+            ds.clearInUse();
+            boolean pmScan = gc.isPersistenceManagerScan();
             gc.setPersistenceManagerScan(allowPmScan);
             gotNullNode = false;
             gotNode = false;
-            gc.setScanEventListener(this);
-            gc.scan();
-            gc.stopScan();
+            gc.setMarkEventListener(this);
+            gc.mark();
             if (pmScan && allowPmScan) {
                 assertTrue("PM scan without null Node", gotNullNode);
                 assertFalse("PM scan, but got a real node", gotNode);
@@ -91,7 +93,7 @@
                 assertFalse("Not a PM scan - but got a null Node", gotNullNode);
                 assertTrue("Not a PM scan - without a real node", gotNode);
             }
-            int deleted = gc.deleteUnused();
+            int deleted = gc.sweep();
             LOG.debug("Deleted " + deleted);
             assertTrue("Should delete at least one item", deleted >= 0);
             gc.close();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCThread.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCThread.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCThread.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GCThread.java Wed Oct 21 11:38:31 2009
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.core.data;
 
+import org.apache.jackrabbit.api.management.DataStoreGarbageCollector;
+import org.apache.jackrabbit.api.management.MarkEventListener;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -29,7 +31,7 @@
 /**
  * Helper class that runs data store garbage collection as a background thread.
  */
-public class GCThread implements Runnable, ScanEventListener {
+public class GCThread implements Runnable, MarkEventListener {
 
     /** logger instance */
     private static final Logger LOG = LoggerFactory.getLogger(GCThread.class);
@@ -45,15 +47,16 @@
     public void run() {
 
         try {
-            GarbageCollector gc = ((SessionImpl) session).createDataStoreGarbageCollector();
-            gc.setScanEventListener(this);
+            GarbageCollector gc = ((SessionImpl) session)
+                    .createDataStoreGarbageCollector();
+            gc.setMarkEventListener(this);
             while (!stop) {
                 LOG.debug("Scanning...");
-                gc.scan();
+                gc.mark();
                 int count = listIdentifiers(gc);
                 LOG.debug("Stop; currently " + count + " identifiers");
                 gc.stopScan();
-                int numDeleted = gc.deleteUnused();
+                int numDeleted = gc.sweep();
                 if (numDeleted > 0) {
                     LOG.debug("Deleted " + numDeleted + " identifiers");
                 }
@@ -75,8 +78,9 @@
         return exception;
     }
 
-    private int listIdentifiers(GarbageCollector gc) throws DataStoreException {
-        Iterator<DataIdentifier> it = gc.getDataStore().getAllIdentifiers();
+    private int listIdentifiers(DataStoreGarbageCollector gc) throws DataStoreException {
+        DataStore ds = ((GarbageCollector) gc).getDataStore();
+        Iterator<DataIdentifier> it = ds.getAllIdentifiers();
         int count = 0;
         while (it.hasNext()) {
             DataIdentifier id = it.next();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/GarbageCollectorTest.java Wed Oct 21 11:38:31 2009
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.core.data;
 
+import org.apache.jackrabbit.api.management.DataStoreGarbageCollector;
+import org.apache.jackrabbit.api.management.MarkEventListener;
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.test.AbstractJCRTest;
@@ -48,22 +50,15 @@
             LOG.info("testConcurrentClose skipped. Data store is not used.");
             return;
         }
-        final GarbageCollector gc = ((SessionImpl) session).createDataStoreGarbageCollector();
+        final DataStoreGarbageCollector gc = ((SessionImpl) session).createDataStoreGarbageCollector();
         final Exception[] ex = new Exception[1];
-        gc.setScanEventListener(new ScanEventListener() {
+        gc.setMarkEventListener(new MarkEventListener() {
             boolean closed;
 
-            public void afterScanning(Node n) throws RepositoryException {
-                closeTest();
-            }
-
             public void beforeScanning(Node n) throws RepositoryException {
                 closeTest();
             }
 
-            public void done() {
-            }
-
             private void closeTest() throws RepositoryException {
                 if (closed) {
                     ex[0] = new Exception("Scanning after the session is closed");
@@ -74,7 +69,7 @@
 
         });
         try {
-            gc.scan();
+            gc.mark();
             fail("Exception 'session has been closed' expected");
         } catch (RepositoryException e) {
             LOG.debug("Expected exception caught: " + e.getMessage());
@@ -127,10 +122,9 @@
             }
         }.start();
         assertEquals("x", sync.take());
-        GarbageCollector gc = ((SessionImpl) session).createDataStoreGarbageCollector();
-        gc.scan();
-        gc.stopScan();
-        gc.deleteUnused();
+        DataStoreGarbageCollector gc = ((SessionImpl) session).createDataStoreGarbageCollector();
+        gc.mark();
+        gc.sweep();
         sync.put("deleted");
         assertEquals("saved", sync.take());
         InputStream in = node.getProperty("slowBlob").getBinary().getStream();
@@ -176,13 +170,13 @@
         }
 
         LOG.debug("scanning...");
-        gc.scan();
+        gc.mark();
         int count = listIdentifiers(gc);
         LOG.debug("stop scanning; currently " + count + " identifiers");
         gc.stopScan();
         LOG.debug("deleting...");
         gc.getDataStore().clearInUse();
-        assertTrue(gc.deleteUnused() > 0);
+        assertTrue(gc.sweep() > 0);
         int count2 = listIdentifiers(gc);
         assertEquals(count - 1, count2);
 
@@ -193,17 +187,17 @@
 
     private void runGC(Session session, boolean all) throws Exception {
         GarbageCollector gc = ((SessionImpl)session).createDataStoreGarbageCollector();
-        gc.setScanEventListener(this);
+        gc.setMarkEventListener(this);
         if (gc.getDataStore() instanceof FileDataStore) {
             // make sure the file is old (access time resolution is 2 seconds)
             Thread.sleep(2000);
         }
-        gc.scan();
+        gc.mark();
         gc.stopScan();
         if (all) {
             gc.getDataStore().clearInUse();
         }
-        gc.deleteUnused();
+        gc.sweep();
         gc.close();
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/NodeTypeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/NodeTypeTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/NodeTypeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/NodeTypeTest.java Wed Oct 21 11:38:31 2009
@@ -16,17 +16,21 @@
  */
 package org.apache.jackrabbit.core.data;
 
-import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
-import org.apache.jackrabbit.test.AbstractJCRTest;
-
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
 
 import javax.jcr.Node;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 
+import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
+import org.apache.jackrabbit.commons.cnd.CndImporter;
+import org.apache.jackrabbit.commons.cnd.ParseException;
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
 /**
  * Test node types with binary default values.
  */
@@ -35,16 +39,18 @@
     /**
      * Test a node type with a binary default value
      * @throws RepositoryException
+     * @throws ParseException
      */
     public void testNodeTypesWithBinaryDefaultValue()
-            throws RepositoryException, IOException {
+            throws RepositoryException, IOException, ParseException {
+
         doTestNodeTypesWithBinaryDefaultValue(0);
         doTestNodeTypesWithBinaryDefaultValue(10);
         doTestNodeTypesWithBinaryDefaultValue(10000);
     }
 
     public void doTestNodeTypesWithBinaryDefaultValue(int len)
-            throws RepositoryException, IOException {
+            throws RepositoryException, IOException, ParseException {
         char[] chars = new char[len];
         for (int i = 0; i < chars.length; i++) {
             chars[i] = 'a';
@@ -58,9 +64,8 @@
         JackrabbitNodeTypeManager manager = (JackrabbitNodeTypeManager)
             superuser.getWorkspace().getNodeTypeManager();
         if (!manager.hasNodeType(type)) {
-            manager.registerNodeTypes(
-                    new ByteArrayInputStream(cnd.getBytes("UTF-8")),
-                    JackrabbitNodeTypeManager.TEXT_X_JCR_CND);
+            Reader cndReader = new InputStreamReader(new ByteArrayInputStream(cnd.getBytes("UTF-8")));
+            CndImporter.registerNodeTypes(cndReader, superuser);
         }
 
         Node root = superuser.getRootNode();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/TestAll.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/TestAll.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/TestAll.java Wed Oct 21 11:38:31 2009
@@ -34,6 +34,7 @@
      */
     public static Test suite() {
         TestSuite suite = new ConcurrentTestSuite("Data tests");
+        suite.addTestSuite(DataStoreAPITest.class);
         suite.addTestSuite(LazyFileInputStreamTest.class);
         suite.addTestSuite(OpenFilesTest.class);
         suite.addTestSuite(DataStoreTest.class);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/journal/FileJournalTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/journal/FileJournalTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/journal/FileJournalTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/journal/FileJournalTest.java Wed Oct 21 11:38:31 2009
@@ -17,14 +17,14 @@
 package org.apache.jackrabbit.core.journal;
 
 import java.io.File;
-import java.util.Properties;
+
+import javax.jcr.RepositoryException;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.core.cluster.ClusterNode;
 import org.apache.jackrabbit.core.cluster.SimpleClusterContext;
-import org.apache.jackrabbit.core.config.BeanConfig;
 import org.apache.jackrabbit.core.config.ClusterConfig;
-import org.apache.jackrabbit.core.config.JournalConfig;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.test.JUnitTest;
 
 /**
@@ -87,20 +87,25 @@
      * @see <a href="http://issues.apache.org/jira/browse/JCR-904">JCR-904</a>
      */
     public void testRevisionIsOptional() throws Exception {
-        Properties params = new Properties();
-        params.setProperty("directory", journalDirectory.getPath());
-
-        BeanConfig bc = new BeanConfig(FileJournal.class.getName(), params);
-        JournalConfig jc = new JournalConfig(bc);
-
-        ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jc);
+        final FileJournal journal = new FileJournal();
+        journal.setDirectory(journalDirectory.getPath());
+        JournalFactory jf = new JournalFactory() {
+            public Journal getJournal(NamespaceResolver resolver) {
+                return journal;
+            }
+        };
+        ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jf);
         SimpleClusterContext context = new SimpleClusterContext(cc, repositoryHome);
 
+        journal.setRepositoryHome(repositoryHome);
+        journal.init(CLUSTER_NODE_ID, context.getNamespaceResolver());
+
         ClusterNode clusterNode = new ClusterNode();
         clusterNode.init(context);
 
         try {
-            File revisionFile = new File(repositoryHome, FileJournal.DEFAULT_INSTANCE_FILE_NAME);
+            File revisionFile =
+                new File(repositoryHome, FileJournal.DEFAULT_INSTANCE_FILE_NAME);
             assertTrue(revisionFile.exists());
         } finally {
             clusterNode.stop();
@@ -114,12 +119,13 @@
      * @throws Exception
      */
     public void testClusterInitIncompleteBadJournalClass() throws Exception {
-        Properties params = new Properties();
-
-        BeanConfig bc = new BeanConfig(Object.class.getName(), params);
-        JournalConfig jc = new JournalConfig(bc);
-
-        ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jc);
+        JournalFactory jf = new JournalFactory() {
+            public Journal getJournal(NamespaceResolver resolver)
+                    throws RepositoryException {
+                throw new RepositoryException("Journal not available");
+            }
+        };
+        ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jf);
         SimpleClusterContext context = new SimpleClusterContext(cc);
 
         ClusterNode clusterNode = new ClusterNode();
@@ -142,16 +148,23 @@
      * @throws Exception
      */
     public void testClusterInitIncompleteMissingParam() throws Exception {
-        Properties params = new Properties();
-
-        BeanConfig bc = new BeanConfig(FileJournal.class.getName(), params);
-        JournalConfig jc = new JournalConfig(bc);
-
-        ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jc);
+        JournalFactory jf = new JournalFactory() {
+            public Journal getJournal(NamespaceResolver resolver)
+                    throws RepositoryException {
+                try {
+                    FileJournal journal = new FileJournal();
+                    // no setDirectory() call here
+                    journal.init(CLUSTER_NODE_ID, resolver);
+                    return journal;
+                } catch (JournalException e) {
+                    throw new RepositoryException("Expected failure", e);
+                }
+            }
+        };
+        ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jf);
         SimpleClusterContext context = new SimpleClusterContext(cc);
 
         ClusterNode clusterNode = new ClusterNode();
-
         try {
             clusterNode.init(context);
             fail("Bad cluster configuration.");

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/CyclicNodeTypeRegistrationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/CyclicNodeTypeRegistrationTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/CyclicNodeTypeRegistrationTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/CyclicNodeTypeRegistrationTest.java Wed Oct 21 11:38:31 2009
@@ -18,9 +18,15 @@
 
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.commons.nodetype.QNodeDefinitionBuilder;
+import org.apache.jackrabbit.spi.commons.nodetype.QPropertyDefinitionBuilder;
+import org.apache.jackrabbit.spi.commons.nodetype.QNodeTypeDefinitionBuilder;
 import org.apache.jackrabbit.test.AbstractJCRTest;
 import org.apache.jackrabbit.spi.NameFactory;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
@@ -54,7 +60,7 @@
     /**
      * The cyclic dependent node type definitions we use for the tests
      */
-    private Collection ntDefCollection;
+    private Collection<QNodeTypeDefinition> ntDefCollection;
 
     /**
      * The name factory
@@ -110,29 +116,29 @@
          * [bar]
          * + myFooInBar (foo)
          */
-        final NodeTypeDef foo = new NodeTypeDef();
+        final QNodeTypeDefinitionBuilder foo = new QNodeTypeDefinitionBuilder();
         foo.setName(nameFactory.create("", "foo"));
         foo.setSupertypes(new Name[]{NameConstants.NT_BASE});
 
-        final NodeTypeDef bar = new NodeTypeDef();
+        final QNodeTypeDefinitionBuilder bar = new QNodeTypeDefinitionBuilder();
         bar.setName(nameFactory.create("", "bar"));
         bar.setSupertypes(new Name[]{NameConstants.NT_BASE});
 
-        NodeDefImpl myBarInFoo = new NodeDefImpl();
+        QNodeDefinitionBuilder myBarInFoo = new QNodeDefinitionBuilder();
         myBarInFoo.setRequiredPrimaryTypes(new Name[]{bar.getName()});
         myBarInFoo.setName(nameFactory.create("", "myBarInFoo"));
         myBarInFoo.setDeclaringNodeType(foo.getName());
 
-        NodeDefImpl myFooInBar = new NodeDefImpl();
+        QNodeDefinitionBuilder myFooInBar = new QNodeDefinitionBuilder();
         myFooInBar.setRequiredPrimaryTypes(new Name[]{foo.getName()});
         myFooInBar.setName(nameFactory.create("", "myFooInBar"));
         myFooInBar.setDeclaringNodeType(bar.getName());
 
-        foo.setChildNodeDefs(new NodeDefImpl[]{myBarInFoo});
-        bar.setChildNodeDefs(new NodeDefImpl[]{myFooInBar});
-        ntDefCollection = new LinkedList();
-        ntDefCollection.add(foo);
-        ntDefCollection.add(bar);
+        foo.setChildNodeDefs(new QNodeDefinition[]{myBarInFoo.build()});
+        bar.setChildNodeDefs(new QNodeDefinition[]{myFooInBar.build()});
+        ntDefCollection = new LinkedList<QNodeTypeDefinition>();
+        ntDefCollection.add(foo.build());
+        ntDefCollection.add(bar.build());
 
         try {
             ntreg.registerNodeTypes(ntDefCollection);
@@ -158,19 +164,19 @@
          * + myNTInFoo (I_am_an_invalid_required_primary_type)
          *
          */
-        final NodeTypeDef foo = new NodeTypeDef();
+        final QNodeTypeDefinitionBuilder foo = new QNodeTypeDefinitionBuilder();
         foo.setName(nameFactory.create("", "foo"));
         foo.setSupertypes(new Name[]{NameConstants.NT_BASE});
 
 
-        NodeDefImpl myBarInFoo = new NodeDefImpl();
+        QNodeDefinitionBuilder myBarInFoo = new QNodeDefinitionBuilder();
         myBarInFoo.setRequiredPrimaryTypes(new Name[]{nameFactory.create("", "I_am_an_invalid_required_primary_type")});
         myBarInFoo.setName(nameFactory.create("", "myNTInFoo"));
         myBarInFoo.setDeclaringNodeType(foo.getName());
 
-        foo.setChildNodeDefs(new NodeDefImpl[]{myBarInFoo});
-        ntDefCollection = new LinkedList();
-        ntDefCollection.add(foo);
+        foo.setChildNodeDefs(new QNodeDefinition[]{myBarInFoo.build()});
+        ntDefCollection = new LinkedList<QNodeTypeDefinition>();
+        ntDefCollection.add(foo.build());
 
         try {
             ntreg.registerNodeTypes(ntDefCollection);
@@ -202,46 +208,48 @@
          *
          */
 
-        final NodeTypeDef folder = new NodeTypeDef();
+        final QNodeTypeDefinitionBuilder folder = new QNodeTypeDefinitionBuilder();
         folder.setName(nameFactory.create("", "Folder"));
 
-        final NodeTypeDef cmsObject = new NodeTypeDef();
+        final QNodeTypeDefinitionBuilder cmsObject = new QNodeTypeDefinitionBuilder();
         cmsObject.setName(nameFactory.create("", "CmsObject"));
         cmsObject.setSupertypes(new Name[]{NameConstants.NT_BASE});
-        NodeDefImpl parentFolder = new NodeDefImpl();
+
+        QNodeDefinitionBuilder parentFolder = new QNodeDefinitionBuilder();
         parentFolder.setRequiredPrimaryTypes(new Name[]{folder.getName()});
         parentFolder.setName(nameFactory.create("", "parentFolder"));
         parentFolder.setDeclaringNodeType(cmsObject.getName());
-        cmsObject.setChildNodeDefs(new NodeDefImpl[]{parentFolder});
+        cmsObject.setChildNodeDefs(new QNodeDefinition[]{parentFolder.build()});
 
 
-        final NodeTypeDef document = new NodeTypeDef();
+        final QNodeTypeDefinitionBuilder document = new QNodeTypeDefinitionBuilder();
         document.setName(nameFactory.create("", "Document"));
         document.setSupertypes(new Name[]{cmsObject.getName()});
-        PropDefImpl sizeProp = new PropDefImpl();
+        QPropertyDefinitionBuilder sizeProp = new QPropertyDefinitionBuilder();
         sizeProp.setName(nameFactory.create("", "size"));
         sizeProp.setRequiredType(PropertyType.LONG);
         sizeProp.setDeclaringNodeType(document.getName());
-        document.setPropertyDefs(new PropDef[]{sizeProp});
+        document.setPropertyDefs(new QPropertyDefinition[]{sizeProp.build()});
 
 
         folder.setSupertypes(new Name[]{cmsObject.getName()});
 
-        NodeDefImpl folders = new NodeDefImpl();
+        QNodeDefinitionBuilder folders = new QNodeDefinitionBuilder();
         folders.setRequiredPrimaryTypes(new Name[]{folder.getName()});
         folders.setName(nameFactory.create("", "folders"));
         folders.setDeclaringNodeType(folder.getName());
 
-        NodeDefImpl documents = new NodeDefImpl();
+        QNodeDefinitionBuilder documents = new QNodeDefinitionBuilder();
         documents.setRequiredPrimaryTypes(new Name[]{document.getName()});
         documents.setName(nameFactory.create("", "documents"));
         documents.setDeclaringNodeType(folder.getName());
 
-        folder.setChildNodeDefs(new NodeDefImpl[]{folders, documents});
-        ntDefCollection = new LinkedList();
-        ntDefCollection.add(folder);
-        ntDefCollection.add(document);
-        ntDefCollection.add(cmsObject);
+        folder.setChildNodeDefs(new QNodeDefinition[]{
+                folders.build(), documents.build()});
+        ntDefCollection = new LinkedList<QNodeTypeDefinition>();
+        ntDefCollection.add(folder.build());
+        ntDefCollection.add(document.build());
+        ntDefCollection.add(cmsObject.build());
 
         try {
             ntreg.registerNodeTypes(ntDefCollection);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/NodeTypesInContentTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/NodeTypesInContentTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/NodeTypesInContentTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/NodeTypesInContentTest.java Wed Oct 21 11:38:31 2009
@@ -20,6 +20,7 @@
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.nodetype.xml.NodeTypeReader;
 import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 
 import javax.jcr.ItemVisitor;
 import javax.jcr.Property;
@@ -45,7 +46,7 @@
         super.setUp();
         
         InputStream xml = getClass().getClassLoader().getResourceAsStream(TEST_NODETYPES);
-        NodeTypeDef[] ntDefs = NodeTypeReader.read(xml);
+        QNodeTypeDefinition[] ntDefs = NodeTypeReader.read(xml);
         NodeTypeRegistry ntReg = ((SessionImpl) superuser).getNodeTypeManager().getNodeTypeRegistry();
         if (!ntReg.isRegistered(ntDefs[0].getName())) {
             ntReg.registerNodeTypes(Arrays.asList(ntDefs));