axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/test/wsdd TestBadWSDD.java PackageTests.java
Date Wed, 05 Dec 2001 18:36:26 GMT
gdaniels    01/12/05 10:36:26

  Modified:    java/test/wsdd PackageTests.java
  Added:       java/test/wsdd TestBadWSDD.java
  Log:
  Add test for bad WSDD
  
  Revision  Changes    Path
  1.7       +1 -0      xml-axis/java/test/wsdd/PackageTests.java
  
  Index: PackageTests.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdd/PackageTests.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PackageTests.java	2001/11/15 16:31:25	1.6
  +++ PackageTests.java	2001/12/05 18:36:26	1.7
  @@ -22,6 +22,7 @@
           suite.addTestSuite(TestOptions.class);
           suite.addTestSuite(TestUndeployment.class);
           suite.addTestSuite(TestStructure.class);
  +        suite.addTestSuite(TestBadWSDD.class);
   
           return suite;
       }
  
  
  
  1.1                  xml-axis/java/test/wsdd/TestBadWSDD.java
  
  Index: TestBadWSDD.java
  ===================================================================
  package test.wsdd;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import org.apache.axis.deployment.wsdd.WSDDDocument;
  import org.apache.axis.deployment.wsdd.WSDDDeployment;
  import org.apache.axis.deployment.wsdd.WSDDHandler;
  import org.apache.axis.deployment.wsdd.WSDDConstants;
  import org.apache.axis.configuration.XMLStringProvider;
  import org.apache.axis.server.AxisServer;
  import org.apache.axis.Handler;
  import org.apache.axis.transport.local.LocalTransport;
  import org.apache.axis.utils.Options;
  import org.apache.axis.utils.JavaUtils;
  import org.apache.axis.client.AdminClient;
  
  import java.io.ByteArrayInputStream;
  
  /**
   * Try various bad deployments, and make sure that we get back reasonable
   * errors and don't screw up the engine's configuration.
   * 
   * @author Glen Daniels (gdaniels@macromedia.com)
   */ 
  public class TestBadWSDD extends TestCase
  {
      static final String HANDLER_NAME = "logger";
      static final String PARAM_NAME = "testParam";
      static final String PARAM_VAL  = "testValue";
  
      static final String goodWSDD =
              "<deployment xmlns=\"http://xml.apache.org/axis/wsdd/\" " +
                    "xmlns:java=\"" + WSDDConstants.WSDD_JAVA + "\">\n" +
              " <handler type=\"java:org.apache.axis.handlers.LogHandler\" " +
                        "name=\"" + HANDLER_NAME + "\">\n" +
              "  <parameter name=\"" + PARAM_NAME +
                            "\" value=\"" + PARAM_VAL + "\"/>\n" +
              " </handler>\n" +
              " <handler type=\"logger\" name=\"other\"/>\n" +
              " <service name=\"AdminService\" provider=\"java:MSG\">\n" + 
              "  <parameter name=\"methodName\" value=\"AdminService\"/>" +
              "  <parameter name=\"enableRemoteAdmin\" value=\"false\"/>" +
              "  <parameter name=\"className\"" +
                      " value=\"org.apache.axis.utils.Admin\"/>" +
              " </service>" +
              "</deployment>";
  
      static final String header =
              "<deployment xmlns=\"http://xml.apache.org/axis/wsdd/\" " +
                    "xmlns:java=\"" + WSDDConstants.WSDD_JAVA + "\">\n";
      static final String footer =
              "</deployment>";
  
      static final String badHandler = 
              " <handler name=\"nameButNoType\"/>\n";
  
      public TestBadWSDD (String name) {
          super(name);
      }
  
      public static Test suite() {
          return new TestSuite(TestBadWSDD.class);
      }
  
      protected void setup() {
      }
  
      /**
       * Initialize an engine with a single handler with a parameter set, and
       * another reference to that same handler with a different name.
       *
       * Make sure the param is set for both the original and the reference
       * handler.
       * 
       */ 
      public void testOptions() throws Exception
      {
          XMLStringProvider provider = new XMLStringProvider(goodWSDD);
          AxisServer server = new AxisServer(provider);
          
          Handler h1 = server.getHandler(HANDLER_NAME);
          assertNotNull("Couldn't get logger handler from engine!", h1);
  
          AdminClient client = new AdminClient();
          String doc = header + badHandler + footer;
          ByteArrayInputStream stream = new ByteArrayInputStream(doc.getBytes());
          
          LocalTransport transport = new LocalTransport(server);
          transport.setUrl("local:///AdminService");
          client.getCall().setTransport(transport);
          try {
              client.process(stream);
          } catch (Exception e) {
              assertEquals("Wrong exception message processing bad Handler",
                           "Must include type attribute for Handler deployment!",
                           e.getMessage());
              return;
          }
          
          fail("Successfully processed bad WSDD!");
      }
      
      public static void main(String[] args) throws Exception {
          TestBadWSDD tester = new TestBadWSDD("foo");
          tester.testOptions();
      }
  }
  
  
  

Mime
View raw message