use of com.alipay.sofa.ark.container.testdata.impl.TestObjectA in project sofa-ark by alipay.
the class RegistryServiceTest method testContainerService.
@Test
public void testContainerService() {
registryService.publishService(ITest.class, new TestObjectA(), new ArkContainerServiceProvider("test1", 20000));
registryService.publishService(ITest.class, new TestObjectB(), new ArkContainerServiceProvider("test2", 100));
registryService.publishService(ITest.class, new TestObjectC());
Assert.assertEquals(TestObjectB.OUTPUT, registryService.referenceService(ITest.class).getService().test());
Assert.assertEquals(3, registryService.referenceServices(ITest.class).size());
}
use of com.alipay.sofa.ark.container.testdata.impl.TestObjectA in project sofa-ark by alipay.
the class PluginActivatorADup method start.
@Override
public void start(PluginContext context) throws ArkException {
context.publishService(ITest.class, new TestObjectA());
context.publishService(ITest.class, new TestObjectA());
}
use of com.alipay.sofa.ark.container.testdata.impl.TestObjectA in project sofa-ark by alipay.
the class ServiceRegistrationTest method testReferenceService.
@Test
public void testReferenceService() {
registryService.publishService(ITest.class, new TestObjectA(), new ContainerServiceProvider());
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 ServiceRegistrationTest method testPublishDuplicateService.
@Test
@SuppressWarnings("unchecked")
public void testPublishDuplicateService() {
registryService.publishService(ITest.class, new TestObjectA(), new ContainerServiceProvider());
registryService.publishService(ITest.class, new TestObjectB(), new ContainerServiceProvider());
// 只有第一个服务发布成功
Assert.assertEquals(1, registryService.referenceServices(ITest.class).size());
Assert.assertEquals(TestObjectA.OUTPUT, registryService.referenceService(ITest.class).getService().test());
registryService.unPublishServices(new DefaultServiceFilter().setServiceInterface(ITest.class));
Assert.assertEquals(0, registryService.referenceServices(ITest.class).size());
registryService.publishService(ITest.class, new TestObjectA(), "testA", new ContainerServiceProvider());
registryService.publishService(ITest.class, new TestObjectB(), "testB", new ContainerServiceProvider());
Assert.assertEquals(2, registryService.referenceServices(new DefaultServiceFilter().setServiceInterface(ITest.class)).size());
Assert.assertEquals(TestObjectA.OUTPUT, registryService.referenceService(ITest.class, "testA").getService().test());
Assert.assertEquals(TestObjectB.OUTPUT, registryService.referenceService(ITest.class, "testB").getService().test());
int c = registryService.unPublishServices(new DefaultServiceFilter().setUniqueId("testA"));
Assert.assertTrue(c == 1);
c = registryService.unPublishServices(new DefaultServiceFilter().setProviderType(ServiceProviderType.ARK_CONTAINER).setServiceInterface(ITest.class));
Assert.assertTrue(c == 1);
Assert.assertEquals(0, registryService.referenceServices(ITest.class).size());
}
use of com.alipay.sofa.ark.container.testdata.impl.TestObjectA in project sofa-ark by alipay.
the class ServiceRegistrationTest method testContainerService.
@Test
public void testContainerService() {
registryService.publishService(ITest.class, new TestObjectA(), new ContainerServiceProvider(20000));
registryService.publishService(ITest.class, new TestObjectB(), new ContainerServiceProvider(100));
registryService.publishService(ITest.class, new TestObjectC(), new ContainerServiceProvider(200));
Assert.assertEquals(TestObjectB.OUTPUT, registryService.referenceService(ITest.class).getService().test());
Assert.assertEquals(3, registryService.referenceServices(ITest.class).size());
}
Aggregations