From 866c7b4850ee1b024b458e2543c89fda0bff8e9c Mon Sep 17 00:00:00 2001 From: huangsimin Date: Thu, 15 Aug 2019 18:28:50 +0800 Subject: [PATCH] =?UTF-8?q?TODO:=20=E6=B7=BB=E5=8A=A0Apollo=E7=9A=84?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/usergw/TestHttp2DubboConfig5.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig5.java diff --git a/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig5.java b/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig5.java new file mode 100644 index 0000000..c69bf3b --- /dev/null +++ b/usergw-service/src/test/java/cn/ecpark/service/usergw/TestHttp2DubboConfig5.java @@ -0,0 +1,59 @@ +package cn.ecpark.service.usergw; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import reactor.netty.http.client.HttpClient; +import reactor.netty.http.client.HttpClient.ResponseReceiver; +import reactor.netty.http.client.HttpClientResponse; + +// TODO: 添加附加Dubbo Service for Test启动进程 +@SpringBootTest(classes = App.class, webEnvironment = WebEnvironment.RANDOM_PORT) +@RunWith(SpringRunner.class) +@TestPropertySource(locations = "classpath:/resources/test4.properties", properties = {"apollo.meta=", "app.id="}) +public class TestHttp2DubboConfig5 { + + @LocalServerPort + private int serverPort; + + @Test + public void Test1RequestHttp2DubboSetHeader() { + // Test Base Url + for(int i = 0; i < 50;i++) { + HttpClient client = HttpClient.create(); + ResponseReceiver receiver; + String content; + + receiver = client.baseUrl("http://localhost:" + serverPort + "/dubbo/hello") + .headers(h -> h.set("method", "Hello")).get(); + + HttpClientResponse response = receiver.response().block(); + Assert.assertNotNull(response); + + if(response.status().code() == 200) { + content = receiver.responseContent().asString().blockLast(); + Assert.assertNotNull(content); + Assert.assertEquals(content, "Hello Dubbo"); + } else { + Assert.assertEquals(response.status().code(), 429); + } + } + + } + + + // @Test + // @SuppressWarnings("unchecked") + // public void Test3RestfulFilters() { + + + // } + + +} \ No newline at end of file