[dna-commits] DNA SVN: r743 - in trunk: dna-graph/src/test/java/org/jboss/dna/graph and 4 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Mon Mar 2 15:03:51 EST 2009


Author: rhauch
Date: 2009-03-02 15:03:51 -0500 (Mon, 02 Mar 2009)
New Revision: 743

Modified:
   trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/StandardValueFactories.java
   trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/StringValueFactory.java
   trunk/dna-graph/src/test/java/org/jboss/dna/graph/LocationTest.java
   trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathOldTest.java
   trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathSegmentTest.java
   trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathTest.java
   trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BooleanValueFactoryTest.java
   trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/DecimalValueFactoryTest.java
   trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/DoubleValueFactoryTest.java
   trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/InMemoryBinaryValueFactoryTest.java
   trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/JodaDateTimeValueFactoryTest.java
   trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/LongValueFactoryTest.java
   trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/NameValueFactoryTest.java
   trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/PathValueFactoryTest.java
   trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/UuidValueFactoryTest.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNamespaceRegistry.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrProperty.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java
   trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
   trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JackrabbitJcrTckTest.java
   trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWorkspaceTest.java
Log:
DNA-286 Implement namespace management

This change corrects the behavior of the Session's namespace-related methods, which are not the same as those in the NamespaceRegistry implementation associated with the workspace.  This also corrected several of the TCK tests associated with namespaces.

Note that the StringValueFactory in 'dna-graph' was changed to use a DNA namespace registry to convert a Name and Path to a string using the namespace prefixes.  (This change affected a number of unit tests.)  The result is that any Name and Path property values are treated correctly and properly converted to a string using the current namespace prefixes in the namespace registry.  However, the BinaryValueFactory implementations should not use this StringValueFactory, since they need to convert values using the non-prefixed form (that is, the namespace URI).

In the case of our JCR implementation, the above change to the Graph factories means that property values are properly mapped to strings using the Session's local mappings (which fall back on the Workspace's mappings).  This corrected at least one TCK test.

Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/StandardValueFactories.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/StandardValueFactories.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/StandardValueFactories.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -105,9 +105,12 @@
         }
 
         // Now assign the members, using the factories in the map or (if null) the supplied default ...
-        this.stringFactory = getFactory(factories, new StringValueFactory(this.decoder, this.encoder));
-        this.binaryFactory = (BinaryFactory)getFactory(factories,
-                                                       new InMemoryBinaryValueFactory(this.decoder, this.stringFactory));
+        this.stringFactory = getFactory(factories, new StringValueFactory(this.namespaceRegistry, this.decoder, this.encoder));
+
+        // The binary factory should NOT use the string factory that converts namespaces to prefixes ...
+        StringValueFactory stringFactoryWithoutNamespaces = new StringValueFactory(this.decoder, this.encoder);
+        this.binaryFactory = (BinaryFactory)getFactory(factories, new InMemoryBinaryValueFactory(this.decoder,
+                                                                                                 stringFactoryWithoutNamespaces));
         this.booleanFactory = getFactory(factories, new BooleanValueFactory(this.decoder, this.stringFactory));
         this.dateFactory = (DateTimeFactory)getFactory(factories, new JodaDateTimeValueFactory(this.decoder, this.stringFactory));
         this.decimalFactory = getFactory(factories, new DecimalValueFactory(this.decoder, this.stringFactory));

Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/StringValueFactory.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/StringValueFactory.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/StringValueFactory.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -43,6 +43,7 @@
 import org.jboss.dna.graph.property.DateTime;
 import org.jboss.dna.graph.property.IoException;
 import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.NamespaceRegistry;
 import org.jboss.dna.graph.property.Path;
 import org.jboss.dna.graph.property.PropertyType;
 import org.jboss.dna.graph.property.Reference;
@@ -59,14 +60,26 @@
 public class StringValueFactory extends AbstractValueFactory<String> {
 
     private final TextEncoder encoder;
+    private final NamespaceRegistry namespaceRegistry;
 
     public StringValueFactory( TextDecoder decoder,
                                TextEncoder encoder ) {
         super(PropertyType.STRING, decoder, null);
         CheckArg.isNotNull(encoder, "encoder");
         this.encoder = encoder;
+        this.namespaceRegistry = null;
     }
 
+    public StringValueFactory( NamespaceRegistry namespaceRegistry,
+                               TextDecoder decoder,
+                               TextEncoder encoder ) {
+        super(PropertyType.STRING, decoder, null);
+        CheckArg.isNotNull(encoder, "encoder");
+        CheckArg.isNotNull(namespaceRegistry, "namespaceRegistry");
+        this.encoder = encoder;
+        this.namespaceRegistry = namespaceRegistry;
+    }
+
     /**
      * @return encoder
      */
@@ -173,6 +186,9 @@
      */
     public String create( Name value ) {
         if (value == null) return null;
+        if (this.namespaceRegistry != null) {
+            return value.getString(this.namespaceRegistry, getEncoder());
+        }
         return value.getString(getEncoder());
     }
 
@@ -181,6 +197,9 @@
      */
     public String create( Path value ) {
         if (value == null) return null;
+        if (this.namespaceRegistry != null) {
+            return value.getString(this.namespaceRegistry, getEncoder());
+        }
         return value.getString(getEncoder());
     }
 
@@ -220,8 +239,8 @@
         } catch (UnsupportedEncodingException err) {
             throw new ValueFormatException(value, getPropertyType(),
                                            GraphI18n.errorConvertingType.text(byte[].class.getSimpleName(),
-                                                                            String.class.getSimpleName(),
-                                                                            value), err);
+                                                                              String.class.getSimpleName(),
+                                                                              value), err);
         }
     }
 
@@ -262,12 +281,11 @@
         } catch (UnsupportedEncodingException err) {
             throw new ValueFormatException(value, getPropertyType(),
                                            GraphI18n.errorConvertingType.text(InputStream.class.getSimpleName(),
-                                                                            String.class.getSimpleName(),
-                                                                            value), err);
+                                                                              String.class.getSimpleName(),
+                                                                              value), err);
         } catch (IOException err) {
-            throw new IoException(
-                                  GraphI18n.errorConvertingIo.text(InputStream.class.getSimpleName(), String.class.getSimpleName()),
-                                  err);
+            throw new IoException(GraphI18n.errorConvertingIo.text(InputStream.class.getSimpleName(),
+                                                                   String.class.getSimpleName()), err);
         }
     }
 
@@ -280,7 +298,8 @@
         try {
             return IoUtil.read(reader);
         } catch (IOException err) {
-            throw new IoException(GraphI18n.errorConvertingIo.text(Reader.class.getSimpleName(), String.class.getSimpleName()), err);
+            throw new IoException(GraphI18n.errorConvertingIo.text(Reader.class.getSimpleName(), String.class.getSimpleName()),
+                                  err);
         }
     }
 

Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/LocationTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/LocationTest.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/LocationTest.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -30,6 +30,7 @@
 import java.util.List;
 import java.util.UUID;
 import org.jboss.dna.common.text.NoOpEncoder;
+import org.jboss.dna.graph.property.NamespaceRegistry;
 import org.jboss.dna.graph.property.Path;
 import org.jboss.dna.graph.property.PathFactory;
 import org.jboss.dna.graph.property.Property;
@@ -47,11 +48,11 @@
 public class LocationTest {
 
     private static final NoOpEncoder NO_OP_ENCODER = new NoOpEncoder();
-    private static final StringValueFactory STRING_VALUE_FACTORY = new StringValueFactory(NO_OP_ENCODER, NO_OP_ENCODER);
-    private static final NameValueFactory NAME_VALUE_FACTORY = new NameValueFactory(
-                                                                                    new SimpleNamespaceRegistry(
-                                                                                                                "http://www.jboss.org/dna/1.0"),
-                                                                                    NO_OP_ENCODER, STRING_VALUE_FACTORY);
+    private static final NamespaceRegistry NAMESPACE_REGISTRY = new SimpleNamespaceRegistry("http://www.jboss.org/dna/1.0");
+    private static final StringValueFactory STRING_VALUE_FACTORY = new StringValueFactory(NAMESPACE_REGISTRY, NO_OP_ENCODER,
+                                                                                          NO_OP_ENCODER);
+    private static final NameValueFactory NAME_VALUE_FACTORY = new NameValueFactory(NAMESPACE_REGISTRY, NO_OP_ENCODER,
+                                                                                    STRING_VALUE_FACTORY);
 
     private PathFactory pathFactory = new PathValueFactory(NO_OP_ENCODER, STRING_VALUE_FACTORY, NAME_VALUE_FACTORY);
 

Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathOldTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathOldTest.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathOldTest.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -78,7 +78,8 @@
         path = new BasicPath(validSegmentsList, true);
         namespaceRegistry = new SimpleNamespaceRegistry();
         namespaceRegistry.register(validNamespacePrefix, validNamespaceUri);
-        StringValueFactory stringValueFactory = new StringValueFactory(Path.DEFAULT_DECODER, Path.DEFAULT_ENCODER);
+        StringValueFactory stringValueFactory = new StringValueFactory(namespaceRegistry, Path.DEFAULT_DECODER,
+                                                                       Path.DEFAULT_ENCODER);
         NameValueFactory nameValueFactory = new NameValueFactory(namespaceRegistry, Path.DEFAULT_DECODER, stringValueFactory);
         pathFactory = new PathValueFactory(Path.DEFAULT_DECODER, stringValueFactory, nameValueFactory);
     }

Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathSegmentTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathSegmentTest.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathSegmentTest.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -55,7 +55,7 @@
     public void beforeEach() {
         this.registry = new SimpleNamespaceRegistry();
         this.registry.register(DnaLexicon.Namespace.PREFIX, DnaLexicon.Namespace.URI);
-        this.stringValueFactory = new StringValueFactory(Path.DEFAULT_DECODER, Path.DEFAULT_ENCODER);
+        this.stringValueFactory = new StringValueFactory(registry, Path.DEFAULT_DECODER, Path.DEFAULT_ENCODER);
         this.nameFactory = new NameValueFactory(registry, Path.DEFAULT_DECODER, stringValueFactory);
         this.validName = nameFactory.create("dna:something");
         this.factory = new PathValueFactory(Path.DEFAULT_DECODER, stringValueFactory, nameFactory);

Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathTest.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BasicPathTest.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -77,7 +77,8 @@
         super.path = new BasicPath(validSegmentsList, true);
         namespaceRegistry = new SimpleNamespaceRegistry();
         namespaceRegistry.register(validNamespacePrefix, validNamespaceUri);
-        StringValueFactory stringValueFactory = new StringValueFactory(Path.DEFAULT_DECODER, Path.DEFAULT_ENCODER);
+        StringValueFactory stringValueFactory = new StringValueFactory(namespaceRegistry, Path.DEFAULT_DECODER,
+                                                                       Path.DEFAULT_ENCODER);
         NameValueFactory nameValueFactory = new NameValueFactory(namespaceRegistry, Path.DEFAULT_DECODER, stringValueFactory);
         pathFactory = new PathValueFactory(Path.DEFAULT_DECODER, stringValueFactory, nameValueFactory);
     }

Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BooleanValueFactoryTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BooleanValueFactoryTest.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/BooleanValueFactoryTest.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -35,11 +35,10 @@
 import java.util.Iterator;
 import java.util.List;
 import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.NamespaceRegistry;
 import org.jboss.dna.graph.property.Path;
 import org.jboss.dna.graph.property.Reference;
 import org.jboss.dna.graph.property.ValueFormatException;
-import org.jboss.dna.graph.property.basic.BooleanValueFactory;
-import org.jboss.dna.graph.property.basic.StringValueFactory;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -49,6 +48,7 @@
  */
 public class BooleanValueFactoryTest {
 
+    private NamespaceRegistry registry;
     private BooleanValueFactory factory;
     private StringValueFactory stringFactory;
 
@@ -57,7 +57,8 @@
      */
     @Before
     public void setUp() throws Exception {
-        stringFactory = new StringValueFactory(Path.URL_DECODER, Path.DEFAULT_ENCODER);
+        registry = new SimpleNamespaceRegistry();
+        stringFactory = new StringValueFactory(registry, Path.URL_DECODER, Path.DEFAULT_ENCODER);
         factory = new BooleanValueFactory(Path.URL_DECODER, stringFactory);
     }
 

Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/DecimalValueFactoryTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/DecimalValueFactoryTest.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/DecimalValueFactoryTest.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -36,11 +36,10 @@
 import java.util.Iterator;
 import java.util.List;
 import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.NamespaceRegistry;
 import org.jboss.dna.graph.property.Path;
 import org.jboss.dna.graph.property.Reference;
 import org.jboss.dna.graph.property.ValueFormatException;
-import org.jboss.dna.graph.property.basic.DecimalValueFactory;
-import org.jboss.dna.graph.property.basic.StringValueFactory;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -50,6 +49,7 @@
  */
 public class DecimalValueFactoryTest {
 
+    private NamespaceRegistry registry;
     private DecimalValueFactory factory;
     private StringValueFactory stringFactory;
 
@@ -58,7 +58,8 @@
      */
     @Before
     public void setUp() throws Exception {
-        stringFactory = new StringValueFactory(Path.URL_DECODER, Path.DEFAULT_ENCODER);
+        registry = new SimpleNamespaceRegistry();
+        stringFactory = new StringValueFactory(registry, Path.URL_DECODER, Path.DEFAULT_ENCODER);
         factory = new DecimalValueFactory(Path.URL_DECODER, stringFactory);
     }
 

Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/DoubleValueFactoryTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/DoubleValueFactoryTest.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/DoubleValueFactoryTest.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -36,11 +36,10 @@
 import java.util.Iterator;
 import java.util.List;
 import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.NamespaceRegistry;
 import org.jboss.dna.graph.property.Path;
 import org.jboss.dna.graph.property.Reference;
 import org.jboss.dna.graph.property.ValueFormatException;
-import org.jboss.dna.graph.property.basic.DoubleValueFactory;
-import org.jboss.dna.graph.property.basic.StringValueFactory;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -50,6 +49,7 @@
  */
 public class DoubleValueFactoryTest {
 
+    private NamespaceRegistry registry;
     private DoubleValueFactory factory;
     private StringValueFactory stringFactory;
 
@@ -58,7 +58,8 @@
      */
     @Before
     public void setUp() throws Exception {
-        stringFactory = new StringValueFactory(Path.URL_DECODER, Path.URL_ENCODER);
+        registry = new SimpleNamespaceRegistry();
+        stringFactory = new StringValueFactory(registry, Path.URL_DECODER, Path.URL_ENCODER);
         factory = new DoubleValueFactory(Path.URL_DECODER, stringFactory);
     }
 

Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/InMemoryBinaryValueFactoryTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/InMemoryBinaryValueFactoryTest.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/InMemoryBinaryValueFactoryTest.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -64,13 +64,16 @@
     @Before
     public void setUp() throws Exception {
         encoder = Path.URL_ENCODER;
-        stringFactory = new StringValueFactory(Path.URL_DECODER, encoder);
-        factory = new InMemoryBinaryValueFactory(Path.URL_DECODER, stringFactory);
         namespaceRegistry = new SimpleNamespaceRegistry();
         namespaceRegistry.register("jboss", "http://www.jboss.org");
         namespaceRegistry.register("dna", "http://www.jboss.org/dna");
+        stringFactory = new StringValueFactory(namespaceRegistry, Path.URL_DECODER, encoder);
         nameFactory = new NameValueFactory(namespaceRegistry, Path.URL_DECODER, stringFactory);
         pathFactory = new PathValueFactory(Path.URL_DECODER, stringFactory, nameFactory);
+
+        // The binary factory should convert between names and paths without using prefixes ...
+        StringValueFactory noNamespaceStringFactory = new StringValueFactory(Path.URL_DECODER, encoder);
+        factory = new InMemoryBinaryValueFactory(Path.URL_DECODER, noNamespaceStringFactory);
     }
 
     @Test

Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/JodaDateTimeValueFactoryTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/JodaDateTimeValueFactoryTest.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/JodaDateTimeValueFactoryTest.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -39,9 +39,6 @@
 import org.jboss.dna.graph.property.Path;
 import org.jboss.dna.graph.property.Reference;
 import org.jboss.dna.graph.property.ValueFormatException;
-import org.jboss.dna.graph.property.basic.JodaDateTime;
-import org.jboss.dna.graph.property.basic.JodaDateTimeValueFactory;
-import org.jboss.dna.graph.property.basic.StringValueFactory;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -68,7 +65,7 @@
      */
     @Before
     public void setUp() throws Exception {
-        stringFactory = new StringValueFactory(Path.URL_DECODER, Path.URL_ENCODER);
+        stringFactory = new StringValueFactory(new SimpleNamespaceRegistry(), Path.URL_DECODER, Path.URL_ENCODER);
         factory = new JodaDateTimeValueFactory(Path.URL_DECODER, stringFactory);
     }
 

Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/LongValueFactoryTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/LongValueFactoryTest.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/LongValueFactoryTest.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -39,8 +39,6 @@
 import org.jboss.dna.graph.property.Path;
 import org.jboss.dna.graph.property.Reference;
 import org.jboss.dna.graph.property.ValueFormatException;
-import org.jboss.dna.graph.property.basic.LongValueFactory;
-import org.jboss.dna.graph.property.basic.StringValueFactory;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -58,7 +56,7 @@
      */
     @Before
     public void setUp() throws Exception {
-        stringFactory = new StringValueFactory(Path.URL_DECODER, Path.URL_ENCODER);
+        stringFactory = new StringValueFactory(new SimpleNamespaceRegistry(), Path.URL_DECODER, Path.URL_ENCODER);
         factory = new LongValueFactory(Path.URL_DECODER, stringFactory);
     }
 

Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/NameValueFactoryTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/NameValueFactoryTest.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/NameValueFactoryTest.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -58,7 +58,7 @@
         this.registry.register("dna", "http://www.jboss.org/dna/namespace");
         this.encoder = Path.DEFAULT_ENCODER;
         this.decoder = Path.DEFAULT_DECODER;
-        this.stringValueFactory = new StringValueFactory(decoder, encoder);
+        this.stringValueFactory = new StringValueFactory(registry, decoder, encoder);
         this.factory = new NameValueFactory(registry, decoder, stringValueFactory);
     }
 

Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/PathValueFactoryTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/PathValueFactoryTest.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/PathValueFactoryTest.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -54,7 +54,7 @@
     public void beforeEach() {
         this.registry = new SimpleNamespaceRegistry();
         this.registry.register("dna", "http://www.jboss.org/dna/namespace");
-        this.stringValueFactory = new StringValueFactory(Path.DEFAULT_DECODER, Path.DEFAULT_ENCODER);
+        this.stringValueFactory = new StringValueFactory(registry, Path.DEFAULT_DECODER, Path.DEFAULT_ENCODER);
         this.nameFactory = new NameValueFactory(registry, Path.DEFAULT_DECODER, stringValueFactory);
         this.factory = new PathValueFactory(Path.DEFAULT_DECODER, stringValueFactory, nameFactory);
     }

Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/UuidValueFactoryTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/UuidValueFactoryTest.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/UuidValueFactoryTest.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -39,9 +39,6 @@
 import org.jboss.dna.graph.property.Name;
 import org.jboss.dna.graph.property.Path;
 import org.jboss.dna.graph.property.ValueFormatException;
-import org.jboss.dna.graph.property.basic.StringValueFactory;
-import org.jboss.dna.graph.property.basic.UuidReference;
-import org.jboss.dna.graph.property.basic.UuidValueFactory;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -60,7 +57,7 @@
      */
     @Before
     public void setUp() throws Exception {
-        stringFactory = new StringValueFactory(Path.URL_DECODER, Path.URL_ENCODER);
+        stringFactory = new StringValueFactory(new SimpleNamespaceRegistry(), Path.URL_DECODER, Path.URL_ENCODER);
         factory = new UuidValueFactory(Path.URL_DECODER, stringFactory);
         uuid = UUID.randomUUID();
     }

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -54,12 +54,14 @@
     public static I18n unableToUnregisterReservedNamespacePrefix;
     public static I18n unableToUnregisterReservedNamespaceUri;
     public static I18n unableToUnregisterPrefixForNamespaceThatIsNotRegistered;
+    public static I18n unableToRemapUriNotRegisteredInNamespaceRegistry;
+    public static I18n unableToRemapUriUsingPrefixUsedInNamespaceRegistry;
 
     public static I18n errorWhileInitializingTheNamespaceRegistry;
     public static I18n invalidPathParameter;
-    
+
     public static I18n typeNotFound;
-    
+
     public static I18n REP_NAME_DESC;
     public static I18n REP_VENDOR_DESC;
     public static I18n SPEC_NAME_DESC;

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNamespaceRegistry.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNamespaceRegistry.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNamespaceRegistry.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -32,7 +32,7 @@
 import javax.jcr.NamespaceException;
 import javax.jcr.RepositoryException;
 import javax.xml.XMLConstants;
-import net.jcip.annotations.ThreadSafe;
+import net.jcip.annotations.NotThreadSafe;
 import org.jboss.dna.common.util.CheckArg;
 import org.jboss.dna.common.xml.XmlCharacters;
 import org.jboss.dna.graph.JcrLexicon;
@@ -40,17 +40,25 @@
 import org.jboss.dna.graph.JcrNtLexicon;
 import org.jboss.dna.graph.property.NamespaceRegistry;
 import org.jboss.dna.graph.property.NamespaceRegistry.Namespace;
-import org.jboss.dna.graph.property.basic.SimpleNamespaceRegistry;
-import org.jboss.dna.graph.property.basic.ThreadSafeNamespaceRegistry;
 
 /**
  * A thread-safe JCR {@link javax.jcr.NamespaceRegistry} implementation that has the standard JCR namespaces pre-registered and
  * enforces the JCR semantics for {@link #registerNamespace(String, String) registering} and {@link #unregisterNamespace(String)
  * unregistering} namespaces.
+ * <p>
+ * Note that this implementation is {@link NotThreadSafe not thread safe}, since it is used within a single {@link JcrWorkspace}
+ * and single {@link JcrSession}, and according to the JCR specification these interfaces are not thread safe.
+ * </p>
  */
- at ThreadSafe
+ at NotThreadSafe
 class JcrNamespaceRegistry implements javax.jcr.NamespaceRegistry {
 
+    public static enum Behavior {
+        JSR170_SESSION,
+        JSR283_SESSION,
+        WORKSPACE;
+    }
+
     static final String DEFAULT_NAMESPACE_PREFIX = "";
     static final String DEFAULT_NAMESPACE_URI = "";
 
@@ -89,18 +97,27 @@
         STANDARD_BUILT_IN_URIS = Collections.unmodifiableSet(new HashSet<String>(namespaces.values()));
     }
 
+    private final Behavior behavior;
     private final NamespaceRegistry registry;
+    private final NamespaceRegistry workspaceRegistry;
 
-    JcrNamespaceRegistry() {
-        this(new ThreadSafeNamespaceRegistry(new SimpleNamespaceRegistry())); // thread-safe implementation
+    JcrNamespaceRegistry( NamespaceRegistry workspaceRegistry ) {
+        this(Behavior.WORKSPACE, null, workspaceRegistry);
     }
 
-    JcrNamespaceRegistry( NamespaceRegistry dnaRegistry ) {
-        this.registry = dnaRegistry;
+    JcrNamespaceRegistry( Behavior behavior,
+                          NamespaceRegistry localRegistry,
+                          NamespaceRegistry workspaceRegistry ) {
+        this.behavior = behavior;
+        this.registry = localRegistry != null ? localRegistry : workspaceRegistry;
+        this.workspaceRegistry = workspaceRegistry;
         // Add the built-ins, ensuring we overwrite any badly-initialized values ...
         for (Map.Entry<String, String> builtIn : STANDARD_BUILT_IN_NAMESPACES_BY_PREFIX.entrySet()) {
             this.registry.register(builtIn.getKey(), builtIn.getValue());
         }
+        assert this.behavior != null;
+        assert this.registry != null;
+        assert this.workspaceRegistry != null;
     }
 
     /**
@@ -109,11 +126,13 @@
      * @see javax.jcr.NamespaceRegistry#getPrefix(java.lang.String)
      */
     public String getPrefix( String uri ) throws NamespaceException, RepositoryException {
-        // Check the standard ones first, ensuring that invalid changes to the persistent storage don't matter ...
-        String prefix = STANDARD_BUILT_IN_PREFIXES_BY_NAMESPACE.get(uri);
-        if (prefix != null) return prefix;
+        if (behavior == Behavior.WORKSPACE) {
+            // Check the standard ones first, ensuring that invalid changes to the persistent storage don't matter ...
+            String prefix = STANDARD_BUILT_IN_PREFIXES_BY_NAMESPACE.get(uri);
+            if (prefix != null) return prefix;
+        }
         // Now check the underlying registry ...
-        prefix = registry.getPrefixForNamespaceUri(uri, false);
+        String prefix = registry.getPrefixForNamespaceUri(uri, false);
         if (prefix == null) {
             throw new NamespaceException(JcrI18n.noNamespaceWithUri.text(uri));
         }
@@ -141,11 +160,13 @@
      * @see javax.jcr.NamespaceRegistry#getURI(java.lang.String)
      */
     public String getURI( String prefix ) throws NamespaceException, RepositoryException {
-        // Check the standard ones first, ensuring that invalid changes to the persistent storage don't matter ...
-        String uri = STANDARD_BUILT_IN_NAMESPACES_BY_PREFIX.get(prefix);
-        if (uri != null) return uri;
+        if (behavior == Behavior.WORKSPACE) {
+            // Check the standard ones first, ensuring that invalid changes to the persistent storage don't matter ...
+            String uri = STANDARD_BUILT_IN_NAMESPACES_BY_PREFIX.get(prefix);
+            if (uri != null) return uri;
+        }
         // Now check the underlying registry ...
-        uri = registry.getNamespaceForPrefix(prefix);
+        String uri = registry.getNamespaceForPrefix(prefix);
         if (uri == null) {
             throw new NamespaceException(JcrI18n.noNamespaceWithPrefix.text(prefix));
         }
@@ -176,17 +197,94 @@
                                                 String uri ) throws NamespaceException, RepositoryException {
         CheckArg.isNotNull(prefix, "prefix");
         CheckArg.isNotNull(uri, "uri");
+
+        switch (behavior) {
+            case JSR170_SESSION:
+                // ----------------------------------------------------------
+                // JSR-170 Session remapping behavior (see Section 6.3.3) ...
+                // ----------------------------------------------------------
+                // Section 6.3.3:
+                // "If existingUri is not registered in the NamespaceRegistry a NamespaceException will be thrown.
+                //
+                // If newPrefix is already locally mapped to existingUri (i.e., within this Session, by virtue
+                // of an earlier setNamespaceRegistry call) then this method returns silently and has no effect.
+                //
+                // If newPrefix is already locally mapped to a URI other than existingUri, then that URI reverts to its
+                // globally mapped prefix (as set in the NamespaceRegistry) and newPrefix is locally mapped to existingUri.
+                //
+                // If newPrefix is already assigned in the global NamespaceRegistry to otheruri (which differs from
+                // existingUri) and otherUri has not been locally mapped to another prefix which differs from newPrefix,
+                // then a NamespaceException will be thrown. In order to successfully locally map newPrefix to existingUri,
+                // otherUri must first be locally mapped to another prefix."
+
+                // The URI must already be registered ...
+                String existingPrefix = registry.getPrefixForNamespaceUri(uri, false);
+                if (existingPrefix == null) {
+                    // Paragraph 1 ...
+                    throw new NamespaceException(JcrI18n.unableToRemapUriNotRegisteredInNamespaceRegistry.text(prefix, uri));
+                }
+                if (existingPrefix.equals(prefix)) return; // Paragraph 2
+
+                // Is the prefix already used in a mapping ...
+                String existingUri = registry.getNamespaceForPrefix(prefix);
+                if (existingUri != null) {
+                    // Is this existing mapping local, or is it in the global (workspace) registry?
+                    String globalPrefix = workspaceRegistry.getPrefixForNamespaceUri(existingUri, false);
+                    if (!prefix.equals(globalPrefix)) {
+                        // Paragraph 3: The mapping is local to the session, so this local mapping should just be reverted ...
+                        registry.unregister(existingUri);
+                    }
+
+                    // Paragraph 4: The mapping is global, so this is not allowed; the existing ...
+                    String msg = JcrI18n.unableToRemapUriUsingPrefixUsedInNamespaceRegistry.text(prefix, uri, existingUri);
+                    throw new NamespaceException(msg);
+                }
+
+                // Otherwise, the prefix is not already used in a mapping, so we can continue ...
+
+                break;
+
+            case JSR283_SESSION:
+                // --------------------------------------
+                // JSR-283 Session remapping behavior ...
+                // --------------------------------------
+                // Section 4.3.3 (of the Draft specification):
+                // "All local mappings already present in the Session that include either the specified prefix
+                // or the specified uri are removed and the new mapping is added."
+                String existingUriForPrefix = registry.getNamespaceForPrefix(prefix);
+                if (existingUriForPrefix != null) {
+                    registry.unregister(existingUriForPrefix);
+                }
+                registry.unregister(uri);
+
+                break;
+
+            case WORKSPACE:
+                // --------------------------------------------------
+                // JSR-170 & JSR-283 Workspace namespace registry ...
+                // --------------------------------------------------
+
+                // Check the zero-length prefix and zero-length URI ...
+                if (DEFAULT_NAMESPACE_PREFIX.equals(prefix) || DEFAULT_NAMESPACE_URI.equals(uri)) {
+                    throw new NamespaceException(JcrI18n.unableToChangeTheDefaultNamespace.text());
+                }
+                // Check whether the prefix or URI are reserved (case-sensitive) ...
+                if (STANDARD_BUILT_IN_PREFIXES.contains(prefix)) {
+                    throw new NamespaceException(JcrI18n.unableToRegisterReservedNamespacePrefix.text(prefix, uri));
+                }
+                if (STANDARD_BUILT_IN_URIS.contains(uri)) {
+                    throw new NamespaceException(JcrI18n.unableToRegisterReservedNamespaceUri.text(prefix, uri));
+                }
+                break;
+            default:
+                assert false; // should never happen
+        }
+
         // Check the zero-length prefix and zero-length URI ...
         if (DEFAULT_NAMESPACE_PREFIX.equals(prefix) || DEFAULT_NAMESPACE_URI.equals(uri)) {
             throw new NamespaceException(JcrI18n.unableToChangeTheDefaultNamespace.text());
         }
-        // Check whether the prefix or URI are reserved (case-sensitive) ...
-        if (STANDARD_BUILT_IN_PREFIXES.contains(prefix)) {
-            throw new NamespaceException(JcrI18n.unableToRegisterReservedNamespacePrefix.text(prefix, uri));
-        }
-        if (STANDARD_BUILT_IN_URIS.contains(uri)) {
-            throw new NamespaceException(JcrI18n.unableToRegisterReservedNamespaceUri.text(prefix, uri));
-        }
+
         // Check whether the prefix begins with 'xml' (in any case) ...
         if (prefix.toLowerCase().startsWith(XML_NAMESPACE_PREFIX)) {
             throw new NamespaceException(JcrI18n.unableToRegisterNamespaceUsingXmlPrefix.text(prefix, uri));

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrProperty.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrProperty.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrProperty.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -131,7 +131,7 @@
 
     /**
      * {@inheritDoc}
-     *  
+     * 
      * @see javax.jcr.Property#getString()
      */
     public String getString() throws RepositoryException {
@@ -163,8 +163,7 @@
      * @see javax.jcr.Property#getValues()
      */
     public Value[] getValues() throws ValueFormatException {
-
-        return new Value[] {jcrValue};
+        throw new ValueFormatException();
     }
 
     /*

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -61,6 +61,7 @@
 import org.jboss.dna.graph.property.UuidFactory;
 import org.jboss.dna.graph.property.ValueFactories;
 import org.jboss.dna.graph.property.basic.LocalNamespaceRegistry;
+import org.jboss.dna.jcr.JcrNamespaceRegistry.Behavior;
 import org.xml.sax.ContentHandler;
 import com.google.common.base.ReferenceType;
 import com.google.common.collect.ReferenceMap;
@@ -93,7 +94,7 @@
     /**
      * The execution context for this session, which uses the {@link #sessionRegistry session's namespace registry}
      */
-    private final ExecutionContext executionContext;
+    protected final ExecutionContext executionContext;
 
     /**
      * The graph representing this session, which uses the {@link #graph session's graph}.
@@ -123,9 +124,10 @@
         this.workspace = workspace;
 
         // Create an execution context for this session, which should use the local namespace registry ...
-        NamespaceRegistry local = new LocalNamespaceRegistry(workspaceContext.getNamespaceRegistry());
+        NamespaceRegistry workspaceRegistry = workspaceContext.getNamespaceRegistry();
+        NamespaceRegistry local = new LocalNamespaceRegistry(workspaceRegistry);
         this.executionContext = workspaceContext.with(local);
-        this.sessionRegistry = new JcrNamespaceRegistry(local);
+        this.sessionRegistry = new JcrNamespaceRegistry(Behavior.JSR170_SESSION, local, workspaceRegistry);
 
         // Set up the graph to use for this session (which uses the session's namespace registry and context) ...
         this.graph = Graph.create(this.repository.getRepositorySourceName(),
@@ -425,10 +427,7 @@
         populateNode(rootNode, graph.getNodeAt(executionContext.getValueFactories().getPathFactory().createRootPath()));
 
         // Root nodes need to have a type in JCR land
-        // JcrProperty primaryType = new JcrProperty(rootNode, getExecutionContext(), JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.BASE);
-        String typeValue = JcrNtLexicon.BASE.getString(executionContext.getNamespaceRegistry());
-        JcrProperty primaryType = new JcrProperty(rootNode, executionContext, JcrLexicon.PRIMARY_TYPE, typeValue);
-
+        JcrProperty primaryType = new JcrProperty(rootNode, executionContext, JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.BASE);
         // TODO: Not liking the hard-code
         rootNode.properties.add(primaryType);
 
@@ -603,7 +602,8 @@
                 if (uuid == null && DnaLexicon.UUID.equals(name)) uuid = uuidFactory.create(dnaProp.getValues()).next();
                 else if (jcrUuidName.equals(name)) dnaUuidProp = dnaProp;
                 else if (jcrMixinTypesName.equals(name)) {
-                    org.jboss.dna.graph.property.ValueFactory<String> stringFactory = executionContext.getValueFactories().getStringFactory();
+                    org.jboss.dna.graph.property.ValueFactory<String> stringFactory = executionContext.getValueFactories()
+                                                                                                      .getStringFactory();
                     for (String mixin : stringFactory.create(dnaProp)) {
                         if ("mix:referenceable".equals(mixin)) referenceable = true;
                     }

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -65,7 +65,6 @@
 import org.jboss.dna.graph.property.PropertyFactory;
 import org.jboss.dna.graph.property.ValueFormatException;
 import org.jboss.dna.graph.property.basic.GraphNamespaceRegistry;
-import org.jboss.dna.graph.property.basic.ThreadSafeNamespaceRegistry;
 import org.xml.sax.ContentHandler;
 
 /**
@@ -144,10 +143,9 @@
         org.jboss.dna.graph.property.NamespaceRegistry persistentRegistry = new GraphNamespaceRegistry(namespaceGraph,
                                                                                                        namespacesPath,
                                                                                                        uriProperty, namespaceType);
-        persistentRegistry = new ThreadSafeNamespaceRegistry(persistentRegistry);
         this.context = context.with(persistentRegistry);
 
-        // Set up and initialize the persistent (and thread-safe) JCR namespace registry ...
+        // Set up and initialize the persistent JCR namespace registry ...
         this.workspaceRegistry = new JcrNamespaceRegistry(persistentRegistry);
 
         // Now create a graph with this new execution context ...

Modified: trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
===================================================================
--- trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties	2009-03-02 20:03:51 UTC (rev 743)
@@ -44,6 +44,8 @@
 unableToUnregisterReservedNamespacePrefix = Unable to unregister the namespace "{1}" with prefix "{0}" because this prefix is reserved
 unableToUnregisterReservedNamespaceUri = Unable to unregister the namespace "{1}" with prefix "{0}" because this URI is reserved
 unableToUnregisterPrefixForNamespaceThatIsNotRegistered = The namespace with prefix "{0}" is not registered and cannot be unregistered
+unableToRemapUriNotRegisteredInNamespaceRegistry = Unable to remap the namespace "{1}" to prefix "{0}" because the URI is not already registered in the workspace's namespace registry
+unableToRemapUriUsingPrefixUsedInNamespaceRegistry = Unable to remap the namespace "{1}" to prefix "{0}" because the prefix is already used as the prefix for the namespace "{2}" in the workspace's namespace registry
 
 errorWhileInitializingTheNamespaceRegistry = Error while initializing the namespace registry for workspace "{0}"
 invalidPathParameter = The "{1}" parameter value "{0}" was not a valid path

Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JackrabbitJcrTckTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JackrabbitJcrTckTest.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JackrabbitJcrTckTest.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -87,7 +87,7 @@
             // addTestSuite(org.apache.jackrabbit.test.api.StringPropertyTest.class);
             addTestSuite(org.apache.jackrabbit.test.api.UndefinedPropertyTest.class);
             addTestSuite(org.apache.jackrabbit.test.api.NamespaceRegistryReadMethodsTest.class);
-            // addTestSuite(org.apache.jackrabbit.test.api.NamespaceRemappingTest.class);
+            addTestSuite(org.apache.jackrabbit.test.api.NamespaceRemappingTest.class);
             addTestSuite(org.apache.jackrabbit.test.api.NodeIteratorTest.class);
             // addTestSuite(org.apache.jackrabbit.test.api.PropertyReadMethodsTest.class);
             addTestSuite(org.apache.jackrabbit.test.api.RepositoryDescriptorTest.class);

Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWorkspaceTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWorkspaceTest.java	2009-03-02 17:40:37 UTC (rev 742)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWorkspaceTest.java	2009-03-02 20:03:51 UTC (rev 743)
@@ -150,9 +150,9 @@
         assertThat(registry.getURI(JcrLexicon.Namespace.PREFIX), is(JcrLexicon.Namespace.URI));
     }
 
-    @Test( expected = UnsupportedOperationException.class )
-    public void shouldNotAllowGetNodeTypeManager() throws Exception {
-        workspace.getNodeTypeManager();
+    @Test
+    public void shouldGetNodeTypeManager() throws Exception {
+        assertThat(workspace.getNodeTypeManager(), is(notNullValue()));
     }
 
     @Test( expected = UnsupportedOperationException.class )




More information about the dna-commits mailing list