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 2020/04/02 11:00:37 UTC

[sling-org-apache-sling-junit-teleporter] branch master updated (1256b5b -> 9cf6c32)

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

bdelacretaz pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-junit-teleporter.git.


    from 1256b5b  [maven-release-plugin] prepare for next development iteration
     new b81ebb9  SLING-9327 - allow for running tests with jdk11
     new a20c63b  SLING-9327 - add base64 encoding tests before switching encoder
     new dd456c3  .gitignore
     new 7281da1  SLING-9327 - switch to commons-code base64 encoder, suspecting it's java.util.Base64 which uses DatatypeConverter
     new 9cf6c32  SLING-9327 - remove osgi.core dependency which was not really used

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore                                         |  1 +
 pom.xml                                            | 15 ++++++-------
 .../teleporter/client/ClientSideTeleporter.java    |  3 +--
 .../teleporter/client/TeleporterHttpClient.java    | 26 ++++++++++++++++------
 .../client/TeleporterHttpClientTest.java           | 14 ++++++++++++
 5 files changed, 42 insertions(+), 17 deletions(-)


[sling-org-apache-sling-junit-teleporter] 03/05: .gitignore

Posted by bd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-junit-teleporter.git

commit dd456c346c14758c424c7a32596e5270a263d1b1
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Apr 2 12:55:21 2020 +0200

    .gitignore
---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index 5b783ed..19758c5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,4 @@ maven-eclipse.xml
 .DS_Store
 jcr.log
 atlassian-ide-plugin.xml
+.vscode


[sling-org-apache-sling-junit-teleporter] 04/05: SLING-9327 - switch to commons-code base64 encoder, suspecting it's java.util.Base64 which uses DatatypeConverter

Posted by bd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-junit-teleporter.git

commit 7281da17f0f73f275d02adc9bc0eb5a443ca3250
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Apr 2 12:55:31 2020 +0200

    SLING-9327 - switch to commons-code base64 encoder, suspecting it's java.util.Base64 which uses DatatypeConverter
---
 pom.xml                                            |  5 +++++
 .../teleporter/client/TeleporterHttpClient.java    | 22 +++++++++++++++-------
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/pom.xml b/pom.xml
index 10cb6bc..19f6ed8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -116,6 +116,11 @@
       <version>3.4</version>
     </dependency>
     <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+      <version>1.14</version>
+    </dependency>
+    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
     </dependency>
diff --git a/src/main/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClient.java b/src/main/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClient.java
index 2966335..abad021 100644
--- a/src/main/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClient.java
+++ b/src/main/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClient.java
@@ -23,13 +23,13 @@ import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.io.StringReader;
 import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
-import java.util.Base64;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -43,6 +43,7 @@ import javax.json.JsonString;
 import javax.json.JsonValue;
 import javax.json.JsonValue.ValueType;
 
+import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.io.IOUtils;
 import org.junit.runner.Result;
 import org.junit.runner.notification.Failure;
@@ -50,9 +51,10 @@ import org.junit.runners.model.MultipleFailureException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/** Barebones HTTP client that supports just what the teleporter needs,
- *  with no dependencies outside of java.* and org.junit. Prevents us 
- *  from imposing a particular HTTP client version. 
+/**
+ * Barebones HTTP client that supports just what the teleporter needs, with no
+ * dependencies outside of java.* and org.junit. Prevents us from imposing a
+ * particular HTTP client version.
  */
 class TeleporterHttpClient {
     private final Logger log = LoggerFactory.getLogger(getClass());
@@ -62,7 +64,7 @@ class TeleporterHttpClient {
     private String credentials = null;
     private final String testServletPath;
     private final int httpTimeoutSeconds;
-    
+
     static final class SimpleHttpResponse {
         private final int status;
         private final String body;
@@ -72,14 +74,16 @@ class TeleporterHttpClient {
             this.status = status;
             this.body = body;
         }
+
         public int getStatus() {
             return status;
         }
+
         public String getBody() {
             return body;
         }
     }
-    
+
     TeleporterHttpClient(String baseUrl, String testServletPath) {
         this(baseUrl, testServletPath, ClientSideTeleporter.DEFAULT_TEST_READY_TIMEOUT_SECONDS);
     }
@@ -102,7 +106,11 @@ class TeleporterHttpClient {
     }
 
     static String encodeBase64(String data) {
-        return Base64.getEncoder().encodeToString(data.getBytes());
+        try {
+            return Base64.encodeBase64String(data.getBytes("UTF-8"));
+        } catch(UnsupportedEncodingException uee) {
+            throw new RuntimeException(uee);
+        }
     }
     
     public void setConnectionCredentials(URLConnection c) {


[sling-org-apache-sling-junit-teleporter] 02/05: SLING-9327 - add base64 encoding tests before switching encoder

Posted by bd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-junit-teleporter.git

commit a20c63bf3627ae85dba8415d96bf8b5df096d249
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Apr 2 12:38:56 2020 +0200

    SLING-9327 - add base64 encoding tests before switching encoder
---
 .../testing/teleporter/client/TeleporterHttpClient.java    |  6 +++++-
 .../teleporter/client/TeleporterHttpClientTest.java        | 14 ++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClient.java b/src/main/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClient.java
index 2a5699e..2966335 100644
--- a/src/main/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClient.java
+++ b/src/main/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClient.java
@@ -100,10 +100,14 @@ class TeleporterHttpClient {
     int getHttpTimeoutSeconds() {
         return httpTimeoutSeconds;
     }
+
+    static String encodeBase64(String data) {
+        return Base64.getEncoder().encodeToString(data.getBytes());
+    }
     
     public void setConnectionCredentials(URLConnection c) {
         if(credentials != null && !credentials.isEmpty()) {
-            final String basicAuth = "Basic " + Base64.getEncoder().encodeToString(credentials.getBytes());
+            final String basicAuth = "Basic " + encodeBase64(credentials);
             c.setRequestProperty ("Authorization", basicAuth);
             log.debug("Credentials set");
         }
diff --git a/src/test/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClientTest.java b/src/test/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClientTest.java
index c746a37..fd8de5c 100644
--- a/src/test/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClientTest.java
+++ b/src/test/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClientTest.java
@@ -176,4 +176,18 @@ public class TeleporterHttpClientTest {
             // as expected due to timeout
         }
     }
+
+    @Test
+    public void testBase64Encoding() {
+        assertEquals("", TeleporterHttpClient.encodeBase64(""));
+        assertEquals("Zm9v", TeleporterHttpClient.encodeBase64("foo"));
+        assertEquals("dGhlIHF1aWNrIGJyb3duIGZveA==", TeleporterHttpClient.encodeBase64("the quick brown fox"));
+
+        try {
+            TeleporterHttpClient.encodeBase64(null);
+            fail("Expected a NullPointerException");
+        } catch(NullPointerException asExpected) {
+            // as expected
+        }
+    }
 }
\ No newline at end of file


[sling-org-apache-sling-junit-teleporter] 01/05: SLING-9327 - allow for running tests with jdk11

Posted by bd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-junit-teleporter.git

commit b81ebb99b04ba9bd0754efdfe294ba933ecb0d52
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Apr 2 12:38:19 2020 +0200

    SLING-9327 - allow for running tests with jdk11
---
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index c0069ac..10cb6bc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,8 +21,8 @@
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>org.apache.sling</groupId>
-    <artifactId>sling</artifactId>
-    <version>33</version>
+    <artifactId>sling-bundle-parent</artifactId>
+    <version>38</version>
     <relativePath />
   </parent>
 


[sling-org-apache-sling-junit-teleporter] 05/05: SLING-9327 - remove osgi.core dependency which was not really used

Posted by bd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-junit-teleporter.git

commit 9cf6c329304e0168222e3b1a9792a7c4981b99d4
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Apr 2 13:00:22 2020 +0200

    SLING-9327 - remove osgi.core dependency which was not really used
---
 pom.xml                                                             | 6 ------
 .../sling/testing/teleporter/client/ClientSideTeleporter.java       | 3 +--
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/pom.xml b/pom.xml
index 19f6ed8..9a5a4dd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -146,12 +146,6 @@
       <version>1.1.4</version>
       <scope>test</scope>
     </dependency>
-    <!-- OSGi -->
-    <dependency>
-      <groupId>org.osgi</groupId>
-      <artifactId>osgi.core</artifactId>
-      <scope>provided</scope>
-    </dependency>
   </dependencies>
   
   <scm>
diff --git a/src/main/java/org/apache/sling/testing/teleporter/client/ClientSideTeleporter.java b/src/main/java/org/apache/sling/testing/teleporter/client/ClientSideTeleporter.java
index f1073a9..ed0e199 100644
--- a/src/main/java/org/apache/sling/testing/teleporter/client/ClientSideTeleporter.java
+++ b/src/main/java/org/apache/sling/testing/teleporter/client/ClientSideTeleporter.java
@@ -43,7 +43,6 @@ import org.junit.runner.Description;
 import org.junit.runners.model.Statement;
 import org.ops4j.pax.tinybundles.core.TinyBundle;
 import org.ops4j.pax.tinybundles.core.TinyBundles;
-import org.osgi.framework.Constants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.helpers.NOPLogger;
@@ -79,7 +78,7 @@ public class ClientSideTeleporter extends TeleporterRule {
     
     private InputStream buildTestBundle(Class<?> c, Collection<Class<?>> embeddedClasses, String bundleSymbolicName) throws IOException {
         final TinyBundle b = TinyBundles.bundle()
-            .set(Constants.BUNDLE_SYMBOLICNAME, bundleSymbolicName)
+            .set("Bundle-SymbolicName", bundleSymbolicName)
             .set("Sling-Test-Regexp", c.getName() + ".*")
             .set("Sling-Test-WaitForService-Timeout", Integer.toString(waitForServiceTimout))
             .add(c);