use of io.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.
the class TestConsumerSchemaFactory method testConnectToConsumerSame.
@Test
public void testConnectToConsumerSame() {
MicroserviceMeta microserviceMeta = consumerSchemaFactory.getOrCreateConsumer("ms", "latest");
SchemaMeta schemaMeta = microserviceMeta.ensureFindSchemaMeta("schema");
Map<String, ConsumerOperationMeta> consumerOperationMap = new HashMap<>();
consumerSchemaFactory.connectToConsumer(schemaMeta, null, consumerOperationMap);
Assert.assertEquals(1, consumerOperationMap.size());
ConsumerOperationMeta consumerOperationMeta = consumerOperationMap.get("add");
Assert.assertEquals(ConsumerArgumentSame.class, consumerOperationMeta.getArgsMapper().getArgumentMapper(0).getClass());
Assert.assertEquals(ConsumerResponseSame.class, consumerOperationMeta.getResponseMapper().getClass());
}
use of io.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.
the class UnitTestMeta method getOrCreateSchemaMeta.
public SchemaMeta getOrCreateSchemaMeta(String appId, String microserviceName, String schemaId, Class<?> impl) {
String longName = appId + ":" + microserviceName;
MicroserviceMeta microserviceMeta = microserviceMetaManager.getOrCreateMicroserviceMeta(longName);
SchemaMeta schemaMeta = microserviceMeta.findSchemaMeta(schemaId);
if (schemaMeta != null) {
return schemaMeta;
}
Swagger swagger = UnitTestSwaggerUtils.generateSwagger(impl).getSwagger();
return schemaLoader.registerSchema(microserviceMeta, schemaId, swagger);
}
use of io.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.
the class ProducerProviderManager method init.
public void init() throws Exception {
for (ProducerProvider provider : producerProviderList) {
provider.init();
}
MicroserviceMeta microserviceMeta = microserviceMetaManager.getOrCreateMicroserviceMeta(RegistryUtils.getMicroservice().getServiceName());
for (SchemaMeta schemaMeta : microserviceMeta.getSchemaMetas()) {
String content = SchemaUtils.swaggerToString(schemaMeta.getSwagger());
RegistryUtils.getMicroservice().addSchema(schemaMeta.getSchemaId(), content);
}
}
use of io.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.
the class TestConsumer method testInvocation.
@Test
public void testInvocation() {
OperationMeta oOperationMeta = Mockito.mock(OperationMeta.class);
SchemaMeta oSchemaMeta = Mockito.mock(SchemaMeta.class);
AsyncResponse asyncResp = Mockito.mock(AsyncResponse.class);
List<Handler> oHandlerList = new ArrayList<>();
Mockito.when(oSchemaMeta.getProviderHandlerChain()).thenReturn(oHandlerList);
Mockito.when(oSchemaMeta.getMicroserviceName()).thenReturn("TMK");
Mockito.when(oOperationMeta.getSchemaMeta()).thenReturn(oSchemaMeta);
Endpoint oEndpoint = Mockito.mock(Endpoint.class);
Transport oTransport = Mockito.mock(Transport.class);
Mockito.when(oEndpoint.getTransport()).thenReturn(oTransport);
Mockito.when(oOperationMeta.getOperationId()).thenReturn("TMK");
Invocation oInvocation = new Invocation(oEndpoint, oOperationMeta, null);
Assert.assertNotNull(oInvocation.getTransport());
Assert.assertNotNull(oInvocation.getInvocationType());
oInvocation.setResponseExecutor(Mockito.mock(Executor.class));
Assert.assertNotNull(oInvocation.getResponseExecutor());
Assert.assertNotNull(oInvocation.getSchemaMeta());
Assert.assertNotNull(oInvocation.getOperationMeta());
Assert.assertNull(oInvocation.getArgs());
Assert.assertNotNull(oInvocation.getEndpoint());
oInvocation.setEndpoint(null);
Map<String, String> map = oInvocation.getContext();
Assert.assertNotNull(map);
String str = oInvocation.getSchemaId();
Assert.assertEquals(null, str);
String str1 = oInvocation.getMicroserviceName();
Assert.assertEquals("TMK", str1);
Map<String, Object> mapp = oInvocation.getHandlerContext();
Assert.assertNotNull(mapp);
Assert.assertEquals(true, oInvocation.getHandlerIndex() >= 0);
oInvocation.setHandlerIndex(8);
Assert.assertEquals("TMK", oInvocation.getOperationName());
Assert.assertEquals("TMK", oInvocation.getMicroserviceName());
boolean validAssert;
try {
validAssert = true;
oInvocation.next(asyncResp);
} catch (Exception e) {
// TODO Auto-generated catch block
validAssert = false;
}
Assert.assertFalse(validAssert);
}
use of io.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.
the class HighwayServerInvoke method doInit.
private void doInit(NetSocket netSocket, long msgId, RequestHeader header, Buffer bodyBuffer) throws Exception {
this.netSocket = netSocket;
this.msgId = msgId;
this.header = header;
MicroserviceMeta microserviceMeta = microserviceMetaManager.ensureFindValue(header.getDestMicroservice());
SchemaMeta schemaMeta = microserviceMeta.ensureFindSchemaMeta(header.getSchemaId());
this.operationMeta = schemaMeta.ensureFindOperation(header.getOperationName());
this.operationProtobuf = ProtobufManager.getOrCreateOperation(operationMeta);
this.bodyBuffer = bodyBuffer;
}
Aggregations