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;
}
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);
}
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);
}
Aggregations