1 package org.jbpm.bpel.tutorial.hello; 2 3 import java.util.Properties ; 4 import javax.naming.InitialContext ; 5 import javax.naming.NamingException ; 6 import junit.framework.TestCase; 7 8 12 public class HelloTest extends TestCase { 13 14 private HelloPT greeter; 15 16 public HelloTest(String name) { 17 super(name); 18 } 19 20 protected void setUp() throws Exception { 21 InitialContext ctx = getInitialContext(); 22 String serviceRefName = "service/Hello"; 24 HelloPTService service = (HelloPTService) ctx.lookup("java:comp/env/" + serviceRefName); 26 greeter = service.getHelloPTPort(); 28 } 29 30 public void testSayHello() throws Exception { 31 String name = "Popeye"; 32 String greeting = greeter.sayHello(name); 33 assertEquals("Hello, Popeye!", greeting); 34 } 35 36 protected InitialContext getInitialContext() throws NamingException { 37 String envContextName = "hello-client"; 39 Properties env = new Properties (); 41 env.setProperty("j2ee.clientName", envContextName); 42 return new InitialContext (env); 44 } 45 } | Popular Tags |