incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1300244 - /sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerTest.java
Date Tue, 13 Mar 2012 17:17:32 GMT
Author: cziegeler
Date: Tue Mar 13 17:17:32 2012
New Revision: 1300244

URL: http://svn.apache.org/viewvc?rev=1300244&view=rev
Log:
SLING-2435 : Sporadic test failure in JcrResourceListenerTest#testInWs2

Modified:
    sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerTest.java

Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerTest.java?rev=1300244&r1=1300243&r2=1300244&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerTest.java
(original)
+++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceListenerTest.java
Tue Mar 13 17:17:32 2012
@@ -21,7 +21,6 @@ import static org.mockito.Mockito.when;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Random;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
@@ -49,6 +48,7 @@ public class JcrResourceListenerTest ext
     public void testDefaultWorkspace() throws Exception {
         List<Event> events = generateEvents(null);
 
+        assertTrue("Received: " + events, events.size() >= 3);
         Event event = events.get(0);
         assertEquals(SlingConstants.TOPIC_RESOURCE_ADDED, event.getTopic());
         assertEquals(createdPath, event.getProperty(SlingConstants.PROPERTY_PATH));
@@ -69,7 +69,7 @@ public class JcrResourceListenerTest ext
     public void testInWs2() throws Exception {
         List<Event> events = generateEvents("ws2");
 
-        assertEquals(3, events.size());
+        assertTrue("Received: " + events, events.size() >= 3);
         Event event = events.get(0);
         assertEquals(SlingConstants.TOPIC_RESOURCE_ADDED, event.getTopic());
         assertEquals("ws2:" + createdPath, event.getProperty(SlingConstants.PROPERTY_PATH));
@@ -118,8 +118,11 @@ public class JcrResourceListenerTest ext
 
     }
 
+    int counter = 0;
+
     private String createTestPath() {
-        return "/test" + System.currentTimeMillis() + new Random().nextInt();
+        counter++;
+        return "/test" + System.currentTimeMillis() + counter;
     }
 
     private List<Event> generateEvents(String workspaceName) throws Exception {
@@ -130,7 +133,7 @@ public class JcrResourceListenerTest ext
         addNodeToModify(session);
         addNodeToDelete(session);
 
-        JcrResourceResolverFactoryImpl factory = new JcrResourceResolverFactoryImpl();
+        final JcrResourceResolverFactoryImpl factory = new JcrResourceResolverFactoryImpl();
         PrivateAccessor.setField(factory, "repository", getRepository());
         PrivateAccessor.setField(factory, "useMultiWorkspaces", Boolean.TRUE);
 
@@ -161,8 +164,6 @@ public class JcrResourceListenerTest ext
         deleted.remove();
         session.save();
 
-        listener.dispose();
-
         Session newSession = getRepository().loginAdministrative(workspaceName);
         EventHelper helper = new EventHelper(newSession);
         helper.waitForEvents(5000);
@@ -170,6 +171,8 @@ public class JcrResourceListenerTest ext
         newSession.logout();
         session.logout();
 
+        listener.dispose();
+
         return events;
     }
 }



Mime
View raw message