use of org.apache.servicecomb.foundation.common.net.URIEndpointObject in project incubator-servicecomb-java-chassis by apache.
the class TestRestServerVerticle method testRestServerVerticleWithRouter.
@Test
public void testRestServerVerticleWithRouter(@Mocked Transport transport, @Mocked Vertx vertx, @Mocked Context context, @Mocked JsonObject jsonObject, @Mocked Future<Void> startFuture) throws Exception {
URIEndpointObject endpointObject = new URIEndpointObject("http://127.0.0.1:8080");
new Expectations() {
{
transport.parseAddress("http://127.0.0.1:8080");
result = endpointObject;
}
};
Endpoint endpiont = new Endpoint(transport, "http://127.0.0.1:8080");
new Expectations() {
{
context.config();
result = jsonObject;
jsonObject.getValue(AbstractTransport.ENDPOINT_KEY);
result = endpiont;
}
};
RestServerVerticle server = new RestServerVerticle();
// process stuff done by Expectations
server.init(vertx, context);
server.start(startFuture);
}
use of org.apache.servicecomb.foundation.common.net.URIEndpointObject in project incubator-servicecomb-java-chassis by apache.
the class TestRestServerVerticle method testRestServerVerticleWithRouterSSL.
@Test
public void testRestServerVerticleWithRouterSSL(@Mocked Transport transport, @Mocked Vertx vertx, @Mocked Context context, @Mocked JsonObject jsonObject, @Mocked Future<Void> startFuture) throws Exception {
URIEndpointObject endpointObject = new URIEndpointObject("http://127.0.0.1:8080?sslEnabled=true");
new Expectations() {
{
transport.parseAddress("http://127.0.0.1:8080?sslEnabled=true");
result = endpointObject;
}
};
Endpoint endpiont = new Endpoint(transport, "http://127.0.0.1:8080?sslEnabled=true");
new Expectations() {
{
context.config();
result = jsonObject;
jsonObject.getValue(AbstractTransport.ENDPOINT_KEY);
result = endpiont;
}
};
RestServerVerticle server = new RestServerVerticle();
// process stuff done by Expectations
server.init(vertx, context);
server.start(startFuture);
}
use of org.apache.servicecomb.foundation.common.net.URIEndpointObject in project incubator-servicecomb-java-chassis by apache.
the class TestHighwayVerticle method testHighwayVehicle.
@Test
public void testHighwayVehicle(@Mocked Transport transport, @Mocked Vertx vertx, @Mocked Context context, @Mocked JsonObject json) {
HighwayServerVerticle highwayVehicle = new HighwayServerVerticle();
URIEndpointObject endpointObject = new URIEndpointObject("highway://127.0.0.1:9090");
new Expectations() {
{
transport.parseAddress(anyString);
result = endpointObject;
}
};
Endpoint endpoint = new Endpoint(transport, "highway://127.0.0.1:9090");
new Expectations() {
{
context.config();
result = json;
json.getValue(anyString);
result = endpoint;
}
};
highwayVehicle.init(vertx, context);
@SuppressWarnings("unchecked") Promise<Void> startPromise = Mockito.mock(Promise.class);
highwayVehicle.startListen(startPromise);
MockUtil.getInstance().mockHighwayConfig();
try {
highwayVehicle.startListen(startPromise);
Assertions.assertTrue(true);
} catch (Exception e) {
Assertions.fail();
}
}
use of org.apache.servicecomb.foundation.common.net.URIEndpointObject in project incubator-servicecomb-java-chassis by apache.
the class RestClientInvocation method createRequestPath.
protected String createRequestPath(RestOperationMeta swaggerRestOperation) throws Exception {
URIEndpointObject address = (URIEndpointObject) invocation.getEndpoint().getAddress();
String urlPrefix = address.getFirst(DefinitionConst.URL_PREFIX);
String path = (String) invocation.getHandlerContext().get(RestConst.REST_CLIENT_REQUEST_PATH);
if (path == null) {
path = swaggerRestOperation.getPathBuilder().createRequestPath(invocation.getSwaggerArguments());
}
if (StringUtils.isEmpty(urlPrefix) || path.startsWith(urlPrefix)) {
return path;
}
return urlPrefix + path;
}
use of org.apache.servicecomb.foundation.common.net.URIEndpointObject in project incubator-servicecomb-java-chassis by apache.
the class RestTransportClient method findHttpClientPool.
protected HttpClientWithContext findHttpClientPool(Invocation invocation) {
URIEndpointObject endpoint = (URIEndpointObject) invocation.getEndpoint().getAddress();
HttpClientWithContext httpClientWithContext;
if (endpoint.isHttp2Enabled()) {
httpClientWithContext = HttpClients.getClient(Http2TransportHttpClientOptionsSPI.CLIENT_NAME, invocation.isSync());
} else {
httpClientWithContext = HttpClients.getClient(HttpTransportHttpClientOptionsSPI.CLIENT_NAME, invocation.isSync());
}
return httpClientWithContext;
}
Aggregations