use of io.servicecomb.foundation.common.net.URIEndpointObject in project java-chassis by ServiceComb.
the class TestTcp method testTcpServerStarter.
@Test
public void testTcpServerStarter() {
URIEndpointObject endpiont = new URIEndpointObject("highway://127.0.0.1:9900");
TcpServer oStarter = new TcpServer(endpiont);
oStarter.init(Vertx.vertx(), "", null);
Assert.assertNotNull(oStarter);
//TODO Need to find a way to Assert TcpServerStarter as this obbject does not return any values.
}
use of io.servicecomb.foundation.common.net.URIEndpointObject in project java-chassis by ServiceComb.
the class TestHighwayTransport method commonHighwayMock.
private void commonHighwayMock(Invocation invocation) {
OperationMeta operationMeta = Mockito.mock(OperationMeta.class);
Mockito.when(invocation.getOperationMeta()).thenReturn(operationMeta);
OperationProtobuf operationProtobuf = Mockito.mock(OperationProtobuf.class);
Mockito.when(operationMeta.getExtData("protobuf")).thenReturn(operationProtobuf);
Endpoint lEndpoint = Mockito.mock(Endpoint.class);
Mockito.when(invocation.getEndpoint()).thenReturn(lEndpoint);
WrapSchema lWrapSchema = Mockito.mock(WrapSchema.class);
Mockito.when(operationProtobuf.getRequestSchema()).thenReturn(lWrapSchema);
URIEndpointObject ep = Mockito.mock(URIEndpointObject.class);
Mockito.when(lEndpoint.getAddress()).thenReturn(ep);
Mockito.when(ep.getHostOrIp()).thenReturn("127.0.0.1");
Mockito.when(ep.getPort()).thenReturn(80);
}
use of io.servicecomb.foundation.common.net.URIEndpointObject in project java-chassis by ServiceComb.
the class VertxRestTransport method send.
@Override
public void send(Invocation invocation, AsyncResponse asyncResp) throws Exception {
URIEndpointObject endpoint = (URIEndpointObject) invocation.getEndpoint().getAddress();
RestTransportClient client = RestTransportClientManager.INSTANCE.getRestTransportClient(endpoint.isSslEnabled());
client.send(invocation, asyncResp);
}
use of io.servicecomb.foundation.common.net.URIEndpointObject in project java-chassis by ServiceComb.
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 io.servicecomb.foundation.common.net.URIEndpointObject in project java-chassis by ServiceComb.
the class TestVertxRestTransport method testSendException.
@Test
public void testSendException() {
boolean validAssert;
Invocation invocation = Mockito.mock(Invocation.class);
AsyncResponse asyncResp = Mockito.mock(AsyncResponse.class);
URIEndpointObject endpoint = Mockito.mock(URIEndpointObject.class);
Endpoint end = Mockito.mock(Endpoint.class);
Mockito.when(invocation.getEndpoint()).thenReturn(end);
Mockito.when(invocation.getEndpoint().getAddress()).thenReturn(endpoint);
try {
validAssert = true;
instance.send(invocation, asyncResp);
} catch (Exception e) {
validAssert = false;
}
Assert.assertFalse(validAssert);
}
Aggregations