1 16 17 package test.functional; 18 19 import junit.framework.TestCase; 20 import org.apache.axis.client.AdminClient; 21 import org.apache.axis.components.logger.LogFactory; 22 import org.apache.axis.deployment.wsdd.WSDDConstants; 23 import org.apache.axis.utils.Options; 24 import org.apache.commons.logging.Log; 25 import samples.misc.TestClient; 26 27 import java.io.ByteArrayInputStream ; 28 29 30 32 public class TestMiscSample extends TestCase { 33 static Log log = 34 LogFactory.getLog(TestMiscSample.class.getName()); 35 36 static final String deployDoc = 37 "<deployment xmlns=\"http://xml.apache.org/axis/wsdd/\" " + 38 "xmlns:java=\"" + WSDDConstants.URI_WSDD_JAVA + "\">\n" + 39 " <service name=\"EchoService\" provider=\"Handler\">\n" + 40 " <parameter name=\"handlerClass\" " + 41 " value=\"org.apache.axis.handlers.EchoHandler\"/>\n" + 42 " </service>\n" + 43 "</deployment>"; 44 45 static final String undeployDoc = 46 "<undeployment xmlns=\"http://xml.apache.org/axis/wsdd/\">\n" + 47 " <service name=\"EchoService\"/>\n" + 48 "</undeployment>"; 49 50 AdminClient client; 51 Options opts = null; 52 53 public TestMiscSample(String name) throws Exception { 54 super(name); 55 client = new AdminClient(); 56 opts = new Options(new String [] { 57 "-lhttp://localhost:8080/axis/services/AdminService" } ); 58 } 59 60 public void doDeploy () throws Exception { 61 client.process(opts, new ByteArrayInputStream (deployDoc.getBytes())); 62 } 63 64 public void doUndeploy () throws Exception { 65 client.process(opts, new ByteArrayInputStream (undeployDoc.getBytes())); 66 } 67 68 public void doTest () throws Exception { 69 String [] args = { "-d" }; 70 TestClient.main(args); 71 } 72 73 public void testService () throws Exception { 74 try { 75 log.info("Testing misc sample."); 76 doDeploy(); 77 log.info("Testing service..."); 78 doTest(); 79 doUndeploy(); 80 log.info("Test complete."); 81 } 82 catch( Exception e ) { 83 e.printStackTrace(); 84 throw new Exception ("Fault returned from test: "+e); 85 } 86 } 87 88 public static void main(String [] args) throws Exception { 89 TestMiscSample tester = new TestMiscSample("tester"); 90 tester.testService(); 91 } 92 } 93 94 | Popular Tags |