This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-clients.git


The following commit(s) were added to refs/heads/master by this push:
     new 04db1b5  SLING-7261 - Caches are invalidated when using 
AbstractSlingClient#doGet(String requestPath, int... expectedStatus)
04db1b5 is described below

commit 04db1b512ab022acb82b283a7b71ed8f9a7dca26
Author: Andrei Tuicu <[email protected]>
AuthorDate: Thu Nov 23 08:26:15 2017 +0200

    SLING-7261 - Caches are invalidated when using 
AbstractSlingClient#doGet(String requestPath, int... expectedStatus)
---
 .../org/apache/sling/testing/clients/AbstractSlingClient.java |  8 +++++---
 .../apache/sling/testing/AbstractSlingClientGetUrlTest.java   | 11 +++++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/testing/clients/AbstractSlingClient.java 
b/src/main/java/org/apache/sling/testing/clients/AbstractSlingClient.java
index 51c57d8..2d3f70d 100644
--- a/src/main/java/org/apache/sling/testing/clients/AbstractSlingClient.java
+++ b/src/main/java/org/apache/sling/testing/clients/AbstractSlingClient.java
@@ -144,7 +144,8 @@ public class AbstractSlingClient implements HttpClient, 
Closeable {
      * Creates a full URL for a given path with additional parameters. Same as 
{@link #getUrl(String)}, but adds the parameters in the URI.
      *
      * @param path path relative to server url; can start with / but should 
not include the server context path
-     * @param parameters url parameters to be added to the url
+     * @param parameters url parameters to be added to the url. If the given 
argument is {@code null}, nothing will be added to the url.
+     *                   If the given argument is an empty array, it will 
force a "?" at the end of the url.
      * @return full url as URI
      * @throws IllegalArgumentException if path or parameters cannot be parsed 
into an URI
      * @throws NullPointerException if path is null
@@ -153,8 +154,9 @@ public class AbstractSlingClient implements HttpClient, 
Closeable {
         // add server url and path
         URIBuilder uriBuilder = new URIBuilder(getUrl(path));
         // add parameters
-        parameters = (parameters != null) ? parameters : new 
ArrayList<NameValuePair>(0);
-        uriBuilder.addParameters(parameters);
+        if(parameters != null) {
+            uriBuilder.addParameters(parameters);
+        }
 
         try {
             return uriBuilder.build();
diff --git 
a/src/test/java/org/apache/sling/testing/AbstractSlingClientGetUrlTest.java 
b/src/test/java/org/apache/sling/testing/AbstractSlingClientGetUrlTest.java
index 665b595..9af1f62 100644
--- a/src/test/java/org/apache/sling/testing/AbstractSlingClientGetUrlTest.java
+++ b/src/test/java/org/apache/sling/testing/AbstractSlingClientGetUrlTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.sling.testing;
 
+import org.apache.http.NameValuePair;
+import org.apache.http.message.BasicNameValuePair;
 import org.apache.sling.testing.clients.ClientException;
 import org.apache.sling.testing.clients.SlingClient;
 import org.junit.Test;
@@ -23,8 +25,10 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.List;
 
 import static org.junit.Assert.assertEquals;
 
@@ -105,6 +109,10 @@ public class AbstractSlingClientGetUrlTest {
         });
     }
 
+
+    private static final List<NameValuePair> TEST_PARAMETERS = 
Arrays.<NameValuePair>asList(new BasicNameValuePair("key", "value"));
+    private static final String STRING_TEST_PARAMETERS = "key=value";
+
     @Parameterized.Parameter(value = 0)
     public String serverUrl;
 
@@ -118,5 +126,8 @@ public class AbstractSlingClientGetUrlTest {
     public void testGetUrlWithParam() throws ClientException {
         SlingClient c = new SlingClient(URI.create(serverUrl), "USER", "PWD");
         assertEquals("", URI.create(expectedUrl), c.getUrl(inputPath));
+        assertEquals(URI.create(expectedUrl), c.getUrl(inputPath, null));
+        assertEquals(URI.create(expectedUrl + "?"), c.getUrl(inputPath, new 
ArrayList<NameValuePair>()));
+        assertEquals(URI.create(expectedUrl + "?" + STRING_TEST_PARAMETERS), 
c.getUrl(inputPath, TEST_PARAMETERS));
     }
 }

-- 
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].

Reply via email to