You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2021/10/21 09:11:19 UTC

[pulsar] 01/13: Make AuthenticationTokenTest to run on windows (#12329)

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

penghui pushed a commit to branch branch-2.8
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 8386c9ef76852aa8ccc0a52f276e1234ccbc440c
Author: ZhangJian He <sh...@gmail.com>
AuthorDate: Wed Oct 13 09:44:00 2021 +0800

    Make AuthenticationTokenTest to run on windows (#12329)
    
    ### Motivation
    Make AuthenticationTokenTest to run on windows
    
    ### Modifications
    Replace the '\' to '/'
    
    (cherry picked from commit 5f00b870987664978792b1d6f1bddb051fa9fa57)
---
 .../pulsar/client/impl/auth/AuthenticationTokenTest.java  | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/auth/AuthenticationTokenTest.java b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/auth/AuthenticationTokenTest.java
index 5648386..ffa4582 100644
--- a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/auth/AuthenticationTokenTest.java
+++ b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/auth/AuthenticationTokenTest.java
@@ -30,7 +30,6 @@ import java.util.Collections;
 import java.util.function.Supplier;
 
 import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.SerializationUtils;
 import org.apache.pulsar.client.api.Authentication;
 import org.apache.pulsar.client.api.AuthenticationDataProvider;
 import org.apache.pulsar.client.impl.PulsarClientImpl;
@@ -100,12 +99,12 @@ public class AuthenticationTokenTest {
 
     @Test
     public void testAuthTokenConfigFromFile() throws Exception {
-        File tokenFile = File.createTempFile("pular-test-token", ".key");
+        File tokenFile = File.createTempFile("pulsar-test-token", ".key");
         tokenFile.deleteOnExit();
         FileUtils.write(tokenFile, "my-test-token-string", Charsets.UTF_8);
 
         AuthenticationToken authToken = new AuthenticationToken();
-        authToken.configure("file://" + tokenFile);
+        authToken.configure(getTokenFileUri(tokenFile));
         assertEquals(authToken.getAuthMethodName(), "token");
 
         AuthenticationDataProvider authData = authToken.getAuthData();
@@ -128,12 +127,12 @@ public class AuthenticationTokenTest {
      */
     @Test
     public void testAuthTokenConfigFromFileWithNewline() throws Exception {
-        File tokenFile = File.createTempFile("pular-test-token", ".key");
+        File tokenFile = File.createTempFile("pulsar-test-token", ".key");
         tokenFile.deleteOnExit();
         FileUtils.write(tokenFile, "  my-test-token-string  \r\n", Charsets.UTF_8);
 
         AuthenticationToken authToken = new AuthenticationToken();
-        authToken.configure("file://" + tokenFile);
+        authToken.configure(getTokenFileUri(tokenFile));
         assertEquals(authToken.getAuthMethodName(), "token");
 
         AuthenticationDataProvider authData = authToken.getAuthData();
@@ -197,10 +196,14 @@ public class AuthenticationTokenTest {
         assertEquals(tokenSupplier.token, ts.getAuthData().getCommandData());
     }
 
+    private String getTokenFileUri(File file) {
+        return "file:///" + file.toString().replace('\\', '/');
+    }
+
     public static class SerializableSupplier implements Supplier<String>, Serializable {
 
         private static final long serialVersionUID = 6259616338933150683L;
-        private String token;
+        private final String token;
 
         public SerializableSupplier(final String token) {
             super();