Skip to content

Commit 0017b25

Browse files
committed
test: 反代和静态资源单元测试
1 parent ff0c16a commit 0017b25

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/test/java/top/meethigher/proxy/http/ReverseHttpProxyTest.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,20 @@ public void testStatic() throws Exception {
5252
proxy.start();
5353
ProxyRoute proxyRoute = new ProxyRoute();
5454
proxyRoute.setHttpKeepAlive(false);
55-
// proxyRoute.setSourceUrl("/*");
56-
// proxyRoute.setTargetUrl("static:D:/Desktop");
57-
proxyRoute.setSourceUrl("/blog/*");
58-
proxyRoute.setTargetUrl("static:D:/3Develop/www/hexoBlog/blog/public");
59-
proxy.addRoute(proxyRoute);
55+
proxyRoute.setSourceUrl("/*");
56+
proxyRoute.setTargetUrl("https://reqres.in");
57+
proxy.addRoute(proxyRoute, Integer.MAX_VALUE);
58+
59+
ProxyRoute proxyRoute1 = new ProxyRoute();
60+
proxyRoute1.setSourceUrl("/test/*");
61+
proxyRoute1.setTargetUrl("https://meethigher.top");
62+
proxy.addRoute(proxyRoute1, Integer.MAX_VALUE - 1);
63+
64+
// 若静态路径下的内容不存在,则会匹配到/*。此时就会出现个假象,order未生效。
65+
ProxyRoute proxyRoute2 = new ProxyRoute();
66+
proxyRoute2.setSourceUrl("/static/*");
67+
proxyRoute2.setTargetUrl("static:D:/3Develop/www");
68+
proxy.addRoute(proxyRoute2, Integer.MAX_VALUE - 2);
6069
TimeUnit.HOURS.sleep(1);
6170
proxy.stop();
6271
}

0 commit comments

Comments
 (0)