You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2010/05/06 08:48:05 UTC

svn commit: r941589 - in /felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios: component/FooProviderWithAnonymousClass.java ps/PropertiesInAnonymousClassTest.java

Author: clement
Date: Thu May  6 06:48:05 2010
New Revision: 941589

URL: http://svn.apache.org/viewvc?rev=941589&view=rev
Log:
Try to reproduce FELIX-2296, the configuration seems to work correctly.

Modified:
    felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderWithAnonymousClass.java
    felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/PropertiesInAnonymousClassTest.java

Modified: felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderWithAnonymousClass.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderWithAnonymousClass.java?rev=941589&r1=941588&r2=941589&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderWithAnonymousClass.java (original)
+++ felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderWithAnonymousClass.java Thu May  6 06:48:05 2010
@@ -20,6 +20,8 @@ package org.apache.felix.ipojo.test.scen
 
 import java.util.Properties;
 
+import javax.swing.SwingUtilities;
+
 import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
 
 public class FooProviderWithAnonymousClass implements FooService {
@@ -62,7 +64,26 @@ public class FooProviderWithAnonymousCla
 		return p;
 	}
 
-	public boolean getBoolean() { return true; }
+	public boolean getBoolean() {
+		SwingUtilities.invokeLater(new Runnable() {
+			public void run() {
+				intProp = 3;
+				boolProp = true;
+				if(strProp.equals("foo")) { strProp = "bar"; }
+				else { strProp = "foo"; }
+				strAProp = new String[] {"foo", "bar", "baz"};
+				intAProp = new int[] {3, 2, 1};
+			}
+		});
+
+		try {
+			Thread.sleep(500);
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+
+		return true;
+	}
 
 	public double getDouble() { return 1.0; }
 

Modified: felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/PropertiesInAnonymousClassTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/PropertiesInAnonymousClassTest.java?rev=941589&r1=941588&r2=941589&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/PropertiesInAnonymousClassTest.java (original)
+++ felix/trunk/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/PropertiesInAnonymousClassTest.java Thu May  6 06:48:05 2010
@@ -20,7 +20,7 @@ public class PropertiesInAnonymousClassT
 		helper.dispose();
 	}
 
-	public void testProperties1() {
+	public void testRunnable() {
 		ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProviderAno-1");
 		assertNotNull("Check the availability of the FS service", sr);
 
@@ -74,4 +74,58 @@ public class PropertiesInAnonymousClassT
 		fs = null;
 	}
 
+	public void testSwingWorker() {
+		ServiceReference sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProviderAno-1");
+		assertNotNull("Check the availability of the FS service", sr);
+
+		// Check service properties
+		Integer intProp = (Integer) sr.getProperty("int");
+		Boolean boolProp = (Boolean) sr.getProperty("boolean");
+		String strProp = (String) sr.getProperty("string");
+		String[] strAProp = (String[]) sr.getProperty("strAProp");
+		int[] intAProp = (int[]) sr.getProperty("intAProp");
+
+		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"));
+		assertNotNull("Check strAProp not nullity (1)", strAProp);
+		String[] v = new String[] {"foo", "bar"};
+		for (int i = 0; i < strAProp.length; i++) {
+			if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality (1)"); }
+		}
+		assertNotNull("Check intAProp not nullity", intAProp);
+		int[] v2 = new int[] {1, 2, 3};
+		for (int i = 0; i < intAProp.length; i++) {
+			if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality (1)"); }
+		}
+
+		// Invoke
+		FooService fs = (FooService) getServiceObject(sr);
+		assertTrue("invoke fs", fs.getBoolean());
+
+		sr = helper.getServiceReferenceByName(FooService.class.getName(), "FooProviderAno-1");
+		// Re-check the property (change)
+		intProp = (Integer) sr.getProperty("int");
+		boolProp = (Boolean) sr.getProperty("boolean");
+		strProp = (String) sr.getProperty("string");
+		strAProp = (String[]) sr.getProperty("strAProp");
+		intAProp = (int[]) sr.getProperty("intAProp");
+
+		assertEquals("Check intProp equality (2)", intProp, new Integer(3));
+		assertEquals("Check longProp equality (2)", boolProp, new Boolean(true));
+		assertEquals("Check strProp equality (2)", strProp, new String("bar"));
+		assertNotNull("Check strAProp not nullity (2)", strAProp);
+		v = new String[] {"foo", "bar", "baz"};
+		for (int i = 0; i < strAProp.length; i++) {
+			if(!strAProp[i].equals(v[i])) { fail("Check the strAProp Equality (2)"); }
+		}
+		assertNotNull("Check intAProp not nullity (2)", intAProp);
+		v2 = new int[] {3, 2, 1};
+		for (int i = 0; i < intAProp.length; i++) {
+			if(intAProp[i] != v2[i]) { fail("Check the intAProp Equality (2)"); }
+		}
+
+		fs = null;
+	}
+
 }