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 2016/04/29 16:03:33 UTC

svn commit: r1741632 [4/4] - in /sling/trunk/testing/http: ./ clients/ clients/src/ clients/src/main/ clients/src/main/java/ clients/src/main/java/org/ clients/src/main/java/org/apache/ clients/src/main/java/org/apache/sling/ clients/src/main/java/org/...

Added: sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/InstanceConfig.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/InstanceConfig.java?rev=1741632&view=auto
==============================================================================
--- sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/InstanceConfig.java (added)
+++ sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/InstanceConfig.java Fri Apr 29 14:03:32 2016
@@ -0,0 +1,40 @@
+/*
+ * 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.testing.clients.util.config;
+
+/**
+ * Allows saving and restoring an instance configuration.
+ * Implementations define the behaviour of save() and restore()
+ */
+public interface InstanceConfig {
+
+    /**
+     * Saves the current status of the configuration
+     *
+     * @return this
+     * @throws InstanceConfigException if saving the configuration fails
+     */
+    public InstanceConfig save() throws InstanceConfigException;
+
+    /**
+     * Restores the saved status of the configuration
+     *
+     * @return this
+     * @throws InstanceConfigException if restoring the configuration fails
+     */
+    public InstanceConfig restore() throws InstanceConfigException;
+}

Added: sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/InstanceConfigCache.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/InstanceConfigCache.java?rev=1741632&view=auto
==============================================================================
--- sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/InstanceConfigCache.java (added)
+++ sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/InstanceConfigCache.java Fri Apr 29 14:03:32 2016
@@ -0,0 +1,25 @@
+/*
+ * 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.testing.clients.util.config;
+
+import java.util.Collection;
+
+/**
+ * A cache for different {@link InstanceConfig} objects
+ */
+public interface InstanceConfigCache  extends InstanceConfig, Collection<InstanceConfig> {
+}

Added: sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/InstanceConfigException.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/InstanceConfigException.java?rev=1741632&view=auto
==============================================================================
--- sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/InstanceConfigException.java (added)
+++ sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/InstanceConfigException.java Fri Apr 29 14:03:32 2016
@@ -0,0 +1,39 @@
+/*
+ * 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.testing.clients.util.config;
+
+public class InstanceConfigException extends Exception {
+
+    public InstanceConfigException(Exception e) {
+        super(e);
+    }
+
+    public InstanceConfigException() {
+    }
+
+    public InstanceConfigException(String message) {
+        super(message);
+    }
+
+    public InstanceConfigException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public InstanceConfigException(Throwable cause) {
+        super(cause);
+    }
+}

Added: sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/impl/EmptyInstanceConfig.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/impl/EmptyInstanceConfig.java?rev=1741632&view=auto
==============================================================================
--- sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/impl/EmptyInstanceConfig.java (added)
+++ sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/impl/EmptyInstanceConfig.java Fri Apr 29 14:03:32 2016
@@ -0,0 +1,36 @@
+/*
+ * 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.testing.clients.util.config.impl;
+
+import org.apache.sling.testing.clients.util.config.InstanceConfig;
+import org.apache.sling.testing.clients.util.config.InstanceConfigException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class EmptyInstanceConfig implements InstanceConfig {
+    private static final Logger LOG = LoggerFactory.getLogger(EmptyInstanceConfig.class);
+
+    public InstanceConfig save() throws InstanceConfigException {
+        LOG.debug("Saved nothing");
+        return this;
+    }
+
+    public InstanceConfig restore() throws InstanceConfigException {
+        LOG.debug("Restored nothing");
+        return this;
+    }
+}

Added: sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/impl/InstanceConfigCacheImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/impl/InstanceConfigCacheImpl.java?rev=1741632&view=auto
==============================================================================
--- sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/impl/InstanceConfigCacheImpl.java (added)
+++ sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/impl/InstanceConfigCacheImpl.java Fri Apr 29 14:03:32 2016
@@ -0,0 +1,120 @@
+/*
+ * 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.testing.clients.util.config.impl;
+
+import org.apache.sling.testing.clients.util.config.InstanceConfig;
+import org.apache.sling.testing.clients.util.config.InstanceConfigCache;
+import org.apache.sling.testing.clients.util.config.InstanceConfigException;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+public class InstanceConfigCacheImpl implements InstanceConfigCache {
+    List<InstanceConfig> configs;
+
+    public InstanceConfigCacheImpl(List<InstanceConfig> configs) {
+        this.configs = configs;
+    }
+
+    public InstanceConfigCacheImpl() {
+        this.configs = new ArrayList<InstanceConfig>();
+    }
+
+    @Override
+    public int size() {
+        return configs.size();
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return configs.isEmpty();
+    }
+
+    @Override
+    public boolean contains(Object o) {
+        return configs.contains(o);
+    }
+
+    @Override
+    public Iterator<InstanceConfig> iterator() {
+        return configs.iterator();
+    }
+
+    @Override
+    public Object[] toArray() {
+        return configs.toArray();
+    }
+
+    @Override
+    public <T> T[] toArray(T[] a) {
+        return configs.toArray(a);
+    }
+
+    @Override
+    public boolean add(InstanceConfig instanceConfig) {
+        return configs.add(instanceConfig);
+    }
+
+    @Override
+    public boolean remove(Object o) {
+        return configs.remove(o);
+    }
+
+    @Override
+    public boolean containsAll(Collection<?> c) {
+        return configs.containsAll(c);
+    }
+
+    @Override
+    public boolean addAll(Collection<? extends InstanceConfig> c) {
+        return configs.addAll(c);
+    }
+
+    @Override
+    public boolean removeAll(Collection<?> c) {
+        return configs.removeAll(c);
+    }
+
+    @Override
+    public boolean retainAll(Collection<?> c) {
+        return configs.retainAll(c);
+    }
+
+    @Override
+    public void clear() {
+       configs.clear();
+    }
+
+
+    @Override
+    public InstanceConfig save() throws InstanceConfigException {
+        for (InstanceConfig ic : configs) {
+            ic.save();
+        }
+        return this;
+    }
+
+    @Override
+    public InstanceConfig restore() throws InstanceConfigException {
+        for (InstanceConfig ic : configs) {
+            ic.restore();
+        }
+        return this;
+    }
+}

Added: sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/package-info.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/package-info.java?rev=1741632&view=auto
==============================================================================
--- sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/package-info.java (added)
+++ sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/config/package-info.java Fri Apr 29 14:03:32 2016
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+@Version("1.0.0")
+package org.apache.sling.testing.clients.util.config;
+
+import aQute.bnd.annotation.Version;
+

Added: sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/poller/AbstractPoller.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/poller/AbstractPoller.java?rev=1741632&view=auto
==============================================================================
--- sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/poller/AbstractPoller.java (added)
+++ sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/poller/AbstractPoller.java Fri Apr 29 14:03:32 2016
@@ -0,0 +1,69 @@
+/*
+ * 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.testing.clients.util.poller;
+
+public abstract class AbstractPoller  implements Poller {
+
+    private final long waitInterval;
+    private final long waitCount;
+
+    /**
+     * Convenience method to execute a generic call and do polling until a condition is met
+     * The user must implement the {@link Poller#call()} and {@link Poller#condition()} methods
+     * @param waitInterval Number of milliseconds to wait between polls
+     * @param waitCount Number of wait intervals
+     */
+    public AbstractPoller(long waitInterval, long waitCount) {
+        this.waitInterval = waitInterval;
+        this.waitCount = waitCount;
+    }
+
+    /**
+     * Calls the {@link Poller#call()} once and then calls {@link Poller#condition()} until it returns true
+     * The method waits AbstractPoller#waitInterval milliseconds between calls to {@link Poller#condition()}
+     * A maximum of AbstractPoller#waitCount intervals are checked
+     * @return true if the condition is met after waiting a maximum of AbstractPoller#waitCount intervals, false otherwise
+     * @throws InterruptedException to mark this operation as "waiting"
+     */
+    public boolean callAndWait() throws InterruptedException {
+        if (!call()) return false;
+        for (int i=0; i<waitCount; i++) {
+            if (condition()) return true;
+            Thread.sleep(waitInterval);
+        }
+        return false;
+    }
+
+    /**
+     * Calls the @see: Poller#call() and then calls {@link Poller#condition()} until it returns true
+     * The Poller#call() method is called in each wait interval, before the Poller#condition().
+     * The method waits AbstractPoller#waitInterval milliseconds between calls to {@link Poller#condition()}
+     * A maximum of AbstractPoller#waitCount intervals are checked
+     * @return true if the condition is met after waiting a maximum of AbstractPoller#waitCount intervals, false otherwise
+     * @throws InterruptedException to mark this operation as "waiting"
+     */
+    public boolean callUntilCondition() throws InterruptedException {
+        if (!call()) return false;
+        if (condition()) return true;
+        for (int i = 0; i < waitCount; i++) {
+            Thread.sleep(waitInterval);
+            if (!call()) return false;
+            if (condition()) return true;
+        }
+        return false;
+    }
+}

Added: sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/poller/Poller.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/poller/Poller.java?rev=1741632&view=auto
==============================================================================
--- sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/poller/Poller.java (added)
+++ sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/clients/util/poller/Poller.java Fri Apr 29 14:03:32 2016
@@ -0,0 +1,28 @@
+/*
+ * 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.testing.clients.util.poller;
+
+/**
+ * Abstract Poller interface.
+ * Provides simple methods to implement custom pollers
+ */
+public interface Poller {
+    boolean call();
+    boolean condition();
+    boolean callAndWait() throws InterruptedException;
+    boolean callUntilCondition() throws InterruptedException;
+}

Added: sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/timeouts/TimeoutsProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/timeouts/TimeoutsProvider.java?rev=1741632&view=auto
==============================================================================
--- sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/timeouts/TimeoutsProvider.java (added)
+++ sling/trunk/testing/http/clients/src/main/java/org/apache/sling/testing/timeouts/TimeoutsProvider.java Fri Apr 29 14:03:32 2016
@@ -0,0 +1,77 @@
+/*
+ * 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.testing.timeouts;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Return timeout values that can be multiplied by a configurable
+ *  factor. Useful to cope with slower integration testing systems:
+ *  use timeout constants in your code that work for usual development
+ *  systems, and set a multiplier when running on a slower system.
+ */
+public class TimeoutsProvider {
+    private static final Logger log = LoggerFactory.getLogger(TimeoutsProvider.class);
+    public static final String PROP_TIMEOUT_MULTIPLIER = "sling.testing.timeout.multiplier";
+    private static float timeoutFactor = -1;
+    private static TimeoutsProvider INSTANCE;
+    
+    private TimeoutsProvider() {
+        if(timeoutFactor < 0) {
+            timeoutFactor = 1;
+            final String str = System.getProperty(PROP_TIMEOUT_MULTIPLIER);
+            if(str != null) {
+                try {
+                    timeoutFactor = Float.valueOf(str.trim());
+                    log.info("Timeout factor set to {} from system property {}", 
+                            timeoutFactor, PROP_TIMEOUT_MULTIPLIER);
+                } catch(NumberFormatException nfe) {
+                    throw new IllegalStateException("Invalid timeout factor: " + PROP_TIMEOUT_MULTIPLIER + "=" + str);
+                }
+            }
+        }
+    }
+    
+    public static TimeoutsProvider getInstance() {
+        if(INSTANCE == null) {
+            synchronized (TimeoutsProvider.class) {
+                INSTANCE = new TimeoutsProvider();
+            }
+        }
+        return INSTANCE;
+    }
+    
+    public long getTimeout(long nomimalValue) {
+        final long result = (long)(nomimalValue * timeoutFactor);
+        return result;
+    }
+    
+    public int getTimeout(int nomimalValue) {
+        final int result = (int)(nomimalValue * timeoutFactor);
+        return result;
+    }
+    
+    /** Get timeout from a system property, with default value */
+    public int getTimeout(String systemPropertyName, int defaultNominalValue) {
+        int result = defaultNominalValue;
+        final String str = System.getProperty(systemPropertyName);
+        if(str != null) {
+            result = Integer.parseInt(str);
+        }
+        return getTimeout(result);
+    }
+}

Added: sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/AbstractSlingClientGetPathTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/AbstractSlingClientGetPathTest.java?rev=1741632&view=auto
==============================================================================
--- sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/AbstractSlingClientGetPathTest.java (added)
+++ sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/AbstractSlingClientGetPathTest.java Fri Apr 29 14:03:32 2016
@@ -0,0 +1,162 @@
+/*
+ * 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.testing;
+
+import org.apache.sling.testing.clients.ClientException;
+import org.apache.sling.testing.clients.SlingClient;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Parameterized.class)
+public class AbstractSlingClientGetPathTest {
+
+    @Parameterized.Parameters(name = "{index} - serverUrl: {0}, input: {1}, expected: {2}")
+    public static Collection<String[]> data() {
+        return Arrays.asList(new String[][] {
+                {"http://HOST",              "http://HOST/page.html",             "/page.html"},
+                {"http://HOST",              "http://HOST/my/page.html",          "/my/page.html"},
+                {"http://HOST",              "http://HOST/my/",                   "/my/"},
+                {"http://HOST",              "http://HOST/my",                    "/my"},
+                {"http://HOST",              "http://HOST/",                      "/"},
+                {"http://HOST",              "http://HOST",                       "/"},
+                {"http://HOST",              "/page.html",                        "/page.html"},
+                {"http://HOST",              "/my/page.html",                     "/my/page.html"},
+                {"http://HOST",              "/my/",                              "/my/"},
+                {"http://HOST",              "/",                                 "/"},
+                {"http://HOST",              "page.html",                         "/page.html"},
+                {"http://HOST",              "my/page.html",                      "/my/page.html"},
+                {"http://HOST",              "my",                                "/my"},
+                {"http://HOST",              "",                                  "/"},
+
+                {"http://HOST:4502",         "http://HOST:4502/page.html",        "/page.html"},
+                {"http://HOST:4502",         "http://HOST:4502/my/page.html",     "/my/page.html"},
+                {"http://HOST:4502",         "http://HOST:4502/my/",              "/my/"},
+                {"http://HOST:4502",         "http://HOST:4502/my",               "/my"},
+                {"http://HOST:4502",         "http://HOST:4502/",                 "/"},
+                {"http://HOST:4502",         "http://HOST:4502",                  "/"},
+                {"http://HOST:4502",         "/page.html",                        "/page.html"},
+                {"http://HOST:4502",         "/my/page.html",                     "/my/page.html"},
+                {"http://HOST:4502",         "/my/",                              "/my/"},
+                {"http://HOST:4502",         "/my",                               "/my"},
+                {"http://HOST:4502",         "/",                                 "/"},
+                {"http://HOST:4502",         "page.html",                         "/page.html"},
+                {"http://HOST:4502",         "my/page.html",                      "/my/page.html"},
+                {"http://HOST:4502",         "my/",                               "/my/"},
+                {"http://HOST:4502",         "my",                                "/my"},
+                {"http://HOST:4502",         "",                                  "/"},
+
+                {"http://HOST:4502/",        "http://HOST:4502/page.html",        "/page.html"},
+                {"http://HOST:4502/",        "http://HOST:4502/my/page.html",     "/my/page.html"},
+                {"http://HOST:4502/",        "http://HOST:4502/my/",              "/my/"},
+                {"http://HOST:4502/",        "http://HOST:4502/my",               "/my"},
+                {"http://HOST:4502/",        "http://HOST:4502/",                 "/"},
+                {"http://HOST:4502/",        "http://HOST:4502",                  "/"},
+                {"http://HOST:4502/",        "/page.html",                        "/page.html"},
+                {"http://HOST:4502/",        "/my/page.html",                     "/my/page.html"},
+                {"http://HOST:4502/",        "/my/",                              "/my/"},
+                {"http://HOST:4502/",        "/my",                               "/my"},
+                {"http://HOST:4502/",        "/",                                 "/"},
+                {"http://HOST:4502/",        "page.html",                         "/page.html"},
+                {"http://HOST:4502/",        "my/page.html",                      "/my/page.html"},
+                {"http://HOST:4502/",        "my/",                               "/my/"},
+                {"http://HOST:4502/",        "my",                                "/my"},
+                {"http://HOST:4502/",        "",                                  "/"},
+
+                {"http://HOST:4502/CTX",     "http://HOST:4502/CTX/page.html",    "/page.html"},
+                {"http://HOST:4502/CTX",     "http://HOST:4502/CTX/my/page.html", "/my/page.html"},
+                {"http://HOST:4502/CTX",     "http://HOST:4502/CTX/my/",          "/my/"},
+                {"http://HOST:4502/CTX",     "http://HOST:4502/CTX/my",           "/my"},
+                {"http://HOST:4502/CTX",     "http://HOST:4502/CTX/",             "/"},
+                {"http://HOST:4502/CTX",     "http://HOST:4502/CTX",              "/"},
+                {"http://HOST:4502/CTX",     "/CTX",                              "/"},
+                {"http://HOST:4502/CTX",     "/CTX/",                             "/"},
+                {"http://HOST:4502/CTX",     "/CTX/page.html",                    "/page.html"},
+                {"http://HOST:4502/CTX",     "/page.html",                        "/page.html"},
+                {"http://HOST:4502/CTX",     "/my/page.html",                     "/my/page.html"},
+                {"http://HOST:4502/CTX",     "/my/",                              "/my/"},
+                {"http://HOST:4502/CTX",     "/my",                               "/my"},
+                {"http://HOST:4502/CTX",     "/",                                 "/"},
+                {"http://HOST:4502/CTX",     "CTX",                               "/"},
+                {"http://HOST:4502/CTX",     "CTX/",                              "/"},
+                {"http://HOST:4502/CTX",     "CTX/page.html",                     "/page.html"},
+                {"http://HOST:4502/CTX",     "page.html",                         "/page.html"},
+                {"http://HOST:4502/CTX",     "my/page.html",                      "/my/page.html"},
+                {"http://HOST:4502/CTX",     "my/",                               "/my/"},
+                {"http://HOST:4502/CTX",     "my",                                "/my"},
+                {"http://HOST:4502/CTX",     "",                                  "/"},
+
+                {"http://HOST:4502/CTX/",    "http://HOST:4502/CTX/page.html",    "/page.html"},
+                {"http://HOST:4502/CTX/",    "http://HOST:4502/CTX/my/page.html", "/my/page.html"},
+                {"http://HOST:4502/CTX/",    "http://HOST:4502/CTX/my/",          "/my/"},
+                {"http://HOST:4502/CTX/",    "http://HOST:4502/CTX/my",           "/my"},
+                {"http://HOST:4502/CTX/",    "http://HOST:4502/CTX/",             "/"},
+                {"http://HOST:4502/CTX/",    "http://HOST:4502/CTX",              "/"},
+                {"http://HOST:4502/CTX/",    "/CTX",                              "/"},
+                {"http://HOST:4502/CTX/",    "/CTX/",                             "/"},
+                {"http://HOST:4502/CTX/",    "/CTX/page.html",                    "/page.html"},
+                {"http://HOST:4502/CTX/",    "/page.html",                        "/page.html"},
+                {"http://HOST:4502/CTX/",    "/my/page.html",                     "/my/page.html"},
+                {"http://HOST:4502/CTX/",    "/my/",                              "/my/"},
+                {"http://HOST:4502/CTX/",    "/my",                               "/my"},
+                {"http://HOST:4502/CTX/",    "/",                                 "/"},
+                {"http://HOST:4502/CTX/",    "CTX",                               "/"},
+                {"http://HOST:4502/CTX/",    "CTX/",                              "/"},
+                {"http://HOST:4502/CTX/",    "CTX/page.html",                     "/page.html"},
+                {"http://HOST:4502/CTX/",    "page.html",                         "/page.html"},
+                {"http://HOST:4502/CTX/",    "my/page.html",                      "/my/page.html"},
+                {"http://HOST:4502/CTX/",    "my/",                               "/my/"},
+                {"http://HOST:4502/CTX/",    "my",                                "/my"},
+                {"http://HOST:4502/CTX/",    "",                                  "/"},
+
+                {"http://HOST:4502/CTX/",    "http://www.google.com",             "http://www.google.com"},
+        });
+    }
+
+    @Parameterized.Parameter(value = 0)
+    public String serverUrl;
+
+    @Parameterized.Parameter(value = 1)
+    public String inputUri;
+
+    @Parameterized.Parameter(value = 2)
+    public String expectedPath;
+
+    @Test
+    public void testGetPath() throws ClientException, URISyntaxException {
+        SlingClient c = new SlingClient(URI.create(serverUrl), "USER", "PWD");
+        assertEquals(URI.create(expectedPath), c.getPath(inputUri));
+    }
+}
+
+
+
+
+
+
+
+
+
+
+

Added: sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/AbstractSlingClientGetServerUrlTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/AbstractSlingClientGetServerUrlTest.java?rev=1741632&view=auto
==============================================================================
--- sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/AbstractSlingClientGetServerUrlTest.java (added)
+++ sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/AbstractSlingClientGetServerUrlTest.java Fri Apr 29 14:03:32 2016
@@ -0,0 +1,56 @@
+/*
+ * 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.testing;
+
+import org.apache.sling.testing.clients.ClientException;
+import org.apache.sling.testing.clients.SlingClient;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Parameterized.class)
+public class AbstractSlingClientGetServerUrlTest {
+
+    @Parameterized.Parameters(name = "{index} - serverUrl: {0}, path: {1}, expected: {2}")
+    public static Collection<String[]> data() {
+        return Arrays.asList(new String[][] {
+                {"http://HOST",             "http://HOST/"},
+                {"http://HOST:4502",        "http://HOST:4502/"},
+                {"http://HOST:4502/",       "http://HOST:4502/"},
+                {"http://HOST:4502/CTX",    "http://HOST:4502/CTX/"},
+                {"http://HOST:4502/CTX/",   "http://HOST:4502/CTX/"},
+        });
+    }
+
+    @Parameterized.Parameter(value = 0)
+    public String serverUrl;
+
+    @Parameterized.Parameter(value = 1)
+    public String expectedUrl;
+
+    @Test
+    public void testGetUrl() throws ClientException {
+        SlingClient c = new SlingClient(URI.create(serverUrl), "USER", "PWD");
+        assertEquals("", URI.create(expectedUrl), c.getUrl());
+    }
+}

Added: sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/AbstractSlingClientGetUrlTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/AbstractSlingClientGetUrlTest.java?rev=1741632&view=auto
==============================================================================
--- sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/AbstractSlingClientGetUrlTest.java (added)
+++ sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/AbstractSlingClientGetUrlTest.java Fri Apr 29 14:03:32 2016
@@ -0,0 +1,122 @@
+/*
+ * 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.testing;
+
+import org.apache.sling.testing.clients.ClientException;
+import org.apache.sling.testing.clients.SlingClient;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Parameterized.class)
+public class AbstractSlingClientGetUrlTest {
+
+    @Parameterized.Parameters(name = "{index} - serverUrl: {0}, path: {1}, expected: {2}")
+    public static Collection<String[]> data() {
+        return Arrays.asList(new String[][] {
+                // Server URL with no port
+                {"http://HOST",              "/page.html",            "http://HOST/page.html"},
+                {"http://HOST",              "/my/page.html",         "http://HOST/my/page.html"},
+                {"http://HOST",              "/my/",                  "http://HOST/my/"},
+                {"http://HOST",              "/my",                   "http://HOST/my"},
+                {"http://HOST",              "/",                     "http://HOST/"},
+
+                {"http://HOST",              "page.html",             "http://HOST/page.html"},
+                {"http://HOST",              "my/page.html",          "http://HOST/my/page.html"},
+                {"http://HOST",              "my/",                   "http://HOST/my/"},
+                {"http://HOST",              "my",                    "http://HOST/my"},
+                {"http://HOST",              "",                      "http://HOST/"},
+
+                // Server URL with with port
+                {"http://HOST:4502",         "/page.html",            "http://HOST:4502/page.html"},
+                {"http://HOST:4502",         "/my/page.html",         "http://HOST:4502/my/page.html"},
+                {"http://HOST:4502",         "/my/",                  "http://HOST:4502/my/"},
+                {"http://HOST:4502",         "/my",                   "http://HOST:4502/my"},
+                {"http://HOST:4502",         "/",                     "http://HOST:4502/"},
+
+                {"http://HOST:4502",         "page.html",             "http://HOST:4502/page.html"},
+                {"http://HOST:4502",         "my/page.html",          "http://HOST:4502/my/page.html"},
+                {"http://HOST:4502",         "my/",                   "http://HOST:4502/my/"},
+                {"http://HOST:4502",         "my",                    "http://HOST:4502/my"},
+                {"http://HOST:4502",         "",                      "http://HOST:4502/"},
+
+                // Server URL with with port and trailing slash
+                {"http://HOST:4502/",        "/page.html",            "http://HOST:4502/page.html"},
+                {"http://HOST:4502/",        "/my/page.html",         "http://HOST:4502/my/page.html"},
+                {"http://HOST:4502/",        "/my/",                  "http://HOST:4502/my/"},
+                {"http://HOST:4502/",        "/my",                   "http://HOST:4502/my"},
+                {"http://HOST:4502/",        "/",                     "http://HOST:4502/"},
+
+                {"http://HOST:4502/",        "page.html",             "http://HOST:4502/page.html"},
+                {"http://HOST:4502/",        "my/page.html",          "http://HOST:4502/my/page.html"},
+                {"http://HOST:4502/",        "my/",                   "http://HOST:4502/my/"},
+                {"http://HOST:4502/",        "my",                    "http://HOST:4502/my"},
+                {"http://HOST:4502/",        "",                      "http://HOST:4502/"},
+
+                // Server URL with with port and context path (no trailing slash)
+                {"http://HOST:4502/CTX",     "/page.html",            "http://HOST:4502/CTX/page.html"},
+                {"http://HOST:4502/CTX",     "/my/page.html",         "http://HOST:4502/CTX/my/page.html"},
+                {"http://HOST:4502/CTX",     "/my/",                  "http://HOST:4502/CTX/my/"},
+                {"http://HOST:4502/CTX",     "/my",                   "http://HOST:4502/CTX/my"},
+                {"http://HOST:4502/CTX",     "/",                     "http://HOST:4502/CTX/"},
+
+                {"http://HOST:4502/CTX",     "page.html",             "http://HOST:4502/CTX/page.html"},
+                {"http://HOST:4502/CTX",     "my/page.html",          "http://HOST:4502/CTX/my/page.html"},
+                {"http://HOST:4502/CTX",     "my/",                   "http://HOST:4502/CTX/my/"},
+                {"http://HOST:4502/CTX",     "my",                    "http://HOST:4502/CTX/my"},
+                {"http://HOST:4502/CTX",     "",                      "http://HOST:4502/CTX/"},
+
+                // Server URL with with port and context path and trailing slash
+                {"http://HOST:4502/CTX/",    "/page.html",            "http://HOST:4502/CTX/page.html"},
+                {"http://HOST:4502/CTX/",    "/my/page.html",         "http://HOST:4502/CTX/my/page.html"},
+                {"http://HOST:4502/CTX/",    "/my/",                  "http://HOST:4502/CTX/my/"},
+                {"http://HOST:4502/CTX/",    "/my",                   "http://HOST:4502/CTX/my"},
+                {"http://HOST:4502/CTX/",    "/",                     "http://HOST:4502/CTX/"},
+
+                {"http://HOST:4502/CTX/",    "page.html",             "http://HOST:4502/CTX/page.html"},
+                {"http://HOST:4502/CTX/",    "my/page.html",          "http://HOST:4502/CTX/my/page.html"},
+                {"http://HOST:4502/CTX/",    "my/",                   "http://HOST:4502/CTX/my/"},
+                {"http://HOST:4502/CTX/",    "my",                    "http://HOST:4502/CTX/my"},
+                {"http://HOST:4502/CTX/",    "",                      "http://HOST:4502/CTX/"},
+
+                // External URLs
+                {"http://HOST:4502/CTX/",    "http://www.google.com", "http://www.google.com"},
+                {"http://HOST:4502/CTX/",    "http://HOST:4502/CTX/my/page.html", "http://HOST:4502/CTX/my/page.html"},
+        });
+    }
+
+    @Parameterized.Parameter(value = 0)
+    public String serverUrl;
+
+    @Parameterized.Parameter(value = 1)
+    public String inputPath;
+
+    @Parameterized.Parameter(value = 2)
+    public String expectedUrl;
+
+    @Test
+    public void testGetUrlWithParam() throws ClientException {
+        SlingClient c = new SlingClient(URI.create(serverUrl), "USER", "PWD");
+        assertEquals("", URI.create(expectedUrl), c.getUrl(inputPath));
+    }
+}

Added: sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/DelayRequestInterceptorTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/DelayRequestInterceptorTest.java?rev=1741632&view=auto
==============================================================================
--- sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/DelayRequestInterceptorTest.java (added)
+++ sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/DelayRequestInterceptorTest.java Fri Apr 29 14:03:32 2016
@@ -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.testing;
+
+import org.apache.sling.testing.clients.interceptors.DelayRequestInterceptor;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class DelayRequestInterceptorTest {
+
+    @Test
+    public void testDelay() throws Exception {
+        DelayRequestInterceptor interceptor = new DelayRequestInterceptor(1000);
+        long before = System.currentTimeMillis();
+        interceptor.process(null, null);
+        long after = System.currentTimeMillis();
+        Assert.assertTrue(after - before >= 1000);
+    }
+
+}

Added: sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/util/UniquePathsTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/util/UniquePathsTest.java?rev=1741632&view=auto
==============================================================================
--- sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/util/UniquePathsTest.java (added)
+++ sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/util/UniquePathsTest.java Fri Apr 29 14:03:32 2016
@@ -0,0 +1,76 @@
+/*
+ * 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.testing.util;
+
+import org.apache.sling.testing.clients.util.UniquePaths;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.lang.reflect.Field;
+import java.util.concurrent.atomic.AtomicLong;
+
+import static org.junit.Assert.assertEquals;
+
+public class UniquePathsTest {
+
+    @Before
+    public void setup() throws Exception {
+        // Set known startTime and counter values for tests
+        {
+            final Field f = UniquePaths.class.getDeclaredField("startTime");
+            f.setAccessible(true);
+            f.set(UniquePaths.class, 1234L);
+        }
+        {
+            final Field f = UniquePaths.class.getDeclaredField("counter");
+            f.setAccessible(true);
+            f.set(UniquePaths.class, new AtomicLong(9362L));
+        }
+    }
+    
+    @Test
+    public void testNoUPattern() {
+        assertEquals("/tmp/UniquePathsTest_1234_9363", UniquePaths.get(this, "/tmp/"));
+        assertEquals("/bar/UniquePathsTest_1234_9364", UniquePaths.get(this, "/bar/"));
+    }
+    
+    @Test
+    public void testSingleUPattern() {
+        assertEquals("/tmp/UniquePathsTest_1234_9363/foo", UniquePaths.get(this, "/tmp/_UNIQ_/foo"));
+    }
+    
+    @Test
+    public void testMultipleUPattern() {
+        assertEquals(
+                "/tmp/UniquePathsTest_1234_9363/foo/UniquePathsTest_1234_9363.html", 
+                UniquePaths.get(this, "/tmp/_UNIQ_/foo/_UNIQ_.html"));
+    }
+    
+    @Test
+    public void testNullPattern() {
+        assertEquals(
+                "UniquePathsTest_1234_9363", 
+                UniquePaths.get(this, null));
+    }
+    
+    @Test
+    public void testNoPattern() {
+        assertEquals(
+                "UniquePathsTest_1234_9363", 
+                UniquePaths.get(this));
+    }
+}

Added: sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/util/poller/AbstractPollerTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/util/poller/AbstractPollerTest.java?rev=1741632&view=auto
==============================================================================
--- sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/util/poller/AbstractPollerTest.java (added)
+++ sling/trunk/testing/http/clients/src/test/java/org/apache/sling/testing/util/poller/AbstractPollerTest.java Fri Apr 29 14:03:32 2016
@@ -0,0 +1,107 @@
+/*
+ * 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.testing.util.poller;
+
+import org.apache.sling.testing.clients.util.poller.AbstractPoller;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AbstractPollerTest {
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractPollerTest.class);
+
+    @Test
+    public void testCallAndWaitSuccess() throws InterruptedException {
+        AbstractPoller poller = new AbstractPoller(100, 5) {
+            int callNumber = 0;
+
+            @Override
+            public boolean call() {
+                return true;
+            }
+
+            @Override
+            public boolean condition() {
+                callNumber += 1;
+                LOG.debug("Call nr " + callNumber);
+                if (callNumber == 4) {
+                    return true;
+                }
+                return false;
+            }
+        };
+        Assert.assertTrue(poller.callAndWait());
+    }
+
+    @Test
+    public void testCallAndWaitFailure() throws InterruptedException {
+        AbstractPoller poller = new AbstractPoller(100, 5) {
+            @Override
+            public boolean call() {
+                return true;
+            }
+
+            @Override
+            public boolean condition() {
+                return false;
+            }
+        };
+        Assert.assertFalse(poller.callAndWait());
+    }
+
+    @Test
+    public void testCallUntilSuccess() throws InterruptedException {
+        AbstractPoller poller = new AbstractPoller(100, 5) {
+            int callNumber = 0;
+
+            @Override
+            public boolean call() {
+                callNumber += 1;
+                LOG.debug("Call nr " + callNumber);
+                return true;
+            }
+
+            @Override
+            public boolean condition() {
+                if (callNumber == 4) {
+                    return true;
+                }
+                return false;
+            }
+        };
+        Assert.assertTrue(poller.callUntilCondition());
+    }
+
+    @Test
+    public void testCallUntilFailure() throws InterruptedException {
+        AbstractPoller poller = new AbstractPoller(100, 5) {
+            @Override
+            public boolean call() {
+                return true;
+            }
+
+            @Override
+            public boolean condition() {
+                return false;
+            }
+        };
+        Assert.assertFalse(poller.callUntilCondition());
+    }
+
+
+}