(no commit message)
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Fri, 28 Mar 2008 23:18:20 +0000 (23:18 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Fri, 28 Mar 2008 23:18:20 +0000 (23:18 +0000)
trunk/system/general/src/main/java/org/wamblee/system/ProvidedServiceDescriptor.java [new file with mode: 0644]
trunk/system/general/src/test/java/org/wamblee/system/DefaultServiceDescriptorTest.java [new file with mode: 0644]

diff --git a/trunk/system/general/src/main/java/org/wamblee/system/ProvidedServiceDescriptor.java b/trunk/system/general/src/main/java/org/wamblee/system/ProvidedServiceDescriptor.java
new file mode 100644 (file)
index 0000000..94eb43d
--- /dev/null
@@ -0,0 +1,7 @@
+package org.wamblee.system;
+
+import java.util.Collection;
+
+public interface ProvidedServiceDescriptor extends ServiceDescriptor {
+    // Empty
+}
diff --git a/trunk/system/general/src/test/java/org/wamblee/system/DefaultServiceDescriptorTest.java b/trunk/system/general/src/test/java/org/wamblee/system/DefaultServiceDescriptorTest.java
new file mode 100644 (file)
index 0000000..b222d28
--- /dev/null
@@ -0,0 +1,66 @@
+package org.wamblee.system;
+
+import java.io.Serializable;
+
+import junit.framework.TestCase;
+
+public class DefaultServiceDescriptorTest extends TestCase {
+
+       public void testOneRequiredOneProvidedMatch() { 
+               ProvidedServiceDescriptor provided = new DefaultProvidedServiceDescriptor("name", String.class);
+               RequiredServiceDescriptor required = new DefaultRequiredServiceDescriptor("name", String.class);
+               assertTrue(required.implementedBy(provided));
+       }
+       
+       public void testOneRequiredOneProvidedMatchSubClass() { 
+               ProvidedServiceDescriptor provided = new DefaultProvidedServiceDescriptor("name", Integer.class);
+               RequiredServiceDescriptor required = new DefaultRequiredServiceDescriptor("name", Number.class);
+               assertTrue(required.implementedBy(provided));
+       }
+       
+       public void testOneRequiredOneProvidedNoMatch() { 
+               ProvidedServiceDescriptor provided = new DefaultProvidedServiceDescriptor("name", String.class);
+               RequiredServiceDescriptor required = new DefaultRequiredServiceDescriptor("name", Number.class);
+               assertFalse(required.implementedBy(provided));
+       }
+       
+       public void testOneRequiredMultipleProvidedMatch() { 
+               ProvidedServiceDescriptor provided = new DefaultProvidedServiceDescriptor("name", 
+                               new Class[] { String.class, Integer.class} );
+               RequiredServiceDescriptor required = new DefaultRequiredServiceDescriptor("name", String.class);
+               assertTrue(required.implementedBy(provided));
+       }
+       
+       private static class MyMultiple implements Runnable, Serializable { 
+               @Override
+               public void run() {
+                       // Empty        
+               }
+       }
+       
+       public void testMultipleRequiredOneProvidedMatch() { 
+               ProvidedServiceDescriptor provided = new DefaultProvidedServiceDescriptor("name", 
+                               MyMultiple.class );
+               RequiredServiceDescriptor required = new DefaultRequiredServiceDescriptor("name", 
+                               new Class[] {Runnable.class, Serializable.class} );
+               assertTrue(required.implementedBy(provided));
+       }
+       
+       public void testMultipleRequiredOneProvidedNoMatch() { 
+               ProvidedServiceDescriptor provided = new DefaultProvidedServiceDescriptor("name", 
+                               MyMultiple.class );
+               RequiredServiceDescriptor required = new DefaultRequiredServiceDescriptor("name", 
+                               new Class[] { String.class, Runnable.class} );
+               assertFalse(required.implementedBy(provided));
+       }
+       
+       public void testMultipleRequiredMultipleProvidedMatch() { 
+               ProvidedServiceDescriptor provided = new DefaultProvidedServiceDescriptor("name", 
+                               new Class[] { Runnable.class, Serializable.class, String.class}  );
+               RequiredServiceDescriptor required = new DefaultRequiredServiceDescriptor("name", 
+                               new Class[] {Runnable.class, Serializable.class} );
+               assertTrue(required.implementedBy(provided));
+       }
+       
+       
+}