felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1565829 - /felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ComponentTest.java
Date Fri, 07 Feb 2014 22:12:08 GMT
Author: marrs
Date: Fri Feb  7 22:12:07 2014
New Revision: 1565829

URL: http://svn.apache.org/r1565829
Log:
Added more explanations in asserts.

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

Modified: felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ComponentTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ComponentTest.java?rev=1565829&r1=1565828&r2=1565829&view=diff
==============================================================================
--- felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ComponentTest.java (original)
+++ felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ComponentTest.java Fri Feb
 7 22:12:07 2014
@@ -21,6 +21,7 @@ public class ComponentTest {
 		c.stop();
 		Assert.assertEquals("should no longer be available when stopped", false, c.isAvailable());
 	}
+	
 	@Test
 	public void createComponentAddDependencyAndStartComponent() {
 		Component c = new ComponentImpl();
@@ -31,6 +32,7 @@ public class ComponentTest {
 		c.stop();
 		c.remove(d);
 	}
+	
 	@Test
 	public void createComponentStartItAndAddDependency() {
 		Component c = new ComponentImpl();
@@ -43,6 +45,7 @@ public class ComponentTest {
 		c.remove(d);
 		c.stop();
 	}
+	
 	@Test
 	public void createComponentStartItAddDependencyAndMakeDependencyAvailable() {
 		Component c = new ComponentImpl();
@@ -59,6 +62,7 @@ public class ComponentTest {
 		c.stop();
 		Assert.assertEquals("component is stopped, should be unavailable now", false, c.isAvailable());
 	}
+	
 	@Test
 	public void createComponentStartItAddDependencyAndListenerMakeDependencyAvailableAndUnavailableImmediately()
{
 		Component c = new ComponentImpl();
@@ -66,22 +70,28 @@ public class ComponentTest {
 		ComponentStateListener l = new ComponentStateListener() {
 			@Override
 			public void changed(State state) {
+				// make the dependency unavailable
 				d.changed(new EventImpl(false));
 			}
 		};
 		c.start();
 		c.add(d);
+		// we add a listener here which immediately triggers an 'external event' that
+		// makes the dependency unavailable again as soon as it's invoked
 		c.add(l);
-		Assert.assertEquals(false, c.isAvailable());
+		Assert.assertEquals("component unavailable, dependency unavailable", false, c.isAvailable());
+		// so even though we make the dependency available here, before our call returns it
+		// is made unavailable again
 		d.changed(new EventImpl(true));
-		Assert.assertEquals(false, c.isAvailable());
+		Assert.assertEquals("component *still* unavailable, because the listener immediately makes
the dependency unavailable", false, c.isAvailable());
 		c.remove(l);
-		Assert.assertEquals(false, c.isAvailable());
+		Assert.assertEquals("listener removed, component still unavailable", false, c.isAvailable());
 		c.remove(d);
-		Assert.assertEquals(true, c.isAvailable());
+		Assert.assertEquals("dependency removed, component available", true, c.isAvailable());
 		c.stop();
-		Assert.assertEquals(false, c.isAvailable());
+		Assert.assertEquals("component stopped, should be unavailable", false, c.isAvailable());
 	}
+	
 	@Test
 	public void createComponentAddTwoDependenciesMakeBothAvailableAndUnavailable() {
 		Component c = new ComponentImpl();
@@ -90,20 +100,20 @@ public class ComponentTest {
 		c.start();
 		c.add(d1);
 		c.add(d2);
-		Assert.assertEquals(false, c.isAvailable());
+		Assert.assertEquals("component should be unavailable, both dependencies are too", false,
c.isAvailable());
 		d1.changed(new EventImpl(true));
-		Assert.assertEquals(false, c.isAvailable());
+		Assert.assertEquals("one dependency available, component should still be unavailable",
false, c.isAvailable());
 		d2.changed(new EventImpl(true));
-		Assert.assertEquals(true, c.isAvailable());
+		Assert.assertEquals("both dependencies available, component should be available", true,
c.isAvailable());
 		d1.changed(new EventImpl(false));
-		Assert.assertEquals(false, c.isAvailable());
+		Assert.assertEquals("one dependency unavailable again, component should be unavailable
too", false, c.isAvailable());
 		d2.changed(new EventImpl(false));
-		Assert.assertEquals(false, c.isAvailable());
+		Assert.assertEquals("both dependencies unavailable, component should be too", false, c.isAvailable());
 		c.remove(d2);
-		Assert.assertEquals(false, c.isAvailable());
+		Assert.assertEquals("removed one dependency, still unavailable", false, c.isAvailable());
 		c.remove(d1);
-		Assert.assertEquals(true, c.isAvailable());
+		Assert.assertEquals("removed the other dependency, component should be available now",
true, c.isAvailable());
 		c.stop();
-		Assert.assertEquals(false, c.isAvailable());
+		Assert.assertEquals("component stopped, should be unavailable again", false, c.isAvailable());
 	}
 }



Mime
View raw message