felix-commits mailing list archives

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

URL: http://svn.apache.org/r1572320
Log:
- Fixed testAddAvailableDependencyFromInitCallback, which seems to be using a wrong step in
the 'destroy' callback.
So far, we did not see the problem, because component's lifecyce callbacks exceptions were
not logged. Now they are.
- Same fix for the createComponentWithOptionalAndRequiredDependency: remove can be called
multiple times.
- Added new "createComponentAddAvailableDependencyRemoveDependencyCheckStopCalledBeforeUnbind"
test, which reproduces
a problem we had in the DependencyImpl.removeDependency() method.

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=1572320&r1=1572319&r2=1572320&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 22:48:52 2014
@@ -110,7 +110,7 @@ public class ComponentTest {
 			}
 			void destroy() {
 				System.out.println("destroy");
-				e.step(7);
+				e.step(9);
 			}
 		});
 		e.step(1);
@@ -521,7 +521,7 @@ public class ComponentTest {
 				e.step();
 			}
 			public void remove() {
-				e.step(5);
+				e.step();
 			}
 		});
 		DependencyImpl d1 = new DependencyImpl();
@@ -556,4 +556,41 @@ public class ComponentTest {
 		c.remove(d1);
 		Assert.assertEquals("Component stopped, should be unavailable again", false, c.isAvailable());
 	}
+	
+	@Test
+	public void createComponentAddAvailableDependencyRemoveDependencyCheckStopCalledBeforeUnbind()
{
+		final Ensure e = new Ensure();
+		ComponentImpl c = new ComponentImpl();
+		c.setImplementation(new Object() {
+			void add() {
+				e.step(1);
+			}
+			void start() {
+				e.step(2);
+			}
+			void stop() {
+				e.step(4);
+			}
+			void remove() {
+				e.step(5);
+			}
+		});
+		DependencyImpl d = new DependencyImpl();
+		d.setCallbacks("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