| 1 |
/* |
| 2 |
* Copyright 2001-2004 The Apache Software Foundation. |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
*/ |
| 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 |
/** Test the stock sample code. |
| 31 |
*/ |
| 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 |
|