Revision: 1626 http://svn.sourceforge.net/spring-rich-c/?rev=1626&view=rev Author: kevinstembridge Date: 2007-01-08 05:02:07 -0800 (Mon, 08 Jan 2007)
Log Message: ----------- Initial import Added Paths: ----------- trunk/spring-richclient/support/src/test/java/org/springframework/richclient/application/support/BeanFactoryViewDescriptorRegistryTests.java Added: trunk/spring-richclient/support/src/test/java/org/springframework/richclient/application/support/BeanFactoryViewDescriptorRegistryTests.java =================================================================== --- trunk/spring-richclient/support/src/test/java/org/springframework/richclient/application/support/BeanFactoryViewDescriptorRegistryTests.java (rev 0) +++ trunk/spring-richclient/support/src/test/java/org/springframework/richclient/application/support/BeanFactoryViewDescriptorRegistryTests.java 2007-01-08 13:02:07 UTC (rev 1626) @@ -0,0 +1,108 @@ +/* + * 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 junit.framework.Assert; +import junit.framework.TestCase; + +import org.springframework.beans.factory.BeanNotOfRequiredTypeException; +import org.springframework.context.support.StaticApplicationContext; +import org.springframework.richclient.application.ViewDescriptor; + + +/** + * Provides a suite of unit tests for the [EMAIL PROTECTED] BeanFactoryViewDescriptorRegistry} class. + * + * @author Kevin Stembridge + * @since 0.3 + * + */ +public class BeanFactoryViewDescriptorRegistryTests extends TestCase { + + /** + * Test method for [EMAIL PROTECTED] BeanFactoryViewDescriptorRegistry#getViewDescriptor(java.lang.String)}. + */ + public final void testGetViewDescriptor() { + + BeanFactoryViewDescriptorRegistry registry = new BeanFactoryViewDescriptorRegistry(); + StaticApplicationContext appCtx = new StaticApplicationContext(); + registry.setApplicationContext(appCtx); + + appCtx.registerSingleton("view1", DefaultViewDescriptor.class); + appCtx.registerSingleton("view2", DefaultViewDescriptor.class); + appCtx.registerSingleton("bogusView", String.class); + + Assert.assertNotNull(registry.getViewDescriptor("view1")); + Assert.assertNotNull(registry.getViewDescriptor("view2")); + + Assert.assertNull("Should return null when viewName not found", registry.getViewDescriptor("bogus")); + + try { + registry.getViewDescriptor("bogusView"); + Assert.fail("Should have thrown BeanNotOfRequiredTypeException"); + } + catch (BeanNotOfRequiredTypeException e) { + //do nothing, test succeeded + } + + } + + /** + * Performs the following assertions on the + * [EMAIL PROTECTED] BeanFactoryViewDescriptorRegistry#getViewDescriptors()} method: + * + * <ul> + * <li>The method does not return null if there are no view descriptors in the underlying + * registry</li> + * <li>The correct number of descriptors are returned.</li> + * </ul> + */ + public void testGetViewDescriptors() { + + BeanFactoryViewDescriptorRegistry registry = new BeanFactoryViewDescriptorRegistry(); + StaticApplicationContext appCtx = new StaticApplicationContext(); + registry.setApplicationContext(appCtx); + + ViewDescriptor[] viewDescriptors = registry.getViewDescriptors(); + + Assert.assertNotNull("View descriptor array should never be null", viewDescriptors); + Assert.assertEquals("Should be no view descriptors in the array", 0, viewDescriptors.length); + + appCtx.registerSingleton("view1", DefaultViewDescriptor.class); + appCtx.registerSingleton("view2", DefaultViewDescriptor.class); + + viewDescriptors = registry.getViewDescriptors(); + Assert.assertEquals("Should be 2 view descriptors in the array", 2, viewDescriptors.length); + + } + + /** + * Confirms that an IllegalArgumentException is thrown if a null viewName is passed to the + * [EMAIL PROTECTED] BeanFactoryViewDescriptorRegistry#getViewDescriptor(String)} method. + */ + public void testForNullViewId() { + + try { + new BeanFactoryViewDescriptorRegistry().getViewDescriptor(null); + Assert.fail("Should have thrown an IllegalArgumentException for null view ID"); + } + catch (IllegalArgumentException e) { + //do nothing, test succeeded + } + + } + +} Property changes on: trunk/spring-richclient/support/src/test/java/org/springframework/richclient/application/support/BeanFactoryViewDescriptorRegistryTests.java ___________________________________________________________________ Name: svn:keywords + Author Id Revision Date HeadURL Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ spring-rich-c-cvs mailing list spring-rich-c-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs