KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > appclient > unit > AppClientUnitTestCase


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.ejb3.test.appclient.unit;
23
24 import java.net.URL JavaDoc;
25 import java.util.Date JavaDoc;
26
27 import junit.framework.Test;
28
29 import org.jboss.ejb3.client.ClientLauncher;
30 import org.jboss.ejb3.metamodel.ApplicationClientDD;
31 import org.jboss.ejb3.test.appclient.client.HelloWorldClient;
32 import org.jboss.test.JBossTestCase;
33
34 /**
35  * Comment
36  *
37  * @author <a HREF="mailto:carlo.dewolf@jboss.com">Carlo de Wolf</a>
38  * @version $Revision: $
39  */

40 public class AppClientUnitTestCase extends JBossTestCase
41 {
42    public AppClientUnitTestCase(String JavaDoc name)
43    {
44       super(name);
45    }
46
47    public void test1() throws Exception JavaDoc
48    {
49       URL JavaDoc url = Thread.currentThread().getContextClassLoader().getResource("appclient/application-client.xml");
50       URL JavaDoc jbossClientURL = Thread.currentThread().getContextClassLoader().getResource("appclient/jboss-client.xml");
51       ApplicationClientDD xml = ClientLauncher.loadXML(url, jbossClientURL);
52       
53       String JavaDoc mainClassName = HelloWorldClient.class.getName();
54       String JavaDoc applicationClientName = "applicationclient_test"; // must match JNDI name in jboss-client.xml or display-name in application-client.xml
55
String JavaDoc name = new Date JavaDoc().toString();
56       String JavaDoc args[] = { name };
57       
58       ClientLauncher.launch(xml, mainClassName, applicationClientName, args);
59       
60       String JavaDoc actual = HelloWorldClient.getResult();
61       String JavaDoc expected = "Hi " + name + ", how are you?";
62       assertEquals(expected, actual);
63    }
64    
65    public static Test suite() throws Exception JavaDoc
66    {
67       return getDeploySetup(AppClientUnitTestCase.class, "appclient-test.ear");
68       //return getDeploySetup(AppClientUnitTestCase.class, "appclient-test.jar,appclient-test-client.jar");
69
}
70 }
71
Popular Tags