dblevins 2005/03/09 01:19:56
Modified: modules/core/src/test/org/openejb/server/xfire
WSContainerTest.java
Log:
First run of axis integration. more to sew up yet.
Revision Changes Path
1.5 +11 -53
openejb/modules/core/src/test/org/openejb/server/xfire/WSContainerTest.java
Index: WSContainerTest.java
===================================================================
RCS file:
/scm/openejb/openejb/modules/core/src/test/org/openejb/server/xfire/WSContainerTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- WSContainerTest.java 6 Mar 2005 02:49:42 -0000 1.4
+++ WSContainerTest.java 9 Mar 2005 06:19:56 -0000 1.5
@@ -71,6 +71,7 @@
import org.apache.geronimo.kernel.management.State;
import org.codehaus.xfire.MessageContext;
import org.openejb.server.StandardServiceStackGBean;
+import org.openejb.server.soap.SoapHttpListenerGBean;
import org.openejb.server.httpd.HttpListener;
import org.openejb.server.httpd.HttpRequest;
import org.openejb.server.httpd.HttpResponse;
@@ -195,57 +196,6 @@
assertEquals("should be running: " + objectName,
State.RUNNING_INDEX, state);
}
- public static class TestSoapHttpListener implements HttpListener {
-
- private final WSContainer container;
-
- public TestSoapHttpListener(WSContainer container) {
- this.container = container;
- }
-
- public void onMessage(HttpRequest req, HttpResponse res) throws
IOException {
- try {
- MessageContext context = new MessageContext("not-used",
null, res.getOutputStream(), null, req.getURI().toString());
- context.setRequestStream(req.getInputStream());
- res.setContentType("text/xml");
- container.invoke(context);
- } catch (IOException e) {
- e.printStackTrace();
- throw e;
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
-
- public static final GBeanInfo GBEAN_INFO;
-
- static {
- GBeanInfoBuilder infoFactory = new
GBeanInfoBuilder(TestSoapHttpListener.class);
- infoFactory.addOperation("onMessage", new
Class[]{HttpRequest.class, HttpResponse.class});
-
- infoFactory.setConstructor(new String[]{"WSContainer"});
-
- infoFactory.addReference("WSContainer", WSContainer.class, null);
-
- GBEAN_INFO = infoFactory.getBeanInfo();
- }
-
- public static GBeanInfo getGBeanInfo() {
- return GBEAN_INFO;
- }
-
- public static ObjectName addGBean(Kernel kernel, String name,
ObjectName wsContainer) throws GBeanAlreadyExistsException,
GBeanNotFoundException {
- ClassLoader classLoader =
org.openejb.server.xfire.SoapHttpListener.class.getClassLoader();
- ObjectName SERVICE_NAME =
JMXUtil.getObjectName("openejb:type=TestSoapHttpListener,name=" + name);
-
- GBeanData gbean = new GBeanData(SERVICE_NAME,
TestSoapHttpListener.GBEAN_INFO);
- gbean.setReferencePattern("WSContainer", wsContainer);
- kernel.loadGBean(gbean, classLoader);
- kernel.startGBean(SERVICE_NAME);
- return SERVICE_NAME;
- }
- }
-
private String getResult(InputStream responseStream) throws
ParserConfigurationException, SAXException, IOException {
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
SAXParser saxParser = saxParserFactory.newSAXParser();
@@ -256,9 +206,17 @@
private static class TestHandler extends DefaultHandler {
String result;
+ boolean found;
+ public void endElement(String uri, String localName, String qName)
throws SAXException {
+ if (qName.equals("result")){
+ found = true;
+ }
+ }
public void characters(char ch[], int start, int length) throws
SAXException {
- result = new String(ch, start, length);
+ if (!found){
+ result = new String(ch, start, length);
+ }
}
}
}