Search in sources :

Example 1 with ConsumerProviderManager

use of org.apache.servicecomb.core.provider.consumer.ConsumerProviderManager 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)

Example 2 with ConsumerProviderManager

use of org.apache.servicecomb.core.provider.consumer.ConsumerProviderManager in project incubator-servicecomb-java-chassis by apache.

the class TestConsumer method testConsumerProviderManager.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testConsumerProviderManager() {
    ConsumerProviderManager oConsumerProviderManager = new ConsumerProviderManager();
    RegisterManager oRegisterManager = new RegisterManager("cse consumer provider manager");
    oRegisterManager.register("cse.references.cse consumer provider manager", "cse consumer provider manager");
    boolean validAssert = true;
    try {
        oConsumerProviderManager.getReferenceConfig("consumer provider manager");
    } catch (Throwable ee) {
        Assert.assertNotEquals(null, ee);
        validAssert = false;
    }
    Assert.assertFalse(validAssert);
}
Also used : RegisterManager(org.apache.servicecomb.foundation.common.RegisterManager) ConsumerProviderManager(org.apache.servicecomb.core.provider.consumer.ConsumerProviderManager) Test(org.junit.Test)

Example 3 with ConsumerProviderManager

use of org.apache.servicecomb.core.provider.consumer.ConsumerProviderManager in project incubator-servicecomb-java-chassis by apache.

the class MockUtil method mockConsumerProviderManager.

public void mockConsumerProviderManager() {
    ConsumerProviderManager consumerProviderManager = new MockUp<ConsumerProviderManager>() {

        @Mock
        public ReferenceConfig getReferenceConfig(String microserviceName) {
            return new ReferenceConfig(CseContext.getInstance().getConsumerSchemaFactory(), "test", "test", "test");
        }
    }.getMockInstance();
    CseContext.getInstance().setConsumerProviderManager(consumerProviderManager);
}
Also used : ConsumerProviderManager(org.apache.servicecomb.core.provider.consumer.ConsumerProviderManager) ReferenceConfig(org.apache.servicecomb.core.provider.consumer.ReferenceConfig) Mock(mockit.Mock)

Aggregations

ConsumerProviderManager (org.apache.servicecomb.core.provider.consumer.ConsumerProviderManager)3 Mock (mockit.Mock)1 Handler (org.apache.servicecomb.core.Handler)1 ConsumerSchemaFactory (org.apache.servicecomb.core.definition.schema.ConsumerSchemaFactory)1 Config (org.apache.servicecomb.core.handler.config.Config)1 SimpleLoadBalanceHandler (org.apache.servicecomb.core.handler.impl.SimpleLoadBalanceHandler)1 ReferenceConfig (org.apache.servicecomb.core.provider.consumer.ReferenceConfig)1 RegisterManager (org.apache.servicecomb.foundation.common.RegisterManager)1 Test (org.junit.Test)1 ApplicationContext (org.springframework.context.ApplicationContext)1