You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2013/11/01 15:19:58 UTC

svn commit: r1537944 - in /sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest: EventsCounterTest.java util/EventsCounterUtil.java

Author: bdelacretaz
Date: Fri Nov  1 14:19:57 2013
New Revision: 1537944

URL: http://svn.apache.org/r1537944
Log:
SLING-2788 - EventsCounterUtil

Added:
    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/EventsCounterTest.java

Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/EventsCounterTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/EventsCounterTest.java?rev=1537944&r1=1537943&r2=1537944&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/EventsCounterTest.java (original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/EventsCounterTest.java Fri Nov  1 14:19:57 2013
@@ -17,10 +17,11 @@
 package org.apache.sling.launchpad.webapp.integrationtest;
 
 import static org.junit.Assert.assertTrue;
-import org.apache.sling.commons.json.JSONObject;
+
 import org.apache.sling.commons.testing.integration.HttpTest;
 import org.apache.sling.commons.testing.junit.Retry;
 import org.apache.sling.commons.testing.junit.RetryRule;
+import org.apache.sling.launchpad.webapp.integrationtest.util.EventsCounterUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Rule;
@@ -39,15 +40,10 @@ public class EventsCounterTest {
     /** HTTP tests helper */
     private static final HttpTest H = new HttpTest();
     
-    private static int getResourceEventsCount() throws Exception {
-        final JSONObject json = new JSONObject(H.getContent(HttpTest.HTTP_BASE_URL + "/testing/EventsCounter.json", HttpTest.CONTENT_TYPE_JSON));
-        return json.has(TOPIC) ? json.getInt(TOPIC) : 0;
-    }
-    
     @BeforeClass
     public static void setupClass() throws Exception {
         H.setUp();
-        initialResourceEventsCount = getResourceEventsCount();
+        initialResourceEventsCount = EventsCounterUtil.getEventsCount(H, TOPIC);
         final String testResourcePath = HttpTest.HTTP_BASE_URL + "/testing/" + EventsCounterTest.class.getName() + "." + System.currentTimeMillis();
         toDelete = H.getTestClient().createNode(testResourcePath, null);
     }
@@ -61,6 +57,6 @@ public class EventsCounterTest {
     @Retry
     @Test
     public void testResourceEvents() throws Exception {
-        assertTrue("Expecting events counter to have changed", getResourceEventsCount() > initialResourceEventsCount);
+        assertTrue("Expecting events counter to have changed", EventsCounterUtil.getEventsCount(H, TOPIC) > initialResourceEventsCount);
     }
 }

Added: 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=1537944&view=auto
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/EventsCounterUtil.java (added)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/util/EventsCounterUtil.java Fri Nov  1 14:19:57 2013
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.launchpad.webapp.integrationtest.util;
+
+import java.io.IOException;
+
+import org.apache.sling.commons.json.JSONException;
+import org.apache.sling.commons.json.JSONObject;
+import org.apache.sling.commons.testing.integration.HttpTest;
+import org.apache.sling.commons.testing.integration.HttpTestBase;
+
+/** Give access to info provided by the test-services EventsCounterServlet */
+public class EventsCounterUtil {
+    public static int getEventsCount(HttpTestBase b, String topic) throws JSONException, IOException {
+        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;
+    }
+}
\ No newline at end of file