Revision: 1222
Author:   anodos
Date:     2006-07-12 10:57:17 -0700 (Wed, 12 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/spring-rich-c/?rev=1222&view=rev

Log Message:
-----------
- Fixes RCP-383, "DefaultApplicationWindow.removePageListener will always fail 
with IllegalArgumentException."
- Added DefaultApplicationWindowTests, which contains only the single 
regression test for RCP-383 at the moment.
- Added createApplicationLifecycleAdvisor method to SpringRichTestCase, which a 
subclass can override to provide a custom ApplicationLifecycleAdvisor for its 
tests.  This was necessary for the new DefaultApplicationWindowTests.

Modified Paths:
--------------
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/DefaultApplicationWindow.java
    
trunk/spring-richclient/support/src/test/java/org/springframework/richclient/test/SpringRichTestCase.java

Added Paths:
-----------
    
trunk/spring-richclient/support/src/test/java/org/springframework/richclient/application/support/DefaultApplicationWindowTests.java
Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/DefaultApplicationWindow.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/DefaultApplicationWindow.java
      2006-07-12 12:33:39 UTC (rev 1221)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/DefaultApplicationWindow.java
      2006-07-12 17:57:17 UTC (rev 1222)
@@ -341,7 +341,7 @@
     }
 
     public void removePageListener(PageListener listener) {
-        this.pageListeners.remove(PageListener.class);
+        this.pageListeners.remove(listener);
     }
 
     public boolean close() {

Added: 
trunk/spring-richclient/support/src/test/java/org/springframework/richclient/application/support/DefaultApplicationWindowTests.java
===================================================================
--- 
trunk/spring-richclient/support/src/test/java/org/springframework/richclient/application/support/DefaultApplicationWindowTests.java
                         (rev 0)
+++ 
trunk/spring-richclient/support/src/test/java/org/springframework/richclient/application/support/DefaultApplicationWindowTests.java
 2006-07-12 17:57:17 UTC (rev 1222)
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2002-2004 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy 
of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.springframework.richclient.application.support;
+
+import static org.easymock.EasyMock.*;
+
+import org.springframework.richclient.test.SpringRichTestCase;
+import org.springframework.richclient.application.PageListener;
+import org.springframework.richclient.application.ApplicationWindow;
+import 
org.springframework.richclient.application.config.ApplicationLifecycleAdvisor;
+import 
org.springframework.richclient.application.config.DefaultApplicationLifecycleAdvisor;
+import 
org.springframework.richclient.application.config.ApplicationWindowConfigurer;
+import org.springframework.richclient.command.CommandGroup;
+
+/**
+ * Test cases for [EMAIL PROTECTED] DefaultApplicationWindow}.
+ * 
+ * @author Andy DePue
+ */
+public class DefaultApplicationWindowTests extends SpringRichTestCase {
+
+    public void testRegressionFailureToRemovePageListener() {
+        PageListener pageListener = createNiceMock(PageListener.class);
+        replay(pageListener);
+        DefaultApplicationWindow daw = new DefaultApplicationWindow();
+        daw.addPageListener(pageListener);
+
+        try {
+            daw.removePageListener(pageListener);
+        } catch(IllegalArgumentException iae) {
+            iae.printStackTrace();
+            fail("DefaultApplicationWindow.removePageListener threw 
IllegalArgumentException when removing a valid pageListener: " + iae);
+        }
+    }
+
+    /**
+     * Mocks out various methods on the returned ApplicationLifecycleAdvisor
+     * as they are not needed for the current unit test(s) and will throw
+     * exceptions without further setup for the test.  If more unit tests
+     * are added to this class in the future, then the returned
+     * ApplicationLifecycleAdvisor should be revisited to ensure it still
+     * meets the needs of this test case.
+     */
+    @Override
+    protected ApplicationLifecycleAdvisor createApplicationLifecycleAdvisor() {
+        return new DefaultApplicationLifecycleAdvisor() {
+            @Override
+            public void onPreWindowOpen(ApplicationWindowConfigurer 
configurer) {
+            }
+
+            @Override
+            public void onCommandsCreated(ApplicationWindow window) {
+            }
+
+            @Override
+            public ApplicationWindowCommandManager 
createWindowCommandManager() {
+                return null;
+            }
+
+            @Override
+            public CommandGroup getMenuBarCommandGroup() {
+                return null;
+            }
+
+            @Override
+            public CommandGroup getToolBarCommandGroup() {
+                return null;
+            }
+        };
+    }
+}

Modified: 
trunk/spring-richclient/support/src/test/java/org/springframework/richclient/test/SpringRichTestCase.java
===================================================================
--- 
trunk/spring-richclient/support/src/test/java/org/springframework/richclient/test/SpringRichTestCase.java
   2006-07-12 12:33:39 UTC (rev 1221)
+++ 
trunk/spring-richclient/support/src/test/java/org/springframework/richclient/test/SpringRichTestCase.java
   2006-07-12 17:57:17 UTC (rev 1222)
@@ -24,6 +24,7 @@
 import org.springframework.richclient.application.Application;
 import org.springframework.richclient.application.ApplicationServicesLocator;
 import 
org.springframework.richclient.application.config.DefaultApplicationLifecycleAdvisor;
+import 
org.springframework.richclient.application.config.ApplicationLifecycleAdvisor;
 import 
org.springframework.richclient.application.support.DefaultApplicationServices;
 
 /**
@@ -48,7 +49,10 @@
             applicationServices = new DefaultApplicationServices();
             new ApplicationServicesLocator(applicationServices);
 
-            new Application(new DefaultApplicationLifecycleAdvisor());
+            final ApplicationLifecycleAdvisor advisor = 
createApplicationLifecycleAdvisor();
+            final Application application = new Application(advisor);
+            advisor.setApplication(application);
+            
             StaticApplicationContext applicationContext = new 
StaticApplicationContext();
             Application.instance().setApplicationContext(applicationContext);
             applicationServices.setApplicationContext(applicationContext);
@@ -64,7 +68,18 @@
         }
     }
 
+
     /**
+     * Subclasses may override this to return a custom
+     * ApplicationLifecycleAdvisor.
+     */
+    protected ApplicationLifecycleAdvisor createApplicationLifecycleAdvisor() {
+        return new DefaultApplicationLifecycleAdvisor();
+    }
+    
+    
+
+    /**
      * Register the application services needed for our tests.
      */
     protected void registerBasicServices( DefaultApplicationServices 
applicationServices ) {


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
spring-rich-c-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to