| 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.deployment.wsdd.WSDDDeployment; |
| 10 |
import org.apache.axis.deployment.wsdd.WSDDDocument; |
| 11 |
import org.apache.axis.server.AxisServer; |
| 12 |
import org.apache.axis.utils.XMLUtils; |
| 13 |
|
| 14 |
import java.io.InputStream; |
| 15 |
import java.io.StringBufferInputStream; |
| 16 |
|
| 17 |
/** |
| 18 |
* Test WSDD undeployment. |
| 19 |
* |
| 20 |
* @author Glen Daniels ([email protected]) |
| 21 |
*/ |
| 22 |
public class TestUndeployment extends TestCase |
| 23 |
{ |
| 24 |
static final String HANDLER_NAME = "logger"; |
| 25 |
static final String PARAM_NAME = "testParam"; |
| 26 |
static final String PARAM_VAL = "testValue"; |
| 27 |
|
| 28 |
static final String deployDoc = |
| 29 |
"<deployment xmlns=\"http://xml.apache.org/axis/wsdd/\" " + |
| 30 |
"xmlns:java=\"" + WSDDConstants.URI_WSDD_JAVA + "\">\n" + |
| 31 |
" <handler type=\"java:org.apache.axis.handlers.LogHandler\" " + |
| 32 |
"name=\"" + HANDLER_NAME + "\">\n" + |
| 33 |
" <parameter name=\"" + PARAM_NAME + |
| 34 |
"\" value=\"" + PARAM_VAL + "\"/>\n" + |
| 35 |
" </handler>\n" + |
| 36 |
" <handler type=\"logger\" name=\"other\"/>\n" + |
| 37 |
"</deployment>"; |
| 38 |
|
| 39 |
static final String undeployDoc = |
| 40 |
"<undeployment xmlns=\"http://xml.apache.org/axis/wsdd/\">\n" + |
| 41 |
" <handler name=\"other\"/>\n" + |
| 42 |
"</undeployment>"; |
| 43 |
|
| 44 |
public TestUndeployment (String name) { |
| 45 |
super(name); |
| 46 |
} |
| 47 |
|
| 48 |
public static Test suite() { |
| 49 |
return new TestSuite(TestUndeployment.class); |
| 50 |
} |
| 51 |
|
| 52 |
protected void setup() { |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Load up a server with a couple of handlers as spec'ed above, |
| 57 |
* then undeploy one of them. Confirm that all looks reasonable |
| 58 |
* throughout. |
| 59 |
*/ |
| 60 |
public void testUndeployHandler() throws Exception |
| 61 |
{ |
| 62 |
XMLStringProvider provider = new XMLStringProvider(deployDoc); |
| 63 |
AxisServer server = new AxisServer(provider); |
| 64 |
|
| 65 |
Handler handler = server.getHandler("other"); |
| 66 |
assertNotNull("Couldn't get handler", handler); |
| 67 |
|
| 68 |
InputStream is = new StringBufferInputStream(undeployDoc); |
| 69 |
WSDDDocument doc = new WSDDDocument(XMLUtils.newDocument(is)); |
| 70 |
|
| 71 |
WSDDDeployment dep = provider.getDeployment(); |
| 72 |
doc.deploy(dep); |
| 73 |
|
| 74 |
server.refreshGlobalOptions(); |
| 75 |
|
| 76 |
handler = server.getHandler("other"); |
| 77 |
assertNull("Undeployed handler is still available", handler); |
| 78 |
|
| 79 |
handler = server.getHandler(HANDLER_NAME); |
| 80 |
assertNotNull("Couldn't get handler (2nd time)", handler); |
| 81 |
} |
| 82 |
|
| 83 |
public static void main(String[] args) throws Exception { |
| 84 |
TestUndeployment tester = new TestUndeployment("foo"); |
| 85 |
tester.testUndeployHandler(); |
| 86 |
} |
| 87 |
} |