Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 36087CA19 for ; Fri, 1 Nov 2013 14:29:06 +0000 (UTC) Received: (qmail 46613 invoked by uid 500); 1 Nov 2013 14:29:03 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 46575 invoked by uid 500); 1 Nov 2013 14:29:00 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 46559 invoked by uid 99); 1 Nov 2013 14:28:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Nov 2013 14:28:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Nov 2013 14:28:57 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C5C822388A02; Fri, 1 Nov 2013 14:28:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1537945 - in /sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest: VanityPathTest.java util/EventsCounterUtil.java Date: Fri, 01 Nov 2013 14:28:37 -0000 To: commits@sling.apache.org From: bdelacretaz@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131101142837.C5C822388A02@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bdelacretaz Date: Fri Nov 1 14:28:37 2013 New Revision: 1537945 URL: http://svn.apache.org/r1537945 Log: SLING-2788 - Use more robust event-based sync in VanityPathTest instead of fixed sleep time Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/VanityPathTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/EventsCounterUtil.java Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/VanityPathTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/VanityPathTest.java?rev=1537945&r1=1537944&r2=1537945&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/VanityPathTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/VanityPathTest.java Fri Nov 1 14:28:37 2013 @@ -25,6 +25,7 @@ import java.util.Map; import org.apache.commons.httpclient.NameValuePair; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.sling.commons.testing.integration.HttpTestBase; +import org.apache.sling.launchpad.webapp.integrationtest.util.EventsCounterUtil; import org.apache.sling.servlets.post.SlingPostConstants; /** @@ -35,7 +36,9 @@ public class VanityPathTest extends Http private String postUrl; private String vanityPath; private String vanityUrl; - + private int mappingEventCount; + public static final String MAPPING_UPDATE_TOPIC = "org/apache/sling/api/resource/ResourceResolverMapping/CHANGED"; + @Override protected void setUp() throws Exception { super.setUp(); @@ -47,10 +50,10 @@ public class VanityPathTest extends Http + SlingPostConstants.DEFAULT_CREATE_SUFFIX; vanityPath = "/" + getClass().getSimpleName() + "_" + System.currentTimeMillis() + "/vanity"; vanityUrl = HTTP_BASE_URL + vanityPath; - - + + mappingEventCount = EventsCounterUtil.getEventsCount(this, MAPPING_UPDATE_TOPIC); } - + /** test vanity path with internal redirect */ public void testInternalRedirect() throws IOException { // create a node with a vanity path @@ -190,9 +193,6 @@ public class VanityPathTest extends Http * MapEntries to reinitialize. */ private void waitForMapReload() { - try { - Thread.sleep(750L); - } catch (InterruptedException e) { - } + EventsCounterUtil.waitForEvent(this, MAPPING_UPDATE_TOPIC, 5000, mappingEventCount); } } Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/EventsCounterUtil.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/EventsCounterUtil.java?rev=1537945&r1=1537944&r2=1537945&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/EventsCounterUtil.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/EventsCounterUtil.java Fri Nov 1 14:28:37 2013 @@ -24,6 +24,8 @@ import org.apache.sling.commons.json.JSO import org.apache.sling.commons.json.JSONObject; import org.apache.sling.commons.testing.integration.HttpTest; import org.apache.sling.commons.testing.integration.HttpTestBase; +import org.apache.sling.testing.tools.retry.RetryLoop; +import org.apache.sling.testing.tools.retry.RetryLoop.Condition; /** Give access to info provided by the test-services EventsCounterServlet */ public class EventsCounterUtil { @@ -31,4 +33,17 @@ public class EventsCounterUtil { final JSONObject json = new JSONObject(b.getContent(HttpTest.HTTP_BASE_URL + "/testing/EventsCounter.json", HttpTest.CONTENT_TYPE_JSON)); return json.has(topic) ? json.getInt(topic) : 0; } + + public static void waitForEvent(final HttpTestBase b, final String topic, int timeoutMsec, final int previousCount) { + final Condition c = new Condition() { + public String getDescription() { + return "Wait for OSGi event on topic " + topic; + } + + public boolean isTrue() throws Exception { + return getEventsCount(b, topic) > previousCount; + } + }; + new RetryLoop(c, timeoutMsec, 500); + } } \ No newline at end of file