/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

// $Id: ExternalUnitTestCase.java,v 1.1.1.1.4.1 2004/08/09 09:54:35 tdiesler Exp $

package org.jboss.test.jbossnet.external;

import junit.framework.Test;
import org.jboss.test.jbossnet.WSTests;

/**
 * tests connectivity to external, global web services.
 * @version $Rev:$
 * @author cgjung
 * @since 10.2002
 */

public class ExternalUnitTestCase extends WSTests
{
   protected String FEDERATED_SOAP_ACTION = "FederatedService";

   // Constructors --------------------------------------------------
   public ExternalUnitTestCase(String name)
   {
      super(name);
   }

   /** the session bean with which we interact */
   FederatedService federation;

   /** setup the bean */
   public void setUp() throws Exception
   {
      super.setUp();
      federation =
         (FederatedService) createAxisService(FederatedService.class,
               FEDERATED_SOAP_ACTION);
   }

   /** test a federated call */
   public void testFederated() throws Exception
   {
      String result =
         federation.findAndTranslate(
            "JBoss is a killer server and Mr. Fleury is a damned genius");
      System.out.println(
         getClass().getName()
            + ".testFederated(): For your pleasure, here is the result of the translated search "
            + result);
      String sometimes =
         "JBoss ist ein Mörderbediener und Herr Fleury ist ein verdammtes\nGenie ";
      String othertimes =
         "JBoss ist ein Mörderbediener und Herr Fleury ist ein verdammtes Genie ";
      String shittimes =
         "This service is currently disabled.";
      assertTrue(
         "got the translation right",
         sometimes.equals(result)
            || othertimes.equals(result)
            || shittimes.equals(result));
   }

   /** where the config is stored */
   protected String getAxisConfiguration()
   {
      return "jbossnet/external/client/" + super.getAxisConfiguration();
   }

   /** this is to deploy the whole ear */
   public static Test suite() throws Exception
   {
      return getDeploySetup(ExternalUnitTestCase.class, "wsexternal.ear");
   }

   public static void main(String[] args)
   {
      junit.textui.TestRunner.run(ExternalUnitTestCase.class);
   }
}
