Skip to content

Commit

Permalink
test: 1.5.33
Browse files Browse the repository at this point in the history
  • Loading branch information
mySingleLive committed Aug 28, 2023
1 parent 5ebb933 commit 57377b3
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Forest是一个高层的、极简的声明式HTTP调用API框架<br>
-------------------------------------
* [项目主页](http://forest.dtflyx.com/)

* [中文文档](https://forest.dtflyx.com/pages/1.5.32/intro/)
* [中文文档](https://forest.dtflyx.com/pages/1.5.33/intro/)

* [JavaDoc](https://apidoc.gitee.com/dt_flys/forest/)

Expand Down Expand Up @@ -86,7 +86,7 @@ Forest有哪些特性?
<dependency>
<groupId>com.dtflys.forest</groupId>
<artifactId>forest-spring-boot-starter</artifactId>
<version>1.5.32</version>
<version>1.5.33</version>
</dependency>
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,26 @@ public String cacheKey() {
return builder.toString();
}

/**
* 获取代理的协议类型
*
* @return 代理的协议类型
* @since 1.5.33
*/
public ForestProxyType getType() {
return type;
}

/**
* 获取代理的协议类型
*
* @return 代理的协议类型
* @since 1.5.33
*/
public ForestProxyType type() {
return type;
}

/**
* 获取代理主机地址
*
Expand All @@ -98,6 +114,16 @@ public String getHost() {
return host;
}

/**
* 获取代理主机地址
*
* @return 代理主机地址
* @since 1.5.33
*/
public String host() {
return host;
}

/**
* 获取代理主机端口
*
Expand All @@ -107,6 +133,16 @@ public int getPort() {
return port;
}

/**
* 获取代理主机端口
*
* @return 代理主机端口
* @since 1.5.33
*/
public int port() {
return port;
}

/**
* 获取代理用户名
*
Expand All @@ -132,6 +168,7 @@ public ForestProxy setUsername(String username) {
*
* @param username 代理用户名
* @return {@link ForestProxy}对象实例
* @since 1.5.33
*/
public ForestProxy username(String username) {
this.username = username;
Expand All @@ -143,6 +180,7 @@ public String getCharset() {
return charset;
}


public ForestProxy setCharset(String charset) {
this.charset = charset;
return this;
Expand All @@ -154,6 +192,8 @@ public ForestProxy charset(String charset) {
}




/**
* 获取代理密码
*
Expand All @@ -178,7 +218,8 @@ public ForestProxy setPassword(String password) {
* 获取代理密码
*
* @param password 代理密码
* @return
* @return {@link ForestProxy}类实例
* @since 1.5.33
*/
public ForestProxy password(String password) {
this.password = password;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public interface HTTPProxyClient {
ForestRequest<String> sendHostPortSocks(String host, int port);

@Post("/")
@SocksProxy(host = "${0}", port = "${1}")
@SocksProxy(host = "${0}", port = "${1}", username = "", password = "")
ForestRequest<String> sendHostPortSocks2(String host, int port);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public class MyHTTPProxySource implements HTTPProxySource {

@Override
public ForestProxy getProxy(ForestRequest request) {
return new ForestProxy("127.0.0.1", (Integer) request.variableValue("port"));
return ForestProxy.http("127.0.0.1", (Integer) request.variableValue("port"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,29 @@ public void testRetry() {
String backendName = backend.getName();
Mockito.verify(logger).info("[Forest] Request (" + backendName + "): \n" +
"\t[Retry]: 1\n" +
"\tGET https://www.thebeastshop.com/autopage/shops.htm HTTPS");
"\tGET https://www.thebeastshop.com/autopage/shops.htm HTTPS\n" +
"\tHeaders: \n" +
"\t\tUser-Agent: forest/1.5.33");
Mockito.verify(logger).info("[Forest] Request (" + backendName + "): \n" +
"\t[Retry]: 2\n" +
"\tGET https://www.thebeastshop.com/autopage/shops.htm HTTPS");
"\tGET https://www.thebeastshop.com/autopage/shops.htm HTTPS\n" +
"\tHeaders: \n" +
"\t\tUser-Agent: forest/1.5.33");
Mockito.verify(logger).info("[Forest] Request (" + backendName + "): \n" +
"\t[Retry]: 3\n" +
"\tGET https://www.thebeastshop.com/autopage/shops.htm HTTPS");
"\tGET https://www.thebeastshop.com/autopage/shops.htm HTTPS\n" +
"\tHeaders: \n" +
"\t\tUser-Agent: forest/1.5.33");
Mockito.verify(logger).info("[Forest] Request (" + backendName + "): \n" +
"\t[Retry]: 4\n" +
"\tGET https://www.thebeastshop.com/autopage/shops.htm HTTPS");
"\tGET https://www.thebeastshop.com/autopage/shops.htm HTTPS\n" +
"\tHeaders: \n" +
"\t\tUser-Agent: forest/1.5.33");
Mockito.verify(logger).info("[Forest] Request (" + backendName + "): \n" +
"\t[Retry]: 5\n" +
"\tGET https://www.thebeastshop.com/autopage/shops.htm HTTPS");
"\tGET https://www.thebeastshop.com/autopage/shops.htm HTTPS\n" +
"\tHeaders: \n" +
"\t\tUser-Agent: forest/1.5.33");
// Mockito.verify(logger).info("[Forest] [Network Error]: connect timed out");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public void testClient2() {
String result = (String) request.execute();
assertThat(result.startsWith("Global: ")).isTrue();
Mockito.verify(logger).info("[Forest] [Test2] 请求: \n" +
"\tGET https://gitee.com/dt_flys HTTPS");
"\tGET https://gitee.com/dt_flys HTTPS\n" +
"\t请求头: \n" +
"\t\tUser-Agent: forest/1.5.33");
}


Expand Down
2 changes: 1 addition & 1 deletion forest-solon-plugin/src/test/resources/app-test2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ forest:
read-timeout: 6000
max-retry-count: 0
interceptors:
com.dtflys.forest.solon.test.interceptor.GlobalInterceptor
- com.dtflys.forest.solon.test.interceptor.GlobalInterceptor


test:
Expand Down

0 comments on commit 57377b3

Please sign in to comment.