use of io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse in project grpc-java by grpc.
the class MessagePrinterTest method printRdsResponse_v3.
@Test
public void printRdsResponse_v3() {
RouteConfiguration routeConfiguration = RouteConfiguration.newBuilder().setName("route-foo.googleapis.com").addVirtualHosts(VirtualHost.newBuilder().setName("virtualhost.googleapis.com").addDomains("foo.googleapis.com").addDomains("bar.googleapis.com").addRoutes(Route.newBuilder().setMatch(RouteMatch.newBuilder().setPath("foo.googleapis.com")).setRoute(RouteAction.newBuilder().setCluster("cluster.googleapis.com")))).build();
DiscoveryResponse response = DiscoveryResponse.newBuilder().setTypeUrl("type.googleapis.com/envoy.config.route.v3.RouteConfiguration").setVersionInfo("0").addResources(Any.pack(routeConfiguration)).setNonce("0000").build();
String expectedString = "{\n" + " \"versionInfo\": \"0\",\n" + " \"resources\": [{\n" + " \"@type\": \"type.googleapis.com/envoy.config.route.v3.RouteConfiguration\",\n" + " \"name\": \"route-foo.googleapis.com\",\n" + " \"virtualHosts\": [{\n" + " \"name\": \"virtualhost.googleapis.com\",\n" + " \"domains\": [\"foo.googleapis.com\", \"bar.googleapis.com\"],\n" + " \"routes\": [{\n" + " \"match\": {\n" + " \"path\": \"foo.googleapis.com\"\n" + " },\n" + " \"route\": {\n" + " \"cluster\": \"cluster.googleapis.com\"\n" + " }\n" + " }]\n" + " }]\n" + " }],\n" + " \"typeUrl\": \"type.googleapis.com/envoy.config.route.v3.RouteConfiguration\",\n" + " \"nonce\": \"0000\"\n" + "}";
String res = MessagePrinter.print(response);
assertThat(res).isEqualTo(expectedString);
}
Aggregations