Refactor tests
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1479345 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceConfigurableProperties.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceConfigurableProperties.java
index 7bb4b7f..7a07108 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceConfigurableProperties.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManagedServiceConfigurableProperties.java
@@ -43,7 +43,6 @@
public class TestManagedServiceConfigurableProperties extends Common {
-
/**
* Instance where the ManagedServicePID is provided by the component type.
*/
@@ -58,15 +57,8 @@
*/
ComponentInstance instance3;
-
-
@Before
public void setUp() {
- osgiHelper = new OSGiHelper(bc);
- ipojoHelper = new IPOJOHelper(bc);
-
- cleanupConfigurationAdmin();
-
String type = "CONFIG-FooProviderType-4";
Hashtable<String, String> p = new Hashtable<String, String>();
p.put("instance.name", "instance");
@@ -102,22 +94,6 @@
instance3 = null;
}
- private void cleanupConfigurationAdmin() {
- ConfigurationAdmin admin = (ConfigurationAdmin) osgiHelper.getServiceObject(ConfigurationAdmin.class.getName
- (), null);
- assertNotNull("Check configuration admin availability", admin);
- try {
- Configuration[] configurations = admin.listConfigurations(null);
- for (int i = 0; configurations != null && i < configurations.length; i++) {
- configurations[i].delete();
- }
- } catch (IOException e) {
- e.printStackTrace();
- } catch (InvalidSyntaxException e) {
- e.printStackTrace();
- }
- }
-
@Test
public void testStaticInstance1() {
ServiceReference fooRef = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), instance1.getInstanceName());
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestMethodProperties.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestMethodProperties.java
index 42b32d8..f57f256 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestMethodProperties.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestMethodProperties.java
@@ -46,8 +46,6 @@
@Before
public void setUp() {
- osgiHelper = new OSGiHelper(bc);
- ipojoHelper = new IPOJOHelper(bc);
Factory fact = ipojoHelper.getFactory("CONFIG-MethodConfigurableCheckService");
Properties props = new Properties();
props.put("instance.name", "under-test");
@@ -116,8 +114,6 @@
@After
public void tearDown() {
- ipojoHelper.dispose();
- osgiHelper.dispose();
instance.dispose();
instance2.dispose();
instance3.dispose();
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSimpleProperties.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSimpleProperties.java
index e8f2d00..0982b00 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSimpleProperties.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSimpleProperties.java
@@ -41,12 +41,8 @@
ComponentInstance fooProvider2;
ComponentInstance fooProvider3;
-
-
@Before
public void setUp() {
- osgiHelper = new OSGiHelper(bc);
- ipojoHelper = new IPOJOHelper(bc);
String type = "CONFIG-FooProviderType-Conf";
Hashtable<String, String> p1 = new Hashtable<String, String>();
@@ -60,7 +56,7 @@
p2.put("string", new String("bar"));
p2.put("strAProp", new String[]{"bar", "foo"});
p2.put("intAProp", new int[]{1, 2, 3});
- fooProvider2 = ipojoHelper.createComponentInstance(bc.getBundle(), type, p2);
+ fooProvider2 = ipojoHelper.createComponentInstance(type, p2);
Hashtable<String, String> p3 = new Hashtable<String, String>();
p3.put("instance.name", "FooProvider-3");
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSuperMethodProperties.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSuperMethodProperties.java
index 7d873a9..4e94aea 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSuperMethodProperties.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSuperMethodProperties.java
@@ -35,16 +35,10 @@
public class TestSuperMethodProperties extends Common {
-
-
ComponentInstance instance;
-
-
@Before
public void setUp() {
- osgiHelper = new OSGiHelper(bc);
- ipojoHelper = new IPOJOHelper(bc);
Factory fact = ipojoHelper.getFactory("CONFIG-ParentMethodConfigurableCheckService");
Properties props = new Properties();
props.put("instance.name", "under-test");
@@ -78,7 +72,6 @@
@After
public void tearDown() {
-
instance.dispose();
instance = null;
}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethod.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethod.java
index f89047d..916a721 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethod.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethod.java
@@ -37,18 +37,12 @@
public class TestUpdatedMethod extends Common {
-
-
ComponentInstance fooProvider1;
ComponentInstance fooProvider2;
ComponentInstance fooProvider3;
-
-
@Before
public void setUp() {
- osgiHelper = new OSGiHelper(bc);
- ipojoHelper = new IPOJOHelper(bc);
String type = "CONFIG-FooProviderType-ConfUpdated";
Hashtable<String, String> p1 = new Hashtable<String, String>();
@@ -57,12 +51,12 @@
Properties p2 = new Properties();
p2.put("instance.name", "FooProvider-2");
- p2.put("int", new Integer(4));
- p2.put("boolean", new Boolean(false));
- p2.put("string", new String("bar"));
+ p2.put("int", 4);
+ p2.put("boolean", false);
+ p2.put("string", "bar");
p2.put("strAProp", new String[]{"bar", "foo"});
p2.put("intAProp", new int[]{1, 2, 3});
- fooProvider2 = ipojoHelper.createComponentInstance(bc.getBundle(), type, p2);
+ fooProvider2 = ipojoHelper.createComponentInstance(type, p2);
Hashtable<String, String> p3 = new Hashtable<String, String>();
p3.put("instance.name", "FooProvider-3");
@@ -71,7 +65,6 @@
@After
public void tearDown() {
-
fooProvider1.dispose();
fooProvider2.dispose();
fooProvider3.dispose();
@@ -98,8 +91,8 @@
Dictionary dict = (Dictionary) toCheck.get("lastupdated");
assertEquals("Check intProp equality (1)", intProp, new Integer(2));
- assertEquals("Check longProp equality (1)", boolProp, new Boolean(false));
- assertEquals("Check strProp equality (1)", strProp, new String("foo"));
+ assertEquals("Check longProp equality (1)", boolProp, false);
+ assertEquals("Check strProp equality (1)", strProp, "foo");
assertNotNull("Check strAProp not nullity (1)", strAProp);
String[] v = new String[]{"foo", "bar"};
for (int i = 0; i < strAProp.length; i++) {
@@ -135,8 +128,8 @@
dict = (Dictionary) toCheck.get("lastupdated");
assertEquals("Check intProp equality (2) (" + intProp + ")", intProp, new Integer(3));
- assertEquals("Check longProp equality (2)", boolProp, new Boolean(true));
- assertEquals("Check strProp equality (2)", strProp, new String("bar"));
+ assertEquals("Check longProp equality (2)", boolProp, true);
+ assertEquals("Check strProp equality (2)", strProp, "bar");
assertNotNull("Check strAProp not nullity (2)", strAProp);
v = new String[]{"foo", "bar", "baz"};
for (int i = 0; i < strAProp.length; i++) {
@@ -179,7 +172,7 @@
Dictionary dict = (Dictionary) toCheck.get("lastupdated");
assertEquals("Check intProp equality", intProp, new Integer(0));
- assertEquals("Check longProp equality", boolProp, new Boolean(false));
+ assertEquals("Check longProp equality", boolProp, false);
assertEquals("Check strProp equality", strProp, null);
assertNull("Check strAProp nullity", strAProp);
assertNull("Check intAProp nullity", intAProp);
@@ -201,8 +194,8 @@
dict = (Dictionary) toCheck.get("lastupdated");
assertEquals("Check intProp equality", intProp, new Integer(3));
- assertEquals("Check longProp equality", boolProp, new Boolean(true));
- assertEquals("Check strProp equality", strProp, new String("bar"));
+ assertEquals("Check longProp equality", boolProp, true);
+ assertEquals("Check strProp equality", strProp, "bar");
assertNotNull("Check strAProp not nullity", strAProp);
String[] v = new String[]{"foo", "bar", "baz"};
for (int i = 0; i < strAProp.length; i++) {
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethodAndConfigAdmin.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethodAndConfigAdmin.java
index a2cf1e0..58f2cfc 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethodAndConfigAdmin.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethodAndConfigAdmin.java
@@ -51,11 +51,6 @@
@Before
public void setUp() {
- osgiHelper = new OSGiHelper(bc);
- ipojoHelper = new IPOJOHelper(bc);
-
- cleanupConfigurationAdmin();
-
String type = "CONFIG-FooProviderType-3Updated";
Hashtable<String, String> p1 = new Hashtable<String, String>();
@@ -73,29 +68,12 @@
@After
public void tearDown() {
-
instance.dispose();
instance2.dispose();
instance2 = null;
instance = null;
}
- private void cleanupConfigurationAdmin() {
- ConfigurationAdmin admin = (ConfigurationAdmin) osgiHelper.getServiceObject(ConfigurationAdmin.class.getName
- (), null);
- assertNotNull("Check configuration admin availability", admin);
- try {
- Configuration[] configurations = admin.listConfigurations(null);
- for (int i = 0; configurations != null && i < configurations.length; i++) {
- configurations[i].delete();
- }
- } catch (IOException e) {
- e.printStackTrace();
- } catch (InvalidSyntaxException e) {
- e.printStackTrace();
- }
- }
-
@Test
public void testStatic() throws IOException, InterruptedException {
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethodAndManagedService.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethodAndManagedService.java
index f58ac8c..6063eac 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethodAndManagedService.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedMethodAndManagedService.java
@@ -57,8 +57,6 @@
@ExamReactorStrategy(PerMethod.class)
public class TestUpdatedMethodAndManagedService extends Common {
-
-
/**
* Instance where the ManagedServicePID is provided by the component type.
*/
@@ -100,7 +98,7 @@
p1.put("foo", "foo");
p1.put("bar", "2");
p1.put("baz", "baz");
- p1.put("managed.service.pid", "instance");
+ p1.put("managed.service.pid", "instance-managed-service");
instance2 = ipojoHelper.createComponentInstance(type, p1);
type = "CONFIG-FooProviderType-3Updated";
@@ -185,7 +183,7 @@
assertEquals("Check baz equality -1", bazP, "baz");
ServiceReference msRef = osgiHelper.getServiceReferenceByPID(ManagedService.class.getName(),
- "instance");
+ "instance-managed-service");
assertNotNull("Check ManagedService availability", msRef);
@@ -319,7 +317,8 @@
assertEquals("Check bar equality", barP, new Integer(2));
assertEquals("Check baz equality", bazP, "baz");
- ServiceReference msRef = osgiHelper.getServiceReferenceByPID(ManagedService.class.getName(), "instance");
+ ServiceReference msRef = osgiHelper.getServiceReferenceByPID(ManagedService.class.getName(),
+ "instance-managed-service");
assertNotNull("Check ManagedServiceFactory availability", msRef);
// Configuration of baz
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndConfigAdmin.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndConfigAdmin.java
index 986c40c..46d588d 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndConfigAdmin.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndConfigAdmin.java
@@ -45,17 +45,10 @@
@ExamReactorStrategy(PerMethod.class)
public class TestUpdatedNoArgMethodAndConfigAdmin extends Common {
-
-
ComponentInstance instance, instance2;
-
-
@Before
public void setUp() {
- osgiHelper = new OSGiHelper(bc);
- ipojoHelper = new IPOJOHelper(bc);
- cleanupConfigurationAdmin();
String type = "CONFIG-FooProviderType-3Updated2";
Hashtable<String, String> p1 = new Hashtable<String, String>();
@@ -79,22 +72,6 @@
instance = null;
}
- private void cleanupConfigurationAdmin() {
- ConfigurationAdmin admin = (ConfigurationAdmin) osgiHelper.getServiceObject(ConfigurationAdmin.class.getName
- (), null);
- Assert.assertNotNull("Check configuration admin availability", admin);
- try {
- Configuration[] configurations = admin.listConfigurations(null);
- for (int i = 0; configurations != null && i < configurations.length; i++) {
- configurations[i].delete();
- }
- } catch (IOException e) {
- e.printStackTrace();
- } catch (InvalidSyntaxException e) {
- e.printStackTrace();
- }
- }
-
@Test
public void testStatic() throws IOException, InterruptedException {
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndManagedService.java b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndManagedService.java
index 2bb65e5..bc346fd 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndManagedService.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-configuration-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestUpdatedNoArgMethodAndManagedService.java
@@ -57,15 +57,8 @@
*/
ComponentInstance instance3;
-
-
@Before
public void setUp() {
- osgiHelper = new OSGiHelper(bc);
- ipojoHelper = new IPOJOHelper(bc);
-
- cleanupConfigurationAdmin();
-
String type = "CONFIG-FooProviderType-4Updated2";
Hashtable<String, String> p = new Hashtable<String, String>();
p.put("instance.name", "any-instance");
@@ -101,22 +94,6 @@
instance3 = null;
}
- private void cleanupConfigurationAdmin() {
- ConfigurationAdmin admin = (ConfigurationAdmin) osgiHelper.getServiceObject(ConfigurationAdmin.class.getName
- (), null);
- assertNotNull("Check configuration admin availability", admin);
- try {
- Configuration[] configurations = admin.listConfigurations(null);
- for (int i = 0; configurations != null && i < configurations.length; i++) {
- configurations[i].delete();
- }
- } catch (IOException e) {
- e.printStackTrace();
- } catch (InvalidSyntaxException e) {
- e.printStackTrace();
- }
- }
-
@Test
public void testStaticInstance1() {
ServiceReference fooRef = osgiHelper.waitForService(FooService.class.getName(),