jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r827966 [9/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/...
Date Wed, 21 Oct 2009 11:38:44 GMT
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java Wed Oct 21 11:38:31 2009
@@ -16,35 +16,40 @@
  */
 package org.apache.jackrabbit.core.nodetype.xml;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.Arrays;
+
+import javax.jcr.NamespaceException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.version.OnParentVersionAction;
+
 import junit.framework.AssertionFailedError;
 
 import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
+import org.apache.jackrabbit.commons.cnd.CndImporter;
 import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
-import org.apache.jackrabbit.core.nodetype.NodeDef;
-import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
-import org.apache.jackrabbit.core.nodetype.PropDef;
-import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.value.InternalValueFactory;
-import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
 import org.apache.jackrabbit.test.AbstractJCRTest;
 
-import javax.jcr.NamespaceException;
-import javax.jcr.NamespaceRegistry;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.version.OnParentVersionAction;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-
 /**
  * Test cases for reading and writing node type definition files.
  */
@@ -76,7 +81,7 @@
     private static final NameFactory FACTORY = NameFactoryImpl.getInstance();
 
     /** Test node types definitions. */
-    private NodeTypeDef[] types;
+    private QNodeTypeDefinition[] types;
 
     /** Registry for the test namespaces. */
     private NamespaceRegistry registry;
@@ -104,7 +109,7 @@
      * @param name node type name
      * @return node type definition
      */
-    private NodeTypeDef getNodeType(String name) {
+    private QNodeTypeDefinition getNodeType(String name) {
         Name qname = FACTORY.create(TEST_NAMESPACE, name);
         for (int i = 0; i < types.length; i++) {
             if (qname.equals(types[i].getName())) {
@@ -126,16 +131,16 @@
      * @param propertyName property name, or <code>null</code>
      * @return property definition
      */
-    private PropDef getPropDef(String typeName, String propertyName) {
+    private QPropertyDefinition getPropDef(String typeName, String propertyName) {
         Name name;
         if (propertyName != null) {
             name = FACTORY.create(TEST_NAMESPACE, propertyName);
         } else {
-            name = PropDef.ANY_NAME;
+            name = NameConstants.ANY_NAME;
         }
 
-        NodeTypeDef def = getNodeType(typeName);
-        PropDef[] defs = def.getPropertyDefs();
+        QNodeTypeDefinition def = getNodeType(typeName);
+        QPropertyDefinition[] defs = def.getPropertyDefs();
         for (int i = 0; i < defs.length; i++) {
             if (name.equals(defs[i].getName())) {
                 return defs[i];
@@ -153,9 +158,9 @@
      * @param index default value index
      * @return default value
      */
-    private String getDefaultValue(PropDef def, int index) {
+    private String getDefaultValue(QPropertyDefinition def, int index) {
         try {
-            InternalValue[] values = def.getDefaultValues();
+            QValue[] values = def.getDefaultValues();
             NamespaceResolver nsResolver = new AdditionalNamespaceResolver(registry);
             NamePathResolver resolver = new DefaultNamePathResolver(nsResolver);
             ValueFactoryQImpl factory = new ValueFactoryQImpl(InternalValueFactory.getInstance(), resolver);
@@ -174,11 +179,11 @@
      * @param nodeName child node name
      * @return child node definition
      */
-    private NodeDef getChildNode(String typeName, String nodeName) {
+    private QNodeDefinition getChildNode(String typeName, String nodeName) {
         Name name = FACTORY.create(TEST_NAMESPACE, nodeName);
 
-        NodeTypeDef def = getNodeType(typeName);
-        NodeDef[] defs = def.getChildNodeDefs();
+        QNodeTypeDefinition def = getNodeType(typeName);
+        QNodeDefinition[] defs = def.getChildNodeDefs();
         for (int i = 0; i < defs.length; i++) {
             if (name.equals(defs[i].getName())) {
                 return defs[i];
@@ -200,7 +205,7 @@
 
     /** Test for the empty node type. */
     public void testEmptyNodeType() {
-        NodeTypeDef def = getNodeType("emptyNodeType");
+        QNodeTypeDefinition def = getNodeType("emptyNodeType");
         assertNotNull("emptyNodeType exists", def);
         assertEquals("emptyNodeType mixin",
                 false, def.isMixin());
@@ -216,27 +221,27 @@
 
     /** Test for the <code>mixin</code> node type attribute. */
     public void testMixinNodeType() {
-        NodeTypeDef def = getNodeType("mixinNodeType");
+        QNodeTypeDefinition def = getNodeType("mixinNodeType");
         assertEquals("mixinNodeType mixin",
                 true, def.isMixin());
     }
 
     /** Test for the <code>hasOrderableChildNodes</code> node type attribute. */
     public void testOrderedNodeType() {
-        NodeTypeDef def = getNodeType("orderedNodeType");
+        QNodeTypeDefinition def = getNodeType("orderedNodeType");
         assertEquals("orderedNodeType hasOrderableChildNodes",
                 true, def.hasOrderableChildNodes());
     }
 
     /** Test for node type item definitions. */
     public void testItemNodeType() {
-        NodeTypeDef def = getNodeType("itemNodeType");
+        QNodeTypeDefinition def = getNodeType("itemNodeType");
         assertEquals("itemNodeType primaryItemName",
                 FACTORY.create(TEST_NAMESPACE, "emptyItem"),
                 def.getPrimaryItemName());
         assertEquals("itemNodeType propertyDefs",
                 10, def.getPropertyDefs().length);
-        PropDef pdef = getPropDef("itemNodeType", null);
+        QPropertyDefinition pdef = getPropDef("itemNodeType", null);
         assertTrue("itemNodeType wildcard property", pdef.definesResidual());
     }
 
@@ -284,11 +289,9 @@
             superuser.getNamespacePrefix("test-namespace3");
             // Ignore test case, node type and namespace already registered
         } catch (NamespaceException e1) {
-            JackrabbitNodeTypeManager ntm = (JackrabbitNodeTypeManager)
-                superuser.getWorkspace().getNodeTypeManager();
-            ntm.registerNodeTypes(
-                    TestAll.class.getResourceAsStream(TEST_NS_CND_NODETYPES),
-                    JackrabbitNodeTypeManager.TEXT_X_JCR_CND);
+            Reader cnd = new InputStreamReader(TestAll.class.getResourceAsStream(TEST_NS_CND_NODETYPES));
+            CndImporter.registerNodeTypes(cnd, superuser);
+            cnd.close();
             try {
                 superuser.getNamespacePrefix("test-namespace3");
             } catch (NamespaceException e2) {
@@ -317,7 +320,7 @@
 
     /** Test for the empty item definition. */
     public void testEmptyItem() {
-        PropDef def = getPropDef("itemNodeType", "emptyItem");
+        QPropertyDefinition def = getPropDef("itemNodeType", "emptyItem");
         assertEquals("emptyItem autoCreate",
                 false, def.isAutoCreated());
         assertEquals("emptyItem mandatory",
@@ -330,96 +333,96 @@
 
     /** Test for the <code>autoCreated</code> item definition attribute. */
     public void testAutoCreateItem() {
-        PropDef def = getPropDef("itemNodeType", "autoCreatedItem");
+        QPropertyDefinition def = getPropDef("itemNodeType", "autoCreatedItem");
         assertEquals("autoCreatedItem autoCreated",
                 true, def.isAutoCreated());
     }
 
     /** Test for the <code>mandatory</code> item definition attribute. */
     public void testMandatoryItem() {
-        PropDef def = getPropDef("itemNodeType", "mandatoryItem");
+        QPropertyDefinition def = getPropDef("itemNodeType", "mandatoryItem");
         assertEquals("mandatoryItem mandatory",
                 true, def.isMandatory());
     }
 
     /** Test for the <code>copy</code> parent version action. */
     public void testCopyItem() {
-        PropDef def = getPropDef("itemNodeType", "copyItem");
+        QPropertyDefinition def = getPropDef("itemNodeType", "copyItem");
         assertEquals("copyItem onParentVersion",
                 OnParentVersionAction.COPY, def.getOnParentVersion());
     }
 
     /** Test for the <code>version</code> parent version action. */
     public void testVersionItem() {
-        PropDef def = getPropDef("itemNodeType", "versionItem");
+        QPropertyDefinition def = getPropDef("itemNodeType", "versionItem");
         assertEquals("versionItem onParentVersion",
                 OnParentVersionAction.VERSION, def.getOnParentVersion());
     }
 
     /** Test for the <code>initialize</code> parent version action. */
     public void testInitializeItem() {
-        PropDef def = getPropDef("itemNodeType", "initializeItem");
+        QPropertyDefinition def = getPropDef("itemNodeType", "initializeItem");
         assertEquals("initializeItem onParentVersion",
                 OnParentVersionAction.INITIALIZE, def.getOnParentVersion());
     }
 
     /** Test for the <code>compute</code> parent version action. */
     public void testComputeItem() {
-        PropDef def = getPropDef("itemNodeType", "computeItem");
+        QPropertyDefinition def = getPropDef("itemNodeType", "computeItem");
         assertEquals("computeItem onParentVersion",
                 OnParentVersionAction.COMPUTE, def.getOnParentVersion());
     }
 
     /** Test for the <code>abort</code> parent version action. */
     public void testAbortItem() {
-        PropDef def = getPropDef("itemNodeType", "abortItem");
+        QPropertyDefinition def = getPropDef("itemNodeType", "abortItem");
         assertEquals("abortItem onParentVersion",
                 OnParentVersionAction.ABORT, def.getOnParentVersion());
     }
 
     /** Test for the <code>protected</code> item definition attribute. */
     public void testProtectedItem() {
-        PropDef def = getPropDef("itemNodeType", "protectedItem");
+        QPropertyDefinition def = getPropDef("itemNodeType", "protectedItem");
         assertEquals("protectedItem protected",
                 true, def.isProtected());
     }
 
     /** Test for node type property definitions. */
     public void testPropertyNodeType() {
-        NodeTypeDef def = getNodeType("propertyNodeType");
+        QNodeTypeDefinition def = getNodeType("propertyNodeType");
         assertEquals("propertyNodeType propertyDefs",
                 13, def.getPropertyDefs().length);
     }
 
     /** Test for the empty property definition. */
     public void testEmptyProperty() {
-        PropDef def = getPropDef("propertyNodeType", "emptyProperty");
+        QPropertyDefinition def = getPropDef("propertyNodeType", "emptyProperty");
         assertEquals("emptyProperty requiredType",
                 PropertyType.UNDEFINED, def.getRequiredType());
         assertEquals("emptyProperty multiple",
                 false, def.isMultiple());
-        assertEquals("emptyProperty defaultValues",
-                0, def.getDefaultValues().length);
+        assertNull("emptyProperty defaultValues",
+                def.getDefaultValues());
         assertEquals("emptyProperty valueConstraints",
                 0, def.getValueConstraints().length);
     }
 
     /** Test for the <code>binary</code> property definition type. */
     public void testBinaryProperty() {
-        PropDef def = getPropDef("propertyNodeType", "binaryProperty");
+        QPropertyDefinition def = getPropDef("propertyNodeType", "binaryProperty");
         assertEquals("binaryProperty requiredType",
                 PropertyType.BINARY, def.getRequiredType());
         assertEquals("binaryProperty valueConstraints",
                 1, def.getValueConstraints().length);
         assertEquals("binaryProperty valueConstraints[0]",
                 "[0,)", (def.getValueConstraints())[0].getString());
-        assertEquals("binaryProperty defaultValues",
-                0, def.getDefaultValues().length);
+        assertNull("binaryProperty defaultValues",
+                def.getDefaultValues());
     }
 
     /** Test for the <code>boolean</code> property definition type. */
     public void testBooleanProperty() {
-        PropDef def = getPropDef("propertyNodeType", "booleanProperty");
+        QPropertyDefinition def = getPropDef("propertyNodeType", "booleanProperty");
         assertEquals("booleanProperty requiredType",
                 PropertyType.BOOLEAN, def.getRequiredType());
         assertEquals("booleanProperty valueConstraints",
@@ -436,7 +439,7 @@
 
     /** Test for the <code>date</code> property definition type. */
     public void testDateProperty() {
-        PropDef def = getPropDef("propertyNodeType", "dateProperty");
+        QPropertyDefinition def = getPropDef("propertyNodeType", "dateProperty");
         assertEquals("dateProperty requiredType",
                 PropertyType.DATE, def.getRequiredType());
         assertEquals("dateProperty valueConstraints",
@@ -452,7 +455,7 @@
 
     /** Test for the <code>double</code> property definition type. */
     public void testDoubleProperty() {
-        PropDef def = getPropDef("propertyNodeType", "doubleProperty");
+        QPropertyDefinition def = getPropDef("propertyNodeType", "doubleProperty");
         assertEquals("doubleProperty requiredType",
                 PropertyType.DOUBLE, def.getRequiredType());
         assertEquals("doubleProperty valueConstraints",
@@ -471,7 +474,7 @@
 
     /** Test for the <code>long</code> property definition type. */
     public void testLongProperty() {
-        PropDef def = getPropDef("propertyNodeType", "longProperty");
+        QPropertyDefinition def = getPropDef("propertyNodeType", "longProperty");
         assertEquals("longProperty requiredType",
                 PropertyType.LONG, def.getRequiredType());
         assertEquals("longProperty valueConstraints",
@@ -490,7 +493,7 @@
 
     /** Test for the <code>name</code> property definition type. */
     public void testNameProperty() {
-        PropDef def = getPropDef("propertyNodeType", "nameProperty");
+        QPropertyDefinition def = getPropDef("propertyNodeType", "nameProperty");
         assertEquals("nameProperty requiredType",
                 PropertyType.NAME, def.getRequiredType());
         assertEquals("nameProperty valueConstraints",
@@ -506,7 +509,7 @@
 
     /** Test for the <code>path</code> property definition type. */
     public void testPathProperty() {
-        PropDef def = getPropDef("propertyNodeType", "pathProperty");
+        QPropertyDefinition def = getPropDef("propertyNodeType", "pathProperty");
         assertEquals("pathProperty requiredType",
                 PropertyType.PATH, def.getRequiredType());
         assertEquals("pathProperty valueConstraints",
@@ -514,13 +517,13 @@
         assertEquals("pathProperty valueConstraints[0]",
                 "{}\t{http://www.apache.org/jackrabbit/test}testPath",
                 (def.getValueConstraints())[0].getString());
-        assertEquals("pathProperty defaultValues",
-                0, def.getDefaultValues().length);
+        assertNull("pathProperty defaultValues",
+                def.getDefaultValues());
     }
 
     /** Test for the <code>path</code> property definition type. */
     public void testPathProperty1() {
-        PropDef def = getPropDef("propertyNodeType", "pathProperty1");
+        QPropertyDefinition def = getPropDef("propertyNodeType", "pathProperty1");
         assertEquals("pathProperty requiredType",
                 PropertyType.PATH, def.getRequiredType());
         assertEquals("pathProperty valueConstraints",
@@ -528,13 +531,13 @@
         assertEquals("pathProperty valueConstraints[0]",
                 "{}\t{http://www.apache.org/jackrabbit/test}testPath\t{}*",
                 (def.getValueConstraints())[0].getString());
-        assertEquals("pathProperty defaultValues",
-                0, def.getDefaultValues().length);
+        assertNull("pathProperty defaultValues",
+                def.getDefaultValues());
     }
 
     /** Test for the <code>path</code> property definition type. */
     public void testPathProperty2() {
-        PropDef def = getPropDef("propertyNodeType", "pathProperty2");
+        QPropertyDefinition def = getPropDef("propertyNodeType", "pathProperty2");
         assertEquals("pathProperty requiredType",
                 PropertyType.PATH, def.getRequiredType());
         assertEquals("pathProperty valueConstraints",
@@ -542,13 +545,13 @@
         assertEquals("pathProperty valueConstraints[0]",
                 "{http://www.apache.org/jackrabbit/test}testPath\t{}*",
                 (def.getValueConstraints())[0].getString());
-        assertEquals("pathProperty defaultValues",
-                0, def.getDefaultValues().length);
+        assertNull("pathProperty defaultValues",
+                def.getDefaultValues());
     }
 
     /** Test for the <code>reference</code> property definition type. */
     public void testReferenceProperty() {
-        PropDef def = getPropDef("propertyNodeType", "referenceProperty");
+        QPropertyDefinition def = getPropDef("propertyNodeType", "referenceProperty");
         assertEquals("referenceProperty requiredType",
                 PropertyType.REFERENCE, def.getRequiredType());
         assertEquals("referenceProperty valueConstraints",
@@ -556,13 +559,13 @@
         assertEquals("referenceProperty valueConstraints[0]",
                 "{http://www.jcp.org/jcr/nt/1.0}base",
                 (def.getValueConstraints())[0].getString());
-        assertEquals("referenceProperty defaultValues",
-                0, def.getDefaultValues().length);
+        assertNull("referenceProperty defaultValues",
+                def.getDefaultValues());
     }
 
     /** Test for the <code>string</code> property definition type. */
     public void testStringProperty() {
-        PropDef def = getPropDef("propertyNodeType", "stringProperty");
+        QPropertyDefinition def = getPropDef("propertyNodeType", "stringProperty");
         assertEquals("stringProperty requiredType",
                 PropertyType.STRING, def.getRequiredType());
         assertEquals("stringProperty valueConstraints",
@@ -580,21 +583,21 @@
 
     /** Test for the <code>multiple</code> property definition attribute. */
     public void testMultipleProperty() {
-        PropDef def = getPropDef("propertyNodeType", "multipleProperty");
+        QPropertyDefinition def = getPropDef("propertyNodeType", "multipleProperty");
         assertEquals("multipleProperty multiple",
                 true, def.isMultiple());
     }
 
     /** Test for node type child node definitions. */
     public void testChildNodeType() {
-        NodeTypeDef def = getNodeType("childNodeType");
+        QNodeTypeDefinition def = getNodeType("childNodeType");
         assertEquals("childNodeType childNodeDefs",
                 4, def.getChildNodeDefs().length);
     }
 
     /** Test for the empty child node definition. */
     public void testEmptyNode() {
-        NodeDef def = getChildNode("childNodeType", "emptyNode");
+        QNodeDefinition def = getChildNode("childNodeType", "emptyNode");
         assertEquals("emptyNode allowsSameNameSiblings",
                 false, def.allowsSameNameSiblings());
         assertEquals("emptyNode defaultPrimaryType",
@@ -603,14 +606,14 @@
 
     /** Test for the <code>allowsSameNameSiblings</code> child node attribute. */
     public void testSiblingNode() {
-        NodeDef def = getChildNode("childNodeType", "siblingNode");
+        QNodeDefinition def = getChildNode("childNodeType", "siblingNode");
         assertEquals("siblingNode allowsSameNameSiblings",
                 true, def.allowsSameNameSiblings());
     }
 
     /** Test for the <code>defaultPrimaryType</code> child node attribute. */
     public void testDefaultTypeNode() {
-        NodeDef def = getChildNode("childNodeType", "defaultTypeNode");
+        QNodeDefinition def = getChildNode("childNodeType", "defaultTypeNode");
         assertEquals("defaultTypeNode defaultPrimaryType",
                 FACTORY.create(Name.NS_NT_URI, "base"),
                 def.getDefaultPrimaryType());
@@ -618,7 +621,7 @@
 
     /** Test for the <code>requiredPrimaryTypes</code> child node attributes. */
     public void testRequiredTypeNode() {
-        NodeDef def = getChildNode("childNodeType", "requiredTypeNode");
+        QNodeDefinition def = getChildNode("childNodeType", "requiredTypeNode");
         assertEquals("requiredTypeNode requiredPrimaryTypes",
                 2, def.getRequiredPrimaryTypes().length);
         Name[] types = def.getRequiredPrimaryTypes();
@@ -643,7 +646,7 @@
             ByteArrayOutputStream xml = new ByteArrayOutputStream();
             NodeTypeWriter.write(xml, types, registry);
             byte[] bytes = xml.toByteArray();
-            NodeTypeDef[] output =
+            QNodeTypeDefinition[] output =
                 NodeTypeReader.read(new ByteArrayInputStream(bytes));
             assertTrue("write output", Arrays.equals(types, output));
         } catch (InvalidNodeTypeDefException e) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/FulltextQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/FulltextQueryTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/FulltextQueryTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/FulltextQueryTest.java Wed Oct 21 11:38:31 2009
@@ -16,11 +16,18 @@
  */
 package org.apache.jackrabbit.core.query;
 
+import java.io.IOException;
+import java.io.InputStream;
+
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryResult;
 
+import org.apache.commons.io.IOUtils;
+
 /**
  * Performs tests with the <code>CONTAINS</code> function.
  */
@@ -276,6 +283,39 @@
         testRootNode.addNode(nodeName1).setProperty("text", content);
         testRootNode.save();
 
+        assertContainsQuery(statement, match);
+    }
+
+    public void testFileContains() throws Exception {
+        assertFileContains(
+                "test.txt", "text/plain", "AE502DBEA2C411DEBD340AD156D89593");
+        assertFileContains(
+                "test.rtf", "text/rtf", "quick brown fox");
+    }
+
+    private void assertFileContains(
+            String name, String type, String... statements) throws Exception {
+        while (testRootNode.hasNode(nodeName1)) {
+            testRootNode.getNode(nodeName1).remove();
+        }
+        Node resource = testRootNode.addNode(nodeName1, NodeType.NT_RESOURCE);
+        resource.setProperty("jcr:mimeType", type);
+        InputStream stream = FulltextQueryTest.class.getResourceAsStream(name);
+        try {
+            resource.setProperty("jcr:data", stream);
+        } finally {
+            stream.close();
+        }
+        testRootNode.save();
+        getSearchIndex().flush();
+
+        for (String statement : statements) {
+            assertContainsQuery(statement, true);
+        }
+    }
+
+    private void assertContainsQuery(String statement, boolean match)
+            throws InvalidQueryException, RepositoryException {
         StringBuffer stmt = new StringBuffer();
         stmt.append("/jcr:root").append(testRoot).append("/*");
         stmt.append("[jcr:contains(., '").append(statement);
@@ -292,4 +332,5 @@
         q = superuser.getWorkspace().getQueryManager().createQuery(stmt.toString(), Query.SQL);
         checkResult(q.execute(), match ? 1 : 0);
     }
+
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/MixinTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/MixinTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/MixinTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/MixinTest.java Wed Oct 21 11:38:31 2009
@@ -16,19 +16,23 @@
  */
 package org.apache.jackrabbit.core.query;
 
-import javax.jcr.RepositoryException;
+import java.io.ByteArrayInputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.Calendar;
+
 import javax.jcr.Node;
+import javax.jcr.RepositoryException;
 
 import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
-
-import java.io.ByteArrayInputStream;
-import java.util.Calendar;
+import org.apache.jackrabbit.commons.cnd.CndImporter;
 
 /**
  * Tests if mixin types are queried correctly when using element test: element()
  */
 public class MixinTest extends AbstractQueryTest {
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
 
@@ -38,9 +42,9 @@
             String cnd =
                 "<test='http://www.apache.org/jackrabbit/test'>\n"
                 + "[test:mimeType] > mix:mimeType mixin";
-            manager.registerNodeTypes(
-                    new ByteArrayInputStream(cnd.getBytes()),
-                    JackrabbitNodeTypeManager.TEXT_X_JCR_CND);
+
+            Reader cndReader = new InputStreamReader(new ByteArrayInputStream(cnd.getBytes()));
+            CndImporter.registerNodeTypes(cndReader, superuser);
         }
     }
 

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

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/UpperLowerCaseQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/UpperLowerCaseQueryTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/UpperLowerCaseQueryTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/UpperLowerCaseQueryTest.java Wed Oct 21 11:38:31 2009
@@ -26,7 +26,7 @@
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.QueryResult;
 
-import org.apache.jackrabbit.spi.commons.query.qom.Operator;
+import org.apache.jackrabbit.commons.query.qom.Operator;
 
 /**
  * <code>UpperLowerCaseQueryTest</code> tests the functions fn:lower-case() and

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingQueueTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingQueueTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingQueueTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingQueueTest.java Wed Oct 21 11:38:31 2009
@@ -16,24 +16,22 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
-import org.apache.jackrabbit.extractor.TextExtractor;
-import org.apache.jackrabbit.core.query.AbstractIndexingTest;
-import org.apache.jackrabbit.core.RepositoryImpl;
-import org.apache.jackrabbit.core.TestHelper;
-import org.apache.jackrabbit.core.fs.local.FileUtil;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Calendar;
 
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.query.Query;
-import java.io.Reader;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.Calendar;
+
+import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.TestHelper;
+import org.apache.jackrabbit.core.fs.local.FileUtil;
+import org.apache.jackrabbit.core.query.AbstractIndexingTest;
 
 /**
  * <code>IndexingQueueTest</code> checks if the indexing queue properly indexes
@@ -44,15 +42,15 @@
 
     private static final File TEMP_DIR = new File(System.getProperty("java.io.tmpdir")); 
 
-    private static final String CONTENT_TYPE = "application/indexing-queue-test";
+    private static final String CONTENT_TYPE = "text/plain";
 
     private static final String ENCODING = "UTF-8";
 
     public void testQueue() throws Exception {
-        Extractor.sleepTime = 200;
         SearchIndex index = getSearchIndex();
         IndexingQueue queue = index.getIndex().getIndexingQueue();
 
+        JackrabbitParser.block();
         assertEquals(0, queue.getNumPendingDocuments());
 
         String text = "the quick brown fox jumps over the lazy dog.";
@@ -70,6 +68,7 @@
         NodeIterator nodes = q.execute().getNodes();
         assertFalse(nodes.hasNext());
 
+        JackrabbitParser.unblock();
         index.flush();
         assertEquals(0, queue.getNumPendingDocuments());
 
@@ -79,7 +78,7 @@
     }
 
     public void testInitialIndex() throws Exception {
-        Extractor.sleepTime = 200;
+        JackrabbitParser.block();
         File indexDir = new File(getSearchIndex().getPath());
 
         // fill workspace
@@ -105,7 +104,7 @@
 
         int initialNumExtractorFiles = getNumExtractorFiles();
 
-        Extractor.sleepTime = 20;
+        JackrabbitParser.unblock();
         Thread t = new Thread(new Runnable() {
             public void run() {
                 try {
@@ -140,7 +139,7 @@
      * Test case for JCR-2082
      */
     public void testReaderUpToDate() throws Exception {
-        Extractor.sleepTime = 10;
+        JackrabbitParser.block();
         SearchIndex index = getSearchIndex();
         File indexDir = new File(index.getPath());
 
@@ -159,6 +158,7 @@
             fail("Unable to delete index directory");
         }
 
+        JackrabbitParser.unblock();
         // start workspace again by getting a session
         session = getHelper().getSuperuserSession(WORKSPACE_NAME);
 
@@ -202,22 +202,4 @@
         }).length;
     }
 
-    public static final class Extractor implements TextExtractor {
-
-        protected static volatile int sleepTime = 200;
-
-        public String[] getContentTypes() {
-            return new String[]{CONTENT_TYPE};
-        }
-
-        public Reader extractText(InputStream stream, String type, String encoding)
-        throws IOException {
-            try {
-                Thread.sleep(sleepTime);
-            } catch (InterruptedException e) {
-                throw new IOException();
-            }
-            return new InputStreamReader(stream, encoding);
-        }
-    }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/AuthorizableImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/AuthorizableImplTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/AuthorizableImplTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/AuthorizableImplTest.java Wed Oct 21 11:38:31 2009
@@ -54,16 +54,13 @@
 
         if (superuser instanceof SessionImpl) {
             NameResolver resolver = (SessionImpl) superuser;
-            protectedUserProps.add(resolver.getJCRName(UserConstants.P_USERID));
             protectedUserProps.add(resolver.getJCRName(UserConstants.P_PASSWORD));
             protectedUserProps.add(resolver.getJCRName(UserConstants.P_GROUPS));
             protectedUserProps.add(resolver.getJCRName(UserConstants.P_IMPERSONATORS));
             protectedUserProps.add(resolver.getJCRName(UserConstants.P_PRINCIPAL_NAME));
-            protectedUserProps.add(resolver.getJCRName(UserConstants.P_REFEREES));
 
             protectedUserProps.add(resolver.getJCRName(UserConstants.P_GROUPS));
             protectedGroupProps.add(resolver.getJCRName(UserConstants.P_PRINCIPAL_NAME));
-            protectedGroupProps.add(resolver.getJCRName(UserConstants.P_REFEREES));
         } else {
             throw new NotExecutableException();
         }
@@ -86,8 +83,8 @@
 
     public void testSetSpecialProperties() throws NotExecutableException, RepositoryException {
         Value v = superuser.getValueFactory().createValue("any_value");
-        User u = getTestUser(superuser);
 
+        User u = getTestUser(superuser);
         for (Iterator it = protectedUserProps.iterator(); it.hasNext();) {
             String pName = it.next().toString();
             try {
@@ -97,11 +94,12 @@
                 // success
             }
         }
+        
         Group g = getTestGroup(superuser);
         for (Iterator it = protectedGroupProps.iterator(); it.hasNext();) {
             String pName = it.next().toString();
             try {
-                u.setProperty(pName, v);
+                g.setProperty(pName, v);
                 fail("changing the '" +pName+ "' property on a Group should fail.");
             } catch (RepositoryException e) {
                 // success
@@ -124,7 +122,7 @@
         for (Iterator it = protectedGroupProps.iterator(); it.hasNext();) {
             String pName = it.next().toString();
             try {
-                u.removeProperty(pName);
+                g.removeProperty(pName);
                 fail("removing the '" +pName+ "' property on a Group should fail.");
             } catch (RepositoryException e) {
                 // success
@@ -136,11 +134,8 @@
         UserImpl user = (UserImpl) getTestUser(superuser);
         NodeImpl n = user.getNode();
 
-        checkProtected(n.getProperty(UserConstants.P_USERID));
+        checkProtected(n.getProperty(UserConstants.P_PASSWORD));
         checkProtected(n.getProperty(UserConstants.P_PRINCIPAL_NAME));
-        if (n.hasProperty(UserConstants.P_REFEREES)) {
-           checkProtected(n.getProperty(UserConstants.P_REFEREES));
-        }
         if (n.hasProperty(UserConstants.P_GROUPS)) {
             checkProtected(n.getProperty(UserConstants.P_GROUPS));
         }
@@ -157,9 +152,6 @@
         if (n.hasProperty(UserConstants.P_GROUPS)) {
             checkProtected(n.getProperty(UserConstants.P_GROUPS));
         }
-        if (n.hasProperty(UserConstants.P_REFEREES)) {
-           checkProtected(n.getProperty(UserConstants.P_REFEREES));
-        }
     }
 
     public void testSetSpecialPropertiesDirectly() throws NotExecutableException, RepositoryException {
@@ -175,14 +167,7 @@
         } catch (ConstraintViolationException e) {
             // ok.
         }
-
-        try {
-            String refereeName = "anyreferee";
-            n.setProperty(UserConstants.P_REFEREES, new Value[] {new StringValue(refereeName)});
-            fail("Attempt to change protected property rep:referees should fail.");
-        } catch (ConstraintViolationException e) {
-            // ok.
-        }
+        
         try {
             String imperson = "anyimpersonator";
             n.setProperty(UserConstants.P_IMPERSONATORS, new Value[] {new StringValue(imperson)});

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/GroupAdministratorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/GroupAdministratorTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/GroupAdministratorTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/GroupAdministratorTest.java Wed Oct 21 11:38:31 2009
@@ -39,7 +39,6 @@
 
     // group-admin
     private String uID;
-    private String uPath;
     private Session uSession;
 
     private String otherUID;
@@ -63,7 +62,6 @@
         Credentials creds = buildCredentials(p.getName(), pw);
         User user = userMgr.createUser(p.getName(), pw);
         uID = user.getID();
-        uPath = ((UserImpl) user).getNode().getPath();
 
         // make other user a group-administrator:
         Authorizable grAdmin = userMgr.getAuthorizable(UserConstants.GROUP_ADMIN_GROUP_NAME);
@@ -101,7 +99,7 @@
         if (otherUID2 == null) {
             // create a third user
             Principal p = getTestPrincipal();
-            otherUID2 = userMgr.createUser(p.getName(), buildPassword(p), p, uPath).getID();
+            otherUID2 = userMgr.createUser(p.getName(), buildPassword(p)).getID();
         }
         return otherUID2;
     }
@@ -157,7 +155,7 @@
         Group testGroup = null;
         try {
             testGroup = umgr.createGroup(getTestPrincipal(), "/any/intermediate/path");
-            assertEquals("Intermediate path must be ignored.",-1, ((GroupImpl)testGroup).getNode().getPath().indexOf("/any/intermediate/path"));
+            assertTrue(Text.isDescendant(UserConstants.GROUPS_PATH + "/any/intermediate/path", ((GroupImpl)testGroup).getNode().getPath()));
         } finally {
             if (testGroup != null) {
                 testGroup.remove();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/ImpersonationImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/ImpersonationImplTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/ImpersonationImplTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/ImpersonationImplTest.java Wed Oct 21 11:38:31 2009
@@ -21,8 +21,6 @@
 import org.apache.jackrabbit.api.security.user.User;
 import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.test.NotExecutableException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.jcr.AccessDeniedException;
 import javax.jcr.Credentials;
@@ -35,15 +33,12 @@
  */
 public class ImpersonationImplTest extends AbstractUserTest {
 
-    private static Logger log = LoggerFactory.getLogger(ImpersonationImplTest.class);
-
     private Credentials creds;
     private String uID;
     private Session uSession;
     private UserManager uMgr;
 
     private String otherUID;
-    private Credentials otherCreds;
 
     protected void setUp() throws Exception {
         super.setUp();
@@ -61,8 +56,7 @@
         // create a second user 'below' the first user.
         p = getTestPrincipal();
         pw = buildPassword(p);
-        otherCreds = buildCredentials(p.getName(), pw);
-        User u2 = userMgr.createUser(p.getName(), pw, p, u.getNode().getPath());
+        User u2 = userMgr.createUser(p.getName(), pw);
         otherUID = u2.getID();
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeResolverTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeResolverTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeResolverTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeResolverTest.java Wed Oct 21 11:38:31 2009
@@ -125,16 +125,6 @@
         }
     }
 
-    public void testFindNodeByUserID() throws NotExecutableException, RepositoryException {
-        UserImpl currentUser = getCurrentUser(superuser);
-
-        NodeResolver nr = createNodeResolver(currentUser.getNode().getSession());
-
-        Node result = nr.findNode(UserConstants.P_USERID, currentUser.getID(), UserConstants.NT_REP_USER);
-        assertNotNull(result);
-        assertTrue(currentUser.getNode().isSame(result));
-    }
-
     public void testFindNodeByMultiValueProp() throws NotExecutableException, RepositoryException {
         UserImpl currentUser = getCurrentUser(superuser);
 
@@ -209,7 +199,7 @@
             throw new NotExecutableException();
         }
 
-        NodeIterator result = nodeResolver.findNodes(UserConstants.P_REFEREES, "anyValue", UserConstants.NT_REP_AUTHORIZABLE, true);
+        NodeIterator result = nodeResolver.findNodes(UserConstants.P_PRINCIPAL_NAME, "anyValue", UserConstants.NT_REP_AUTHORIZABLE, true);
         assertNotNull(result);
         assertFalse(result.hasNext());
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NotUserAdministratorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NotUserAdministratorTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NotUserAdministratorTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NotUserAdministratorTest.java Wed Oct 21 11:38:31 2009
@@ -39,7 +39,6 @@
 
     // test user that is NOT user admin
     private String uID;
-    private String uPath;
     private Session uSession;
     private UserManager uMgr;
 
@@ -52,7 +51,6 @@
         String pw = buildPassword(p);
         UserImpl u = (UserImpl) userMgr.createUser(p.getName(), pw);
         uID = u.getID();
-        uPath = u.getNode().getPath();
 
         // create a session for the other user.
         uSession = getHelper().getRepository().login(new SimpleCredentials(uID, pw.toCharArray()));
@@ -118,7 +116,7 @@
     public void testRemoveChildUser() throws RepositoryException {
         // let superuser create a child-user.
         Principal p = getTestPrincipal();
-        String childID = userMgr.createUser(p.getName(), buildPassword(p), p, uPath).getID();
+        String childID = userMgr.createUser(p.getName(), buildPassword(p)).getID();
         try {
             Authorizable a = uMgr.getAuthorizable(childID);
             a.remove();
@@ -156,7 +154,7 @@
     public void testModifyImpersonation() throws RepositoryException {
         // let superuser create a child-user.
         Principal p = getTestPrincipal();
-        Authorizable child = userMgr.createUser(p.getName(), buildPassword(p), p, uPath);
+        Authorizable child = userMgr.createUser(p.getName(), buildPassword(p));
         try {
             p = child.getPrincipal();
 
@@ -178,7 +176,7 @@
     public void testModifyImpersonationOfChildUser() throws RepositoryException {
         // let superuser create a child-user.
         Principal p = getTestPrincipal();
-        String childID = userMgr.createUser(p.getName(), buildPassword(p), p, uPath).getID();
+        String childID = userMgr.createUser(p.getName(), buildPassword(p)).getID();
         try {
             Authorizable child = uMgr.getAuthorizable(childID);
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserAdministratorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserAdministratorTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserAdministratorTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserAdministratorTest.java Wed Oct 21 11:38:31 2009
@@ -32,6 +32,8 @@
 import java.security.Principal;
 import java.util.Iterator;
 import java.util.Set;
+import java.util.Map;
+import java.util.HashMap;
 
 /**
  * <code>UserAdministratorTest</code>...
@@ -43,7 +45,6 @@
 
     // user-admin 'below'
     private String otherUID;
-    private String otherPath;
     private Session otherSession;
 
     // the user-admin group
@@ -64,7 +65,6 @@
         Credentials otherCreds = buildCredentials(p.getName(), pw);
         User other = userMgr.createUser(p.getName(), pw);
         otherUID = other.getID();
-        otherPath = ((UserImpl) other).getNode().getPath();
 
         // make other user a user-administrator:
         Authorizable ua = userMgr.getAuthorizable(UserConstants.USER_ADMIN_GROUP_NAME);
@@ -136,13 +136,43 @@
     public void testCreateUserWithIntermediatePath() throws RepositoryException, NotExecutableException {
         UserManager umgr = getUserManager(otherSession);
         UserImpl u = null;
+
         // create a new user with intermediate-path
         // -> must succeed and user must be created
-        // -> intermediate path must be ignored.
+        // -> intermediate path must be part of the nodes path
+        Principal p = getTestPrincipal();
+        String usersPath = ((UserManagerImpl) umgr).getUsersPath();
+        Map<String, String> m = new HashMap<String, String>();
+        m.put("/some/intermediate/path", usersPath + "/some/intermediate/path/" + p.getName());
+        m.put("some/intermediate/path", usersPath + "/some/intermediate/path/" + p.getName());
+        m.put("/", usersPath + "/" + p.getName());
+        m.put("", usersPath + "/" + p.getName());
+        m.put(usersPath + "/some/intermediate/path", usersPath + "/some/intermediate/path/" + p.getName());
+
+        for (String intermediatePath : m.keySet()) {
+            try {
+                u = (UserImpl) umgr.createUser(p.getName(), buildPassword(p), p, intermediatePath);
+                String expPath = m.get(intermediatePath);
+                assertEquals(expPath, u.getNode().getPath());
+            } finally {
+                if (u != null) {
+                    u.remove();
+                }
+            }
+        }
+    }
+
+    public void testCreateNestedUsers() throws NotExecutableException, RepositoryException {
+        UserManager umgr = getUserManager(otherSession);
+        UserImpl u = null;
+
+        String invalidIntermediatePath = ((UserImpl) umgr.getAuthorizable(otherUID)).getNode().getPath();
         try {
             Principal p = getTestPrincipal();
-            u = (UserImpl) umgr.createUser(p.getName(), buildPassword(p), p, "/some/intermediate/path");
-            assertEquals(-1, u.getNode().getPath().indexOf("/some/intermediate/path"));
+            u = (UserImpl) umgr.createUser(p.getName(), buildPassword(p), p, invalidIntermediatePath);
+            fail("An attempt to create a user below an existing user must fail.");
+        } catch (RepositoryException e) {
+            // success
         } finally {
             if (u != null) {
                 u.remove();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserManagerImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserManagerImplTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserManagerImplTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserManagerImplTest.java Wed Oct 21 11:38:31 2009
@@ -43,7 +43,6 @@
 public class UserManagerImplTest extends AbstractUserTest {
 
     private String pPrincipalName;
-    private String pUserID;
 
     protected void setUp() throws Exception {
         super.setUp();
@@ -52,7 +51,6 @@
         }
         NameResolver resolver = (SessionImpl) superuser;
         pPrincipalName = resolver.getJCRName(UserConstants.P_PRINCIPAL_NAME);
-        pUserID = resolver.getJCRName(UserConstants.P_USERID);
     }
 
     private String getTestUserId(Principal p) throws RepositoryException {
@@ -262,14 +260,6 @@
             }
             assertTrue("Searching for principal-name must find the created user.", found);
 
-            it = userMgr.findAuthorizables(pUserID, uid, UserManager.SEARCH_TYPE_USER);
-            found = false;
-            while (it.hasNext() && !found) {
-                User nu = (User) it.next();
-                found = nu.getID().equals(uid);
-            }
-            assertTrue("Searching for user id must find the created user.", found);
-
             // but search groups should not find anything
             it = userMgr.findAuthorizables(pPrincipalName, p.getName(), UserManager.SEARCH_TYPE_GROUP);
             assertFalse(it.hasNext());

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/xml/DocumentViewTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/xml/DocumentViewTest.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/xml/DocumentViewTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/xml/DocumentViewTest.java Wed Oct 21 11:38:31 2009
@@ -19,6 +19,8 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
 
 import javax.jcr.ImportUUIDBehavior;
 import javax.jcr.Node;
@@ -28,6 +30,7 @@
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 
 import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
+import org.apache.jackrabbit.commons.cnd.CndImporter;
 import org.apache.jackrabbit.test.AbstractJCRTest;
 
 /**
@@ -43,6 +46,7 @@
      *
      * @throws Exception if an unexpected error occurs
      */
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         JackrabbitNodeTypeManager manager = (JackrabbitNodeTypeManager)
@@ -51,9 +55,8 @@
             manager.getNodeType("DocViewMultiValueTest");
         } catch (NoSuchNodeTypeException e) {
             String cnd = "[DocViewMultiValueTest] - test (boolean) multiple";
-            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);
         }
     }
 
@@ -62,6 +65,7 @@
      *
      * @throws Exception if an unexpected error occurs
      */
+    @Override
     protected void tearDown() throws Exception {
         // TODO: Unregister the MultiValueTestType node type once Jackrabbit
         // supports node type removal.

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository.xml?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository.xml (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/cluster/repository.xml Wed Oct 21 11:38:31 2009
@@ -142,7 +142,7 @@
     <!--
         Cluster configuration with system variables.
     -->
-    <Cluster id="${cluster.id}" syncDelay="${cluster.syncDelay}">
+    <Cluster syncDelay="${cluster.syncDelay}">
         <Journal class="org.apache.jackrabbit.core.journal.JNDIDatabaseJournal">
             <param name="schema" value="oracle" />
         </Journal>

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAResourceAdapter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAResourceAdapter.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAResourceAdapter.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAResourceAdapter.java Wed Oct 21 11:38:31 2009
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.jca;
 
+import java.io.Serializable;
+
 import javax.resource.ResourceException;
 import javax.resource.spi.ActivationSpec;
 import javax.resource.spi.BootstrapContext;
@@ -28,8 +30,10 @@
 /**
  * JCR ResourceAdapter.
  */
-public class JCAResourceAdapter implements ResourceAdapter {
+public class JCAResourceAdapter implements ResourceAdapter, Serializable {
 
+    private static final long serialVersionUID = 7335723888000232035L;
+    
     private final XAResource[] xaResources = new XAResource[0];
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-client/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-client/pom.xml?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-client/pom.xml (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-client/pom.xml Wed Oct 21 11:38:31 2009
@@ -51,14 +51,27 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
-                    <skip>true</skip>
+                    <skip>false</skip>
                     <includes>
                         <include>**/*Test.java</include>
                     </includes>
+                    <workingDirectory>target</workingDirectory> 
                     <forkMode>once</forkMode>
                     <argLine>-Xmx128m -enableassertions</argLine>
                 </configuration>
             </plugin>
+            
+          <plugin>
+              <groupId>org.apache.rat</groupId>
+              <artifactId>apache-rat-plugin</artifactId>
+              <configuration>
+                  <excludes>
+                      <exclude>repository/**</exclude>
+                      <exclude>repository.xml</exclude>
+                      <exclude>derby.log</exclude>
+                  </excludes>
+              </configuration>
+            </plugin>
         </plugins>
     </build>
 
@@ -68,40 +81,55 @@
             <artifactId>jcr</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        
+        <dependency>
             <groupId>org.apache.jackrabbit</groupId>
             <artifactId>jackrabbit-jcr2spi</artifactId>
             <version>2.0-SNAPSHOT</version>
-            <classifier></classifier>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
-            <artifactId>jackrabbit-spi</artifactId>
+            <artifactId>jackrabbit-spi2dav</artifactId>
             <version>2.0-SNAPSHOT</version>
-            <classifier></classifier>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
-            <artifactId>jackrabbit-spi-commons</artifactId>
+            <artifactId>jackrabbit-spi2jcr</artifactId>
             <version>2.0-SNAPSHOT</version>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
-            <artifactId>jackrabbit-spi2jcr</artifactId>
+            <artifactId>jackrabbit-core</artifactId>
             <version>2.0-SNAPSHOT</version>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
-            <artifactId>jackrabbit-spi2dav</artifactId>
+            <artifactId>jackrabbit-spi-commons</artifactId>
             <version>2.0-SNAPSHOT</version>
+            <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-spi</artifactId>
+            <version>2.0-SNAPSHOT</version>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/RepositoryFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/RepositoryFactoryImpl.java?rev=827966&r1=827965&r2=827966&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/RepositoryFactoryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/RepositoryFactoryImpl.java Wed Oct 21 11:38:31 2009
@@ -16,79 +16,66 @@
  */
 package org.apache.jackrabbit.client;
 
-import org.apache.jackrabbit.jcr2spi.RepositoryImpl;
-import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.Map;
 
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.RepositoryFactory;
-import java.util.Map;
 
 /**
- * <code>RepositoryFactoryImpl</code>...
+ * This {@link RepositoryFactory} implementations is capable of creating any
+ * repository which is covered by the Apache Jackrabbit project. It does so by
+ * delegating back to secondary RepositoryFactory implementations. The
+ * parameters passed to the {@link #getRepository(Map)} method determine which
+ * secondare RepositoryFactory this factory delegates to.
  */
 public class RepositoryFactoryImpl implements RepositoryFactory {
 
-    private static Logger log = LoggerFactory.getLogger(RepositoryFactoryImpl.class);
+    /**
+     * When this key parameter is present, this factory delegates to
+     * {@link org.apache.jackrabbit.jcr2spi.Jcr2spiRepositoryFactory}
+     */
+    public static final String PARAM_REPOSITORY_SERVICE_FACTORY = "org.apache.jackrabbit.spi.RepositoryServiceFactory";
 
-    public static final String REPOSITORY_CONFIG = "org.apache.jackrabbit.repository.config";
+    /**
+     * When this key parameter is present, this factory delegates to
+     * {@link org.apache.jackrabbit.jcr2spi.Jcr2spiRepositoryFactory}
+     */
+    public static final String PARAM_REPOSITORY_CONFIG = "org.apache.jackrabbit.jcr2spi.RepositoryConfig";
 
-    //--------------------------------------------------< RepositoryFactory >---
     /**
      * Creates a JCR repository from the given <code>parameters</code>.
-     * If the <code>parameters</code> map is <code>null</code> the default
-     * repository  (i.e. JCR2SPI repository on top of SPI2DAVex) is returned.<p/>
-     * If the <code>parameters</code> map contains a {@link #REPOSITORY_CONFIG}
-     * entry it's value is expected to be a implementation of
-     * {@link org.apache.jackrabbit.jcr2spi.config.RepositoryConfig} and the
-     * repository will be created based on this configuration.<p/>
-     * If the <code>parameters</code> map does not contain a {@link #REPOSITORY_CONFIG}
-     * entry or if the corresponding value isn't a valid <code>RepositoryConfig</code>
-     * an attempt is made to create a
-     * {@link org.apache.jackrabbit.jcr2spi.config.RepositoryConfig} for any of
-     * the known SPI implementations:
-     * <ul>
-     * <li>SPI2DAVex (see jackrabbit-spi2dav module)</li>
-     * <li>SPI2DAV (see jackrabbit-spi2dav module)</li>
-     * <li>SPI2JCR (see jackrabbit-spi2jcr module)</li>
-     * </ul>
-     * NOTE: If the <code>parameters</code> map contains an
-     * {@link org.apache.jackrabbit.client.spilogger.RepositoryConfigImpl#PARAM_LOG_WRITER_PROVIDER PARAM_LOG_WRITER_PROVIDER}
-     * entry the {@link org.apache.jackrabbit.spi.RepositoryService RepositoryService} obtained
-     * from the configuration is wrapped by a SPI logger. See the
-     * {@link org.apache.jackrabbit.spi.commons.logging.SpiLoggerFactory SpiLoggerFactory}
-     * for details.
+     * If either {@link #PARAM_REPOSITORY_SERVICE_FACTORY} or
+     * {@link #PARAM_REPOSITORY_CONFIG} is present, this factory delegates
+     * to {@link org.apache.jackrabbit.jcr2spi.Jcr2spiRepositoryFactory}.
+     * Otherwise it delegates to
+     * {@link org.apache.jackrabbit.core.RepositoryFactoryImpl}.
      *
      * @see RepositoryFactory#getRepository(java.util.Map)
      */
-    public Repository getRepository(Map parameters) throws RepositoryException {
-        RepositoryConfig config = null;
-        if (parameters == null) {
-            config = org.apache.jackrabbit.client.spi2dav.RepositoryConfigImpl.create((Map) null);
-        } else {
-            Object param = parameters.get(REPOSITORY_CONFIG);
-            if (param != null && param instanceof RepositoryConfig) {
-                config = (RepositoryConfig) param;
-            }
-            if (config == null) {
-                config = org.apache.jackrabbit.client.spi2davex.RepositoryConfigImpl.create(parameters);
-                if (config == null) {
-                    config = org.apache.jackrabbit.client.spi2dav.RepositoryConfigImpl.create(parameters);
-                }
-                if (config == null) {
-                    config = org.apache.jackrabbit.client.spi2jcr.RepositoryConfigImpl.create(parameters);
-                }
-            }
+    public Repository getRepository(@SuppressWarnings("unchecked") Map parameters) throws RepositoryException {
+        String repositoryFactoryName = parameters != null && (
+                                       parameters.containsKey(PARAM_REPOSITORY_SERVICE_FACTORY) ||
+                                       parameters.containsKey(PARAM_REPOSITORY_CONFIG))
+                ? "org.apache.jackrabbit.jcr2spi.Jcr2spiRepositoryFactory"
+                : "org.apache.jackrabbit.core.RepositoryFactoryImpl";
+
+        Object repositoryFactory;
+        try {
+            Class<?> repositoryFactoryClass = Class.forName(repositoryFactoryName, true,
+                    Thread.currentThread().getContextClassLoader());
+
+            repositoryFactory = repositoryFactoryClass.newInstance();
+        }
+        catch (Exception e) {
+            throw new RepositoryException(e);
         }
 
-        if (config != null) {
-            config = org.apache.jackrabbit.client.spilogger.RepositoryConfigImpl.create(config, parameters);
-            return RepositoryImpl.create(config);
-        } else {
-            log.debug("Unable to create Repository: Unknown parameters.");
-            return null;
+        if (repositoryFactory instanceof RepositoryFactory) {
+            return ((RepositoryFactory) repositoryFactory).getRepository(parameters);
+        }
+        else {
+            throw new RepositoryException(repositoryFactory + " is not a RepositoryFactory");
         }
     }
 }
\ No newline at end of file



Mime
View raw message