KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > tutorial > hello > HelloTest


1 package org.jbpm.bpel.tutorial.hello;
2
3 import java.util.Properties JavaDoc;
4 import javax.naming.InitialContext JavaDoc;
5 import javax.naming.NamingException JavaDoc;
6 import junit.framework.TestCase;
7
8 /**
9  * @author Alejandro Guízar
10  * @version $Revision: 1.1 $ $Date: 2005/06/08 00:33:27 $
11  */

12 public class HelloTest extends TestCase {
13
14   private HelloPT greeter;
15
16   public HelloTest(String JavaDoc name) {
17     super(name);
18   }
19
20   protected void setUp() throws Exception JavaDoc {
21     InitialContext JavaDoc ctx = getInitialContext();
22     // JNDI name bound to the service interface (in application-client.xml)
23
String JavaDoc serviceRefName = "service/Hello";
24     // lookup the service interface in the environment context
25
HelloPTService service = (HelloPTService) ctx.lookup("java:comp/env/" + serviceRefName);
26     // obtain the dynamic proxy for the web service port
27
greeter = service.getHelloPTPort();
28   }
29
30   public void testSayHello() throws Exception JavaDoc {
31     String JavaDoc name = "Popeye";
32     String JavaDoc greeting = greeter.sayHello(name);
33     assertEquals("Hello, Popeye!", greeting);
34   }
35
36   protected InitialContext JavaDoc getInitialContext() throws NamingException JavaDoc {
37     // JNDI name bound to the client's environment context (in jboss-client.xml)
38
String JavaDoc envContextName = "hello-client";
39     // prepare the enviroment
40
Properties JavaDoc env = new Properties JavaDoc();
41     env.setProperty("j2ee.clientName", envContextName);
42     // the properties in env *and* jndi.properties are placed in the context's environment
43
return new InitialContext JavaDoc(env);
44   }
45 }
Popular Tags