Author: bdelacretaz Date: Wed Oct 15 15:24:22 2014 New Revision: 1632084 URL: http://svn.apache.org/r1632084 Log: SLING-4061 - fail all following tests upon even timeout, to fail the overall test faster
Modified: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/ResourceResolverTest.java Modified: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/ResourceResolverTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/ResourceResolverTest.java?rev=1632084&r1=1632083&r2=1632084&view=diff ============================================================================== --- sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/ResourceResolverTest.java (original) +++ sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/ResourceResolverTest.java Wed Oct 15 15:24:22 2014 @@ -47,6 +47,7 @@ import org.apache.sling.launchpad.testse import org.apache.sling.launchpad.testservices.exported.FakeSlingHttpServletRequest; import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -69,6 +70,7 @@ public class ResourceResolverTest { private String [] vanity; private static List<String> toDelete = new ArrayList<String>(); private static ResourceResolverFactory cleanupResolverFactory; + private static String eventTimeoutTopic; @TestReference private EventsCounter eventsCounter; @@ -88,6 +90,11 @@ public class ResourceResolverTest { * that signals that mappings have been updated. */ private void saveMappings(Session session) throws Exception { + if(eventTimeoutTopic != null) { + // Avoid wasting a lot of time if events are not detected in timely fashion + fail("Event timeout (" + eventTimeoutTopic + ") detected in previous tests, failing saveMappings()"); + } + final int oldEventsCount = eventsCounter.getEventsCount(MAPPING_EVENT_TOPIC); session.save(); final long timeout = System.currentTimeMillis() + updateTimeout; @@ -103,6 +110,7 @@ public class ResourceResolverTest { } catch(InterruptedException ignore) { } } + eventTimeoutTopic = MAPPING_EVENT_TOPIC; fail("Timeout waiting for " + MAPPING_EVENT_TOPIC + " event, after " + updateTimeout + " msec"); } @@ -161,6 +169,12 @@ public class ResourceResolverTest { } @AfterClass + @BeforeClass + public static void clearTimeouts() { + eventTimeoutTopic = null; + } + + @AfterClass public static void deleteTestNodes() throws Exception { final ResourceResolver resolver = cleanupResolverFactory.getAdministrativeResourceResolver(null); final Session session = resolver.adaptTo(Session.class);