1 22 23 package org.jboss.spring.test.ear.unit; 24 25 import org.jboss.spring.test.ear.business.SessionTestBean; 26 import org.jboss.spring.test.ear.pojo.Tester; 27 import org.jboss.test.JBossTestCase; 28 29 import junit.framework.Test; 30 31 34 public class SpringEARUnitTestCase extends JBossTestCase 35 { 36 public SpringEARUnitTestCase(String name) 37 { 38 super(name); 39 } 40 41 private void testInjection(String type) throws Exception 42 { 43 SessionTestBean testBean = (SessionTestBean) getInitialContext(). 44 lookup("spring-test/SessionTestBeanImpl/" + type); 45 Tester tester = testBean.getTester(); 46 if (tester == null) 47 { 48 throw new RuntimeException ("Tester should be injected!!"); 49 } 50 assertEquals(tester.getIntegerValue(), 1); 51 assertEquals(tester.getStringValue(), "Ales"); 52 } 53 54 public void testLocalInjection() throws Exception 55 { 56 testInjection("local"); 57 } 58 59 public void testRemoteInjection() throws Exception 60 { 61 testInjection("remote"); 62 } 63 64 public static Test suite() throws Exception 65 { 66 return getDeploySetup(SpringEARUnitTestCase.class, "spring-test.ear"); 67 } 68 69 } 70 | Popular Tags |