1 package test.wsdd; 2 3 import junit.framework.Test; 4 import junit.framework.TestCase; 5 import junit.framework.TestSuite; 6 import org.apache.axis.Handler; 7 import org.apache.axis.configuration.XMLStringProvider; 8 import org.apache.axis.deployment.wsdd.WSDDConstants; 9 import org.apache.axis.server.AxisServer; 10 11 public class TestOptions extends TestCase 12 { 13 static final String HANDLER_NAME = "logger"; 14 static final String PARAM_NAME = "testParam"; 15 static final String PARAM_VAL = "testValue"; 16 17 static final String doc = 19 "<deployment xmlns=\"http://xml.apache.org/axis/wsdd/\" " + 20 "xmlns:java=\"" + WSDDConstants.URI_WSDD_JAVA + "\">\n" + 21 " <handler type=\"java:org.apache.axis.handlers.LogHandler\" " + 22 "name=\"" + HANDLER_NAME + "\">\n" + 23 " <parameter name=\"" + PARAM_NAME + 24 "\" value=\"" + PARAM_VAL + "\"/>\n" + 25 " </handler>\n" + 26 " <handler type=\"logger\" name=\"other\"/>\n" + 27 "</deployment>"; 28 29 public TestOptions (String name) { 30 super(name); 31 } 32 33 public static Test suite() { 34 return new TestSuite(TestOptions.class); 35 } 36 37 protected void setup() { 38 } 39 40 48 public void testOptions() throws Exception 49 { 50 XMLStringProvider provider = new XMLStringProvider(doc); 51 AxisServer server = new AxisServer(provider); 52 53 Handler h1 = server.getHandler(HANDLER_NAME); 54 assertNotNull("Couldn't get logger handler from engine!", h1); 55 56 Object optVal = h1.getOption(PARAM_NAME); 57 assertNotNull("Option value was null!", optVal); 58 assertEquals("Option was not expected value", optVal, PARAM_VAL); 59 60 optVal = server.getOption("someOptionWhichIsntSet"); 61 assertNull("Got value for bad option!", optVal); 62 63 Handler h2 = server.getHandler("other"); 64 assertNotNull("Couldn't get second handler", h2); 65 66 optVal = h1.getOption(PARAM_NAME); 67 assertNotNull("Option value was null for 2nd handler!", optVal); 68 assertEquals("Option was not expected value for 2nd handler", 69 optVal, PARAM_VAL); 70 71 optVal = server.getOption("someOptionWhichIsntSet"); 72 assertNull("Got value for bad option on 2nd handler!", optVal); 73 } 74 75 public static void main(String [] args) throws Exception { 76 TestOptions tester = new TestOptions("foo"); 77 tester.testOptions(); 78 } 79 } 80 | Popular Tags |