1 22 package org.jboss.ejb3.test.appclient.unit; 23 24 import java.net.URL ; 25 26 import javax.naming.Context ; 27 import javax.naming.NameNotFoundException ; 28 29 import junit.framework.Test; 30 31 import org.jboss.ejb3.client.ClientLauncher; 32 import org.jboss.ejb3.metamodel.ApplicationClientDD; 33 import org.jboss.ejb3.test.appclient.client.SimpleResourceClient; 34 import org.jboss.test.JBossTestCase; 35 36 42 public class SimpleResourceUnitTestCase extends JBossTestCase 43 { 44 45 public SimpleResourceUnitTestCase(String name) 46 { 47 super(name); 48 } 49 50 55 public void testJNDI() throws Exception 56 { 57 String clientName = "appclient-simpleresource-client"; 58 Context ctx = getInitialContext(); 59 try 60 { 61 ctx = (Context ) ctx.lookup(clientName); 62 } 63 catch(NameNotFoundException e) 64 { 65 fail(clientName + " not bound"); 66 } 67 68 try 69 { 70 String value = (String ) ctx.lookup("env/msg"); 71 assertEquals("Hello world", value); 72 } 73 catch(NameNotFoundException e) 74 { 75 fail("env/msg not bound"); 76 } 77 78 80 } 95 96 public void testClientLauncher() throws Exception 97 { 98 URL url = Thread.currentThread().getContextClassLoader().getResource("appclient/simpleresource/application-client.xml"); 99 URL jbossClientURL = null; 101 ApplicationClientDD xml = ClientLauncher.loadXML(url, jbossClientURL); 102 103 String mainClassName = SimpleResourceClient.class.getName(); 104 String applicationClientName = "appclient-simpleresource-client"; String args[] = { }; 106 107 ClientLauncher.launch(xml, mainClassName, applicationClientName, args); 108 } 109 110 public static Test suite() throws Exception 111 { 112 return getDeploySetup(SimpleResourceUnitTestCase.class, "appclient-simpleresource-client.jar"); 113 } 114 115 } 116 | Popular Tags |