use of org.apache.servicecomb.common.rest.RestEngineSchemaListener in project incubator-servicecomb-java-chassis by apache.
the class TestCseClientHttpRequest method testNormal.
@Test
public void testNormal() throws IOException {
ServiceRegistry serviceRegistry = ServiceRegistryFactory.createLocal();
serviceRegistry.init();
RegistryUtils.setServiceRegistry(serviceRegistry);
UnitTestMeta meta = new UnitTestMeta();
CseContext.getInstance().getSchemaListenerManager().setSchemaListenerList(Arrays.asList(new RestEngineSchemaListener()));
SchemaMeta schemaMeta = meta.getOrCreateSchemaMeta(SpringmvcImpl.class);
CseContext.getInstance().getSchemaListenerManager().notifySchemaListener(schemaMeta);
Holder<Invocation> holder = new Holder<>();
CseClientHttpRequest client = new CseClientHttpRequest(URI.create("cse://app:test/" + SpringmvcImpl.class.getSimpleName() + "/bytes"), HttpMethod.POST) {
/**
* {@inheritDoc}
*/
@Override
protected Response doInvoke(Invocation invocation) {
holder.value = invocation;
return Response.ok("result");
}
};
byte[] body = "abc".getBytes();
client.setRequestBody(body);
client.execute();
Assert.assertArrayEquals(body, holder.value.getSwaggerArgument(0));
}
Aggregations