use of io.servicecomb.foundation.common.net.URIEndpointObject in project java-chassis by ServiceComb.
the class TestHighwayVerticle method testHighwayVerticle.
@Test
public void testHighwayVerticle(@Mocked Transport transport, @Mocked Vertx vertx, @Mocked Context context, @Mocked JsonObject json) {
URIEndpointObject endpiontObject = new URIEndpointObject("highway://127.0.0.1:9090");
new Expectations() {
{
transport.parseAddress(anyString);
result = endpiontObject;
}
};
Endpoint endpoint = new Endpoint(transport, "highway://127.0.0.1:9090");
new Expectations() {
{
context.config();
result = json;
json.getValue(anyString);
result = endpoint;
}
};
highwayVerticle.init(vertx, context);
@SuppressWarnings("unchecked") Future<Void> startFuture = Mockito.mock(Future.class);
highwayVerticle.startListen(startFuture);
MockUtil.getInstance().mockHighwayConfig();
try {
highwayVerticle.startListen(startFuture);
Assert.assertTrue(true);
} catch (Exception e) {
Assert.assertTrue(false);
}
}
use of io.servicecomb.foundation.common.net.URIEndpointObject in project java-chassis by ServiceComb.
the class TestServletRestTransport method testSendException.
@Test
public void testSendException() {
boolean status = true;
Invocation invocation = Mockito.mock(Invocation.class);
AsyncResponse asyncResp = Mockito.mock(AsyncResponse.class);
URIEndpointObject endpoint = Mockito.mock(URIEndpointObject.class);
Endpoint endpoint1 = Mockito.mock(Endpoint.class);
Mockito.when(invocation.getEndpoint()).thenReturn(endpoint1);
Mockito.when(invocation.getEndpoint().getAddress()).thenReturn(endpoint);
try {
transport.send(invocation, asyncResp);
} catch (Exception exce) {
Assert.assertNotNull(exce);
status = false;
}
Assert.assertFalse(status);
}
use of io.servicecomb.foundation.common.net.URIEndpointObject in project java-chassis by ServiceComb.
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 io.servicecomb.foundation.common.net.URIEndpointObject in project java-chassis by ServiceComb.
the class TestTcpServer method testTcpServerNonSSL.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testTcpServerNonSSL(@Mocked Vertx vertx, @Mocked AsyncResultCallback<InetSocketAddress> callback, @Mocked NetServer netServer) {
new Expectations() {
{
vertx.createNetServer();
result = netServer;
netServer.connectHandler((Handler) any);
netServer.listen(anyInt, anyString, (Handler) any);
}
};
URIEndpointObject endpointObject = new URIEndpointObject("highway://127.0.0.1:6663");
TcpServer server = new TcpServerForTest(endpointObject);
// assert done in Expectations
server.init(vertx, "", callback);
}
use of io.servicecomb.foundation.common.net.URIEndpointObject in project java-chassis by ServiceComb.
the class TestTcpServer method testTcpServerSSL.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testTcpServerSSL(@Mocked Vertx vertx, @Mocked AsyncResultCallback<InetSocketAddress> callback, @Mocked NetServer netServer) {
new Expectations() {
{
vertx.createNetServer((NetServerOptions) any);
result = netServer;
netServer.connectHandler((Handler) any);
netServer.listen(anyInt, anyString, (Handler) any);
}
};
URIEndpointObject endpointObject = new URIEndpointObject("highway://127.0.0.1:6663?sslEnabled=true");
TcpServer server = new TcpServerForTest(endpointObject);
// assert done in Expectations
server.init(vertx, "", callback);
}
Aggregations