use of org.apache.servicecomb.foundation.common.net.URIEndpointObject in project 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 Promise<Void> startPromise) 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(startPromise);
}
use of org.apache.servicecomb.foundation.common.net.URIEndpointObject in project servicecomb-java-chassis by apache.
the class TestRestServerVerticle method testRestServerVerticleWithHttp2.
@Test
public void testRestServerVerticleWithHttp2(@Mocked Transport transport, @Mocked Vertx vertx, @Mocked Context context, @Mocked JsonObject jsonObject, @Mocked Promise<Void> startPromise) {
URIEndpointObject endpointObject = new URIEndpointObject("http://127.0.0.1:8080?protocol=http2");
new Expectations() {
{
transport.parseAddress("http://127.0.0.1:8080?protocol=http2");
result = endpointObject;
}
};
Endpoint endpiont = new Endpoint(transport, "http://127.0.0.1:8080?protocol=http2");
new Expectations() {
{
context.config();
result = jsonObject;
jsonObject.getValue(AbstractTransport.ENDPOINT_KEY);
result = endpiont;
}
};
RestServerVerticle server = new RestServerVerticle();
boolean status = false;
try {
server.init(vertx, context);
server.start(startPromise);
} catch (Exception e) {
status = true;
}
Assertions.assertFalse(status);
}
use of org.apache.servicecomb.foundation.common.net.URIEndpointObject in project servicecomb-java-chassis by apache.
the class RestClientTransportContextFactory method createRequestPath.
protected String createRequestPath(Invocation invocation, RestOperationMeta restOperationMeta) throws Exception {
String path = invocation.getLocalContext(RestConst.REST_CLIENT_REQUEST_PATH);
if (path == null) {
path = restOperationMeta.getPathBuilder().createRequestPath(invocation.getSwaggerArguments());
}
URIEndpointObject endpoint = (URIEndpointObject) invocation.getEndpoint().getAddress();
String urlPrefix = endpoint.getFirst(DefinitionConst.URL_PREFIX);
if (StringUtils.isEmpty(urlPrefix) || path.startsWith(urlPrefix)) {
return path;
}
return urlPrefix + path;
}
use of org.apache.servicecomb.foundation.common.net.URIEndpointObject in project 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 servicecomb-java-chassis by apache.
the class RestClientInvocation method createRequest.
Future<HttpClientRequest> createRequest(IpPort ipPort, String path) {
URIEndpointObject endpoint = (URIEndpointObject) invocation.getEndpoint().getAddress();
HttpMethod method = getMethod();
RequestOptions requestOptions = new RequestOptions();
requestOptions.setHost(ipPort.getHostOrIp()).setPort(ipPort.getPort()).setSsl(endpoint.isSslEnabled()).setMethod(method).setURI(path);
invocation.getTraceIdLogger().debug(LOGGER, "Sending request by rest, method={}, qualifiedName={}, path={}, endpoint={}.", method, invocation.getMicroserviceQualifiedName(), path, invocation.getEndpoint().getEndpoint());
return httpClientWithContext.getHttpClient().request(requestOptions);
}
Aggregations