use of org.apache.servicecomb.core.definition.loader.SchemaLoader in project incubator-servicecomb-java-chassis by apache.
the class TestConsumerSchemaFactory method init.
@BeforeClass
public static void init() {
ServiceRegistry serviceRegistry = ServiceRegistryFactory.createLocal();
serviceRegistry.init();
RegistryUtils.setServiceRegistry(serviceRegistry);
SchemaListenerManager schemaListenerManager = new SchemaListenerManager();
schemaListenerManager.setSchemaListenerList(Arrays.asList(schemaListener));
MicroserviceMetaManager microserviceMetaManager = new MicroserviceMetaManager();
SchemaLoader schemaLoader = new SchemaLoader() {
@Override
public void putSelfBasePathIfAbsent(String microserviceName, String basePath) {
}
};
CompositeSwaggerGeneratorContext compositeSwaggerGeneratorContext = new CompositeSwaggerGeneratorContext();
ReflectUtils.setField(consumerSchemaFactory, "schemaListenerManager", schemaListenerManager);
ReflectUtils.setField(consumerSchemaFactory, "microserviceMetaManager", microserviceMetaManager);
ReflectUtils.setField(consumerSchemaFactory, "schemaLoader", schemaLoader);
ReflectUtils.setField(consumerSchemaFactory, "compositeSwaggerGeneratorContext", compositeSwaggerGeneratorContext);
SchemaMeta schemaMeta = new UnitTestMeta().getOrCreateSchemaMeta(TestConsumerSchemaFactoryImpl.class);
String content = UnitTestSwaggerUtils.pretty(schemaMeta.getSwagger());
Microservice microservice = new Microservice();
microservice.setAppId("app");
microservice.setServiceId("0");
microservice.setServiceName("ms");
microservice.setVersion("1.0.0");
microservice.addSchema("schema", content);
serviceRegistry.getServiceRegistryClient().registerMicroservice(microservice);
MicroserviceInstance instance = new MicroserviceInstance();
instance.setServiceId("0");
instance.setInstanceId("0");
serviceRegistry.getServiceRegistryClient().registerMicroserviceInstance(instance);
}
use of org.apache.servicecomb.core.definition.loader.SchemaLoader in project incubator-servicecomb-java-chassis by apache.
the class TestProducerSchemaFactory method init.
@BeforeClass
public static void init() {
ServiceRegistry serviceRegistry = ServiceRegistryFactory.createLocal();
RegistryUtils.setServiceRegistry(serviceRegistry);
ConverterMgr converterMgr = new ConverterMgr();
ProducerArgumentsMapperFactory producerArgsMapperFactory = new ProducerArgumentsMapperFactory();
producerArgsMapperFactory.setConverterMgr(converterMgr);
MicroserviceMetaManager microserviceMetaManager = new MicroserviceMetaManager();
SchemaLoader schemaLoader = new SchemaLoader() {
@Override
public void putSelfBasePathIfAbsent(String microserviceName, String basePath) {
}
};
CompositeSwaggerGeneratorContext compositeSwaggerGeneratorContext = new CompositeSwaggerGeneratorContext();
producerSchemaFactory.setSwaggerEnv(swaggerEnv);
ReflectUtils.setField(producerSchemaFactory, "microserviceMetaManager", microserviceMetaManager);
ReflectUtils.setField(producerSchemaFactory, "schemaLoader", schemaLoader);
ReflectUtils.setField(producerSchemaFactory, "compositeSwaggerGeneratorContext", compositeSwaggerGeneratorContext);
Executor reactiveExecutor = new ReactiveExecutor();
Executor normalExecutor = (cmd) -> {
};
new MockUp<BeanUtils>() {
@SuppressWarnings("unchecked")
@Mock
<T> T getBean(String name) {
if (ExecutorManager.EXECUTOR_REACTIVE.equals(name)) {
return (T) reactiveExecutor;
}
return (T) normalExecutor;
}
};
// ApplicationContext applicationContext = Mockito.mock(ApplicationContext.class);
// BeanUtils.setContext(applicationContext);
// Mockito.when(applicationContext.getBean(ExecutorManager.EXECUTOR_REACTIVE)).thenReturn(new ReactiveExecutor());
UnitTestMeta.init();
schemaMeta = producerSchemaFactory.getOrCreateProducerSchema("app:ms", "schema", TestProducerSchemaFactoryImpl.class, new TestProducerSchemaFactoryImpl());
}
Aggregations