incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1522943 - /sling/whiteboard/bdelacretaz/it-repository/src/test/java/org/apache/sling/jcr/repository/it/SlingRepositoryITBase.java
Date Fri, 13 Sep 2013 14:10:20 GMT
Author: bdelacretaz
Date: Fri Sep 13 14:10:20 2013
New Revision: 1522943

URL: http://svn.apache.org/r1522943
Log:
SLING-2788 - testAnonymousHasReadAccess added, fails on Oak for now

Modified:
    sling/whiteboard/bdelacretaz/it-repository/src/test/java/org/apache/sling/jcr/repository/it/SlingRepositoryITBase.java

Modified: sling/whiteboard/bdelacretaz/it-repository/src/test/java/org/apache/sling/jcr/repository/it/SlingRepositoryITBase.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/it-repository/src/test/java/org/apache/sling/jcr/repository/it/SlingRepositoryITBase.java?rev=1522943&r1=1522942&r2=1522943&view=diff
==============================================================================
--- sling/whiteboard/bdelacretaz/it-repository/src/test/java/org/apache/sling/jcr/repository/it/SlingRepositoryITBase.java
(original)
+++ sling/whiteboard/bdelacretaz/it-repository/src/test/java/org/apache/sling/jcr/repository/it/SlingRepositoryITBase.java
Fri Sep 13 14:10:20 2013
@@ -19,10 +19,12 @@ package org.apache.sling.jcr.repository.
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.util.LinkedList;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.inject.Inject;
 import javax.jcr.Credentials;
@@ -37,6 +39,7 @@ import javax.jcr.query.Query;
 
 import org.apache.sling.jcr.api.SlingRepository;
 import org.junit.After;
+import org.junit.Ignore;
 import org.junit.Test;
 
 /** Base class for SlingRepository tests, contains tests
@@ -48,6 +51,8 @@ import org.junit.Test;
  */
 public abstract class SlingRepositoryITBase {
 
+    private final AtomicInteger counter = new AtomicInteger();
+    
     @Inject
     protected SlingRepository repository;
     
@@ -62,6 +67,28 @@ public abstract class SlingRepositoryITB
         return it;
     }
     
+    private String assertCreateRetrieveNode(String nodeType) throws RepositoryException {
+        Session s = repository.loginAdministrative(null);
+        try {
+            final Node root = s.getRootNode();
+            final String name = "TEST_" + counter.incrementAndGet() + "_" + System.currentTimeMillis();
+            final String propName = "PN_" + name;
+            final String propValue = "PV_" + name;
+            final Node child = nodeType == null ? root.addNode(name) : root.addNode(name,
nodeType);
+            child.setProperty(propName, propValue);
+            child.setProperty("foo", child.getPath());
+            s.save();
+            s.logout();
+            s = repository.loginAdministrative(null);
+            final Node n = s.getNode("/" + name);
+            assertNotNull(n);
+            assertEquals(propValue, n.getProperty(propName).getString());
+            return n.getPath();
+        } finally {
+            s.logout();
+        }
+    }
+
     @After
     public void deleteTestItems() throws RepositoryException {
         if(toDelete.isEmpty()) {
@@ -121,26 +148,6 @@ public abstract class SlingRepositoryITB
         s.logout();
     }
     
-    private void assertCreateRetrieveNode(String nodeType) throws RepositoryException {
-        Session s = repository.loginAdministrative(null);
-        try {
-            final Node root = s.getRootNode();
-            final String name = "TEST_" + System.currentTimeMillis();
-            final String propName = "PN_" + name;
-            final String propValue = "PV_" + name;
-            final Node child = nodeType == null ? root.addNode(name) : root.addNode(name,
nodeType);
-            child.setProperty(propName, propValue);
-            s.save();
-            s.logout();
-            s = repository.loginAdministrative(null);
-            final Node n = s.getNode("/" + name);
-            assertNotNull(n);
-            assertEquals(propValue, n.getProperty(propName).getString());
-        } finally {
-            s.logout();
-        }
-    }
-
     @Test
     public void testCreateRetrieveNode() throws RepositoryException {
         assertCreateRetrieveNode(null);
@@ -152,6 +159,20 @@ public abstract class SlingRepositoryITB
     }
 
     @Test
+    @Ignore("Fails on Oak")
+    public void testAnonymousHasReadAccess() throws RepositoryException {
+        final String path = assertCreateRetrieveNode(null);
+        final Session s = repository.login();
+        try {
+            assertTrue("Expecting anonymous to see " + path, s.itemExists(path));
+            final Node n = s.getNode(path);
+            assertEquals("Expecting anonymous to see the foo property", path, n.getProperty("foo").getString());
+        } finally {
+            s.logout();
+        }
+    }
+    
+    @Test
     public void testQuery() throws RepositoryException {
         final Session s = repository.loginAdministrative(null);
         final String id = "ID_" + System.currentTimeMillis();



Mime
View raw message