use of org.mx.service.client.rest.RestClientInvoke in project main by JohnPeng739.
the class TestServer method testHttpServer.
@Test
public void testHttpServer() {
AbstractServerFactory factory = context.getBean(HttpServerFactory.class);
assertNotNull(factory);
Server server = factory.getServer();
assertNotNull(server);
// test service client
try {
RestClientInvoke invoke = new RestClientInvoke();
DataVO<String> str = invoke.get("http://localhost:9999/service/get", DataVO.class);
assertNotNull(str);
assertEquals("match the response data.", "get data.", str.getData());
String data = "hello world";
str = invoke.post("http://localhost:9999/service/post", data, DataVO.class);
assertNotNull(str);
assertEquals("match the response data.", String.format("post data: %s.", data), str.getData());
data = "hello world";
str = invoke.put("http://localhost:9999/service/put", data, DataVO.class);
assertNotNull(str);
assertEquals("match the response data.", String.format("put data: %s.", data), str.getData());
invoke.close();
} catch (RestInvokeException ex) {
ex.printStackTrace();
fail(ex.getMessage());
}
}
Aggregations