jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r812570 [19/24] - in /jackrabbit/sandbox/JCR-1456: ./ jackrabbit-api/ jackrabbit-api/src/main/appended-resources/ jackrabbit-api/src/main/appended-resources/META-INF/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/ jackrabb...
Date Tue, 08 Sep 2009 16:09:45 GMT
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/WeakReferenceValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/WeakReferenceValue.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/WeakReferenceValue.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/WeakReferenceValue.java Tue Sep  8 16:09:28 2009
@@ -16,14 +16,13 @@
  */
 package org.apache.jackrabbit.value;
 
-import org.apache.jackrabbit.uuid.UUID;
-
 import javax.jcr.Node;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.ValueFormatException;
 import java.util.Calendar;
+import java.util.UUID;
 import java.math.BigDecimal;
 
 /**
@@ -148,8 +147,6 @@
     public Calendar getDate()
             throws ValueFormatException, IllegalStateException,
             RepositoryException {
-        setValueConsumed();
-
         throw new ValueFormatException("conversion to date failed: inconvertible types");
     }
 
@@ -159,8 +156,6 @@
     public long getLong()
             throws ValueFormatException, IllegalStateException,
             RepositoryException {
-        setValueConsumed();
-
         throw new ValueFormatException("conversion to long failed: inconvertible types");
     }
 
@@ -170,8 +165,6 @@
     public boolean getBoolean()
             throws ValueFormatException, IllegalStateException,
             RepositoryException {
-        setValueConsumed();
-
         throw new ValueFormatException("conversion to boolean failed: inconvertible types");
     }
 
@@ -181,8 +174,6 @@
     public double getDouble()
             throws ValueFormatException, IllegalStateException,
             RepositoryException {
-        setValueConsumed();
-
         throw new ValueFormatException("conversion to double failed: inconvertible types");
     }
 
@@ -192,8 +183,6 @@
     public BigDecimal getDecimal()
             throws ValueFormatException, IllegalStateException,
             RepositoryException {
-        setValueConsumed();
-
         throw new ValueFormatException("conversion to Decimal failed: inconvertible types");
     }
 }
\ No newline at end of file

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonWriter.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonWriter.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonWriter.java Tue Sep  8 16:09:28 2009
@@ -88,7 +88,7 @@
         final NodeIterator children = node.getNodes();
         if (!children.hasNext()) {
             // no child present at all -> add special property.
-            writeKeyValue(writer, "::NodeIteratorSize", "0", false);
+            writeKeyValue(writer, "::NodeIteratorSize", 0);
         } else {
             // the child nodes
             while (children.hasNext()) {
@@ -162,14 +162,14 @@
             // mark binary properties with a leading ':'
             // the value(s) reflect the jcr-values length instead of the binary data.
             String key = ":" + p.getName();
-            if (p.getDefinition().isMultiple()) {
+            if (p.isMultiple()) {
                 long[] binLengths = p.getLengths();
                 writeKeyArray(w, key, binLengths);
             } else {
                 writeKeyValue(w, key, p.getLength());
             }
         } else {
-            boolean isMultiple = p.getDefinition().isMultiple();
+            boolean isMultiple = p.isMultiple();
             if (type == PropertyType.NAME || type == PropertyType.PATH ||
                     type == PropertyType.REFERENCE || type == PropertyType.DATE ||
                     (isMultiple && p.getValues().length == 0)) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java Tue Sep  8 16:09:28 2009
@@ -335,7 +335,7 @@
      */
     private boolean isMultiple() {
         try {
-            if (exists() && ((Property)item).getDefinition().isMultiple()) {
+            if (exists() && ((Property)item).isMultiple()) {
                 return true;
             }
         } catch (RepositoryException e) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java Tue Sep  8 16:09:28 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.webdav.jcr.observation;
 
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
 import org.apache.jackrabbit.webdav.DavServletResponse;
@@ -50,6 +49,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 
 /**
  * The <code>Subscription</code> class encapsulates a single subscription with

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java Tue Sep  8 16:09:28 2009
@@ -29,6 +29,9 @@
 import org.w3c.dom.Element;
 
 import javax.jcr.Repository;
+import javax.jcr.Value;
+import javax.jcr.RepositoryException;
+import javax.jcr.PropertyType;
 
 /**
  * <code>RepositoryDescriptorsReport</code> allows to retrieve the repository
@@ -96,11 +99,22 @@
     public Element toXml(Document document) {
         Repository repository = getRepositorySession().getRepository();
         Element report = DomUtil.createElement(document, "repositorydescriptors-report", NAMESPACE);
-        String[] keys = repository.getDescriptorKeys();
-        for (int i = 0; i < keys.length; i++) {
+        for (String key : repository.getDescriptorKeys()) {
             Element elem = DomUtil.addChildElement(report, XML_DESCRIPTOR, NAMESPACE);
-            DomUtil.addChildElement(elem, XML_DESCRIPTORKEY, NAMESPACE, keys[i]);
-            DomUtil.addChildElement(elem, XML_DESCRIPTORVALUE, NAMESPACE, repository.getDescriptor(keys[i]));
+            DomUtil.addChildElement(elem, XML_DESCRIPTORKEY, NAMESPACE, key);
+            for (Value v : repository.getDescriptorValues(key)) {
+                String value;
+                try {
+                    value = v.getString();
+                } catch (RepositoryException e) {
+                    log.error("Internal error while reading descriptor value: ", e);
+                    value = repository.getDescriptor(key);
+                }
+                Element child = DomUtil.addChildElement(elem, XML_DESCRIPTORVALUE, NAMESPACE, value);
+                if (PropertyType.STRING != v.getType()) {
+                    child.setAttribute(ATTR_VALUE_TYPE, PropertyType.nameFromValue(v.getType()));
+                }
+            }
         }
         return report;
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java Tue Sep  8 16:09:28 2009
@@ -29,7 +29,6 @@
 import org.apache.jackrabbit.server.io.PropertyExportContext;
 import org.apache.jackrabbit.server.io.PropertyImportContext;
 import org.apache.jackrabbit.util.Text;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.webdav.DavCompliance;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResource;
@@ -83,6 +82,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.UUID;
 
 /**
  * DavResourceImpl implements a DavResource.

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/server/remoting/davex/JsonDiffHandlerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/server/remoting/davex/JsonDiffHandlerTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/server/remoting/davex/JsonDiffHandlerTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/server/remoting/davex/JsonDiffHandlerTest.java Tue Sep  8 16:09:28 2009
@@ -234,7 +234,7 @@
             return null;
         }
 
-        public boolean hasCapability(String arg0, Object arg1, Map arg2)
+        public boolean hasCapability(String arg0, Object arg1, Object[] arg2)
                 throws RepositoryException {
             // TODO Auto-generated method stub
             return false;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/pom.xml?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/pom.xml (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/pom.xml Tue Sep  8 16:09:28 2009
@@ -63,6 +63,8 @@
         <configuration>
           <excludes>
             <exclude>**/nodetype/spec/*.txt</exclude>
+            <exclude>*.log</exclude>
+            <exclude>.checkstyle</exclude>
           </excludes>
         </configuration>
       </plugin>

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java Tue Sep  8 16:09:28 2009
@@ -169,6 +169,11 @@
     protected String ntBase;
 
     /**
+     * JCR Name nt:unstructured using the namespace resolver of the current session.
+     */
+    protected String ntUnstructured;
+
+    /**
      * JCR Name nt:version using the namespace resolver of the current session.
      */
     protected String ntVersion;
@@ -356,6 +361,7 @@
         jcrMergeFailed = superuser.getNamespacePrefix(NS_JCR_URI) + ":mergeFailed";
         jcrSystem = superuser.getNamespacePrefix(NS_JCR_URI) + ":system";
         ntBase = superuser.getNamespacePrefix(NS_NT_URI) + ":base";
+        ntUnstructured = superuser.getNamespacePrefix(NS_NT_URI) + ":unstructured";
         ntVersion = superuser.getNamespacePrefix(NS_NT_URI) + ":version";
         ntVersionHistory = superuser.getNamespacePrefix(NS_NT_URI) + ":versionHistory";
         ntVersionLabels = superuser.getNamespacePrefix(NS_NT_URI) + ":versionLabels";

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BooleanPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BooleanPropertyTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BooleanPropertyTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BooleanPropertyTest.java Tue Sep  8 16:09:28 2009
@@ -137,17 +137,15 @@
         }
         try {
             val.getBoolean();
-            fail("Non stream method call after stream method call " +
-                    "should throw an IllegalStateException");
         } catch (IllegalStateException ise) {
-            //ok
+            fail("Non stream method call after stream method call " +
+                    "should not throw an IllegalStateException");
         }
         try {
             ins = otherVal.getStream();
-            fail("Stream method call after a non stream method call " +
-                    "should throw an IllegalStateException");
         } catch (IllegalStateException ise) {
-            // ok
+            fail("Stream method call after a non stream method call " +
+                    "should not throw an IllegalStateException");
         } finally {
             if (in != null) {
                 in.close();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DatePropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DatePropertyTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DatePropertyTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DatePropertyTest.java Tue Sep  8 16:09:28 2009
@@ -146,17 +146,15 @@
         }
         try {
             val.getDate();
-            fail("Non stream method call after stream method call " +
-                    "should throw an IllegalStateException.");
         } catch (IllegalStateException ise) {
-            //ok
+            fail("Non stream method call after stream method call " +
+                    "should not throw an IllegalStateException.");
         }
         try {
             ins = otherVal.getStream();
-            fail("Stream method call after a non stream method call " +
-                    "should throw an IllegalStateException.");
         } catch (IllegalStateException ise) {
-            // ok
+            fail("Stream method call after a non stream method call " +
+                    "should not throw an IllegalStateException.");
         } finally {
             if (in != null) {
                 in.close();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java Tue Sep  8 16:09:28 2009
@@ -130,17 +130,15 @@
         }
         try {
             val.getDouble();
-            fail("Non stream method call after stream method call " +
-                    "should throw an IllegalStateException.");
         } catch (IllegalStateException ise) {
-            //ok
+            fail("Non stream method call after stream method call " +
+                    "should not throw an IllegalStateException.");
         }
         try {
             ins = otherVal.getStream();
-            fail("Stream method call after a non stream method call " +
-                    "should throw an IllegalStateException.");
         } catch (IllegalStateException ise) {
-            // ok
+            fail("Stream method call after a non stream method call " +
+                    "should not throw an IllegalStateException.");
         } finally {
             if (in != null) {
                 in.close();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java Tue Sep  8 16:09:28 2009
@@ -128,17 +128,15 @@
         }
         try {
             val.getLong();
-            fail("Non stream method call after stream method call " +
-                    "should throw an IllegalStateException.");
         } catch (IllegalStateException ise) {
-            //ok
+            fail("Non stream method call after stream method call " +
+                    "should not throw an IllegalStateException.");
         }
         try {
             ins = otherVal.getStream();
-            fail("Stream method call after a non stream method call " +
-                    "should throw an IllegalStateException.");
         } catch (IllegalStateException ise) {
-            // ok
+            fail("Stream method call after a non stream method call " +
+                    "should not throw an IllegalStateException.");
         } finally {
             if (in != null) {
                 in.close();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencesTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencesTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencesTest.java Tue Sep  8 16:09:28 2009
@@ -24,6 +24,8 @@
 import javax.jcr.PropertyIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
+import java.util.Set;
+import java.util.HashSet;
 
 /**
  * <code>ReferencesTest</code> contains the test cases for the references.
@@ -111,6 +113,88 @@
     }
 
     /**
+     * Tests Node.getReferences(String)
+     */
+    public void testGetReferencesWithName() throws RepositoryException, NotExecutableException {
+        Node n1 = testRootNode.addNode(nodeName1, testNodeType);
+        ensureMixinType(n1, mixReferenceable);
+
+        // with some impls. the mixin type has only affect upon save
+        testRootNode.save();
+
+        // make sure the node is now referenceable
+        assertTrue("test node should be mix:referenceable", n1.isNodeType(mixReferenceable));
+
+        // create references:
+        // n2.p1 -> n1
+        // n2.p2 -> n1
+        // n3.p1 -> n1
+        Node n2 = testRootNode.addNode(nodeName2, testNodeType);
+        Node n3 = testRootNode.addNode(nodeName3, testNodeType);
+
+        Value[] values = new Value[]{superuser.getValueFactory().createValue(n1)};
+
+        // abort test if the repository does not allow setting
+        // reference properties on this node
+        ensureCanSetProperty(n2, propertyName1, values);
+        ensureCanSetProperty(n2, propertyName2, values);
+        ensureCanSetProperty(n3, propertyName1, values);
+
+        Property p1 = n2.setProperty(propertyName1, values);
+        Property p2 = n2.setProperty(propertyName2, values);
+        Property p3 = n3.setProperty(propertyName1, n1);
+        testRootNode.save();
+
+        // get references with name propertyName1
+        // (should return p1 and p3))
+        PropertyIterator iter = n1.getReferences(propertyName1);
+        Set results = new HashSet();
+        while (iter.hasNext()) {
+            results.add(iter.nextProperty().getPath());
+        }
+        assertEquals("wrong number of references reported", 2, results.size());
+        assertTrue("missing reference property: " + p1.getPath(), results.contains(p1.getPath()));
+        assertTrue("missing reference property: " + p3.getPath(), results.contains(p3.getPath()));
+
+        // get references with name propertyName2
+        // (should return p2))
+        iter = n1.getReferences(propertyName2);
+        results.clear();
+        while (iter.hasNext()) {
+            results.add(iter.nextProperty().getPath());
+        }
+        assertEquals("wrong number of references reported", 1, results.size());
+        assertTrue("missing reference property: " + p2.getPath(), results.contains(p2.getPath()));
+
+        // remove reference n3.p1 -> n1
+        testRootNode.getNode(nodeName3).getProperty(propertyName1).remove();
+        testRootNode.save();
+
+        // get references with name propertyName1
+        // (should return p1))
+        iter = n1.getReferences(propertyName1);
+        results.clear();
+        while (iter.hasNext()) {
+            results.add(iter.nextProperty().getPath());
+        }
+        assertEquals("wrong number of references reported", 1, results.size());
+        assertTrue("missing reference property: " + p1.getPath(), results.contains(p1.getPath()));
+
+        // remove reference n2.p1 -> n1
+        p1.remove();
+        testRootNode.save();
+
+        // get references with name propertyName1
+        // (should nothing))
+        iter = n1.getReferences(propertyName1);
+        results.clear();
+        while (iter.hasNext()) {
+            results.add(iter.nextProperty().getPath());
+        }
+        assertEquals("wrong number of references reported", 0, results.size());
+    }
+
+    /**
      * Tests Property.getNode();
      */
     public void testReferenceTarget() throws RepositoryException, NotExecutableException {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/RepositoryDescriptorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/RepositoryDescriptorTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/RepositoryDescriptorTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/RepositoryDescriptorTest.java Tue Sep  8 16:09:28 2009
@@ -20,6 +20,9 @@
 
 import javax.jcr.Repository;
 import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
 import java.util.Set;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -39,21 +42,55 @@
     private static final Set requiredDescriptorKeys = new HashSet();
 
     static {
+        requiredDescriptorKeys.add(Repository.IDENTIFIER_STABILITY);
         requiredDescriptorKeys.add(Repository.LEVEL_1_SUPPORTED);
         requiredDescriptorKeys.add(Repository.LEVEL_2_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.OPTION_NODE_TYPE_MANAGEMENT_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.NODE_TYPE_MANAGEMENT_AUTOCREATED_DEFINITIONS_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.NODE_TYPE_MANAGEMENT_INHERITANCE);
+        requiredDescriptorKeys.add(Repository.NODE_TYPE_MANAGEMENT_MULTIPLE_BINARY_PROPERTIES_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.NODE_TYPE_MANAGEMENT_MULTIVALUED_PROPERTIES_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.NODE_TYPE_MANAGEMENT_ORDERABLE_CHILD_NODES_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.NODE_TYPE_MANAGEMENT_OVERRIDES_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.NODE_TYPE_MANAGEMENT_PRIMARY_ITEM_NAME_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.NODE_TYPE_MANAGEMENT_PROPERTY_TYPES);
+        requiredDescriptorKeys.add(Repository.NODE_TYPE_MANAGEMENT_RESIDUAL_DEFINITIONS_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.NODE_TYPE_MANAGEMENT_SAME_NAME_SIBLINGS_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.NODE_TYPE_MANAGEMENT_VALUE_CONSTRAINTS_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.NODE_TYPE_MANAGEMENT_UPDATE_IN_USE_SUPORTED);
+        requiredDescriptorKeys.add(Repository.OPTION_ACCESS_CONTROL_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.OPTION_JOURNALED_OBSERVATION_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.OPTION_LIFECYCLE_SUPPORTED);
         requiredDescriptorKeys.add(Repository.OPTION_LOCKING_SUPPORTED);
         requiredDescriptorKeys.add(Repository.OPTION_OBSERVATION_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.OPTION_NODE_AND_PROPERTY_WITH_SAME_NAME_SUPPORTED);
         requiredDescriptorKeys.add(Repository.OPTION_QUERY_SQL_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.OPTION_RETENTION_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.OPTION_SHAREABLE_NODES_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.OPTION_SIMPLE_VERSIONING_SUPPORTED);
         requiredDescriptorKeys.add(Repository.OPTION_TRANSACTIONS_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.OPTION_UNFILED_CONTENT_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.OPTION_UPDATE_MIXIN_NODE_TYPES_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.OPTION_UPDATE_PRIMARY_NODE_TYPE_SUPPORTED);
         requiredDescriptorKeys.add(Repository.OPTION_VERSIONING_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.OPTION_WORKSPACE_MANAGEMENT_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.OPTION_XML_EXPORT_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.OPTION_XML_IMPORT_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.OPTION_ACTIVITIES_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.OPTION_BASELINES_SUPPORTED);
+        
+        requiredDescriptorKeys.add(Repository.QUERY_FULL_TEXT_SEARCH_SUPPORTED);
+        requiredDescriptorKeys.add(Repository.QUERY_JOINS);
+        requiredDescriptorKeys.add(Repository.QUERY_LANGUAGES);
+        requiredDescriptorKeys.add(Repository.QUERY_STORED_QUERIES_SUPPORTED);
         requiredDescriptorKeys.add(Repository.QUERY_XPATH_DOC_ORDER);
         requiredDescriptorKeys.add(Repository.QUERY_XPATH_POS_INDEX);
         requiredDescriptorKeys.add(Repository.REP_NAME_DESC);
         requiredDescriptorKeys.add(Repository.REP_VENDOR_DESC);
         requiredDescriptorKeys.add(Repository.REP_VENDOR_URL_DESC);
-        requiredDescriptorKeys.add(Repository.REP_VERSION_DESC);
         requiredDescriptorKeys.add(Repository.SPEC_NAME_DESC);
         requiredDescriptorKeys.add(Repository.SPEC_VERSION_DESC);
+        requiredDescriptorKeys.add(Repository.WRITE_SUPPORTED);
     }
 
     /** The session for the tests */
@@ -83,10 +120,19 @@
      * Tests that the required repository descriptors are available.
      */
     public void testRequiredDescriptors() {
+        Repository rep = session.getRepository();
         for (Iterator it = requiredDescriptorKeys.iterator(); it.hasNext();) {
-            String descriptor = session.getRepository().getDescriptor((String) it.next());
-            assertNotNull("Not all required descriptors are available.",
-                    descriptor);
+            String descName = (String) it.next();
+            assertTrue(descName + " is a standard descriptor", rep.isStandardDescriptor(descName));
+            if (rep.isSingleValueDescriptor(descName)) {
+                Value val = rep.getDescriptorValue(descName);
+                assertNotNull("Required descriptor is missing: " + descName,
+                        val);
+            } else {
+                Value[] vals = rep.getDescriptorValues(descName);
+                assertNotNull("Required descriptor is missing: " + descName,
+                        vals);
+            }
         }
     }
 
@@ -98,9 +144,35 @@
         List keys = Arrays.asList(session.getRepository().getDescriptorKeys());
         for (Iterator it = requiredDescriptorKeys.iterator(); it.hasNext();) {
             String key = (String) it.next();
-            assertTrue(key + " is missing from the required descriptor keys.",
+            assertTrue("Required descriptor is missing: " + key,
                     keys.contains(key));
         }
     }
 
+    /**
+     * Tests whether {@link Repository#getDescriptorValues(String)} returns an
+     * Value[] of size 1 for single valued descriptors.
+     */
+    public void testGetDescriptorValues() {
+        Repository rep = session.getRepository();
+        // "option.node.type.management.supported" denotes a single-valued BOOLEAN descriptor
+        String descName = Repository.OPTION_NODE_TYPE_MANAGEMENT_SUPPORTED;
+        assertTrue(rep.isSingleValueDescriptor(descName));
+        Value[] vals = rep.getDescriptorValues(descName);
+        assertNotNull("Required descriptor is missing: " + descName, vals);
+        assertEquals(1, vals.length);
+        assertEquals(PropertyType.BOOLEAN, vals[0].getType());
+        try {
+            // getDescriptorValue(key).getString() is equivalent to getDescriptor(key)
+            assertEquals(vals[0].getString(), rep.getDescriptor(descName));
+        } catch (RepositoryException e) {
+            fail(e.getMessage());
+        }
+
+        // "option.node.type.management.supported" denotes a single-valued BOOLEAN descriptor
+        descName = Repository.QUERY_LANGUAGES;
+        assertFalse(rep.isSingleValueDescriptor(descName));
+        Value val = rep.getDescriptorValue(descName);
+        assertNull(descName + " is a multi-value descriptor, getDescriptorValue() should return null", val);
+    }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java Tue Sep  8 16:09:28 2009
@@ -452,7 +452,8 @@
             throws Exception {
 
         treeComparator.createExampleTree();
-        Node node = testRootNode.addNode("ntBase", ntBase);
+        String nodetype = testNodeTypeNoChildren == null ? ntBase : testNodeTypeNoChildren;
+        Node node = testRootNode.addNode("ntBase", nodetype);
         session.save();
 
         FileInputStream in = new FileInputStream(file);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionTest.java Tue Sep  8 16:09:28 2009
@@ -667,4 +667,38 @@
         assertFalse("Session should have no pending changes recorded after property has been removed and saved!", superuser.hasPendingChanges());
 
     }
+
+    /**
+     * Checks if {@link javax.jcr.Session#hasCapability(String, Object, Object[])}
+     * works as specified.
+     * <p/>
+     *
+     * @throws RepositoryException
+     */
+    public void testHasCapability() throws RepositoryException {
+        Session roSession = getHelper().getReadOnlySession();
+        try {
+            Node root = roSession.getRootNode();
+            Object[] args = new Object[] { "foo" };
+            if (!roSession.hasCapability("addNode",  root, args)) {
+                // if hasCapability() returns false, the actual method call
+                // is expected to fail
+                try {
+                    root.addNode("foo");
+                    fail("Node.addNode() should fail according to Session.hasCapability()");
+                } catch (RepositoryException e) {
+                    // expected 
+                }
+            } else {
+                // hasCapability() returning true doesn't guarantee that the
+                // actual method call succeeds, it's just a best-effort.
+                // therefore nothing to test here...
+            }
+
+        } finally {
+            roSession.logout();
+        }
+
+    }
+
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java Tue Sep  8 16:09:28 2009
@@ -122,9 +122,7 @@
 
         Property prop;
 
-        // create an extra value for BINARY property to avoid IllegalStateException
-        Value stringValueForBinary = NodeTypeUtil.getValueOfType(superuser, PropertyType.STRING);
-        prop = testNode.setProperty(testPropName, stringValueForBinary, PropertyType.BINARY);
+        prop = testNode.setProperty(testPropName, binaryValue, PropertyType.BINARY);
         assertEquals("setProperty(String, Value, int) of a property of type undefined " +
                      "must assume the property type of the type parameter.",
                      PropertyType.BINARY,
@@ -186,10 +184,7 @@
 
         Property prop;
 
-        // create an extra value for BINARY property to avoid IllegalStateException
-        Value stringValuesForBinary[] =
-            new Value[] {NodeTypeUtil.getValueOfType(superuser, PropertyType.STRING)};
-        prop = testNode.setProperty(testPropName, stringValuesForBinary, PropertyType.BINARY);
+        prop = testNode.setProperty(testPropName, binaryValues, PropertyType.BINARY);
         assertEquals("setProperty(String, Value, int) of a property of type undefined " +
                      "must assume the property type of the type parameter.",
                      PropertyType.BINARY,

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java Tue Sep  8 16:09:28 2009
@@ -38,6 +38,7 @@
 import javax.jcr.version.Version;
 
 import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
 
 /**
  * Tests features available with shareable nodes.
@@ -48,8 +49,13 @@
 
     protected void setUp() throws Exception {
         super.setUp();
-        checkSupportedOption(Repository.OPTION_SHAREABLE_NODES_SUPPORTED);
-        ensureKnowsNodeType(superuser, mixShareable);
+        try {
+            checkSupportedOption(Repository.OPTION_SHAREABLE_NODES_SUPPORTED);
+            ensureKnowsNodeType(superuser, mixShareable);
+        } catch (NotExecutableException e) {
+            cleanUp();
+            throw e;
+        }
         mixShareable = superuser.getNamespacePrefix(NS_MIX_URI) + ":shareable";
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/StringPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/StringPropertyTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/StringPropertyTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/StringPropertyTest.java Tue Sep  8 16:09:28 2009
@@ -193,17 +193,15 @@
         }
         try {
             val.getString();
-            fail("Non stream method call after stream method call " +
-                    "should throw an IllegalStateException.");
         } catch (IllegalStateException ise) {
-            //ok
+            fail("Non stream method call after stream method call " +
+                    "should not throw an IllegalStateException.");
         }
         try {
             otherVal.getStream();
-            fail("Stream method call after a non stream method call " +
-                    "should throw an IllegalStateException.");
         } catch (IllegalStateException ise) {
-            // ok
+            fail("Stream method call after a non stream method call " +
+                    "should not throw an IllegalStateException.");
         }
         in.close();
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TestAll.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TestAll.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TestAll.java Tue Sep  8 16:09:28 2009
@@ -148,22 +148,21 @@
         suite.addTestSuite(GetWeakReferencesTest.class);
 
         //// new Session features
-        
         suite.addTestSuite(SessionRemoveItemTest.class);
         suite.addTestSuite(HasPermissionTest.class);
 
         //// new Workspace features
-        
         suite.addTestSuite(WorkspaceTest.class);
-        
+
         //// shareable nodes
-        
         suite.addTestSuite(ShareableNodeTest.class);
-        
+
         //// repository factory
-        
         suite.addTestSuite(RepositoryFactoryTest.class);
-        
+
+        //// lifecycle management
+        suite.addTestSuite(LifecycleTest.class);
+
         return suite;
     }
 }
\ No newline at end of file

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java Tue Sep  8 16:09:28 2009
@@ -108,7 +108,8 @@
      */
     public void testCloneNodesConstraintViolationException() throws RepositoryException {
         // if parent node is nt:base then no sub nodes can be created
-        Node subNodesNotAllowedNode = testRootNodeW2.addNode(nodeName3, ntBase);
+        String nodetype = testNodeTypeNoChildren == null ? ntBase : testNodeTypeNoChildren;
+        Node subNodesNotAllowedNode = testRootNodeW2.addNode(nodeName3, nodetype);
         testRootNodeW2.save();
         try {
             String dstAbsPath = subNodesNotAllowedNode.getPath() + "/" + node2.getName();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java Tue Sep  8 16:09:28 2009
@@ -91,7 +91,8 @@
      */
     public void testCopyNodesConstraintViolationException() throws RepositoryException {
         // if parent node is nt:base then no sub nodes can be created
-        Node subNodesNotAllowedNode = testRootNodeW2.addNode(nodeName3, ntBase);
+        String nodetype = testNodeTypeNoChildren == null ? ntBase : testNodeTypeNoChildren;
+        Node subNodesNotAllowedNode = testRootNodeW2.addNode(nodeName3, nodetype);
         testRootNodeW2.save();
         try {
             String dstAbsPath = subNodesNotAllowedNode.getPath() + "/" + node2.getName();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java Tue Sep  8 16:09:28 2009
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.test.api.lock;
 
 import javax.jcr.Node;
+import javax.jcr.Property;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
@@ -257,39 +258,34 @@
     /**
      * Test expiration of the lock
      */
-    public void testLockExpiration() throws RepositoryException, NotExecutableException {
+    public synchronized void testLockExpiration()
+            throws RepositoryException, NotExecutableException {
         lockedNode.unlock();
 
-        ObservationManager obsMgr = superuser.getWorkspace().getObservationManager();
-        EventResult listener = new EventResult(((JUnitTest) this).log);
-        try {
-            obsMgr.addEventListener(listener, Event.PROPERTY_REMOVED, lockedNode.getPath(), false, new String[0], new String[0], false);
-
-            boolean lockPropRemoved = false;            
-            long hint = 1;
-            lock = lockMgr.lock(lockedNode.getPath(), isDeep(), isSessionScoped(), hint, null);
-            // only test if timeout hint was respected.
-            if (lock.getSecondsRemaining() <= 1) {
-                Event[] evts = listener.getEvents(2000);
-                for (int i = 0; i < evts.length; i++) {
-                    if (evts[i].getType() == Event.PROPERTY_REMOVED &&
-                            evts[i].getPath().endsWith(jcrLockOwner)) {
-                        lockPropRemoved = true;
-                        // lock property has been removed -> make sure lock has
-                        // been released and lock.getSecondsRemaining behaves properly.
-                        assertTrue("A released lock must return a negative number of seconds", lock.getSecondsRemaining() < 0);
-                        assertFalse("If the timeout hint is respected the lock must be automatically released.", lock.isLive());
-                        assertFalse("If the timeout hint is respected the lock must be automatically released.", lockedNode.isLocked());
-                    }
-                }
-                if (!lockPropRemoved) {
-                    fail("If the timeout hint is respected the lock must be automatically released.");
-                }
-            } else {
-                throw new NotExecutableException("timeout hint was ignored.");
+        long hint = 1;
+        lock = lockMgr.lock(
+                lockedNode.getPath(), isDeep(), isSessionScoped(), hint, null);
+
+        // only test if timeout hint was respected.
+        long remaining = lock.getSecondsRemaining();
+        if (remaining <= hint) {
+            try {
+                wait(remaining * 2000); // wait twice as long to be safe
+            } catch (InterruptedException ignore) {
             }
-        } finally {
-            obsMgr.removeEventListener(listener);
+            long secs = lock.getSecondsRemaining();
+            assertTrue(
+                    "A released lock must return a negative number of seconds, was: " + secs,
+                    secs < 0);
+            String message = "If the timeout hint is respected the lock"
+                + " must be automatically released.";
+            assertFalse(message, lock.isLive());
+            assertFalse(message, lockedNode.isLocked());
+            assertFalse(message, lockMgr.isLocked(lockedNode.getPath()));
+            assertFalse(message, lockedNode.hasProperty(Property.JCR_LOCK_IS_DEEP));
+            assertFalse(message, lockedNode.hasProperty(Property.JCR_LOCK_OWNER));
+        } else {
+            throw new NotExecutableException("timeout hint was ignored.");
         }
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanAddChildNodeCallWithNodeTypeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanAddChildNodeCallWithNodeTypeTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanAddChildNodeCallWithNodeTypeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/CanAddChildNodeCallWithNodeTypeTest.java Tue Sep  8 16:09:28 2009
@@ -16,15 +16,15 @@
  */
 package org.apache.jackrabbit.test.api.nodetype;
 
-import org.apache.jackrabbit.test.AbstractJCRTest;
-import org.apache.jackrabbit.test.NotExecutableException;
-
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.NodeType;
-import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.NodeTypeIterator;
+import javax.jcr.nodetype.NodeTypeManager;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
 
 /**
  * Tests <code>NodeType.canAddChildNode(String childNodeName, String nodeTypeName)</code>
@@ -88,6 +88,10 @@
         NodeType nodeType = nodeDef.getDeclaringNodeType();
         String childNodeName = nodeDef.getName();
         String nodeTypeName = nodeDef.getRequiredPrimaryTypes()[0].getName();
+        if (nodeTypeName.equals(ntBase)) {
+            // nt:base is abstract and can never be added, upgrade for check below
+            nodeTypeName = ntUnstructured;
+        }
 
         assertTrue("NodeType.canAddChildNode(String childNodeName, String nodeTypeName) " +
                 "must return true if childNodeName and nodeTypeName match the " +
@@ -221,6 +225,10 @@
         }
 
         String type = nodeDef.getRequiredPrimaryTypes()[0].getName();
+        if (type.equals(ntBase)) {
+            // nt:base is abstract and can never be added, upgrade for check below
+            type = ntUnstructured;
+        }
         NodeType nodeType = nodeDef.getDeclaringNodeType();
         String undefinedName = NodeTypeUtil.getUndefinedChildNodeName(nodeType);
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeCreationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeCreationTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeCreationTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeCreationTest.java Tue Sep  8 16:09:28 2009
@@ -17,13 +17,22 @@
 package org.apache.jackrabbit.test.api.nodetype;
 
 import java.util.List;
+import java.util.Arrays;
 
 import javax.jcr.PropertyType;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
+import javax.jcr.Value;
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.NodeTypeTemplate;
 import javax.jcr.nodetype.PropertyDefinitionTemplate;
+import javax.jcr.nodetype.NodeDefinitionTemplate;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NodeTypeDefinition;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeTypeExistsException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.query.qom.QueryObjectModelConstants;
 import javax.jcr.version.OnParentVersionAction;
 
@@ -39,9 +48,9 @@
  */
 public class NodeTypeCreationTest extends AbstractJCRTest {
 
-    private static String ns = "http://example.org/jcr-tck/";
-    private static String propname = "{" + ns + "}" + "boolean";
-    
+    private String expandedPropName;
+    private String jcrPropName;
+
     private NodeTypeManager ntm;
     
     /**
@@ -51,6 +60,9 @@
         super.setUp();
         ntm = superuser.getWorkspace().getNodeTypeManager();
         super.checkSupportedOption(Repository.OPTION_NODE_TYPE_MANAGEMENT_SUPPORTED);
+
+        expandedPropName = "{" + NS_JCR_URI + "}" + "boolean";
+        jcrPropName = superuser.getNamespacePrefix(NS_JCR_URI) + ":boolean";
     }
 
     /**
@@ -60,28 +72,176 @@
         super.tearDown();
     }
 
+    public void testEmptyNodeTypeTemplate() throws Exception {
+
+        NodeTypeTemplate ntt = ntm.createNodeTypeTemplate();
+        assertNull(ntt.getName());
+
+        assertFalse(ntt.isMixin());
+        assertFalse(ntt.isAbstract());
+        assertFalse(ntt.hasOrderableChildNodes());
+        
+        // note: isQueryable cannot be tested as defautl value is defined
+        // by the implementation
+
+        assertNotNull(ntt.getDeclaredSupertypeNames());
+        assertEquals(0, ntt.getDeclaredSupertypeNames().length);
+
+        assertNull(ntt.getPrimaryItemName());
+
+        assertNull(ntt.getDeclaredChildNodeDefinitions());
+        assertNull(ntt.getDeclaredPropertyDefinitions());
+
+        assertNotNull(ntt.getNodeDefinitionTemplates());
+        assertTrue(ntt.getNodeDefinitionTemplates().isEmpty());
+
+        assertNotNull(ntt.getPropertyDefinitionTemplates());
+        assertTrue(ntt.getPropertyDefinitionTemplates().isEmpty());
+    }
+    
+    public void testNonEmptyNodeTypeTemplate() throws Exception {
+
+        NodeTypeDefinition ntd = ntm.getNodeType("nt:address");
+        NodeTypeTemplate ntt = ntm.createNodeTypeTemplate(ntm.getNodeType("nt:address"));
+
+        assertEquals(ntt.getName(), ntd.getName());
+        assertEquals(ntt.isMixin(), ntd.isMixin());
+        assertEquals(ntt.isAbstract(), ntd.isAbstract());
+        assertEquals(ntt.hasOrderableChildNodes(), ntd.hasOrderableChildNodes());
+        assertEquals(ntt.isQueryable(), ntd.isQueryable());
+        assertEquals(ntt.getPrimaryItemName(), ntd.getPrimaryItemName());
+        assertTrue(Arrays.equals(ntt.getDeclaredSupertypeNames(), ntd.getDeclaredSupertypeNames()));
+        NodeDefinition[] nda = ntt.getDeclaredChildNodeDefinitions();
+        NodeDefinition[] nda1 = ntd.getDeclaredChildNodeDefinitions();
+        assertEquals(nda.length, nda1.length);
+        for (int i = 0; i < nda.length; i++) {
+            assertEquals(nda[i].getName(), nda1[i].getName());
+            assertEquals(nda[i].allowsSameNameSiblings(), nda1[i].allowsSameNameSiblings());
+            assertTrue(Arrays.equals(nda[i].getRequiredPrimaryTypeNames(), nda1[i].getRequiredPrimaryTypeNames()));
+            assertEquals(nda[i].getDefaultPrimaryTypeName(), nda1[i].getDefaultPrimaryTypeName());
+            assertEquals(nda[i].getRequiredPrimaryTypeNames(), nda1[i].getRequiredPrimaryTypeNames());
+        }
+
+        PropertyDefinition[] pda = ntt.getDeclaredPropertyDefinitions();
+        PropertyDefinition[] pda1 = ntd.getDeclaredPropertyDefinitions();
+        assertEquals(pda.length, pda1.length);
+        for (int i = 0; i < pda.length; i++) {
+            assertEquals(pda[i].getName(), pda1[i].getName());
+            assertEquals(pda[i].getRequiredType(), pda1[i].getRequiredType());
+            assertTrue(Arrays.equals(pda[i].getAvailableQueryOperators(), pda1[i].getAvailableQueryOperators()));
+            assertTrue(Arrays.equals(pda[i].getValueConstraints(), pda1[i].getValueConstraints()));
+            assertEquals(pda[i].isFullTextSearchable(), pda1[i].isFullTextSearchable());
+            assertEquals(pda[i].isMultiple(), pda1[i].isMultiple());
+            assertEquals(pda[i].isQueryOrderable(), pda1[i].isQueryOrderable());
+        }
+    }
+
     public void testNewNodeTypeTemplate() throws Exception {
         
-        String ntname = "{" + ns + "}" + "littlemixin";
+        String expandedName = "{" + NS_MIX_URI + "}" + "littlemixin";
+        String jcrName = superuser.getNamespacePrefix(NS_MIX_URI) + ":littlemixin";
         
         NodeTypeTemplate ntt = ntm.createNodeTypeTemplate();
-        
-        ntt.setName(ntname);
+
+        ntt.setName(expandedName);
+        assertEquals(jcrName, ntt.getName());
+        ntt.setName(jcrName);
+        assertEquals(jcrName, ntt.getName());
+
         ntt.setAbstract(false);
-        ntt.setDeclaredSuperTypeNames(null);
+        assertFalse(ntt.isAbstract());
+
+        try {
+            ntt.setDeclaredSuperTypeNames(null);
+            fail("null isn't a valid array of jcr name");
+        } catch (ConstraintViolationException e) {
+            // success
+        }
+        assertNotNull(ntt.getDeclaredSupertypeNames());
+        assertEquals(0, ntt.getDeclaredSupertypeNames().length);
+
+        ntt.setDeclaredSuperTypeNames(new String[] {mixReferenceable});
+        assertNotNull(ntt.getDeclaredSupertypeNames());
+        assertEquals(1, ntt.getDeclaredSupertypeNames().length);
+        assertEquals(mixReferenceable, ntt.getDeclaredSupertypeNames()[0]);
+
         ntt.setMixin(true);
-        ntt.setOrderableChildNodes(false);
+        assertTrue(ntt.isMixin());
+
+        ntt.setOrderableChildNodes(true);
+        assertTrue(ntt.hasOrderableChildNodes());
+
         ntt.setQueryable(false);
+        assertFalse(ntt.isQueryable());
+
         ntt.setPrimaryItemName(null);
-        
+        assertNull(ntt.getPrimaryItemName());
+
+        ntt.setPrimaryItemName(jcrPrimaryType);
+        assertEquals(jcrPrimaryType, ntt.getPrimaryItemName());
+
+        PropertyDefinitionTemplate pdTemplate = createBooleanPropTemplate();
+
         List pdefs = ntt.getPropertyDefinitionTemplates();
-        pdefs.add(createBooleanPropTemplate());
+        pdefs.add(pdTemplate);
+
+        assertNotNull(ntt.getDeclaredPropertyDefinitions());
+        assertEquals(1, ntt.getDeclaredPropertyDefinitions().length);
+        assertEquals(pdTemplate, ntt.getDeclaredPropertyDefinitions()[0]);
+
+        pdefs = ntt.getPropertyDefinitionTemplates();
+        assertEquals(1, pdefs.size());
+        assertEquals(pdTemplate, pdefs.get(0));
+
+        NodeDefinitionTemplate ndTemplate = ntm.createNodeDefinitionTemplate();
+
+        List ndefs = ntt.getNodeDefinitionTemplates();
+        ndefs.add(ndTemplate);
+
+        assertNotNull(ntt.getDeclaredChildNodeDefinitions());
+        assertEquals(1, ntt.getDeclaredChildNodeDefinitions().length);
+        assertEquals(ndTemplate, ntt.getDeclaredChildNodeDefinitions()[0]);
+
+        ndefs = ntt.getNodeDefinitionTemplates();
+        assertEquals(1, ndefs.size());
+        assertEquals(ndTemplate, ndefs.get(0));
+    }
+
+    public void testEmptyPropertyDefinitionTemplate() throws Exception {
+        PropertyDefinitionTemplate pdt = ntm.createPropertyDefinitionTemplate();
+
+        assertNull(pdt.getName());
+        assertFalse(pdt.isAutoCreated());
+        assertFalse(pdt.isMandatory());
+        assertFalse(pdt.isProtected());
+        assertEquals(OnParentVersionAction.COPY, pdt.getOnParentVersion());
+        assertNull(pdt.getDeclaringNodeType());
+
+        assertEquals(PropertyType.STRING, pdt.getRequiredType());
+        assertFalse(pdt.isMultiple());
+        assertNull(pdt.getValueConstraints());
+        assertNull(pdt.getDefaultValues());
+
+        // the following methods cannot be tested as default value is
+        // implementation specific:
+        // - getAvailableQueryOperators
+        // - isFullTextSearchable
+        // - isQueryOrderable
+
     }
 
     public void testPropertyDefinitionTemplate() throws Exception {
         PropertyDefinitionTemplate pdt = createBooleanPropTemplate();
-        
-        assertEquals(propname, pdt.getName());
+
+        assertEquals(jcrPropName, pdt.getName());
+        try {
+            pdt.setName(null);
+            fail("null isn't a valid JCR name");
+        } catch (ConstraintViolationException e) {
+            // success
+        }
+
+
         assertEquals(false, pdt.isAutoCreated());
         assertEquals(false, pdt.isMandatory());
         assertEquals(OnParentVersionAction.IGNORE, pdt.getOnParentVersion());
@@ -96,11 +256,255 @@
         assertEquals(false, pdt.isFullTextSearchable());
         assertEquals(false, pdt.isQueryOrderable());
     }
-    
-    
+
+    public void testSetDefaultValues() throws Exception {
+
+        PropertyDefinitionTemplate pdt = ntm.createPropertyDefinitionTemplate();
+        pdt.setRequiredType(PropertyType.LONG);
+
+        pdt.setDefaultValues(null);
+        assertNull(pdt.getDefaultValues());
+
+        pdt.setDefaultValues(new Value[0]);
+        assertNotNull(pdt.getDefaultValues());
+        assertEquals(0, pdt.getDefaultValues().length);
+
+        pdt.setDefaultValues(new Value[] { superuser.getValueFactory().createValue(24)});
+        assertNotNull(pdt.getDefaultValues());
+        assertEquals(1, pdt.getDefaultValues().length);
+        assertEquals(24, pdt.getDefaultValues()[0].getLong());
+        assertEquals(PropertyType.LONG, pdt.getDefaultValues()[0].getType());
+    }
+
+    public void testEmptyNodeDefinitionTemplate() throws Exception {
+        NodeDefinitionTemplate ndt = ntm.createNodeDefinitionTemplate();
+
+        assertNull(ndt.getName());
+        assertFalse(ndt.isAutoCreated());
+        assertFalse(ndt.isMandatory());
+        assertFalse(ndt.isProtected());
+        assertEquals(OnParentVersionAction.COPY, ndt.getOnParentVersion());
+        assertNull(ndt.getDeclaringNodeType());
+
+        assertNull(ndt.getRequiredPrimaryTypes());
+        assertNull(ndt.getRequiredPrimaryTypeNames());
+        assertNull(ndt.getDefaultPrimaryType());
+        assertNull(ndt.getDefaultPrimaryTypeName());
+        assertFalse(ndt.allowsSameNameSiblings());
+    }
+
+    public void testNodeDefinitionTemplate() throws Exception {
+        NodeDefinitionTemplate ndt = ntm.createNodeDefinitionTemplate();
+
+        try {
+            ndt.setName(null);
+            fail("null isn't a valid JCR name");
+        } catch (ConstraintViolationException e) {
+            // success
+        }
+
+        String expandedName = "{" + NS_JCR_URI + "}" + "content";
+        String jcrName = superuser.getNamespacePrefix(NS_JCR_URI) + ":content";
+        ndt.setName(expandedName);
+        assertEquals(jcrName, ndt.getName());
+        ndt.setName(jcrName);
+        assertEquals(jcrName, ndt.getName());
+
+        ndt.setSameNameSiblings(true);
+        assertTrue(ndt.allowsSameNameSiblings());
+
+        ndt.setAutoCreated(true);
+        assertTrue(ndt.isAutoCreated());
+
+        ndt.setMandatory(true);
+        assertTrue(ndt.isMandatory());
+
+        ndt.setProtected(true);
+        assertTrue(ndt.isProtected());
+
+        ndt.setOnParentVersion(OnParentVersionAction.VERSION);
+        assertEquals(OnParentVersionAction.VERSION, ndt.getOnParentVersion());
+
+        expandedName = "{" + NS_NT_URI + "}" + "folder";
+        jcrName = superuser.getNamespacePrefix(NS_NT_URI) + ":folder";
+        ndt.setDefaultPrimaryTypeName(expandedName);
+        assertEquals(jcrName, ndt.getDefaultPrimaryTypeName());
+
+        ndt.setDefaultPrimaryTypeName(null);
+        assertEquals("setting null must clear the name.", null, ndt.getDefaultPrimaryTypeName());
+
+        ndt.setRequiredPrimaryTypeNames(new String[] {expandedName});
+        assertNotNull(ndt.getRequiredPrimaryTypeNames());
+        assertEquals(1, ndt.getRequiredPrimaryTypeNames().length);
+        assertEquals(jcrName, ndt.getRequiredPrimaryTypeNames()[0]);
+
+        try {
+            ndt.setRequiredPrimaryTypeNames(null);
+            fail("null isn't a valid array of jcr name");
+        } catch (ConstraintViolationException e) {
+            // success
+        }
+    }
+
+    public void testResidualNames() throws Exception {
+        String residualName = "*";
+
+        NodeDefinitionTemplate ndt = ntm.createNodeDefinitionTemplate();
+        ndt.setName(residualName);
+        assertEquals(residualName, ndt.getName());
+
+        PropertyDefinitionTemplate pdt = ntm.createPropertyDefinitionTemplate();
+        pdt.setName(residualName);
+        assertEquals(residualName, pdt.getName());
+    }
+
+    public void testInvalidJCRNames() throws Exception {
+        String invalidName = ":ab[2]";
+
+        // invalid name(s) passed to NT-template methods
+        NodeTypeTemplate ntt = ntm.createNodeTypeTemplate();
+        try {
+            ntt.setName(invalidName);
+            fail("ConstraintViolationException expected. Nt-name is invalid");
+        } catch (ConstraintViolationException e) {
+            // success
+        }
+        try {
+            ntt.setDeclaredSuperTypeNames(new String[] {"{" + NS_MIX_URI + "}" + "littlemixin", invalidName});
+            fail("ConstraintViolationException expected. One of the super type names is invalid");
+        } catch (ConstraintViolationException e) {
+            // success
+        }
+        try {
+            ntt.setPrimaryItemName(invalidName);
+            fail("ConstraintViolationException expected. Primary item name is invalid");
+        } catch (ConstraintViolationException e) {
+            // success
+        }
+
+        // invalid name(s) passed to NodeDefinitionTemplate
+        NodeDefinitionTemplate ndt = ntm.createNodeDefinitionTemplate();
+        try {
+            ndt.setName(invalidName);
+            fail("ConstraintViolationException expected. Name is invalid");
+        } catch (ConstraintViolationException e) {
+            // success
+        }
+        try {
+            ndt.setRequiredPrimaryTypeNames(new String[] {"{" + NS_MIX_URI + "}" + "littlemixin", invalidName});
+            fail("ConstraintViolationException expected. One of the required primary type names is invalid");
+        } catch (ConstraintViolationException e) {
+            // success
+        }
+        try {
+            ndt.setDefaultPrimaryTypeName(invalidName);
+            fail("ConstraintViolationException expected. Default primary type name is invalid");
+        } catch (ConstraintViolationException e) {
+            // success
+        }
+
+        // invalid name(s) passed to PropertyDefinitionTemplate
+        PropertyDefinitionTemplate pdt = ntm.createPropertyDefinitionTemplate();
+        try {
+            pdt.setName(invalidName);
+            fail("ConstraintViolationException expected. Name is invalid");
+        } catch (ConstraintViolationException e) {
+            // success
+        }
+    }
+
+    public void testRegisterNodeType() throws Exception {
+        NodeTypeTemplate ntt = ntm.createNodeTypeTemplate();
+
+        ntt.setName("mix:foo");
+        ntt.setAbstract(false);
+        ntt.setMixin(true);
+        ntt.setOrderableChildNodes(false);
+        ntt.setQueryable(false);
+
+        PropertyDefinitionTemplate pdt = ntm.createPropertyDefinitionTemplate();
+        pdt.setAutoCreated(false);
+        pdt.setName("foo");
+        pdt.setMultiple(false);
+        pdt.setRequiredType(PropertyType.STRING);
+        List pdefs = ntt.getPropertyDefinitionTemplates();
+        pdefs.add(pdt);
+
+        ntm.registerNodeType(ntt, true);
+
+        try {
+            ntm.registerNodeType(ntt, false);
+            fail("NodeTypeExistsException expected.");
+        } catch (NodeTypeExistsException e) {
+            // success
+        }
+    }
+
+    public void testUnregisterNodeType() throws Exception {
+        try {
+            ntm.unregisterNodeType("unknownnodetype");
+            fail("NoSuchNodeTypeException expected.");
+        } catch (NoSuchNodeTypeException e) {
+            // success
+        }
+
+        try {
+            ntm.unregisterNodeType("nt:base");
+            fail("RepositoryException expected.");
+        } catch (RepositoryException e) {
+            // success
+        }
+    }
+
+    public void testUnregisterNodeTypes() throws Exception {
+        try {
+            ntm.unregisterNodeTypes(new String[] {"unknownnodetype1","unknownnodetype2"});
+            fail("NoSuchNodeTypeException expected.");
+        } catch (NoSuchNodeTypeException e) {
+            // success
+        }
+
+        try {
+            ntm.unregisterNodeTypes(new String[] {"nt:base", "nt:address"});
+            fail("RepositoryException expected.");
+        } catch (RepositoryException e) {
+            // success
+        }
+    }
+
+    public void testRegisterNodeTypes() throws Exception {
+        NodeTypeDefinition[] defs = new NodeTypeDefinition[5];
+        for (int i = 0; i < defs.length; i++) {
+            NodeTypeTemplate ntt = ntm.createNodeTypeTemplate();
+            ntt.setName("mix:foo" + i);
+            ntt.setAbstract(false);
+            ntt.setMixin(true);
+            ntt.setOrderableChildNodes(false);
+            ntt.setQueryable(false);
+
+            PropertyDefinitionTemplate pdt = ntm.createPropertyDefinitionTemplate();
+            pdt.setAutoCreated(false);
+            pdt.setName("foo" + i);
+            pdt.setMultiple(false);
+            pdt.setRequiredType(PropertyType.STRING);
+            List pdefs = ntt.getPropertyDefinitionTemplates();
+            pdefs.add(pdt);
+
+            defs[i] = ntt;
+        }
+        ntm.registerNodeTypes(defs, true);
+
+        try {
+            ntm.registerNodeTypes(defs, false);
+            fail("NodeTypeExistsException expected.");
+        } catch (NodeTypeExistsException e) {
+            // success
+        }
+    }
+
     private PropertyDefinitionTemplate createBooleanPropTemplate() throws RepositoryException {
         PropertyDefinitionTemplate pdt = ntm.createPropertyDefinitionTemplate();
-        pdt.setName(propname);
+        pdt.setName(expandedPropName);
         pdt.setAutoCreated(false);
         pdt.setMandatory(false);
         pdt.setOnParentVersion(OnParentVersionAction.IGNORE);
@@ -114,6 +518,5 @@
         pdt.setQueryOrderable(false);
 
         return pdt;
-    }
-    
+    }    
 }
\ No newline at end of file

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/PredefinedNodeTypeTest.java Tue Sep  8 16:09:28 2009
@@ -97,6 +97,11 @@
         }
     }
 
+    /** Test for the predefined mix:lifecycle node type. */
+    public void testLifecycle() throws NotExecutableException {
+        testPredefinedNodeType("mix:lifecycle");
+    }
+
     /** Test for the predefined mix:lockable node type. */
     public void testLockable() throws NotExecutableException {
         testPredefinedNodeType("mix:lockable");
@@ -122,6 +127,41 @@
         testPredefinedNodeType("mix:simpleVersionable");
     }
 
+    /** Test for the predefined mix:created node type. */
+    public void testMixCreated() throws NotExecutableException {
+        testPredefinedNodeType("mix:created");
+    }
+
+    /** Test for the predefined mix:lastModified node type. */
+    public void testMixLastModified() throws NotExecutableException {
+        testPredefinedNodeType("mix:lastModified");
+    }
+
+    /** Test for the predefined mix:etag node type. */
+    public void testMixETag() throws NotExecutableException {
+        testPredefinedNodeType("mix:etag");
+    }
+
+    /** Test for the predefined mix:title node type. */
+    public void testMixTitle() throws NotExecutableException {
+        testPredefinedNodeType("mix:title");
+    }
+
+    /** Test for the predefined mix:language node type. */
+    public void testMixLanguage() throws NotExecutableException {
+        testPredefinedNodeType("mix:language");
+    }
+
+    /** Test for the predefined mix:language node type. */
+    public void testMixMimeType() throws NotExecutableException {
+        testPredefinedNodeType("mix:mimeType");
+    }
+
+    /** Test for the predefined nt:address node type. */
+    public void testNtAddress() throws NotExecutableException {
+        testPredefinedNodeType("nt:address");
+    }
+
     /** Test for the predefined nt:base node type. */
     public void testBase() throws NotExecutableException {
         testPredefinedNodeType("nt:base");

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/AddEventListenerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/AddEventListenerTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/AddEventListenerTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/AddEventListenerTest.java Tue Sep  8 16:09:28 2009
@@ -161,7 +161,7 @@
         Session s = getHelper().getSuperuserSession();
         try {
             Node n = (Node) s.getItem(n1.getPath());
-            n.addNode(nodeName3, ntBase);
+            n.addNode(nodeName3, testNodeType);
             n = (Node) s.getItem(n2.getPath());
             n.addNode(nodeName3, nodetype2);
             n = (Node) s.getItem(testRoot);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java Tue Sep  8 16:09:28 2009
@@ -20,6 +20,7 @@
 import org.apache.jackrabbit.test.NotExecutableException;
 import org.apache.jackrabbit.test.api.util.ISO9075;
 
+import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.RowIterator;
 import javax.jcr.query.Query;
@@ -126,24 +127,35 @@
      * @throws RepositoryException
      * @see #createQuery(String, String)
      */
-    protected Query createQuery(Statement statement) throws RepositoryException {
+    protected Query createQuery(Statement statement)
+        throws RepositoryException, NotExecutableException {
         return createQuery(statement.getStatement(), statement.getLanguage());
     }
 
     /**
      * Creates a {@link Query} for the given statement in the requested
-     * language
-     *
-     * @param statement the query should be created for
-     * @param language  query language to be used for Query creation
-     * @return
-     *
+     * language, treating optional languages gracefully
+     * @throws RepositoryException
+     */
+    protected Query createQuery(String statement, String language) throws RepositoryException, NotExecutableException {
+        return createQuery(superuser, statement, language);
+    }
+
+    /**
+     * Creates a {@link Query} for the given statement in the requested
+     * language, treating optional languages gracefully
      * @throws RepositoryException
      */
-    protected Query createQuery(String statement, String language) throws RepositoryException {
+    protected Query createQuery(Session session, String statement, String language) throws RepositoryException, NotExecutableException {
         log.println("Creating query: " + statement);
-        return superuser.getWorkspace().getQueryManager().createQuery(statement,
-                language);
+        
+        // check for unsupported query languages early
+        if (! isSupportedLanguage(language) && !Query.JCR_SQL2.equals(language)) {
+            throw new NotExecutableException("Repository does not support " + language + " query syntax");
+        }
+        else {
+            return session.getWorkspace().getQueryManager().createQuery(statement, language);
+        }
     }
 
     /**
@@ -155,7 +167,8 @@
      * @throws RepositoryException
      * @see #execute(String, String)
      */
-    protected QueryResult execute(Statement statement) throws RepositoryException {
+    protected QueryResult execute(Statement statement)
+        throws RepositoryException, NotExecutableException {
         return execute(statement.getStatement(), statement.getLanguage());
     }
 
@@ -170,7 +183,7 @@
      * @throws RepositoryException
      */
     protected QueryResult execute(String statement, String language)
-            throws RepositoryException {
+            throws RepositoryException, NotExecutableException {
         Query query = createQuery(statement, language);
         return query.execute();
     }
@@ -285,10 +298,11 @@
      * @param session the session to use for the query.
      * @param xpath the xpath query.
      * @param nodes the expected result nodes.
+     * @throws NotExecutableException 
      */
     protected void executeXPathQuery(Session session, String xpath, Node[] nodes)
-            throws RepositoryException {
-        QueryResult res = session.getWorkspace().getQueryManager().createQuery(xpath, Query.XPATH).execute();
+            throws RepositoryException, NotExecutableException {
+        QueryResult res = createQuery(session, xpath, Query.XPATH).execute();
         checkResult(res, nodes);
     }
 
@@ -298,10 +312,11 @@
      * @param session the session to use for the query.
      * @param sql the sql query.
      * @param nodes the expected result nodes.
+     * @throws NotExecutableException 
      */
     protected void executeSqlQuery(Session session, String sql, Node[] nodes)
-            throws RepositoryException {
-        QueryResult res = session.getWorkspace().getQueryManager().createQuery(sql, Query.SQL).execute();
+            throws RepositoryException, NotExecutableException {
+        QueryResult res = createQuery(session, sql, Query.SQL).execute();
         checkResult(res, nodes);
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/ElementTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/ElementTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/ElementTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/ElementTest.java Tue Sep  8 16:09:28 2009
@@ -41,12 +41,21 @@
  */
 public class ElementTest extends AbstractQueryTest {
 
+    private String simpleNodeType;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        simpleNodeType = testNodeTypeNoChildren == null ? ntBase : testNodeTypeNoChildren;
+    }
+
     /**
      * Tests the element test without arguments.
+     * @throws NotExecutableException 
      */
-    public void testElementTest() throws RepositoryException {
+    public void testElementTest() throws RepositoryException, NotExecutableException {
+
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        Node n2 = testRootNode.addNode(nodeName2, ntBase);
+        Node n2 = testRootNode.addNode(nodeName2, simpleNodeType);
         Node n3 = testRootNode.addNode(nodeName3, testNodeType);
         testRootNode.save();
 
@@ -56,10 +65,11 @@
 
     /**
      * Tests the element test with one any node argument.
+     * @throws NotExecutableException 
      */
-    public void testElementTestAnyNode() throws RepositoryException {
+    public void testElementTestAnyNode() throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        Node n2 = testRootNode.addNode(nodeName2, ntBase);
+        Node n2 = testRootNode.addNode(nodeName2, simpleNodeType);
         Node n3 = testRootNode.addNode(nodeName3, testNodeType);
         testRootNode.save();
 
@@ -70,10 +80,11 @@
     /**
      * Tests the element test with an any node argument and a type argument
      * that matches all nodes (nt:base).
+     * @throws NotExecutableException 
      */
-    public void testElementTestAnyNodeNtBase() throws RepositoryException {
+    public void testElementTestAnyNodeNtBase() throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        Node n2 = testRootNode.addNode(nodeName2, ntBase);
+        Node n2 = testRootNode.addNode(nodeName2, simpleNodeType);
         Node n3 = testRootNode.addNode(nodeName3, testNodeType);
         testRootNode.save();
 
@@ -84,10 +95,11 @@
     /**
      * Tests the element test with an any node argument and a type argument
      * that matches only certain child nodes.
+     * @throws NotExecutableException 
      */
-    public void testElementTestAnyNodeSomeNT() throws RepositoryException {
+    public void testElementTestAnyNodeSomeNT() throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        testRootNode.addNode(nodeName2, ntBase);
+        testRootNode.addNode(nodeName2, simpleNodeType);
         Node n3 = testRootNode.addNode(nodeName3, testNodeType);
         testRootNode.save();
 
@@ -97,10 +109,11 @@
 
     /**
      * Tests the element test with one single name test argument.
+     * @throws NotExecutableException 
      */
-    public void testElementTestNameTest() throws RepositoryException {
+    public void testElementTestNameTest() throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        testRootNode.addNode(nodeName2, ntBase);
+        testRootNode.addNode(nodeName2, simpleNodeType);
         testRootNode.addNode(nodeName3, testNodeType);
         testRootNode.save();
 
@@ -111,10 +124,11 @@
     /**
      * Tests the element test with a name test argument and a type argument that
      * matches all nodes (nt:base).
+     * @throws NotExecutableException 
      */
-    public void testElementTestNameTestNtBase() throws RepositoryException {
+    public void testElementTestNameTestNtBase() throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        testRootNode.addNode(nodeName2, ntBase);
+        testRootNode.addNode(nodeName2, simpleNodeType);
         testRootNode.addNode(nodeName3, testNodeType);
         testRootNode.save();
 
@@ -125,10 +139,11 @@
     /**
      * Tests the element test with a name test argument and a type argument that
      * matches only certain child nodes.
+     * @throws NotExecutableException 
      */
-    public void testElementTestNameTestSomeNT() throws RepositoryException {
+    public void testElementTestNameTestSomeNT() throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        testRootNode.addNode(nodeName2, ntBase);
+        testRootNode.addNode(nodeName2, simpleNodeType);
         testRootNode.addNode(nodeName3, testNodeType);
         testRootNode.save();
 
@@ -146,9 +161,9 @@
         if (!n1.getDefinition().allowsSameNameSiblings()) {
             throw new NotExecutableException("Node at " + testRoot + " does not allow same name siblings with name " + nodeName1);
         }
-        testRootNode.addNode(nodeName1, ntBase);
+        testRootNode.addNode(nodeName1, simpleNodeType);
         Node n2 = testRootNode.addNode(nodeName1, testNodeType);
-        testRootNode.addNode(nodeName2, ntBase);
+        testRootNode.addNode(nodeName2, simpleNodeType);
         testRootNode.addNode(nodeName3, testNodeType);
         testRootNode.save();
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetSupportedQueryLanguagesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetSupportedQueryLanguagesTest.java?rev=812570&r1=812569&r2=812570&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetSupportedQueryLanguagesTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/GetSupportedQueryLanguagesTest.java Tue Sep  8 16:09:28 2009
@@ -59,15 +59,15 @@
     }
 
     /**
-     * Tests if all implementations return {@link Query#XPATH} with
+     * Tests if all implementations return {@link Query#JCR_SQL2} with
      * {@link QueryManager#getSupportedQueryLanguages()}. Tests if repositores
      * that have the SQL descriptor set in the repository return {@link Query#SQL}.
      */
     public void testGetSupportedQueryLanguages() throws RepositoryException {
         List langs = Arrays.asList(session.getWorkspace().getQueryManager().getSupportedQueryLanguages());
         // all repositories must support XPath
-        assertTrue("XPath not retured with QueryManager.getSupportedQueryLanguages()",
-                langs.contains(Query.XPATH));
+        assertTrue("JCR_SQL2 not retured with QueryManager.getSupportedQueryLanguages()",
+                langs.contains(Query.JCR_SQL2));
 
         // if repository descriptor for sql is present also sql must be returned
         if (isSupported(Repository.OPTION_QUERY_SQL_SUPPORTED)) {



Mime
View raw message