1 /* 2 * Created on 21/Jan/04 3 * 4 * To change the template for this generated file go to 5 * Window>Preferences>Java>Code Generation>Code and Comments 6 */ 7 package replica.command.beans; 8 9 import org.springframework.context.support.ClassPathXmlApplicationContext; 10 import org.springframework.context.support.StaticApplicationContext; 11 12 import replica.command.Command; 13 import replica.command.CommandException; 14 import replica.server.commands.ConnectCommand; 15 import replica.server.commands.sql.SelectCommand; 16 import junit.framework.TestCase; 17 18 /*** 19 * @author no119431 20 * 21 * To change the template for this generated type comment go to 22 * Window>Preferences>Java>Code Generation>Code and Comments 23 */ 24 public class BeansMappingsTest extends TestCase { 25 26 String configFileLocation = "replica/command/beans/test-applicationContext.xml"; 27 BeansMappings beansMappings; 28 29 /*** 30 * Constructor for BeansMappingsTest. 31 * @param arg0 32 */ 33 public BeansMappingsTest(String arg0) { 34 super(arg0); 35 } 36 37 public void testGetExistingNewCommandWithBeanRef() { 38 39 Command command = beansMappings.getNewCommand("select"); 40 41 assertNotNull(command); 42 assertEquals( SelectCommand.class, command.getClass() ); 43 } 44 45 public void testGetExistingNewCommandWithClassName() { 46 47 Command command = beansMappings.getNewCommand("connect"); 48 49 assertNotNull(command); 50 assertEquals( ConnectCommand.class, command.getClass() ); 51 } 52 53 public void testGetNotExistingNewCommand() { 54 55 try{ 56 Command command = beansMappings.getNewCommand("somethingElse"); 57 } 58 catch(CommandException e){ 59 return; // test ok 60 } 61 62 fail(); 63 } 64 65 /* (non-Javadoc) 66 * @see junit.framework.TestCase#setUp() 67 */ 68 protected void setUp() throws Exception { 69 super.setUp(); 70 71 ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(configFileLocation); 72 73 StaticApplicationContext staticApp = (StaticApplicationContext)appContext.getBean("applicationContext"); 74 75 staticApp.setParent( appContext ); 76 77 staticApp.getBeanFactory().setParentBeanFactory( appContext.getBeanFactory() ); 78 79 beansMappings = (BeansMappings)appContext.getBean("serverCommandMappings"); 80 } 81 82 }

This page was automatically generated by Maven