use of com.alipay.sofa.ark.container.testdata.impl.TestObjectA in project sofa-ark by alipay.
the class RegistryServiceTest method testFilter.
@Test
public void testFilter() {
PluginModel pluginA = new PluginModel();
pluginA.setPluginName("plugin A").setPriority(10);
PluginModel pluginB = new PluginModel();
pluginB.setPluginName("plugin B").setPriority(1);
pluginManagerService.registerPlugin(pluginA);
pluginManagerService.registerPlugin(pluginB);
registryService.publishService(ITest.class, new TestObjectA(), new PluginServiceProvider(pluginA));
registryService.publishService(ITest.class, new TestObjectB(), new PluginServiceProvider(pluginB));
registryService.publishService(ITest.class, new TestObjectC());
Assert.assertEquals(pluginB.getPluginName(), registryService.referenceService(ITest.class).getServiceMetadata().getServiceProvider().getServiceProviderName());
Assert.assertEquals(pluginA.getPluginName(), registryService.referenceService(ITest.class, new PluginNameServiceFilter(pluginA.getPluginName())).getServiceMetadata().getServiceProvider().getServiceProviderName());
Assert.assertNull(registryService.referenceService(ITest.class, new PluginNameServiceFilter("not exist")));
Assert.assertEquals("ArkContainer", registryService.referenceService(ITest.class, new ServiceFilter() {
@Override
public boolean match(ServiceProvider serviceProvider) {
return ServiceProviderType.ARK_CONTAINER.equals(serviceProvider.getServiceProviderType());
}
}).getServiceMetadata().getServiceProvider().getServiceProviderName());
}
use of com.alipay.sofa.ark.container.testdata.impl.TestObjectA in project sofa-ark by alipay.
the class RegistryServiceTest method testPublishDuplicateService.
@Test
public void testPublishDuplicateService() throws Exception {
registryService.publishService(ITest.class, new TestObjectA());
registryService.publishService(ITest.class, new TestObjectB());
// 只有第一个服务发布成功
Assert.assertEquals(1, registryService.referenceServices(ITest.class).size());
Assert.assertEquals(TestObjectA.OUTPUT, registryService.referenceService(ITest.class).getService().test());
}
use of com.alipay.sofa.ark.container.testdata.impl.TestObjectA in project sofa-ark by alipay.
the class RegistryServiceTest method testPublishService.
@Test
public void testPublishService() throws Exception {
ServiceReference<ITest> iTestServiceReference = registryService.publishService(ITest.class, new TestObjectA());
Assert.assertNotNull(iTestServiceReference);
Assert.assertEquals(TestObjectA.OUTPUT, iTestServiceReference.getService().test());
}
use of com.alipay.sofa.ark.container.testdata.impl.TestObjectA in project sofa-ark by alipay.
the class RegistryServiceTest method testReferenceService.
@Test
public void testReferenceService() throws Exception {
registryService.publishService(ITest.class, new TestObjectA());
ServiceReference<ITest> iTestServiceReference = registryService.referenceService(ITest.class);
Assert.assertNotNull(iTestServiceReference);
Assert.assertEquals(TestObjectA.OUTPUT, iTestServiceReference.getService().test());
}
use of com.alipay.sofa.ark.container.testdata.impl.TestObjectA in project sofa-ark by alipay.
the class RegistryServiceTest method testContainerServiceNotFoundByPlugin.
@Test
public void testContainerServiceNotFoundByPlugin() {
registryService.publishService(ITest.class, new TestObjectA());
Assert.assertNotNull(registryService.referenceService(ITest.class));
PluginModel pluginA = new PluginModel();
pluginA.setPluginName("plugin A").setPriority(10).setPluginContext(new PluginContextImpl(pluginA));
pluginManagerService.registerPlugin(pluginA);
Assert.assertNull(pluginA.getPluginContext().referenceService(ITest.class));
}
Aggregations