felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1567991 - /felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ComponentTest.java
Date Thu, 13 Feb 2014 18:10:38 GMT
Author: marrs
Date: Thu Feb 13 18:10:38 2014
New Revision: 1567991

URL: http://svn.apache.org/r1567991
Log:
Added another test with optional dependencies.

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=1567991&r1=1567990&r2=1567991&view=diff
==============================================================================
--- felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ComponentTest.java (original)
+++ felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ComponentTest.java Thu Feb
13 18:10:38 2014
@@ -473,4 +473,49 @@ public class ComponentTest {
 		c.remove(d1);
 		Assert.assertEquals("component stopped, should be unavailable again", false, c.isAvailable());
 	}
+
+	@Test
+	public void createComponentWithOptionalAndRequiredDependency() {
+		final Ensure e = new Ensure();
+		Component c = new ComponentImpl();
+		c.setImplementation(new Object() {
+			public void add() {
+				e.step();
+			}
+			public void remove() {
+				e.step(5);
+			}
+		});
+		Dependency d1 = new DependencyImpl();
+		d1.setCallbacks("add", "remove");
+		d1.setRequired(false);
+		Dependency d2 = new DependencyImpl();
+		d2.setCallbacks("add", "remove");
+		d2.setRequired(true);
+		// add the dependencies to the component
+		c.add(d1);
+		c.add(d2);
+		// start the component
+		c.start();
+		Assert.assertEquals("component started with a required and optional dependency, should
not be available", false, c.isAvailable());
+		// make the optional dependency available
+		d1.add(new EventImpl());
+		e.step(1);
+		Assert.assertEquals("component should not be available", false, c.isAvailable());
+		// make the required dependency available
+		d2.add(new EventImpl());
+		e.step(4);
+		Assert.assertEquals("component should be available", true, c.isAvailable());
+		// remove the optional dependency
+		d1.remove(new EventImpl());
+		e.step(6);
+		Assert.assertEquals("component should be available", true, c.isAvailable());
+		// remove the required dependency
+		d1.remove(new EventImpl());
+		e.step(8);
+		Assert.assertEquals("component should be available", true, c.isAvailable());
+		c.stop();
+		c.remove(d1);
+		Assert.assertEquals("component stopped, should be unavailable again", false, c.isAvailable());
+	}
 }



Mime
View raw message