1 10 11 package org.nanocontainer.script.groovy.buildernodes; 12 13 import java.util.Collections ; 14 import java.util.HashMap ; 15 import org.nanocontainer.NanoContainer; 16 import org.nanocontainer.reflection.DefaultNanoPicoContainer; 17 import org.nanocontainer.script.NanoContainerMarkupException; 18 import junit.framework.TestCase; 19 20 24 public class TestAppendContainerNode extends TestCase { 25 private AppendContainerNode appendContainerNode = null; 26 27 protected void setUp() throws Exception { 28 super.setUp(); 29 appendContainerNode = new AppendContainerNode(); 30 } 31 32 protected void tearDown() throws Exception { 33 appendContainerNode = null; 34 super.tearDown(); 35 } 36 37 public void testCreateNewNodeWithoutParameterThrowsException() { 38 try { 39 appendContainerNode.createNewNode(null, Collections.EMPTY_MAP); 40 fail("Should have thrown exception"); 41 } catch (NanoContainerMarkupException ex) { 42 } 44 } 45 46 public void testCreateNodeWithParmeterReturnsParameter() throws NanoContainerMarkupException { 47 HashMap params = new HashMap (); 48 NanoContainer nano = new DefaultNanoPicoContainer(); 49 params.put(AppendContainerNode.CONTAINER, nano); 50 NanoContainer nano2 = (NanoContainer)appendContainerNode.createNewNode(null,params); 51 assertTrue(nano == nano2); 52 } 53 54 public void testCreateWithImproperTypeThrowsClassCastException() throws NanoContainerMarkupException { 55 HashMap params = new HashMap (); 56 params.put(AppendContainerNode.CONTAINER, "This is a test"); 57 try { 58 appendContainerNode.createNewNode(null, params); 59 fail("Should have thrown exception"); 60 } catch (ClassCastException ex) { 61 } 63 } 64 65 } 66 | Popular Tags |