use of org.apache.servicecomb.core.definition.SchemaMeta 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));
}
use of org.apache.servicecomb.core.definition.SchemaMeta in project incubator-servicecomb-java-chassis by apache.
the class MockUtil method mockMicroserviceMeta.
public void mockMicroserviceMeta() {
new MockUp<MicroserviceMeta>() {
@Mock
public SchemaMeta ensureFindSchemaMeta(String schemaId) {
SchemaMeta lSchemaMeta = Mockito.mock(SchemaMeta.class);
Mockito.when(lSchemaMeta.getSwaggerIntf()).thenAnswer(new Answer<Class<? extends TestPojoConsumerProvider>>() {
@Override
public Class<? extends TestPojoConsumerProvider> answer(InvocationOnMock invocation) throws Throwable {
return TestPojoConsumerProvider.class;
}
});
return lSchemaMeta;
}
@Mock
public SchemaMeta ensureFindSchemaMeta(Class<?> schemaIntf) {
return Mockito.mock(SchemaMeta.class);
}
};
}
use of org.apache.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.
the class UrlPathItemTest method initStrBuilder.
@Before
public void initStrBuilder() {
accessLogEvent = new ServerAccessLogEvent();
routingContext = Mockito.mock(RoutingContext.class);
finishEvent = Mockito.mock(InvocationFinishEvent.class);
invocation = Mockito.mock(Invocation.class);
serverRequest = Mockito.mock(HttpServerRequest.class);
operationMeta = Mockito.mock(OperationMeta.class);
schemaMeta = Mockito.mock(SchemaMeta.class);
swagger = Mockito.mock(Swagger.class);
restClientRequest = Mockito.mock(RestClientRequestImpl.class);
clientRequest = Mockito.mock(HttpClientRequest.class);
accessLogEvent.setRoutingContext(routingContext);
strBuilder = new StringBuilder();
}
use of org.apache.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.
the class ProducerTestsAfterBootup method testSchemaNotChange.
public void testSchemaNotChange(SCBEngine scbEngine) {
LOGGER.info("ProducerTestsAfterBootup testing start");
// we can not set microserviceName any more
SchemaMeta meta = scbEngine.getProducerProviderManager().registerSchema("test1", new CodeFirstSpringmvcForSchema());
String codeFirst = getSwaggerContent(meta.getSwagger());
TestMgr.check(EXPECTED_DATA, codeFirst);
}
use of org.apache.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.
the class TestInspectorBootListener method enabled.
@Test
public void enabled() {
Holder<Object> holder = new Holder<>();
SCBEngine scbEngine = SCBBootstrap.createSCBEngineForTest();
scbEngine.setProducerMicroserviceMeta(new MicroserviceMeta(scbEngine, "ms", false));
scbEngine.setProducerProviderManager(new ProducerProviderManager(scbEngine) {
@Override
public SchemaMeta registerSchema(String schemaId, Object instance) {
if ("inspector".equals(schemaId)) {
holder.value = instance;
}
return null;
}
});
InspectorConfig inspectorConfig = new InspectorConfig().setEnabled(true);
new InspectorBootListener(inspectorConfig, null).onAfterTransport(new BootEvent(scbEngine, EventType.AFTER_TRANSPORT));
Assert.assertNotNull(holder.value);
}
Aggregations