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 TestOptions.java PackageTests.java
Date Mon, 12 Nov 2001 20:59:44 GMT
gdaniels    01/11/12 12:59:44

  Modified:    java/src/org/apache/axis/deployment/wsdd
                        WSDDDeployableItem.java
               java/test/wsdd PackageTests.java
  Added:       java/test/wsdd TestOptions.java
  Log:
  If we're creating a handler based on a reference type (rather than a
  direct java class), don't write the options, because they will assumedly
  have already have been set by the original definition we're referencing.
  
  Add a unit test for handler options, which tests option retrieval for both
  the direct and the reference case.
  
  Revision  Changes    Path
  1.18      +4 -4      xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDDeployableItem.java
  
  Index: WSDDDeployableItem.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDDeployableItem.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- WSDDDeployableItem.java	2001/11/12 16:04:06	1.17
  +++ WSDDDeployableItem.java	2001/11/12 20:59:44	1.18
  @@ -314,12 +314,12 @@
   
               if (c != null) {
                   h = (Handler)createInstance(c);
  +
  +                if (h != null) {
  +                    h.setOptions(getParametersTable());
  +                }
               } else {
                   h = registry.getHandler(getType());
  -            }
  -
  -            if (h != null) {
  -                h.setOptions(getParametersTable());
               }
   
               return h;
  
  
  
  1.3       +2 -1      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PackageTests.java	2001/11/12 16:04:06	1.2
  +++ PackageTests.java	2001/11/12 20:59:44	1.3
  @@ -18,7 +18,8 @@
   
           suite.addTestSuite(TestGlobalConfiguration.class);
           suite.addTestSuite(TestScopeOption.class);
  -        
  +        suite.addTestSuite(TestOptions.class);
  +
           return suite;
       }
   }
  
  
  
  1.1                  xml-axis/java/test/wsdd/TestOptions.java
  
  Index: TestOptions.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;
  
  public class TestOptions extends TestCase
  {
      static final String HANDLER_NAME = "logger";
      static final String PARAM_NAME = "testParam";
      static final String PARAM_VAL  = "testValue";
  
      // Two-part WSDD, with a space for scope option in the middle
      static final String doc =
              "<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" +
              "</deployment>";
  
      public TestOptions (String name) {
          super(name);
      }
  
      public static Test suite() {
          return new TestSuite(TestOptions.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(doc);
          AxisServer server = new AxisServer(provider);
          
          Handler h1 = server.getHandler(HANDLER_NAME);
          assertNotNull("Couldn't get logger handler from engine!", h1);
          
          Object optVal = h1.getOption(PARAM_NAME);
          assertNotNull("Option value was null!", optVal);
          assertEquals("Option was not expected value", optVal, PARAM_VAL);
  
          optVal = server.getOption("someOptionWhichIsntSet");
          assertNull("Got value for bad option!", optVal);
  
          Handler h2 = server.getHandler("other");
          assertNotNull("Couldn't get second handler", h2);
  
          optVal = h1.getOption(PARAM_NAME);
          assertNotNull("Option value was null for 2nd handler!", optVal);
          assertEquals("Option was not expected value for 2nd handler",
                       optVal, PARAM_VAL);
  
          optVal = server.getOption("someOptionWhichIsntSet");
          assertNull("Got value for bad option on 2nd handler!", optVal);
      }
      
      public static void main(String[] args) throws Exception {
          TestOptions tester = new TestOptions("foo");
          tester.testOptions();
      }
  }
  
  
  

Mime
View raw message