package org.jboss.test.webservice.jbas897;
import org.jboss.test.JBossTestCase;
import javax.xml.namespace.QName;
import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;
import java.net.URL;
public class JBAS897TestCase extends JBossTestCase
{
private String NAMESPACE = "http://org.jboss.test.webservice/jbas897";
private QName SERVICE_NAME = new QName(NAMESPACE, "HelloService");
public JBAS897TestCase(String name)
{
super(name);
}
public void testJSEEndpoint() throws Exception
{
deploy("ws4ee-jbas897.war");
try
{
ServiceFactory serviceFactory = ServiceFactory.newInstance();
Service service = serviceFactory.createService(new URL("http://" + getServerHost() + ":8080/ws4ee-jbas897/HelloJSE?wsdl"), SERVICE_NAME);
Call call = (Call)service.createCall(new QName(NAMESPACE, "HelloPort"), "sayHello");
String retstr = (String)call.invoke(new Object[]{"Hello"});
assertEquals("'Hello' to you too!", retstr);
}
finally
{
undeploy("ws4ee-jbas897.war");
}
}
public void testJSEEndpointFail() throws Exception
{
try
{
deploy("ws4ee-jbas897-fail.war");
fail("deployment should fail");
}
catch (Exception e)
{
}
testJSEEndpoint();
}
public void testEJBEndpoint() throws Exception
{
deploy("ws4ee-jbas897.jar");
try
{
ServiceFactory serviceFactory = ServiceFactory.newInstance();
Service service = serviceFactory.createService(new URL("http://" + getServerHost() + ":8080/ws4ee-jbas897/HelloEJB?wsdl"), SERVICE_NAME);
Call call = (Call)service.createCall(new QName(NAMESPACE, "HelloPort"), "sayHello");
String retstr = (String)call.invoke(new Object[]{"Hello"});
assertEquals("'Hello' to you too!", retstr);
}
finally
{
undeploy("ws4ee-jbas897.jar");
}
}
public void testEJBEndpointFail() throws Exception
{
deploy("ws4ee-jbas897-fail.jar");
testEJBEndpoint();
}
}