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