[
https://issues.apache.org/jira/browse/SLING-7261?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16263930#comment-16263930
]
ASF GitHub Bot commented on SLING-7261:
---------------------------------------
rombert closed pull request #1: SLING-7261 - Caches are invalidated when using
AbstractSlingClient#doGet(String requestPath, int... expectedStatus)
URL: https://github.com/apache/sling-org-apache-sling-testing-clients/pull/1
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
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 URI getUrl(String path) {
* 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 URI getUrl(String path, List<NameValuePair>
parameters) {
// 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.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 @@
});
}
+
+ 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 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));
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Caches are invalidated when using AbstractSlingClient#doGet(String
> requestPath, int... expectedStatus)
> ------------------------------------------------------------------------------------------------------
>
> Key: SLING-7261
> URL: https://issues.apache.org/jira/browse/SLING-7261
> Project: Sling
> Issue Type: Bug
> Components: Apache Sling Testing Clients
> Affects Versions: Apache Sling Testing Clients 1.1.4
> Reporter: Andrei Tuicu
>
> h3. Problem
> Caches are invalidated when using AbstractSlingClient#doGet(String
> requestPath, int... expectedStatus). This happens because the
> AbstractSlingClient#getUrl(String path, List<NameValuePair> parameters) adds
> an empty parameters array to the url, even when the parameters argument is
> null. This results in urls that have ? at the end for all GET requests
> (http(s)://host:port/requestpath?)
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)