You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by du...@apache.org on 2020/02/14 10:38:10 UTC
[sling-org-apache-sling-testing-clients] 02/02: trivial: Added a
few more test values + fix pom tag
This is an automated email from the ASF dual-hosted git repository.
dulvac pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-clients.git
commit f38f3914a8b665facbdc50267106e35ee9236a9c
Author: Andrei Dulvac <ad...@adobe.com>
AuthorDate: Fri Feb 14 11:37:40 2020 +0100
trivial: Added a few more test values + fix pom tag
---
pom.xml | 2 +-
.../sling/testing/clients/AbstractSlingClient.java | 2 +-
.../testing/AbstractSlingClientGetPathTest.java | 14 +++++++++++
.../clients/SlingClientConstructorTest.java | 27 +++++++++++++++++++++-
4 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index db4b828..257cb2a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,7 +39,7 @@
<connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-clients.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-clients.git</developerConnection>
<url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-testing-clients.git</url>
- <tag>org.apache.sling.testing.clients-1.2.4</tag>
+ <tag>HEAD</tag>
</scm>
<build>
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 3a953ca..117a475 100644
--- a/src/main/java/org/apache/sling/testing/clients/AbstractSlingClient.java
+++ b/src/main/java/org/apache/sling/testing/clients/AbstractSlingClient.java
@@ -154,7 +154,7 @@ public class AbstractSlingClient implements HttpClient, Closeable {
// add server url and path
URIBuilder uriBuilder = new URIBuilder(getUrl(path));
// add parameters
- if(parameters != null) {
+ if (parameters != null) {
uriBuilder.addParameters(parameters);
}
diff --git a/src/test/java/org/apache/sling/testing/AbstractSlingClientGetPathTest.java b/src/test/java/org/apache/sling/testing/AbstractSlingClientGetPathTest.java
index 64f4c73..69b0d0b 100644
--- a/src/test/java/org/apache/sling/testing/AbstractSlingClientGetPathTest.java
+++ b/src/test/java/org/apache/sling/testing/AbstractSlingClientGetPathTest.java
@@ -113,6 +113,7 @@ public class AbstractSlingClientGetPathTest {
{"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"},
@@ -130,6 +131,19 @@ public class AbstractSlingClientGetPathTest {
{"http://HOST:4502/CTX/", "my", "/my"},
{"http://HOST:4502/CTX/", "", "/"},
+ {"http://HOST:4502/CTX/", "/CTX/?param=value", "/?param=value"},
+ {"http://HOST:4502/CTX/", "/CTX/page.html?param=value", "/page.html?param=value"},
+ {"http://HOST:4502/CTX/", "/page.html?param=value", "/page.html?param=value"},
+ {"http://HOST:4502/CTX/", "/my/page.html?param=value", "/my/page.html?param=value"},
+ {"http://HOST:4502/CTX/", "/my/?param=value", "/my/?param=value"},
+ {"http://HOST:4502/CTX/", "/my?param=value", "/my?param=value"},
+ {"http://HOST:4502/CTX/", "CTX/?param=value", "/?param=value"},
+ {"http://HOST:4502/CTX/", "CTX/page.html?param=value", "/page.html?param=value"},
+ {"http://HOST:4502/CTX/", "page.html?param=value", "/page.html?param=value"},
+ {"http://HOST:4502/CTX/", "my/page.html?param=value", "/my/page.html?param=value"},
+ {"http://HOST:4502/CTX/", "my/?param=value", "/my/?param=value"},
+ {"http://HOST:4502/CTX/", "my?param=value", "/my?param=value"},
+
{"http://HOST:4502/CTX/", "http://www.google.com", "http://www.google.com"},
});
}
diff --git a/src/test/java/org/apache/sling/testing/clients/SlingClientConstructorTest.java b/src/test/java/org/apache/sling/testing/clients/SlingClientConstructorTest.java
index ed4bf08..4ae3caf 100644
--- a/src/test/java/org/apache/sling/testing/clients/SlingClientConstructorTest.java
+++ b/src/test/java/org/apache/sling/testing/clients/SlingClientConstructorTest.java
@@ -35,13 +35,30 @@ public class SlingClientConstructorTest {
@Test
public void testConstructorUrlHttp() throws Exception {
+ URI url = URI.create("http://example.com");
+ URI expected = URI.create("http://example.com/");
+ SlingClient c = new SlingClient(url, "user", "pass");
+ assertEquals(expected, c.getUrl());
+ }
+
+ @Test
+ public void testConstructorUrlHttpTrailingSlash() throws Exception {
URI url = URI.create("http://example.com/");
+ URI expected = URI.create("http://example.com/");
SlingClient c = new SlingClient(url, "user", "pass");
- assertEquals(url, c.getUrl());
+ assertEquals(expected, c.getUrl());
}
@Test
public void testConstructorUrlHttps() throws Exception {
+ URI url = URI.create("https://example.com");
+ URI expected = URI.create("https://example.com/");
+ SlingClient c = new SlingClient(url, "user", "pass");
+ assertEquals(expected, c.getUrl());
+ }
+
+ @Test
+ public void testConstructorUrlHttpsTrailingSlash() throws Exception {
URI url = URI.create("https://example.com/");
SlingClient c = new SlingClient(url, "user", "pass");
assertEquals(url, c.getUrl());
@@ -49,6 +66,14 @@ public class SlingClientConstructorTest {
@Test
public void testConstructorUrlBasePath() throws Exception {
+ URI url = URI.create("https://example.com/mypath");
+ URI expected = URI.create("https://example.com/mypath/");
+ SlingClient c = new SlingClient(url, "user", "pass");
+ assertEquals(expected, c.getUrl());
+ }
+
+ @Test
+ public void testConstructorUrlBasePathTrailingSlash() throws Exception {
URI url = URI.create("https://example.com/mypath/");
SlingClient c = new SlingClient(url, "user", "pass");
assertEquals(url, c.getUrl());