This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 6ff7920 Refactor code (#2965)
6ff7920 is described below
commit 6ff7920c5005df087edfe2866fcae0de599bb31f
Author: erdengk <[email protected]>
AuthorDate: Thu Mar 3 18:43:14 2022 +0800
Refactor code (#2965)
* Refactor code
* Refactor code
* Refactor code
* Refactor code
---
.../common/exception/SerializerExceptionTest.java | 6 ------
.../shenyu/common/exception/ShenyuExceptionTest.java | 7 -------
.../register/client/http/utils/OkHttpTools.java | 20 ++++++++++++++++++++
3 files changed, 20 insertions(+), 13 deletions(-)
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/exception/SerializerExceptionTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/exception/SerializerExceptionTest.java
index a203817..3cdbbe4 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/exception/SerializerExceptionTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/exception/SerializerExceptionTest.java
@@ -20,7 +20,6 @@ package org.apache.shenyu.common.exception;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test case for {@link SerializerException}.
@@ -33,7 +32,6 @@ public final class SerializerExceptionTest {
Throwable throwable = new Throwable(message);
SerializerException serializerException = new
SerializerException(throwable);
- assertTrue(serializerException instanceof SerializerException);
assertEquals(serializerException.getCause().getMessage(), message);
assertEquals(serializerException.getCause(), throwable);
}
@@ -42,8 +40,6 @@ public final class SerializerExceptionTest {
public void testAcquireByMessage() {
String message = "error";
SerializerException serializerException = new
SerializerException(message);
-
- assertTrue(serializerException instanceof SerializerException);
assertEquals(serializerException.getMessage(), message);
}
@@ -53,8 +49,6 @@ public final class SerializerExceptionTest {
String throwableMessage = "error throwable";
Throwable throwable = new Throwable(throwableMessage);
SerializerException serializerException = new
SerializerException(message, throwable);
-
- assertTrue(serializerException instanceof SerializerException);
assertEquals(serializerException.getMessage(), message);
assertEquals(serializerException.getCause().getMessage(),
throwableMessage);
assertEquals(serializerException.getCause(), throwable);
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/exception/ShenyuExceptionTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/exception/ShenyuExceptionTest.java
index 86a6390..cb02f90 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/exception/ShenyuExceptionTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/exception/ShenyuExceptionTest.java
@@ -20,7 +20,6 @@ package org.apache.shenyu.common.exception;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test case for {@link ShenyuException}.
@@ -32,8 +31,6 @@ public final class ShenyuExceptionTest {
String message = "error throwable";
Throwable throwable = new Throwable(message);
ShenyuException shenyuException = new ShenyuException(throwable);
-
- assertTrue(shenyuException instanceof ShenyuException);
assertEquals(shenyuException.getCause().getMessage(), message);
assertEquals(shenyuException.getCause(), throwable);
}
@@ -42,8 +39,6 @@ public final class ShenyuExceptionTest {
public void testAcquireByMessage() {
String message = "error";
ShenyuException shenyuException = new ShenyuException(message);
-
- assertTrue(shenyuException instanceof ShenyuException);
assertEquals(shenyuException.getMessage(), message);
}
@@ -53,8 +48,6 @@ public final class ShenyuExceptionTest {
String throwableMessage = "error throwable";
Throwable throwable = new Throwable(throwableMessage);
ShenyuException shenyuException = new ShenyuException(message,
throwable);
-
- assertTrue(shenyuException instanceof ShenyuException);
assertEquals(shenyuException.getMessage(), message);
assertEquals(shenyuException.getCause().getMessage(),
throwableMessage);
assertEquals(shenyuException.getCause(), throwable);
diff --git
a/shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/OkHttpTools.java
b/shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/OkHttpTools.java
index 8a00f28..567f2c8 100644
---
a/shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/OkHttpTools.java
+++
b/shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/main/java/org/apache/shenyu/register/client/http/utils/OkHttpTools.java
@@ -23,6 +23,7 @@ import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Headers;
import okhttp3.HttpUrl;
+import org.apache.shenyu.common.constant.Constants;
import java.io.IOException;
import java.util.Map;
@@ -111,4 +112,23 @@ public final class OkHttpTools {
Request request = reqBuild.build();
return client.newCall(request).execute().body().string();
}
+
+ /**
+ * Get string by username and password.
+ * @param url the url
+ * @param userName the userName
+ * @param passWord the passWord
+ * @return the http result
+ * @throws IOException the io exception
+ */
+ public String get(final String url, final String userName, final String
passWord) throws IOException {
+ Request.Builder reqBuild = new Request.Builder();
+ HttpUrl.Builder urlBuilder = HttpUrl.parse(url).newBuilder();
+ urlBuilder.addQueryParameter(Constants.USER_NAME, userName);
+ urlBuilder.addQueryParameter(Constants.PASS_WORD, passWord);
+ reqBuild.url(urlBuilder.build());
+ Request request = reqBuild.build();
+ return client.newCall(request).execute().body().string();
+ }
+
}