Commit in servicemix/ws/xmlbeans/src/test/java/org/servicemix/ws/addressing on MAIN
AddressingTest.java+121added 1.1
migrated the XMLBeans code into a sub module

servicemix/ws/xmlbeans/src/test/java/org/servicemix/ws/addressing
AddressingTest.java added at 1.1
diff -N AddressingTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ AddressingTest.java	23 Aug 2005 09:02:55 -0000	1.1
@@ -0,0 +1,121 @@
+/** 
+ * 
+ * Copyright 2005 Protique Ltd
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); 
+ * you may not use this file except in compliance with the License. 
+ * You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ * 
+ **/
+package org.servicemix.ws.addressing;
+
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamWriter;
+
+import junit.framework.TestCase;
+
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.codehaus.activesoap.MessageExchange;
+import org.codehaus.activesoap.SoapService;
+import org.codehaus.activesoap.handler.xmlbeans.XMLBeansHandler;
+import org.codehaus.activesoap.handler.xmlbeans.XMLBeansRegistry;
+import org.servicemix.ws.xmlbeans.addressing.v2003_03.ActionDocument;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class AddressingTest extends TestCase {
+    private XmlObject invokeBody;
+
+    public void testParse() throws Exception {
+        System.out.println("Value:"+getClass().getResourceAsStream("wsa.xml"));
+        
+        XmlObject xmlObject = XmlObject.Factory.parse(getClass().getResourceAsStream("wsa.xml"));
+        assertNotNull("null xmlObject", xmlObject);
+
+        System.out.println("Parsed: " + xmlObject);
+        System.out.println("Class: " + xmlObject.getClass());
+
+        QName actionQName = ActionDocument.type.getName();
+
+        XmlCursor cursor = xmlObject.newCursor();
+
+        //System.out.println("current qname: " + cursor.getName());
+
+        while (cursor.hasNextToken()) {
+            XmlCursor.TokenType type = cursor.toNextToken();
+            System.out.println("type: " + type);
+            if (type.isStart()) {
+                QName name = cursor.getName();
+                System.out.println("at start of qname: " + name);
+                if (name.getLocalPart().equals("Action")) {
+                    break;
+                }
+            }
+        }
+        /*
+        XmlObject foo = cursor.getObject();
+        XmlObject[] xmlObjects = foo.selectChildren(actionQName);
+        assertEquals("results", 1, xmlObjects.length);
+        */
+
+        XmlObject action = ""
+        System.out.println("action is: " + action);
+
+        /** TODO
+        assertTrue("Should have AttributedURI  instead of: " + action.getClass(), action instanceof AttributedURI);
+        AttributedURI actionReference = (AttributedURI) action;
+
+        System.out.println("actionRefernce is: " + actionReference);
+        assertEquals("actionURI", "http://docs.oasis-open.org/wsn/2004/06/WS-BaseNotification/Notify", actionReference.xmlText());
+        */
+    }
+
+    public void testAddresssingContext() throws Exception {
+        XMLBeansRegistry registry = new XMLBeansRegistry();
+        registry.setDefaultHandler(new XMLBeansHandler() {
+            protected void handleBody(MessageExchange exchange, XmlObject body, XMLStreamWriter out) throws Exception {
+                invokeBody = body;
+            }
+        });
+
+        SoapService service = new SoapService(registry);
+        service.addPolicy(new AddressingPolicy());
+
+        StringWriter buffer = new StringWriter();
+        service.invoke(new InputStreamReader(getClass().getResourceAsStream("notify.xml")), buffer);
+
+        String text = buffer.toString();
+        System.out.println("Received response");
+        System.out.println(text);
+
+        assertNotNull("null invokeBody", invokeBody);
+
+        /**
+         *
+        EndpointReferenceType endpointReference = AddressingContext.getEndpointReference();
+        assertNotNull("null endpointReference", endpointReference);
+
+        System.out.println("address: " + endpointReference.getAddress());
+        System.out.println("portType: " + endpointReference.getPortType());
+        System.out.println("serviceName: " + endpointReference.getServiceName());
+
+        assertNotNull("null endpointReference.getAddress()", endpointReference.getAddress());
+        assertNotNull("null endpointReference.getPortType()", endpointReference.getPortType());
+        assertNotNull("null endpointReference.getServiceName()", endpointReference.getServiceName());
+        */
+    }
+
+}
CVSspam 0.2.8



Reply via email to