use of io.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.
the class AbstractSchemaFactory method getOrCreateSchema.
// 因为aop的存在,schemaInstance的class不一定等于schemaClass
protected SchemaMeta getOrCreateSchema(CONTEXT context) {
MicroserviceMeta microserviceMeta = context.getMicroserviceMeta();
SchemaMeta schemaMeta = microserviceMeta.findSchemaMeta(context.getSchemaId());
if (schemaMeta == null) {
schemaMeta = createSchema(context);
}
context.setSchemaMeta(schemaMeta);
connectToProvider(context);
return schemaMeta;
}
use of io.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.
the class InvokerUtils method syncInvoke.
public static Object syncInvoke(String microserviceName, String microserviceVersion, String transport, String schemaId, String operationName, Object[] args) {
ReferenceConfig referenceConfig = new ReferenceConfig(microserviceName, microserviceVersion, transport);
SchemaMeta schemaMeta = referenceConfig.getMicroserviceMeta().ensureFindSchemaMeta(schemaId);
Invocation invocation = InvocationFactory.forConsumer(referenceConfig, schemaMeta, operationName, args);
return syncInvoke(invocation);
}
use of io.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.
the class TestOperationProtobuf method testOperationProtobuf.
@Test
public void testOperationProtobuf() throws Exception {
UnitTestMeta meta = new UnitTestMeta();
SchemaMeta schemaMeta = meta.getOrCreateSchemaMeta(Impl.class);
OperationMeta operationMeta = schemaMeta.findOperation("test");
OperationProtobuf operationProtobuf = ProtobufManager.getOrCreateOperation(operationMeta);
Assert.assertEquals(operationMeta, operationProtobuf.getOperationMeta());
Assert.assertEquals(ArgsNotWrapSchema.class, operationProtobuf.getRequestSchema().getClass());
Assert.assertEquals(NormalWrapSchema.class, operationProtobuf.getResponseSchema().getClass());
WrapSchema responseSchema = operationProtobuf.findResponseSchema(200);
Assert.assertEquals(operationProtobuf.getResponseSchema(), responseSchema);
responseSchema = operationProtobuf.findResponseSchema(300);
Assert.assertNotNull(responseSchema);
Assert.assertNotEquals(operationProtobuf.getResponseSchema(), responseSchema);
}
use of io.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.
the class MockUtil method mockRequestMeta.
public void mockRequestMeta() {
new MockUp<RequestMeta>() {
@Mock
public OperationMeta getOperationMeta() throws Exception {
OperationMeta om = new OperationMeta();
om.init(new SchemaMeta(null, new MicroserviceMeta("test"), null), this.getClass().getMethods()[0], "path", "get", null);
return om;
}
};
}
use of io.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.
the class TestRestEngineSchemaListener method test.
@Test
public void test() {
BeanUtils.setContext(Mockito.mock(ApplicationContext.class));
MicroserviceMeta mm = new MicroserviceMeta("app:ms");
List<SchemaMeta> smList = new ArrayList<>();
SwaggerGenerator generator = new SwaggerGenerator(context, Impl.class);
Swagger swagger = generator.generate();
SchemaMeta sm1 = new SchemaMeta(swagger, mm, "sid1");
smList.add(sm1);
RestEngineSchemaListener listener = new RestEngineSchemaListener();
SchemaMeta[] smArr = smList.toArray(new SchemaMeta[smList.size()]);
listener.onSchemaLoaded(smArr);
// 重复调用,不应该出异常
listener.onSchemaLoaded(smArr);
ServicePathManager spm = ServicePathManager.getServicePathManager(mm);
Assert.assertEquals(mm, spm.getMicroserviceMeta());
Assert.assertNotNull(spm.getStaticPathOperationMap().get("Impl/add/"));
}
Aggregations