Revision: 1147
Author:   lstreepy
Date:     2006-05-11 12:17:10 -0700 (Thu, 11 May 2006)
ViewCVS:  http://svn.sourceforge.net/spring-rich-c/?rev=1147&view=rev

Log Message:
-----------
Initial tests for DefaultApplicationServices

Added Paths:
-----------
    
trunk/spring-richclient/support/src/test/java/org/springframework/richclient/application/support/DefaultApplicationServicesTest.java
Added: 
trunk/spring-richclient/support/src/test/java/org/springframework/richclient/application/support/DefaultApplicationServicesTest.java
===================================================================
--- 
trunk/spring-richclient/support/src/test/java/org/springframework/richclient/application/support/DefaultApplicationServicesTest.java
                                (rev 0)
+++ 
trunk/spring-richclient/support/src/test/java/org/springframework/richclient/application/support/DefaultApplicationServicesTest.java
        2006-05-11 19:17:10 UTC (rev 1147)
@@ -0,0 +1,61 @@
+package org.springframework.richclient.application.support;
+
+import java.util.HashMap;
+
+import org.springframework.binding.value.ValueChangeDetector;
+import org.springframework.binding.value.support.DefaultValueChangeDetector;
+import org.springframework.context.MessageSource;
+import org.springframework.context.support.StaticMessageSource;
+import org.springframework.richclient.image.IconSource;
+import org.springframework.richclient.test.SpringRichTestCase;
+import org.springframework.rules.RulesSource;
+
+/**
+ * Test cases for [EMAIL PROTECTED] DefaultApplicationServices}
+ * 
+ * @author Larry Streepy
+ * 
+ */
+public class DefaultApplicationServicesTest extends SpringRichTestCase {
+
+    public void testRegisteredServiceIsReturned() {
+        ValueChangeDetector vcd = new DefaultValueChangeDetector();
+        getApplicationServices().setValueChangeDetector(vcd);
+        assertSame("Expected same object back", vcd, 
getApplicationServices().getService(ValueChangeDetector.class));
+
+        MessageSource msrc = new StaticMessageSource();
+        getApplicationServices().setMessageSource(msrc);
+        assertSame("Expected same object back", msrc, 
getApplicationServices().getService(MessageSource.class));
+    }
+
+    public void testUnknownServiceFails() {
+        try {
+            getApplicationServices().getService(getClass());
+            fail("Unknown service should have caused an exception");
+        } catch( UnsupportedOperationException e ) {
+            ; // expected
+        }
+    }
+
+    public void testSetRegistryEntries() {
+        ValueChangeDetector vcd = new DefaultValueChangeDetector();
+        MessageSource msrc = new StaticMessageSource();
+
+        HashMap entries = new HashMap();
+        entries.put("org.springframework.binding.value.ValueChangeDetector", 
vcd);
+        entries.put("org.springframework.context.MessageSource", msrc);
+
+        getApplicationServices().setRegistryEntries(entries);
+
+        assertSame("Expected same object back", vcd, 
getApplicationServices().getService(ValueChangeDetector.class));
+        assertSame("Expected same object back", msrc, 
getApplicationServices().getService(MessageSource.class));
+    }
+
+    public void testDefaultServicesImplementInterface() {
+        Object rulesSource = 
getApplicationServices().getService(RulesSource.class);
+        assertTrue("Returned service must implement service type", rulesSource 
instanceof RulesSource);
+
+        Object iconSource = 
getApplicationServices().getService(IconSource.class);
+        assertTrue("Returned service must implement service type", iconSource 
instanceof IconSource);
+    }
+}


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
spring-rich-c-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to