KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jbossnet > JBossNetTestBase


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 // $Id: JBossNetTestBase.java,v 1.1.2.4 2005/03/02 14:51:01 tdiesler Exp $
9

10 package org.jboss.test.jbossnet;
11
12 import org.jboss.axis.client.AxisClient;
13 import org.jboss.axis.client.ServiceFactory;
14 import org.jboss.axis.configuration.FileProvider;
15 import org.jboss.test.JBossTestCase;
16
17 import javax.xml.namespace.QName JavaDoc;
18 import javax.xml.rpc.Service JavaDoc;
19 import java.net.URL JavaDoc;
20
21 /**
22  * Junit Test class with some JBoss.Net support
23  * <br>
24  * @since 12. Oktober 2001, 11:20
25  * @author Thomas.Diesler@jboss.org
26  */

27 public abstract class JBossNetTestBase extends JBossTestCase
28 {
29    /** the protocol we use */
30    protected String JavaDoc PROTOCOL = "http://";
31
32    /** the address to which we forward the request */
33    protected String JavaDoc ADDRESS = "" + getServerHost() + ":8080/";
34
35    /** where the axis servlet context is installed */
36    protected String JavaDoc AXIS_CONTEXT = ADDRESS + "jboss-net/";
37
38    /** where the service port is located under */
39    protected String JavaDoc SERVICE_PORT = AXIS_CONTEXT + "services";
40
41    /** has an associated end point that may be configured once */
42    protected String JavaDoc SERVICES_LOCATION = PROTOCOL + SERVICE_PORT;
43
44    /** Creates new JBossNetTestBase */
45    public JBossNetTestBase(String JavaDoc name)
46    {
47       super(name);
48    }
49
50    /** Create a Service that is preconfigured from WSDL
51     */

52    public Service JavaDoc createService(URL JavaDoc wsdlURL, QName JavaDoc serviceQName) throws Exception JavaDoc
53    {
54       // Note, we cannot use javax.xml.rpc.ServiceFactory.newFactory()
55
ServiceFactory factory = new org.jboss.axis.client.ServiceFactory();
56       Service JavaDoc service = factory.createService(wsdlURL, serviceQName);
57
58       // configure the client engine
59
String JavaDoc config = getAxisConfiguration();
60       AxisClient clientEngine = new AxisClient(new FileProvider(config));
61       ((org.jboss.axis.client.Service)service).setEngine(clientEngine);
62
63       return service;
64    }
65
66    /** Create a Service that is preconfigured from WSDL
67     */

68    public Service JavaDoc createService(URL JavaDoc wsdlURL, QName JavaDoc serviceQName, boolean maintainSession) throws Exception JavaDoc
69    {
70       Service JavaDoc service = createService(wsdlURL, serviceQName);
71       ((org.jboss.axis.client.Service)service).setMaintainSession(maintainSession);
72       return service;
73    }
74
75    /** Overwrite to provide the path to the custom client config */
76    protected String JavaDoc getAxisConfiguration()
77    {
78       return "client-config.wsdd";
79    }
80 }
81
Popular Tags