1 2 17 18 package org.springframework.jndi; 19 20 import junit.framework.TestCase; 21 22 25 public class JndiTemplateEditorTests extends TestCase { 26 27 public void testNullIsIllegalArgument() { 28 try { 29 new JndiTemplateEditor().setAsText(null); 30 fail("Null is illegal"); 31 } 32 catch (IllegalArgumentException ex) { 33 } 35 } 36 37 public void testEmptyStringMeansNullEnvironment() { 38 JndiTemplateEditor je = new JndiTemplateEditor(); 39 je.setAsText(""); 40 JndiTemplate jt = (JndiTemplate) je.getValue(); 41 assertTrue(jt.getEnvironment() == null); 42 } 43 44 public void testCustomEnvironment() { 45 JndiTemplateEditor je = new JndiTemplateEditor(); 46 je.setAsText("jndiInitialSomethingOrOther=org.springframework.myjndi.CompleteRubbish\nfoo=bar"); 50 JndiTemplate jt = (JndiTemplate) je.getValue(); 51 assertTrue(jt.getEnvironment().size() == 2); 52 assertTrue(jt.getEnvironment().getProperty("jndiInitialSomethingOrOther").equals("org.springframework.myjndi.CompleteRubbish")); 53 assertTrue(jt.getEnvironment().getProperty("foo").equals("bar")); 54 } 55 56 } 57 | Popular Tags |