Add a method to check if a value is contained in an array. This method is used because sometimes the service interface arrays not have always the same order (depending on the VM). So, this allow to launch the test suites on any VM.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@647984 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/core/ComponentDesc.java b/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/core/ComponentDesc.java
index df3d25a..ec4fef9 100644
--- a/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/core/ComponentDesc.java
+++ b/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/core/ComponentDesc.java
@@ -304,8 +304,8 @@
 		

 		String[] specs = (String[]) sr_foobarProvider.getProperty("component.providedServiceSpecifications");

 		assertEquals("Check component.providedServiceSpecifications length", specs.length, 2);

-		assertEquals("Check component.providedServiceSpecifications 1", FooService.class.getName(), specs[1]);

-		assertEquals("Check component.providedServiceSpecifications 2", BarService.class.getName(), specs[0]);

+		assertTrue("Check component.providedServiceSpecifications 1", Utils.contains(FooService.class.getName(), specs));

+		assertTrue("Check component.providedServiceSpecifications 2", Utils.contains(BarService.class.getName(), specs));

 		

 		PropertyDescription[] pd = (PropertyDescription[]) sr_foobarProvider.getProperty("component.properties");

 		assertEquals("Check component.properties length", pd.length, 0);

@@ -318,8 +318,8 @@
 		

         Element[] specs2 = cd.getElements("provides");

         assertEquals("Check specs length", specs2.length, 2);

-        assertEquals("Check specs", FooService.class.getName(), specs2[1].getAttribute("specification"));

-        assertEquals("Check specs", BarService.class.getName(), specs2[0].getAttribute("specification"));

+        assertTrue("Check specs", containsSpecification(FooService.class.getName(), specs2));

+        assertTrue("Check specs", containsSpecification(BarService.class.getName(), specs2));

         

         Element[] pd2 = cd.getElements("property");

         assertNull("Check props null", pd2);

@@ -330,6 +330,15 @@
 

 	}

 	

+	private boolean containsSpecification(String value, Element[] array) {

+	    for (int i = 0; array != null && i < array.length; i++) {

+            if (array[i] != null && array[i].containsAttribute("specification") && array[i].getAttribute("specification").equals(value)) {

+                return true;

+            }

+        }

+        return false;

+	}

+	

 	

 	

 

diff --git a/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
index 2f8b5e5..cb87c86 100644
--- a/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ b/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
@@ -304,5 +304,23 @@
             return new Object[0];

         }

     }

+    

+    public static boolean contains(String string, String[] array) {

+        for (int i = 0; array != null && i < array.length; i++) {

+            if (array[i] != null  && array[i].equals(string)) {

+                return true;

+            }

+        }

+        return false;

+    }

+    

+    public static boolean contains(int value, int[] array) {

+        for (int i = 0; array != null && i < array.length; i++) {

+            if (array[i] == value) {

+                return true;

+            }

+        }

+        return false;

+    }

 

 }