[dna-commits] DNA SVN: r864 - in trunk/dna-jcr/src: test/java/org/jboss/dna/jcr and 1 other directory.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Wed Apr 29 10:23:58 EDT 2009


Author: rhauch
Date: 2009-04-29 10:23:58 -0400 (Wed, 29 Apr 2009)
New Revision: 864

Modified:
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
   trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrNodeTest.java
Log:
DNA-388 AbstractJcrNode.getReferences() is incorrectly implemented

The method now throws an UnsupportedOperationException, since the method is not implemented correctly.  Also commented out some unit tests that were testing these methods.

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java	2009-04-29 14:14:34 UTC (rev 863)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java	2009-04-29 14:23:58 UTC (rev 864)
@@ -420,6 +420,8 @@
      * @see javax.jcr.Node#getReferences()
      */
     public final PropertyIterator getReferences() throws RepositoryException {
+        if (true) throw new UnsupportedOperationException();
+        // This implementation is just wrong.
         // Iterate through the properties to see which ones have a REFERENCE type ...
         Collection<AbstractJcrProperty> properties = cache.findJcrPropertiesFor(nodeUuid);
         Collection<AbstractJcrProperty> references = new LinkedList<AbstractJcrProperty>();

Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrNodeTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrNodeTest.java	2009-04-29 14:14:34 UTC (rev 863)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrNodeTest.java	2009-04-29 14:23:58 UTC (rev 864)
@@ -25,12 +25,9 @@
 
 import static org.hamcrest.core.Is.is;
 import static org.hamcrest.core.IsNull.notNullValue;
-import static org.hamcrest.core.IsSame.sameInstance;
 import static org.junit.Assert.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.stub;
-import java.util.Arrays;
-import java.util.List;
 import java.util.UUID;
 import javax.jcr.Item;
 import javax.jcr.ItemNotFoundException;
@@ -39,7 +36,6 @@
 import javax.jcr.NodeIterator;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
 import javax.jcr.PropertyType;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
@@ -399,49 +395,49 @@
         node.getPrimaryItem();
     }
 
-    @Test
-    public void shouldReturnEmptyIteratorFromGetReferencesWhenThereAreNoProperties() throws Exception {
-        // Set up two properties (one containing references, the other not) ...
-        List<AbstractJcrProperty> props = Arrays.asList(new AbstractJcrProperty[] {});
-        stub(cache.findJcrPropertiesFor(uuid)).toReturn(props);
-        // Now call the method ...
-        PropertyIterator iter = node.getReferences();
-        assertThat(iter.getSize(), is(0L));
-        assertThat(iter.hasNext(), is(false));
-    }
+    // @Test
+    // public void shouldReturnEmptyIteratorFromGetReferencesWhenThereAreNoProperties() throws Exception {
+    // // Set up two properties (one containing references, the other not) ...
+    // List<AbstractJcrProperty> props = Arrays.asList(new AbstractJcrProperty[] {});
+    // stub(cache.findJcrPropertiesFor(uuid)).toReturn(props);
+    // // Now call the method ...
+    // PropertyIterator iter = node.getReferences();
+    // assertThat(iter.getSize(), is(0L));
+    // assertThat(iter.hasNext(), is(false));
+    // }
+    //
+    // @Test
+    // public void shouldReturnEmptyIteratorFromGetReferencesWhenThereAreNoReferenceProperties() throws Exception {
+    // // Set up two properties (one containing references, the other not) ...
+    // AbstractJcrProperty propertyA = mock(AbstractJcrProperty.class);
+    // AbstractJcrProperty propertyB = mock(AbstractJcrProperty.class);
+    // List<AbstractJcrProperty> props = Arrays.asList(new AbstractJcrProperty[] {propertyA, propertyB});
+    // stub(cache.findJcrPropertiesFor(uuid)).toReturn(props);
+    // stub(propertyA.getType()).toReturn(PropertyType.LONG);
+    // stub(propertyB.getType()).toReturn(PropertyType.BOOLEAN);
+    // // Now call the method ...
+    // PropertyIterator iter = node.getReferences();
+    // assertThat(iter.getSize(), is(0L));
+    // assertThat(iter.hasNext(), is(false));
+    // }
+    //
+    // @Test
+    // public void shouldReturnIteratorFromGetReferencesWhenThereIsAtLeastOneReferenceProperty() throws Exception {
+    // // Set up two properties (one containing references, the other not) ...
+    // AbstractJcrProperty propertyA = mock(AbstractJcrProperty.class);
+    // AbstractJcrProperty propertyB = mock(AbstractJcrProperty.class);
+    // List<AbstractJcrProperty> props = Arrays.asList(new AbstractJcrProperty[] {propertyA, propertyB});
+    // stub(cache.findJcrPropertiesFor(uuid)).toReturn(props);
+    // stub(propertyA.getType()).toReturn(PropertyType.LONG);
+    // stub(propertyB.getType()).toReturn(PropertyType.REFERENCE);
+    // // Now call the method ...
+    // PropertyIterator iter = node.getReferences();
+    // assertThat(iter.getSize(), is(1L));
+    // assertThat(iter.next(), is(sameInstance((Object)propertyB)));
+    // assertThat(iter.hasNext(), is(false));
+    // }
 
     @Test
-    public void shouldReturnEmptyIteratorFromGetReferencesWhenThereAreNoReferenceProperties() throws Exception {
-        // Set up two properties (one containing references, the other not) ...
-        AbstractJcrProperty propertyA = mock(AbstractJcrProperty.class);
-        AbstractJcrProperty propertyB = mock(AbstractJcrProperty.class);
-        List<AbstractJcrProperty> props = Arrays.asList(new AbstractJcrProperty[] {propertyA, propertyB});
-        stub(cache.findJcrPropertiesFor(uuid)).toReturn(props);
-        stub(propertyA.getType()).toReturn(PropertyType.LONG);
-        stub(propertyB.getType()).toReturn(PropertyType.BOOLEAN);
-        // Now call the method ...
-        PropertyIterator iter = node.getReferences();
-        assertThat(iter.getSize(), is(0L));
-        assertThat(iter.hasNext(), is(false));
-    }
-
-    @Test
-    public void shouldReturnIteratorFromGetReferencesWhenThereIsAtLeastOneReferenceProperty() throws Exception {
-        // Set up two properties (one containing references, the other not) ...
-        AbstractJcrProperty propertyA = mock(AbstractJcrProperty.class);
-        AbstractJcrProperty propertyB = mock(AbstractJcrProperty.class);
-        List<AbstractJcrProperty> props = Arrays.asList(new AbstractJcrProperty[] {propertyA, propertyB});
-        stub(cache.findJcrPropertiesFor(uuid)).toReturn(props);
-        stub(propertyA.getType()).toReturn(PropertyType.LONG);
-        stub(propertyB.getType()).toReturn(PropertyType.REFERENCE);
-        // Now call the method ...
-        PropertyIterator iter = node.getReferences();
-        assertThat(iter.getSize(), is(1L));
-        assertThat(iter.next(), is(sameInstance((Object)propertyB)));
-        assertThat(iter.hasNext(), is(false));
-    }
-
-    @Test
     public void shouldProvideSession() throws Exception {
         assertThat((JcrSession)node.getSession(), is(session));
     }




More information about the dna-commits mailing list