Search in sources :

Example 1 with ConsumerSchemaFactory

use of org.apache.servicecomb.core.definition.schema.ConsumerSchemaFactory in project incubator-servicecomb-java-chassis by apache.

the class MockUtil method mockRegisterManager.

public void mockRegisterManager() throws InstantiationException, IllegalAccessException {
    MicroserviceMeta microserviceMeta = microserviceMetaManager.getOrCreateMicroserviceMeta("app:test");
    microserviceMeta.putExtData("RestServicePathManager", new ServicePathManager(microserviceMeta));
    ConsumerSchemaFactory consumerSchemaFactory = new MockUp<ConsumerSchemaFactory>() {

        @Mock
        public MicroserviceMeta getOrCreateConsumer(String microserviceName) {
            return microserviceMeta;
        }
    }.getMockInstance();
    CseContext.getInstance().setConsumerSchemaFactory(consumerSchemaFactory);
}
Also used : MicroserviceMeta(org.apache.servicecomb.core.definition.MicroserviceMeta) ConsumerSchemaFactory(org.apache.servicecomb.core.definition.schema.ConsumerSchemaFactory) Mock(mockit.Mock) ServicePathManager(org.apache.servicecomb.common.rest.locator.ServicePathManager)

Example 2 with ConsumerSchemaFactory

use of org.apache.servicecomb.core.definition.schema.ConsumerSchemaFactory in project incubator-servicecomb-java-chassis by apache.

the class UnitTestMeta method init.

@SuppressWarnings("unchecked")
public static synchronized void init() {
    if (inited) {
        return;
    }
    ConsumerProviderManager consumerProviderManager = new ConsumerProviderManager();
    ConsumerSchemaFactory consumerSchemaFactory = new ConsumerSchemaFactory();
    consumerSchemaFactory.setMicroserviceMetaManager(microserviceMetaManager);
    consumerSchemaFactory.setSchemaListenerManager(schemaListenerManager);
    consumerProviderManager.setConsumerSchemaFactory(consumerSchemaFactory);
    CseContext.getInstance().setConsumerProviderManager(consumerProviderManager);
    CseContext.getInstance().setConsumerSchemaFactory(consumerSchemaFactory);
    CseContext.getInstance().setSchemaListenerManager(schemaListenerManager);
    Config config = new Config();
    Class<?> cls = SimpleLoadBalanceHandler.class;
    config.getHandlerClassMap().put("simpleLB", (Class<Handler>) cls);
    ProducerHandlerManager.INSTANCE.init(new Config());
    ConsumerHandlerManager.INSTANCE.init(config);
    ApplicationContext applicationContext = Mockito.mock(ApplicationContext.class);
    Mockito.when(applicationContext.getBean(Mockito.anyString())).thenReturn(null);
    BeanUtils.setContext(applicationContext);
    inited = true;
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ConsumerProviderManager(org.apache.servicecomb.core.provider.consumer.ConsumerProviderManager) SimpleLoadBalanceHandler(org.apache.servicecomb.core.handler.impl.SimpleLoadBalanceHandler) Config(org.apache.servicecomb.core.handler.config.Config) SimpleLoadBalanceHandler(org.apache.servicecomb.core.handler.impl.SimpleLoadBalanceHandler) Handler(org.apache.servicecomb.core.Handler) ConsumerSchemaFactory(org.apache.servicecomb.core.definition.schema.ConsumerSchemaFactory)

Aggregations

ConsumerSchemaFactory (org.apache.servicecomb.core.definition.schema.ConsumerSchemaFactory)2 Mock (mockit.Mock)1 ServicePathManager (org.apache.servicecomb.common.rest.locator.ServicePathManager)1 Handler (org.apache.servicecomb.core.Handler)1 MicroserviceMeta (org.apache.servicecomb.core.definition.MicroserviceMeta)1 Config (org.apache.servicecomb.core.handler.config.Config)1 SimpleLoadBalanceHandler (org.apache.servicecomb.core.handler.impl.SimpleLoadBalanceHandler)1 ConsumerProviderManager (org.apache.servicecomb.core.provider.consumer.ConsumerProviderManager)1 ApplicationContext (org.springframework.context.ApplicationContext)1