/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.test.webservice.ws4eesimple;

// $Id: SimpleJSETestCase.java,v 1.1.1.1.4.5 2005/06/28 09:53:53 tdiesler Exp $

import junit.framework.Test;
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;

/**
 * Tests of the ws4ee functionality for a simple Hello web component.
 *
 * @author Thomas.Diesler@jboss.org
 * @since 06-May-2004
 */
public class SimpleJSETestCase extends JBossTestCase
{
   private String WSDL_LOCATION = "http://" + getServerHost() + ":8080/ws4ee-simple?wsdl";
   private String NAMESPACE = "http://test.jboss.org/ws4eesimple";
   private QName SERVICE_NAME = new QName(NAMESPACE, "HelloService");

   /**
    * Construct the test case with a given name
    */
   public SimpleJSETestCase(String name)
   {
      super(name);
   }

   /**
    * deploy the test archives
    */
   public static Test suite() throws Exception
   {
      return getDeploySetup(SimpleJSETestCase.class, "ws4ee-simple.war");
   }

   /**
    * test simple EJB access
    */
   public void testSayHello() throws Exception
   {
      ServiceFactory serviceFactory = ServiceFactory.newInstance();
      Service service = serviceFactory.createService(new URL(WSDL_LOCATION), SERVICE_NAME);
      Call call = (Call)service.createCall(new QName(NAMESPACE, "HelloWsPort"), "sayHello");
      String retstr = (String)call.invoke(new Object[]{"Hello"});
      assertEquals("'Hello' to you too!", retstr);
   }
}
