Search in sources :

Example 11 with TestObjectA

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());
}
Also used : TestObjectC(com.alipay.sofa.ark.container.testdata.impl.TestObjectC) TestObjectA(com.alipay.sofa.ark.container.testdata.impl.TestObjectA) ArkContainerServiceProvider(com.alipay.sofa.ark.container.registry.ArkContainerServiceProvider) TestObjectB(com.alipay.sofa.ark.container.testdata.impl.TestObjectB) ITest(com.alipay.sofa.ark.container.testdata.ITest) BaseTest(com.alipay.sofa.ark.container.BaseTest) ITest(com.alipay.sofa.ark.container.testdata.ITest) Test(org.junit.Test)

Example 12 with TestObjectA

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());
}
Also used : TestObjectA(com.alipay.sofa.ark.container.testdata.impl.TestObjectA)

Example 13 with 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());
}
Also used : TestObjectA(com.alipay.sofa.ark.container.testdata.impl.TestObjectA) ITest(com.alipay.sofa.ark.container.testdata.ITest) ContainerServiceProvider(com.alipay.sofa.ark.container.registry.ContainerServiceProvider) BaseTest(com.alipay.sofa.ark.container.BaseTest) ITest(com.alipay.sofa.ark.container.testdata.ITest) Test(org.junit.Test)

Example 14 with TestObjectA

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());
}
Also used : DefaultServiceFilter(com.alipay.sofa.ark.container.registry.DefaultServiceFilter) TestObjectA(com.alipay.sofa.ark.container.testdata.impl.TestObjectA) TestObjectB(com.alipay.sofa.ark.container.testdata.impl.TestObjectB) ITest(com.alipay.sofa.ark.container.testdata.ITest) ContainerServiceProvider(com.alipay.sofa.ark.container.registry.ContainerServiceProvider) BaseTest(com.alipay.sofa.ark.container.BaseTest) ITest(com.alipay.sofa.ark.container.testdata.ITest) Test(org.junit.Test)

Example 15 with TestObjectA

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());
}
Also used : TestObjectC(com.alipay.sofa.ark.container.testdata.impl.TestObjectC) TestObjectA(com.alipay.sofa.ark.container.testdata.impl.TestObjectA) TestObjectB(com.alipay.sofa.ark.container.testdata.impl.TestObjectB) ITest(com.alipay.sofa.ark.container.testdata.ITest) ContainerServiceProvider(com.alipay.sofa.ark.container.registry.ContainerServiceProvider) BaseTest(com.alipay.sofa.ark.container.BaseTest) ITest(com.alipay.sofa.ark.container.testdata.ITest) Test(org.junit.Test)

Aggregations

TestObjectA (com.alipay.sofa.ark.container.testdata.impl.TestObjectA)15 BaseTest (com.alipay.sofa.ark.container.BaseTest)13 ITest (com.alipay.sofa.ark.container.testdata.ITest)13 Test (org.junit.Test)13 ContainerServiceProvider (com.alipay.sofa.ark.container.registry.ContainerServiceProvider)6 TestObjectB (com.alipay.sofa.ark.container.testdata.impl.TestObjectB)6 PluginModel (com.alipay.sofa.ark.container.model.PluginModel)5 DefaultServiceFilter (com.alipay.sofa.ark.container.registry.DefaultServiceFilter)4 TestObjectC (com.alipay.sofa.ark.container.testdata.impl.TestObjectC)4 PluginContextImpl (com.alipay.sofa.ark.container.model.PluginContextImpl)3 PluginServiceProvider (com.alipay.sofa.ark.container.registry.PluginServiceProvider)3 ArkContainerServiceProvider (com.alipay.sofa.ark.container.registry.ArkContainerServiceProvider)2 PluginClassLoader (com.alipay.sofa.ark.container.service.classloader.PluginClassLoader)2 ServiceFilter (com.alipay.sofa.ark.spi.registry.ServiceFilter)2 ServiceProvider (com.alipay.sofa.ark.spi.registry.ServiceProvider)2 ServiceReference (com.alipay.sofa.ark.spi.registry.ServiceReference)2 PluginNameServiceFilter (com.alipay.sofa.ark.container.registry.PluginNameServiceFilter)1 PluginActivatorA (com.alipay.sofa.ark.container.testdata.Activator.PluginActivatorA)1 PluginActivatorB (com.alipay.sofa.ark.container.testdata.Activator.PluginActivatorB)1 PluginActivatorC (com.alipay.sofa.ark.container.testdata.Activator.PluginActivatorC)1