use of org.apache.servicecomb.serviceregistry.client.LocalServiceRegistryClientImpl in project incubator-servicecomb-java-chassis by apache.
the class TestServiceRegistryFactory method testGetRemoteRegistryClient.
@Test
public void testGetRemoteRegistryClient() {
EventBus eventBus = new EventBus();
ServiceRegistryConfig serviceRegistryConfig = ServiceRegistryConfig.INSTANCE;
MicroserviceDefinition microserviceDefinition = new MicroserviceDefinition(Collections.emptyList());
ServiceRegistry serviceRegistry = ServiceRegistryFactory.create(eventBus, serviceRegistryConfig, microserviceDefinition);
serviceRegistry.init();
ServiceRegistryClient client = serviceRegistry.getServiceRegistryClient();
Assert.assertTrue(client instanceof ServiceRegistryClientImpl);
serviceRegistry = ServiceRegistryFactory.getOrCreate(eventBus, serviceRegistryConfig, microserviceDefinition);
Assert.assertTrue(serviceRegistry instanceof RemoteServiceRegistry);
Assert.assertEquals(serviceRegistry, ServiceRegistryFactory.getServiceRegistry());
Deencapsulation.setField(ServiceRegistryFactory.class, "serviceRegistry", null);
System.setProperty("local.registry.file", "/tmp/test.yaml");
serviceRegistry = ServiceRegistryFactory.create(eventBus, serviceRegistryConfig, microserviceDefinition);
serviceRegistry.init();
client = serviceRegistry.getServiceRegistryClient();
Assert.assertTrue(client instanceof LocalServiceRegistryClientImpl);
Assert.assertTrue(ServiceRegistryFactory.getOrCreate(eventBus, serviceRegistryConfig, microserviceDefinition) instanceof LocalServiceRegistry);
System.clearProperty("local.registry.file");
}
use of org.apache.servicecomb.serviceregistry.client.LocalServiceRegistryClientImpl in project java-chassis by ServiceComb.
the class TestServiceRegistryFactory method testGetRemoteRegistryClient.
@Test
public // because what changed is class ServiceRegistryClientImpl
void testGetRemoteRegistryClient(@Mocked ServiceRegistryClientImpl registryClient) {
Configuration configuration = ConfigUtil.createLocalConfig();
EventBus eventBus = new EventBus();
ServiceRegistryConfig serviceRegistryConfig = ServiceRegistryConfig.INSTANCE;
ServiceRegistry serviceRegistry = ServiceRegistryFactory.create(eventBus, serviceRegistryConfig, configuration);
serviceRegistry.init();
ServiceRegistryClient client = serviceRegistry.getServiceRegistryClient();
Assert.assertTrue(client instanceof ServiceRegistryClientImpl);
serviceRegistry = ServiceRegistryFactory.create(eventBus, serviceRegistryConfig, configuration);
Assert.assertTrue(serviceRegistry instanceof RemoteServiceRegistry);
serviceRegistry = LocalServiceRegistryFactory.createLocal(eventBus, serviceRegistryConfig, configuration);
serviceRegistry.init();
client = serviceRegistry.getServiceRegistryClient();
Assert.assertTrue(client instanceof LocalServiceRegistryClientImpl);
Assert.assertTrue(LocalServiceRegistryFactory.createLocal(eventBus, serviceRegistryConfig, configuration) instanceof LocalServiceRegistry);
}
Aggregations