Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-10-15 16:26:07 +0000
committercletavernie2012-10-15 16:26:07 +0000
commit0deece6c1f05e15594d8b111ad8d5ac12e1004ad (patch)
tree60a983e11a4284632422dede675b183846173e03 /incoming
parent3da13f092b20cf10f445dad148945c879057a7f5 (diff)
downloadorg.eclipse.papyrus-0deece6c1f05e15594d8b111ad8d5ac12e1004ad.tar.gz
org.eclipse.papyrus-0deece6c1f05e15594d8b111ad8d5ac12e1004ad.tar.xz
org.eclipse.papyrus-0deece6c1f05e15594d8b111ad8d5ac12e1004ad.zip
391945: [Refactoring] Part 2: Refactoring on Kepler (0.10)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=391945
Diffstat (limited to 'incoming')
-rw-r--r--incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/META-INF/MANIFEST.MF3
-rw-r--r--incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/about.html28
-rw-r--r--incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/build.properties8
-rw-r--r--incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/fragment.xml5
-rw-r--r--incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/plugin.properties2
-rw-r--r--incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/ExtensionServiceDescriptorsWithIdProviderTest.java102
-rw-r--r--incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/FakeServiceFactory.java24
-rw-r--r--incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/ServiceA.java5
-rw-r--r--incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/ServicesRegistryTest.java394
9 files changed, 315 insertions, 256 deletions
diff --git a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/META-INF/MANIFEST.MF b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/META-INF/MANIFEST.MF
index 6572d905f53..6b2ad9b0134 100644
--- a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/META-INF/MANIFEST.MF
+++ b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/META-INF/MANIFEST.MF
@@ -3,8 +3,9 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.papyrus.infra.core.serviceregistry.tests;singleton:=true
Bundle-Version: 0.10.0.qualifier
-Fragment-Host: org.eclipse.papyrus.infra.core.serviceregistry;bundle-version="0.9.0"
+Fragment-Host: org.eclipse.papyrus.infra.core.serviceregistry;bundle-version="0.10.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.junit,
org.eclipse.emf.ecore.xmi
Bundle-Vendor: %providerName
+Bundle-Localization: plugin
diff --git a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/about.html b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/about.html
new file mode 100644
index 00000000000..82d49bf5f81
--- /dev/null
+++ b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/build.properties b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/build.properties
index 3f78ea4cf8d..4f623cf2f57 100644
--- a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/build.properties
+++ b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/build.properties
@@ -1,5 +1,9 @@
-source.. = src/
+source.. = src/,\
+ tests/
output.. = bin/
bin.includes = META-INF/,\
.,\
- fragment.xml
+ resources/,\
+ about.html,\
+ plugin.properties
+src.includes = about.html
diff --git a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/fragment.xml b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/fragment.xml
deleted file mode 100644
index fa1feeceb5d..00000000000
--- a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/fragment.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<fragment>
-
-</fragment>
diff --git a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/plugin.properties b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/plugin.properties
index 376bf25e8b5..dd53c3514dc 100644
--- a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/plugin.properties
+++ b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/plugin.properties
@@ -8,5 +8,5 @@
# Contributors:
# Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
##################################################################################
-pluginName=Papyrus Service Registry
+pluginName=Papyrus Service Registry (Incubation)
providerName=Eclipse Modeling Project
diff --git a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/ExtensionServiceDescriptorsWithIdProviderTest.java b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/ExtensionServiceDescriptorsWithIdProviderTest.java
index b37f5a0adb7..2d3ff70e937 100644
--- a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/ExtensionServiceDescriptorsWithIdProviderTest.java
+++ b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/ExtensionServiceDescriptorsWithIdProviderTest.java
@@ -30,11 +30,12 @@ import org.junit.Test;
/**
* @author cedric dumoulin
- *
+ *
*/
-public class ExtensionServiceDescriptorsWithIdProviderTest extends AbstractServiceDescriptorsWithIdProviderTest{
+public class ExtensionServiceDescriptorsWithIdProviderTest extends AbstractServiceDescriptorsWithIdProviderTest {
static final String PLUGIN_XML = "resources/plugin.xml";
+
/**
* @throws java.lang.Exception
*/
@@ -51,121 +52,134 @@ public class ExtensionServiceDescriptorsWithIdProviderTest extends AbstractServi
/**
* Load a RegistryDesc from the specified declaration file.
- * @param extensionFileName The name of the resource containing declarations
- * @param registryName The name of the registry to load.
+ *
+ * @param extensionFileName
+ * The name of the resource containing declarations
+ * @param registryName
+ * The name of the registry to load.
* @return The descriptor for the registry.
*
* @throws IOException
* @throws ServiceException
* @throws DeclarationException
*/
- public RegistryIdDesc getRegistryDesc(String extensionFileName, String registryName ) throws IOException, ServiceException, DeclarationException {
+ @Override
+ public RegistryIdDesc getRegistryDesc(String extensionFileName, String registryName) throws IOException, ServiceException, DeclarationException {
// create provider, reading description from specified file.
IExtensionRegistry extensionRegistry = EclipseExtensionUtils.instance.createRegistry(extensionFileName);
-
+
ExtensionServiceDescriptorsWithIdProvider declarationsProvider = new ExtensionServiceDescriptorsWithIdProviderFromFile(extensionRegistry);
assertNotNull("provider created", declarationsProvider);
-
+
RegistryIdDesc registryIdDesc = declarationsProvider.getRegistryDescriptor(registryName);
-
+
return registryIdDesc;
}
-
+
/**
* Load a ServiceSetDesc from the specified declaration file.
*
- * @param extensionFileName The name of the resource containing declarations
- * @param serviceSetName The name of the serviceSet to load.
+ * @param extensionFileName
+ * The name of the resource containing declarations
+ * @param serviceSetName
+ * The name of the serviceSet to load.
* @return The descriptor for the ServiceSet
* @throws IOException
* @throws ServiceException
* @throws DeclarationException
*/
- public ServiceSetIdDesc getServiceSetDesc(String extensionFileName, String serviceSetName ) throws IOException, ServiceException, DeclarationException {
+ @Override
+ public ServiceSetIdDesc getServiceSetDesc(String extensionFileName, String serviceSetName) throws IOException, ServiceException, DeclarationException {
// create provider, reading description from specified file.
IExtensionRegistry extensionRegistry = EclipseExtensionUtils.instance.createRegistry(extensionFileName);
-
+
ExtensionServiceDescriptorsWithIdProvider declarationsProvider = new ExtensionServiceDescriptorsWithIdProviderFromFile(extensionRegistry);
assertNotNull("provider created", declarationsProvider);
-
+
ServiceSetIdDesc serviceSetIdDesc = declarationsProvider.getServiceSet(serviceSetName);
-
+
return serviceSetIdDesc;
}
/**
- * Test method for {@link org.eclipse.papyrus.infra.core.serviceregistry.ExtensionServiceDescriptorsWithIdProvider#getServiceSetFragments(java.lang.String)}.
- * @throws IOException
- * @throws ServiceException
- * @throws DeclarationException
+ * Test method for
+ * {@link org.eclipse.papyrus.infra.core.serviceregistry.ExtensionServiceDescriptorsWithIdProvider#getServiceSetFragments(java.lang.String)}.
+ *
+ * @throws IOException
+ * @throws ServiceException
+ * @throws DeclarationException
*/
@Test
public void testGetServiceSetFragments() throws IOException, ServiceException, DeclarationException {
// create provider, reading description from specified file.
IExtensionRegistry extensionRegistry = EclipseExtensionUtils.instance.createRegistry("resources/plugin.xml");
-
+
ExtensionServiceDescriptorsWithIdProvider declarationsProvider = new ExtensionServiceDescriptorsWithIdProviderFromFile(extensionRegistry);
// Tests
assertNotNull("provider created", declarationsProvider);
List<ServiceSetIdDesc> fragments = declarationsProvider.getServiceSetFragments("fragmentA");
assertNotNull("Get fragments", fragments);
-
- assertTrue( "fragments found", fragments.size()>0);
+
+ assertTrue("fragments found", fragments.size() > 0);
// Get the first fragment and test it
ServiceSetIdDesc serviceSet = fragments.get(0);
assertNotNull("Fragment exist", serviceSet);
-
- assertTrue("extends set", serviceSet.getExtends().size()>0);
- assertTrue("extends set", serviceSet.getExtends().contains("fragmentB" ) );
-
+
+ assertTrue("extends set", serviceSet.getExtends().size() > 0);
+ assertTrue("extends set", serviceSet.getExtends().contains("fragmentB"));
+
}
/**
- * Test method for {@link org.eclipse.papyrus.infra.core.serviceregistry.ExtensionServiceDescriptorsWithIdProvider#getServiceSetFragments(java.lang.String)}.
- * @throws IOException
- * @throws ServiceException
- * @throws DeclarationException
+ * Test method for
+ * {@link org.eclipse.papyrus.infra.core.serviceregistry.ExtensionServiceDescriptorsWithIdProvider#getServiceSetFragments(java.lang.String)}.
+ *
+ * @throws IOException
+ * @throws ServiceException
+ * @throws DeclarationException
*/
@Test
public void testGetServiceSetFragmentsWithMultiFragments() throws IOException, ServiceException, DeclarationException {
// create provider, reading description from specified file.
IExtensionRegistry extensionRegistry = EclipseExtensionUtils.instance.createRegistry("resources/plugin.xml");
-
+
ExtensionServiceDescriptorsWithIdProvider declarationsProvider = new ExtensionServiceDescriptorsWithIdProviderFromFile(extensionRegistry);
// Tests
assertNotNull("provider created", declarationsProvider);
List<ServiceSetIdDesc> fragments = declarationsProvider.getServiceSetFragments("multiFragmentA");
assertNotNull("Get fragments", fragments);
-
- assertTrue( "fragments found", fragments.size()>0);
- assertTrue( "fragments found", fragments.size()>1);
+
+ assertTrue("fragments found", fragments.size() > 0);
+ assertTrue("fragments found", fragments.size() > 1);
}
/**
- * Test method for {@link org.eclipse.papyrus.infra.core.serviceregistry.ExtensionServiceDescriptorsWithIdProvider#getServiceSet(java.lang.String)}.
- * @throws IOException
- * @throws ServiceException
- * @throws DeclarationException
+ * Test method for
+ * {@link org.eclipse.papyrus.infra.core.serviceregistry.ExtensionServiceDescriptorsWithIdProvider#getServiceSet(java.lang.String)}.
+ *
+ * @throws IOException
+ * @throws ServiceException
+ * @throws DeclarationException
*/
@Test
public void testGetServiceSetFromMultiFragment() throws IOException, ServiceException, DeclarationException {
// create provider, reading description from specified file.
IExtensionRegistry extensionRegistry = EclipseExtensionUtils.instance.createRegistry("resources/plugin.xml");
-
+
ExtensionServiceDescriptorsWithIdProvider declarationsProvider = new ExtensionServiceDescriptorsWithIdProviderFromFile(extensionRegistry);
// Tests
assertNotNull("provider created", declarationsProvider);
ServiceSetIdDesc serviceSet = declarationsProvider.getServiceSet("multiFragmentA");
-
+
assertNotNull("Fragment exist", serviceSet);
-
- assertTrue("extends set", serviceSet.getExtends().size()>0);
- assertTrue("extends set", serviceSet.getExtends().contains("fragmentB" ) );
-
+
+ assertTrue("extends set", serviceSet.getExtends().size() > 0);
+ assertTrue("extends set", serviceSet.getExtends().contains("fragmentB"));
+
}
diff --git a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/FakeServiceFactory.java b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/FakeServiceFactory.java
index badab2e5d1a..e75a07064d0 100644
--- a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/FakeServiceFactory.java
+++ b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/FakeServiceFactory.java
@@ -1,13 +1,12 @@
package org.eclipse.papyrus.infra.core.serviceregistry;
-import org.eclipse.papyrus.infra.core.serviceregistry.IServiceFactory;
/**
* Fake service factory for testing purpose.
*
* @author cedric dumoulin
- *
+ *
*/
public class FakeServiceFactory extends FakeService implements IServiceFactory {
@@ -15,34 +14,36 @@ public class FakeServiceFactory extends FakeService implements IServiceFactory {
/**
*
* Constructor.
- *
+ *
*/
public FakeServiceFactory() {
- super( "factoryName" + count++ );
+ super("factoryName" + count++);
}
-
+
/**
* Constructor.
- *
+ *
* @param name
*/
public FakeServiceFactory(String name) {
super(name);
}
-
+
/**
* @return the name
*/
+ @Override
public String getName() {
return name;
}
/**
* Create the service
+ *
* @see org.eclipse.papyrus.infra.core.serviceregistry.IServiceFactory#createServiceInstance()
- *
+ *
* @return
*/
public Object createServiceInstance() {
@@ -52,16 +53,17 @@ public class FakeServiceFactory extends FakeService implements IServiceFactory {
/**
* Pseudo service created by the factory.
+ *
* @author dumoulin
- *
+ *
*/
public class FakeCreatedService {
-
+
/**
* @return the name
*/
public String getName() {
return name;
- }
+ }
}
}
diff --git a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/ServiceA.java b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/ServiceA.java
index 985bbc1f0e9..0edde807cf9 100644
--- a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/ServiceA.java
+++ b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/ServiceA.java
@@ -3,14 +3,11 @@ package org.eclipse.papyrus.infra.core.serviceregistry;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.papyrus.infra.core.serviceregistry.IService;
-import org.eclipse.papyrus.infra.core.serviceregistry.ServicesRegistry;
-
public class ServiceA implements IService {
public enum TraceKind {
init, start, dispose
- };
+ }
static List<TraceKind> trace = new ArrayList<TraceKind>();
diff --git a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/ServicesRegistryTest.java b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/ServicesRegistryTest.java
index 0475d3ee0a2..cb1e60205fb 100644
--- a/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/ServicesRegistryTest.java
+++ b/incoming/serviceregistry/org.eclipse.papyrus.infra.core.serviceregistry.test/tests/org/eclipse/papyrus/infra/core/serviceregistry/ServicesRegistryTest.java
@@ -39,6 +39,7 @@ public class ServicesRegistryTest extends TestCase {
/**
* @throws java.lang.Exception
*/
+ @Override
protected void setUp() throws Exception {
servicesRegistry = new ServicesRegistry();
}
@@ -46,12 +47,15 @@ public class ServicesRegistryTest extends TestCase {
/**
* @throws java.lang.Exception
*/
+ @Override
protected void tearDown() throws Exception {
}
/**
- * Test method for {@link org.eclipse.papyrus.infra.core.serviceregistry.ServicesRegistry#add(org.eclipse.papyrus.infra.core.serviceregistry.ServiceDescriptor)} .
- * @throws ServiceMultiException
+ * Test method for
+ * {@link org.eclipse.papyrus.infra.core.serviceregistry.ServicesRegistry#add(org.eclipse.papyrus.infra.core.serviceregistry.ServiceDescriptor)} .
+ *
+ * @throws ServiceMultiException
*/
public void testAdd() throws ServiceMultiException {
@@ -61,14 +65,14 @@ public class ServicesRegistryTest extends TestCase {
servicesRegistry.add(servicePojoADesc);
// Test entries creation
-// try {
-// assertFalse("serviceA stopped", servicesRegistry.isStarted(serviceADesc.getKey()));
-// assertFalse("serviceB stopped", servicesRegistry.isStarted(serviceBDesc.getKey()));
-// assertFalse("serviceC stopped", servicesRegistry.isStarted(serviceCDesc.getKey()));
-// assertFalse("servicePojoA stopped", servicesRegistry.isStarted(servicePojoADesc.getKey()));
-// } catch (ServiceNotFoundException e) {
-// fail("Service should exist." + e.getMessage());
-// }
+ // try {
+ // assertFalse("serviceA stopped", servicesRegistry.isStarted(serviceADesc.getKey()));
+ // assertFalse("serviceB stopped", servicesRegistry.isStarted(serviceBDesc.getKey()));
+ // assertFalse("serviceC stopped", servicesRegistry.isStarted(serviceCDesc.getKey()));
+ // assertFalse("servicePojoA stopped", servicesRegistry.isStarted(servicePojoADesc.getKey()));
+ // } catch (ServiceNotFoundException e) {
+ // fail("Service should exist." + e.getMessage());
+ // }
// Test startup
servicesRegistry.startNewServices();
@@ -100,7 +104,7 @@ public class ServicesRegistryTest extends TestCase {
servicesRegistry.startNewServices();
-
+
// Test lazy service
Object serviceA = servicesRegistry.getService(serviceADesc.getKey());
assertNotNull("service created", serviceA);
@@ -141,7 +145,7 @@ public class ServicesRegistryTest extends TestCase {
servicesRegistry.startNewServices();
-
+
// Test lazy service
ServiceA serviceA = servicesRegistry.getService(ServiceA.class);
assertNotNull("service created", serviceA);
@@ -177,15 +181,15 @@ public class ServicesRegistryTest extends TestCase {
servicesRegistry.add(serviceBDesc);
// Test creation
-// try {
-// assertFalse("serviceA stopped", servicesRegistry.isStarted(serviceADesc.getKey()));
-// assertFalse("serviceB stopped", servicesRegistry.isStarted(serviceBDesc.getKey()));
-// } catch (ServiceNotFoundException e) {
-// fail("Service should exist.");
-// }
+ // try {
+ // assertFalse("serviceA stopped", servicesRegistry.isStarted(serviceADesc.getKey()));
+ // assertFalse("serviceB stopped", servicesRegistry.isStarted(serviceBDesc.getKey()));
+ // } catch (ServiceNotFoundException e) {
+ // fail("Service should exist.");
+ // }
servicesRegistry.startNewServices();
-
+
Object serviceA = servicesRegistry.getService(serviceADesc.getKey());
assertNotNull("Service created", serviceA);
@@ -221,115 +225,118 @@ public class ServicesRegistryTest extends TestCase {
/**
* Test life cycle for directly registered services
+ *
* @throws ServiceException
*/
public void testCallsOrder() throws ServiceException {
// Register services as STARTUP !
- servicesRegistry.add(ServiceA.class, 1, new ServiceA() );
+ servicesRegistry.add(ServiceA.class, 1, new ServiceA());
// Lazy - generate no trace
servicesRegistry.add(ServiceB.class, 1, new ServiceB(), ServiceStartKind.LAZY);
servicesRegistry.add(ServiceC.class, 1, new ServiceC());
servicesRegistry.add(ServicePojoA.class, 1, new ServicePojoA());
-
+
ServiceA.resetTrace();
servicesRegistry.startNewServices();
-
+
// Check orders
//
- int i=0;
+ int i = 0;
assertEquals("service", TraceKind.init, ServiceA.getEvent(i++));
assertEquals("service", TraceKind.init, ServiceA.getEvent(i++));
assertEquals("service", TraceKind.init, ServiceA.getEvent(i++));
-// assertEquals("service", TraceKind.init, ServiceA.getEvent(i++));
-
+ // assertEquals("service", TraceKind.init, ServiceA.getEvent(i++));
+
assertEquals("service", TraceKind.start, ServiceA.getEvent(i++));
assertEquals("service", TraceKind.start, ServiceA.getEvent(i++));
assertEquals("service", TraceKind.start, ServiceA.getEvent(i++));
-// assertEquals("service", TraceKind.start, ServiceA.getEvent(i++));
-
+ // assertEquals("service", TraceKind.start, ServiceA.getEvent(i++));
+
// Now, start lazy service
ServiceB service = servicesRegistry.getService(ServiceB.class);
assertNotNull("service found", service);
assertEquals("service", TraceKind.init, ServiceA.getEvent(i++));
assertEquals("service", TraceKind.start, ServiceA.getEvent(i++));
-
-
+
+
// Check dispose
servicesRegistry.disposeRegistry();
assertEquals("service", TraceKind.dispose, ServiceA.getEvent(i++));
assertEquals("service", TraceKind.dispose, ServiceA.getEvent(i++));
assertEquals("service", TraceKind.dispose, ServiceA.getEvent(i++));
-// assertEquals("service", TraceKind.dispose, ServiceA.getEvent(i++));
-
+ // assertEquals("service", TraceKind.dispose, ServiceA.getEvent(i++));
+
//
}
-
+
/**
- * Test life cycle for services registered wih descriptors
+ * Test life cycle for services registered wih descriptors
+ *
* @throws ServiceException
*/
public void testCallsOrderForDescriptors() throws ServiceException {
// Register services as STARTUP !
// Lazy - generate no trace
- servicesRegistry.add( new LazyServiceBDescriptor() );
- servicesRegistry.add( new ServiceCDescriptor());
-
+ servicesRegistry.add(new LazyServiceBDescriptor());
+ servicesRegistry.add(new ServiceCDescriptor());
+
ServiceA.resetTrace();
servicesRegistry.startNewServices();
// Check orders
//
- int i=0;
+ int i = 0;
assertEquals("service", TraceKind.init, ServiceA.getEvent(i++));
-// assertEquals("service", TraceKind.init, ServiceA.getEvent(i++));
-
+ // assertEquals("service", TraceKind.init, ServiceA.getEvent(i++));
+
assertEquals("service", TraceKind.start, ServiceA.getEvent(i++));
-// assertEquals("service", TraceKind.start, ServiceA.getEvent(i++));
-
+ // assertEquals("service", TraceKind.start, ServiceA.getEvent(i++));
+
// Now, start lazy service
ServiceB service = (ServiceB)servicesRegistry.getService(ServiceB.class.getName());
assertNotNull("service found", service);
assertEquals("service", TraceKind.init, ServiceA.getEvent(i++));
assertEquals("service", TraceKind.start, ServiceA.getEvent(i++));
-
-
+
+
// Check dispose
servicesRegistry.disposeRegistry();
assertEquals("service", TraceKind.dispose, ServiceA.getEvent(i++));
assertEquals("service", TraceKind.dispose, ServiceA.getEvent(i++));
-// assertEquals("service", TraceKind.dispose, ServiceA.getEvent(i++));
-
+ // assertEquals("service", TraceKind.dispose, ServiceA.getEvent(i++));
+
//
}
-
+
/**
* Test the start order for services of type Start and Service
+ *
* @throws ServiceException
*/
public void testStartDependantOrder() throws ServiceException {
-
+
String A = "A";
String B = "B";
String C = "C";
String D = "D";
String E = "E";
-// String F = "F";
-
+ // String F = "F";
+
// Create services E --> D --> C --> B --> A
FakeService.getTrace().reset();
-
- servicesRegistry.add( new ServiceDesc( E, ServiceStartKind.STARTUP, Arrays.asList(D) ));
- servicesRegistry.add( new ServiceDesc( D, ServiceStartKind.STARTUP, Arrays.asList(C) ));
- servicesRegistry.add( new ServiceDesc( C, ServiceStartKind.STARTUP, Arrays.asList(B) ));
- servicesRegistry.add( new ServiceDesc( B, ServiceStartKind.STARTUP, Arrays.asList(A) ));
- servicesRegistry.add( new ServiceDesc( A, ServiceStartKind.STARTUP ));
-// servicesRegistry.add( new ServiceIdDesc( F, ServiceStartKind.STARTUP, Arrays.asList(E) ));
-
+
+ servicesRegistry.add(new ServiceDesc(E, ServiceStartKind.STARTUP, Arrays.asList(D)));
+ servicesRegistry.add(new ServiceDesc(D, ServiceStartKind.STARTUP, Arrays.asList(C)));
+ servicesRegistry.add(new ServiceDesc(C, ServiceStartKind.STARTUP, Arrays.asList(B)));
+ servicesRegistry.add(new ServiceDesc(B, ServiceStartKind.STARTUP, Arrays.asList(A)));
+ servicesRegistry.add(new ServiceDesc(A, ServiceStartKind.STARTUP));
+ // servicesRegistry.add( new ServiceIdDesc( F, ServiceStartKind.STARTUP, Arrays.asList(E) ));
+
// Start services
servicesRegistry.startNewServices();
-
+
// check services
assertTrue("service started", servicesRegistry.isStarted(A));
assertTrue("service started", servicesRegistry.isStarted(B));
@@ -341,28 +348,28 @@ public class ServicesRegistryTest extends TestCase {
String nameC = ((FakeService)servicesRegistry.getService(C)).getName();
String nameD = ((FakeService)servicesRegistry.getService(D)).getName();
String nameE = ((FakeService)servicesRegistry.getService(E)).getName();
-// String nameF = ((FakeService)servicesRegistry.getService(F)).getName();
-
-
+ // String nameF = ((FakeService)servicesRegistry.getService(F)).getName();
+
+
// check order (E and F order are not guaranteed)
// order should be A, B, C, D, E
TestTrace trace = FakeService.getTrace();
int i = 0;
-// assertEquals("order", nameF + ",create", trace.getNameTrace(i++));
+ // assertEquals("order", nameF + ",create", trace.getNameTrace(i++));
assertEquals("order", nameA + ",create", trace.getNameTrace(i++));
assertEquals("order", nameB + ",create", trace.getNameTrace(i++));
assertEquals("order", nameC + ",create", trace.getNameTrace(i++));
assertEquals("order", nameD + ",create", trace.getNameTrace(i++));
assertEquals("order", nameE + ",create", trace.getNameTrace(i++));
-// assertEquals("order", nameF + ",init", trace.getNameTrace(i++));
+ // assertEquals("order", nameF + ",init", trace.getNameTrace(i++));
assertEquals("order", nameA + ",init", trace.getNameTrace(i++));
assertEquals("order", nameB + ",init", trace.getNameTrace(i++));
assertEquals("order", nameC + ",init", trace.getNameTrace(i++));
assertEquals("order", nameD + ",init", trace.getNameTrace(i++));
assertEquals("order", nameE + ",init", trace.getNameTrace(i++));
-// assertEquals("order", nameF + ",start", trace.getNameTrace(i++));
+ // assertEquals("order", nameF + ",start", trace.getNameTrace(i++));
assertEquals("order", nameA + ",start", trace.getNameTrace(i++));
assertEquals("order", nameB + ",start", trace.getNameTrace(i++));
assertEquals("order", nameC + ",start", trace.getNameTrace(i++));
@@ -372,23 +379,24 @@ public class ServicesRegistryTest extends TestCase {
}
/**
- * Start regular services, then add a new service and try to start it.
+ * Start regular services, then add a new service and try to start it.
* This should work.
+ *
* @throws ServiceException
*/
public void testStartRegistryAndThenAddNewServiceAndStartIt() throws ServiceException {
-
+
// Register some services
String A = "A";
String B = "B";
String C = "C";
- servicesRegistry.add( new ServiceFactoryDesc( C, ServiceStartKind.STARTUP ));
- servicesRegistry.add( new ServiceFactoryDesc( B, ServiceStartKind.STARTUP, Arrays.asList(C) ));
- servicesRegistry.add( new ServiceFactoryDesc( A, ServiceStartKind.STARTUP, Arrays.asList(B) ));
+ servicesRegistry.add(new ServiceFactoryDesc(C, ServiceStartKind.STARTUP));
+ servicesRegistry.add(new ServiceFactoryDesc(B, ServiceStartKind.STARTUP, Arrays.asList(C)));
+ servicesRegistry.add(new ServiceFactoryDesc(A, ServiceStartKind.STARTUP, Arrays.asList(B)));
// Start them
servicesRegistry.startNewServices();
-
+
// Register another services as pojo
IService instanciatedService = new ServiceA();
String key = instanciatedService.getClass().getName();
@@ -396,48 +404,49 @@ public class ServicesRegistryTest extends TestCase {
// Try to start it
servicesRegistry.startServices(key);
-
+
// check services
assertTrue("service started", servicesRegistry.isStarted(A));
assertTrue("service started", servicesRegistry.isStarted(B));
assertTrue("service started", servicesRegistry.isStarted(C));
-
+
assertTrue("service started", servicesRegistry.isStarted(key));
-
+
assertEquals("get registered service", instanciatedService, servicesRegistry.getService(key));
}
/**
* Test Service Factory creation
+ *
* @throws ServiceException
*/
public void testServiceFactoryCreation() throws ServiceException {
-
+
String A = "A";
String B = "B";
String C = "C";
-
+
// Create services
FakeService.getTrace().reset();
-
- servicesRegistry.add( new ServiceFactoryDesc( C, ServiceStartKind.STARTUP ));
- servicesRegistry.add( new ServiceFactoryDesc( B, ServiceStartKind.STARTUP, Arrays.asList(C) ));
- servicesRegistry.add( new ServiceFactoryDesc( A, ServiceStartKind.STARTUP, Arrays.asList(B) ));
-
+
+ servicesRegistry.add(new ServiceFactoryDesc(C, ServiceStartKind.STARTUP));
+ servicesRegistry.add(new ServiceFactoryDesc(B, ServiceStartKind.STARTUP, Arrays.asList(C)));
+ servicesRegistry.add(new ServiceFactoryDesc(A, ServiceStartKind.STARTUP, Arrays.asList(B)));
+
// Start services
servicesRegistry.startNewServices();
-
+
// check services
assertSame("service type", FakeCreatedService.class, servicesRegistry.getService(A).getClass());
assertSame("service type", FakeCreatedService.class, servicesRegistry.getService(B).getClass());
-
+
// Get names of created services
String nameA = ((FakeCreatedService)servicesRegistry.getService(A)).getName();
String nameB = ((FakeCreatedService)servicesRegistry.getService(B)).getName();
String nameC = ((FakeCreatedService)servicesRegistry.getService(C)).getName();
-
-
+
+
// check order
// Order should be: C, B, A
TestTrace trace = FakeService.getTrace();
@@ -462,40 +471,41 @@ public class ServicesRegistryTest extends TestCase {
/**
* Test Creation of Service Factory used with class as key.
+ *
* @throws ServiceException
*/
public void testServiceFactoryWithClassKey() throws ServiceException {
-
+
//
Class<?> A = ServiceA.class;
Class<?> B = ServiceB.class;
Class<?> C = ServiceC.class;
-
+
// Specify service types as String
- String serviceClassname1 = FakeServiceFactory.class.getName();;
+ String serviceClassname1 = FakeServiceFactory.class.getName();
String serviceClassname2 = FakeServiceFactory.class.getName();
String serviceClassname3 = FakeServiceFactory.class.getName();
-
+
// Create services
FakeService.getTrace().reset();
-
- servicesRegistry.add( new ServiceFactoryDesc( C, serviceClassname3, ServiceStartKind.STARTUP ));
- servicesRegistry.add( new ServiceFactoryDesc( B, serviceClassname2, ServiceStartKind.STARTUP , Arrays.asList(C.getName()) ));
- servicesRegistry.add( new ServiceFactoryDesc( A, serviceClassname1, ServiceStartKind.STARTUP , Arrays.asList(B.getName()) ));
-
+
+ servicesRegistry.add(new ServiceFactoryDesc(C, serviceClassname3, ServiceStartKind.STARTUP));
+ servicesRegistry.add(new ServiceFactoryDesc(B, serviceClassname2, ServiceStartKind.STARTUP, Arrays.asList(C.getName())));
+ servicesRegistry.add(new ServiceFactoryDesc(A, serviceClassname1, ServiceStartKind.STARTUP, Arrays.asList(B.getName())));
+
// Start services
servicesRegistry.startNewServices();
-
+
// check services
assertSame("service type", FakeCreatedService.class, servicesRegistry.getService(A).getClass());
assertSame("service type", FakeCreatedService.class, servicesRegistry.getService(B).getClass());
-
+
// Get names of created services
String nameA = ((FakeCreatedService)servicesRegistry.getService(A)).getName();
String nameB = ((FakeCreatedService)servicesRegistry.getService(B)).getName();
String nameC = ((FakeCreatedService)servicesRegistry.getService(C)).getName();
-
-
+
+
// check order (E and F order are not guaranteed)
// Order should be
TestTrace trace = FakeService.getTrace();
@@ -517,39 +527,40 @@ public class ServicesRegistryTest extends TestCase {
assertEquals("order", nameB + ",createInstance", trace.getNameTrace(i++));
assertEquals("order", nameC + ",createInstance", trace.getNameTrace(i++));
}
-
+
/**
* Test Service Factory creation order.
* One of the factory try to get the required service from its init() method.
+ *
* @throws ServiceException
*/
public void testServiceFactoryWithRequiredInInit() throws ServiceException {
-
+
String A = "A";
String B = "B";
String C = "C";
-
+
// Create services C --> A --> B
FakeService.getTrace().reset();
-
+
// FakeWithRequiredServiceFactory try to retrieve service "C"
- servicesRegistry.add( new ServiceFactoryDesc( B, FakeWithRequiredServiceFactory.class.getName(), ServiceStartKind.STARTUP, 1, Arrays.asList(C) ));
- servicesRegistry.add( new ServiceFactoryDesc( A, FakeWithRequiredServiceFactory.class.getName(), ServiceStartKind.STARTUP, 1, Arrays.asList(B, C) ));
- servicesRegistry.add( new ServiceFactoryDesc( C, FakeServiceFactory.class.getName(), ServiceStartKind.STARTUP, 1 ));
-
+ servicesRegistry.add(new ServiceFactoryDesc(B, FakeWithRequiredServiceFactory.class.getName(), ServiceStartKind.STARTUP, 1, Arrays.asList(C)));
+ servicesRegistry.add(new ServiceFactoryDesc(A, FakeWithRequiredServiceFactory.class.getName(), ServiceStartKind.STARTUP, 1, Arrays.asList(B, C)));
+ servicesRegistry.add(new ServiceFactoryDesc(C, FakeServiceFactory.class.getName(), ServiceStartKind.STARTUP, 1));
+
// Start services
servicesRegistry.startNewServices();
-
+
// check services
assertSame("service type", FakeCreatedService.class, servicesRegistry.getService(A).getClass());
assertSame("service type", FakeCreatedService.class, servicesRegistry.getService(B).getClass());
-
+
// Get names of created services
String nameA = ((FakeCreatedService)servicesRegistry.getService(A)).getName();
String nameB = ((FakeCreatedService)servicesRegistry.getService(B)).getName();
String nameC = ((FakeCreatedService)servicesRegistry.getService(C)).getName();
-
-
+
+
// check order
// Order should be: C, B, A
TestTrace trace = FakeService.getTrace();
@@ -560,11 +571,11 @@ public class ServicesRegistryTest extends TestCase {
assertEquals("order", nameC + ",init", trace.getNameTrace(i++));
assertEquals("order", nameB + ",init", trace.getNameTrace(i++));
-
+
assertEquals("order", nameC + ",createInstance", trace.getNameTrace(i++));
assertEquals("value", servicesRegistry.getService(C), trace.getValue(i));
assertEquals("order", nameB + ",initEnd", trace.getNameTrace(i++));
-
+
assertEquals("order", nameA + ",init", trace.getNameTrace(i++));
assertEquals("order", nameA + ",initEnd", trace.getNameTrace(i++));
@@ -574,36 +585,36 @@ public class ServicesRegistryTest extends TestCase {
// next order is the order of getService()
assertEquals("order", nameA + ",createInstance", trace.getNameTrace(i++));
-// assertEquals("order", nameB + ",createInstance", trace.getNameTrace(i++));
-// assertEquals("order", nameC + ",createInstance", trace.getNameTrace(i++));
+ // assertEquals("order", nameB + ",createInstance", trace.getNameTrace(i++));
+ // assertEquals("order", nameC + ",createInstance", trace.getNameTrace(i++));
}
/**
- * Test {@link ServicesRegistry#startServicesByClassKeys(List)}.
+ * Test {@link ServicesRegistry#startServicesByClassKeys(List)}.
* Check that services are started.
*
* @throws ServiceException
*/
public void testStartService() throws ServiceException {
-
+
String A = "A";
String B = "B";
String C = "C";
String D = "D";
String E = "E";
-
+
// Create services E --> D --> C --> B --> A
FakeService.getTrace().reset();
-
- servicesRegistry.add( new ServiceDesc( E, ServiceStartKind.STARTUP, Arrays.asList(D) ));
- servicesRegistry.add( new ServiceDesc( D, ServiceStartKind.STARTUP, Arrays.asList(C) ));
- servicesRegistry.add( new ServiceDesc( C, ServiceStartKind.STARTUP, Arrays.asList(A, B) ));
- servicesRegistry.add( new ServiceDesc( B, ServiceStartKind.STARTUP, Arrays.asList(A) ));
- servicesRegistry.add( new ServiceDesc( A, ServiceStartKind.STARTUP ));
-
+
+ servicesRegistry.add(new ServiceDesc(E, ServiceStartKind.STARTUP, Arrays.asList(D)));
+ servicesRegistry.add(new ServiceDesc(D, ServiceStartKind.STARTUP, Arrays.asList(C)));
+ servicesRegistry.add(new ServiceDesc(C, ServiceStartKind.STARTUP, Arrays.asList(A, B)));
+ servicesRegistry.add(new ServiceDesc(B, ServiceStartKind.STARTUP, Arrays.asList(A)));
+ servicesRegistry.add(new ServiceDesc(A, ServiceStartKind.STARTUP));
+
// Start services
servicesRegistry.startServices(Arrays.asList(C));
-
+
// check services
assertTrue("service started", servicesRegistry.isStarted(A));
assertTrue("service started", servicesRegistry.isStarted(B));
@@ -613,11 +624,11 @@ public class ServicesRegistryTest extends TestCase {
String nameA = ((FakeService)servicesRegistry.getService(A)).getName();
String nameB = ((FakeService)servicesRegistry.getService(B)).getName();
String nameC = ((FakeService)servicesRegistry.getService(C)).getName();
-// String nameD = ((FakeService)servicesRegistry.getService(D)).getName();
-// String nameE = ((FakeService)servicesRegistry.getService(E)).getName();
-// String nameF = ((FakeService)servicesRegistry.getService(F)).getName();
-
-
+ // String nameD = ((FakeService)servicesRegistry.getService(D)).getName();
+ // String nameE = ((FakeService)servicesRegistry.getService(E)).getName();
+ // String nameF = ((FakeService)servicesRegistry.getService(F)).getName();
+
+
// check order (E and F order are not guaranteed)
// order should be A, B, C
TestTrace trace = FakeService.getTrace();
@@ -625,20 +636,20 @@ public class ServicesRegistryTest extends TestCase {
assertEquals("order", nameA + ",create", trace.getNameTrace(i++));
assertEquals("order", nameB + ",create", trace.getNameTrace(i++));
assertEquals("order", nameC + ",create", trace.getNameTrace(i++));
-// assertEquals("order", nameD + ",create", trace.getNameTrace(i++));
-// assertEquals("order", nameE + ",create", trace.getNameTrace(i++));
+ // assertEquals("order", nameD + ",create", trace.getNameTrace(i++));
+ // assertEquals("order", nameE + ",create", trace.getNameTrace(i++));
assertEquals("order", nameA + ",init", trace.getNameTrace(i++));
assertEquals("order", nameB + ",init", trace.getNameTrace(i++));
assertEquals("order", nameC + ",init", trace.getNameTrace(i++));
-// assertEquals("order", nameD + ",init", trace.getNameTrace(i++));
-// assertEquals("order", nameE + ",init", trace.getNameTrace(i++));
+ // assertEquals("order", nameD + ",init", trace.getNameTrace(i++));
+ // assertEquals("order", nameE + ",init", trace.getNameTrace(i++));
assertEquals("order", nameA + ",start", trace.getNameTrace(i++));
assertEquals("order", nameB + ",start", trace.getNameTrace(i++));
assertEquals("order", nameC + ",start", trace.getNameTrace(i++));
-// assertEquals("order", nameD + ",start", trace.getNameTrace(i++));
-// assertEquals("order", nameE + ",start", trace.getNameTrace(i++));
+ // assertEquals("order", nameD + ",start", trace.getNameTrace(i++));
+ // assertEquals("order", nameE + ",start", trace.getNameTrace(i++));
}
@@ -648,57 +659,59 @@ public class ServicesRegistryTest extends TestCase {
/**
* Test the alias service.
+ *
* @throws ServiceException
*/
@Test
public void testSimpleStartServices() throws ServiceException {
-
+
Class<?> serviceA = FakeServiceA.class;
Class<?> serviceB = FakeServiceB.class;
Class<?> serviceC = FakeServiceC.class;
-
+
// services A --> B
FakeService.getTrace().reset();
-
+
// Create an alias to B
ServicesRegistry registryA = new ServicesRegistry();
- registryA.add( new ServiceDescriptor( serviceA.getName(), ServiceStartKind.STARTUP, 1, Arrays.asList(serviceB.getName())) );
- registryA.add( new ServiceDescriptor( serviceB.getName(), ServiceStartKind.STARTUP, 1 ));
- registryA.add( new ServiceDescriptor( serviceC.getName(), ServiceStartKind.STARTUP, 1 ));
-
+ registryA.add(new ServiceDescriptor(serviceA.getName(), ServiceStartKind.STARTUP, 1, Arrays.asList(serviceB.getName())));
+ registryA.add(new ServiceDescriptor(serviceB.getName(), ServiceStartKind.STARTUP, 1));
+ registryA.add(new ServiceDescriptor(serviceC.getName(), ServiceStartKind.STARTUP, 1));
+
registryA.startNewServices();
-
-
+
+
// check services
assertNotNull("got service started", registryA.getService(serviceB));
assertNotNull("got service started", registryA.getService(serviceC));
assertNotNull("got service started", registryA.getService(serviceA));
-
+
}
/**
* Test the alias service.
+ *
* @throws ServiceException
*/
@Test
public void testChainWithLazyStartServices() throws ServiceException {
-
+
Class<?> serviceA = FakeServiceA.class;
Class<?> serviceB = FakeServiceB.class;
Class<?> serviceC = FakeServiceC.class;
-
+
FakeService.getTrace().reset();
-
+
// services A --> B (lazy) --> C
ServicesRegistry registryA = new ServicesRegistry();
- registryA.add( new ServiceDescriptor( serviceA.getName(), ServiceStartKind.STARTUP, 1, Arrays.asList(serviceB.getName())) );
- registryA.add( new ServiceDescriptor( serviceB.getName(), ServiceStartKind.LAZY , 1, Arrays.asList(serviceC.getName()) ));
- registryA.add( new ServiceDescriptor( serviceC.getName(), ServiceStartKind.STARTUP, 1 ));
-
+ registryA.add(new ServiceDescriptor(serviceA.getName(), ServiceStartKind.STARTUP, 1, Arrays.asList(serviceB.getName())));
+ registryA.add(new ServiceDescriptor(serviceB.getName(), ServiceStartKind.LAZY, 1, Arrays.asList(serviceC.getName())));
+ registryA.add(new ServiceDescriptor(serviceC.getName(), ServiceStartKind.STARTUP, 1));
+
FakeService.getTrace().reset();
registryA.startNewServices();
-
-
+
+
// check services
// A and C should be started, B should not be started.
assertTrue("A started", registryA.isStarted(serviceA));
@@ -708,7 +721,7 @@ public class ServicesRegistryTest extends TestCase {
// Check if we can get them
assertNotNull("got service started", registryA.getService(serviceC));
assertNotNull("got service started", registryA.getService(serviceA));
-
+
// check creation order (C then A)
// order should be C, A
TestTrace trace = FakeService.getTrace();
@@ -725,7 +738,7 @@ public class ServicesRegistryTest extends TestCase {
// start B
assertNotNull("got service started", registryA.getService(serviceB));
assertTrue("B started", registryA.isStarted(serviceB));
-
+
}
@@ -733,54 +746,57 @@ public class ServicesRegistryTest extends TestCase {
/**
* Test the alias service.
+ *
* @throws ServiceException
*/
@Test
public void testAliasServices() throws ServiceException {
-
+
Class<?> serviceA = FakeServiceA.class;
Class<?> serviceB = FakeServiceB.class;
Class<?> serviceC = FakeServiceC.class;
-
+
String aliasService2 = "AnAlias";
-
+
// services A --> B
FakeService.getTrace().reset();
-
+
// Create an alias to B
ServicesRegistry registryA = new ServicesRegistry();
- registryA.add( new AliasDescriptor( serviceA.getName(), serviceB.getName(), 1) );
- registryA.add( new AliasDescriptor( aliasService2, serviceC.getName(), 1) );
- registryA.add( new ServiceDescriptor( serviceB, serviceB.getName(), ServiceStartKind.STARTUP, 1 ));
- registryA.add( new ServiceDescriptor( serviceC.getName(), ServiceStartKind.STARTUP, 1 ));
-
+ registryA.add(new AliasDescriptor(serviceA.getName(), serviceB.getName(), 1));
+ registryA.add(new AliasDescriptor(aliasService2, serviceC.getName(), 1));
+ registryA.add(new ServiceDescriptor(serviceB, serviceB.getName(), ServiceStartKind.STARTUP, 1));
+ registryA.add(new ServiceDescriptor(serviceC.getName(), ServiceStartKind.STARTUP, 1));
+
registryA.startNewServices();
-
-
+
+
// check services
assertNotNull("got service started", registryA.getService(serviceB));
assertNotNull("got service started", registryA.getService(serviceC));
assertNotNull("got service started", registryA.getService(serviceA));
assertNotNull("got service started", registryA.getService(aliasService2));
-
- assertEquals("Got the same service", registryA.getService(serviceA), registryA.getService(serviceB) );
- assertEquals("Got the same service", registryA.getService(serviceC), registryA.getService(aliasService2) );
-
+
+ assertEquals("Got the same service", registryA.getService(serviceA), registryA.getService(serviceB));
+ assertEquals("Got the same service", registryA.getService(serviceC), registryA.getService(aliasService2));
+
}
/**
* General purpose descriptor.
+ *
* @deprecated use {@link FakeServiceDescriptor}
*/
+ @Deprecated
public class ServiceDesc extends ServiceDescriptor {
- public ServiceDesc( String key, ServiceStartKind startKind) {
- super(key, FakeService.class.getName(), startKind, 1 );
+ public ServiceDesc(String key, ServiceStartKind startKind) {
+ super(key, FakeService.class.getName(), startKind, 1);
}
-
- public ServiceDesc( String key, ServiceStartKind startKind, List<String> requiredService) {
- super(key, FakeService.class.getName(), startKind, 1, requiredService );
+
+ public ServiceDesc(String key, ServiceStartKind startKind, List<String> requiredService) {
+ super(key, FakeService.class.getName(), startKind, 1, requiredService);
}
}
@@ -790,37 +806,39 @@ public class ServicesRegistryTest extends TestCase {
public class ServiceFactoryDesc extends ServiceDescriptor {
- public ServiceFactoryDesc( String key, ServiceStartKind startKind) {
- super(key, FakeServiceFactory.class.getName(), startKind, 1 );
+ public ServiceFactoryDesc(String key, ServiceStartKind startKind) {
+ super(key, FakeServiceFactory.class.getName(), startKind, 1);
setServiceTypeKind(ServiceTypeKind.serviceFactory);
}
-
- public ServiceFactoryDesc( String key, ServiceStartKind startKind, List<String> requiredService) {
- super(key, FakeServiceFactory.class.getName(), startKind, 1, requiredService );
+
+ public ServiceFactoryDesc(String key, ServiceStartKind startKind, List<String> requiredService) {
+ super(key, FakeServiceFactory.class.getName(), startKind, 1, requiredService);
setServiceTypeKind(ServiceTypeKind.serviceFactory);
}
+
/**
* Constructor with a classname and {@link ServiceDescriptor#isStartAtStartup()} = true.
* Constructor.
- *
+ *
* @param key
* @param startKind
* @param requiredService
*/
- public ServiceFactoryDesc( Class<?> key, String classname, ServiceStartKind startKind, List<String> requiredService) {
- super(key, classname, startKind, 1, requiredService );
+ public ServiceFactoryDesc(Class<?> key, String classname, ServiceStartKind startKind, List<String> requiredService) {
+ super(key, classname, startKind, 1, requiredService);
setServiceTypeKind(ServiceTypeKind.serviceFactory);
}
+
/**
* Constructor with a classname and {@link ServiceDescriptor#isStartAtStartup()} = true.
* Constructor.
- *
+ *
* @param key
* @param startKind
* @param requiredService
*/
- public ServiceFactoryDesc( Class<?> key, String classname, ServiceStartKind startKind) {
- super(key, classname, startKind, 1 );
+ public ServiceFactoryDesc(Class<?> key, String classname, ServiceStartKind startKind) {
+ super(key, classname, startKind, 1);
setServiceTypeKind(ServiceTypeKind.serviceFactory);
}
@@ -838,7 +856,7 @@ public class ServicesRegistryTest extends TestCase {
/**
*
* @author dumoulin
- *
+ *
*/
public class LazyServiceADescriptor extends ServiceDescriptor {

Back to the top