felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1572347 - /felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ComponentTest.java
Date Wed, 26 Feb 2014 23:31:49 GMT
Author: pderop
Date: Wed Feb 26 23:31:49 2014
New Revision: 1572347

URL: http://svn.apache.org/r1572347
Log:
Added createDependenciesWithCallbackInstance test

Modified:
    felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ComponentTest.java

Modified: felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ComponentTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ComponentTest.java?rev=1572347&r1=1572346&r2=1572347&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ComponentTest.java (original)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ComponentTest.java Wed Feb
26 23:31:49 2014
@@ -593,4 +593,47 @@ public class ComponentTest {
 		c.remove(d);
 		Assert.assertEquals("Component stopped, should be unavailable", false, c.isAvailable());
 	}
+	
+	@Test
+	public void createDependenciesWithCallbackInstance() {
+		final Ensure e = new Ensure();
+		ComponentImpl c = new ComponentImpl();
+		c.setImplementation(new Object() {
+			void start() {
+				e.step(2);
+			}
+			
+			void stop() {
+				e.step(4);
+			}
+		});
+		
+		Object callbackInstance = new Object() {
+			void add() {
+				e.step(1);
+			}
+			
+			void remove() {
+				e.step(5);
+			}
+		};		
+		
+		DependencyImpl d = new DependencyImpl();
+		d.setCallbacks(callbackInstance, "add", "remove");
+		d.setRequired(true);
+		// add the dependency to the component
+		c.add(d);
+		// start the component
+		c.start();
+		// make the dependency available, we expect the add callback
+		// to be invoked here, then start is called.
+		d.add(new EventImpl());
+		e.step(3);
+		// remove the dependency, should trigger the stop, then remove callback
+		d.remove(new EventImpl());
+		e.step(6);
+		c.stop();
+		c.remove(d);
+		Assert.assertEquals("Component stopped, should be unavailable", false, c.isAvailable());
+	}
 }



Mime
View raw message