Added: 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/wsdl/WsdlOperationInInterceptorTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/wsdl/WsdlOperationInInterceptorTest.java?view=auto&rev=450054
==============================================================================
--- 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/wsdl/WsdlOperationInInterceptorTest.java
 (added)
+++ 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/wsdl/WsdlOperationInInterceptorTest.java
 Tue Sep 26 07:11:40 2006
@@ -0,0 +1,69 @@
+/*

+ * Licensed to the Apache Software Foundation (ASF) under one or more

+ * contributor license agreements.  See the NOTICE file distributed with

+ * this work for additional information regarding copyright ownership.

+ * The ASF licenses this file to You 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.apache.servicemix.soap.interceptors.wsdl;

+

+import java.io.ByteArrayInputStream;

+

+import javax.xml.namespace.QName;

+import javax.xml.stream.XMLStreamReader;

+

+import junit.framework.TestCase;

+

+import org.apache.servicemix.soap.api.Message;

+import org.apache.servicemix.soap.api.model.Binding;

+import org.apache.servicemix.soap.api.model.Operation;

+import org.apache.servicemix.soap.bindings.soap.impl.Wsdl1SoapBindingImpl;

+import org.apache.servicemix.soap.bindings.soap.impl.Wsdl1SoapMessageImpl;

+import org.apache.servicemix.soap.bindings.soap.impl.Wsdl1SoapOperationImpl;

+import org.apache.servicemix.soap.core.MessageImpl;

+import org.apache.servicemix.soap.util.stax.StaxUtil;

+

+public class WsdlOperationInInterceptorTest extends TestCase {

+

+    private Binding<?> binding;

+    private WsdlOperationInInterceptor interceptor;

+    

+    protected void setUp() throws Exception {

+        Wsdl1SoapBindingImpl b = new Wsdl1SoapBindingImpl();

+        Wsdl1SoapOperationImpl o1 = new Wsdl1SoapOperationImpl();

+        Wsdl1SoapMessageImpl input = new Wsdl1SoapMessageImpl();

+        input.setElementName(new QName("hello"));

+        o1.setInput(input);

+        b.addOperation(o1);

+        

+        binding = b;

+        interceptor = new WsdlOperationInInterceptor();

+    }

+    

+    public void test() throws Exception {

+        String str = "<hello />";

+        Message message = createDefaultMessage(str);

+        interceptor.handleMessage(message);

+        

+        assertNotNull(message.get(Operation.class));

+    }

+

+    private Message createDefaultMessage(String str) throws Exception {

+        Message message = new MessageImpl();

+        message.put(Binding.class, binding);

+        XMLStreamReader reader = StaxUtil.createReader(new 
ByteArrayInputStream(str.getBytes()));

+        message.setContent(XMLStreamReader.class, reader);

+        reader.nextTag();

+        return message;

+    }

+    

+}


Added: 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/xml/BodyOutInterceptor.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/xml/BodyOutInterceptor.java?view=auto&rev=450054
==============================================================================
--- 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/xml/BodyOutInterceptor.java
 (added)
+++ 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/xml/BodyOutInterceptor.java
 Tue Sep 26 07:11:40 2006
@@ -0,0 +1,45 @@
+/*

+ * Licensed to the Apache Software Foundation (ASF) under one or more

+ * contributor license agreements.  See the NOTICE file distributed with

+ * this work for additional information regarding copyright ownership.

+ * The ASF licenses this file to You 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.apache.servicemix.soap.interceptors.xml;

+

+import javax.xml.stream.XMLStreamException;

+import javax.xml.stream.XMLStreamReader;

+import javax.xml.stream.XMLStreamWriter;

+import javax.xml.transform.Source;

+

+import org.apache.servicemix.soap.api.Fault;

+import org.apache.servicemix.soap.api.Message;

+import org.apache.servicemix.soap.core.AbstractInterceptor;

+import org.apache.servicemix.soap.util.stax.StaxUtil;

+

+/**

+ * @author <a href="mailto:gnodet [at] gmail.com">Guillaume Nodet</a>

+ */

+public class BodyOutInterceptor extends AbstractInterceptor {

+

+    public void handleMessage(Message message) {

+        Source source = message.getContent(Source.class);

+        XMLStreamWriter writer = message.getContent(XMLStreamWriter.class);

+        XMLStreamReader reader = StaxUtil.createReader(source);

+        try {

+            StaxUtil.copy(reader, writer);

+        } catch (XMLStreamException e) {

+            throw new Fault(e);

+        }

+    }

+

+}


Added: 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/xml/DomInInterceptorTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/xml/DomInInterceptorTest.java?view=auto&rev=450054
==============================================================================
--- 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/xml/DomInInterceptorTest.java
 (added)
+++ 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/xml/DomInInterceptorTest.java
 Tue Sep 26 07:11:40 2006
@@ -0,0 +1,48 @@
+/*

+ * Licensed to the Apache Software Foundation (ASF) under one or more

+ * contributor license agreements.  See the NOTICE file distributed with

+ * this work for additional information regarding copyright ownership.

+ * The ASF licenses this file to You 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.apache.servicemix.soap.interceptors.xml;

+

+import java.io.ByteArrayInputStream;

+import java.io.InputStream;

+

+import junit.framework.TestCase;

+

+import org.apache.servicemix.soap.api.Message;

+import org.apache.servicemix.soap.core.MessageImpl;

+import org.w3c.dom.Document;

+

+public class DomInInterceptorTest extends TestCase {

+

+    private DomInInterceptor interceptor = new DomInInterceptor();

+    

+    public void testNullInput() {

+        Message msg = new MessageImpl();

+        interceptor.handleMessage(msg);

+        assertNull(msg.getContent(Document.class));

+    }

+    

+    public void testValidInput() throws Exception {

+        Message msg = new MessageImpl();

+        InputStream is = new ByteArrayInputStream("<hello/>".getBytes());

+        msg.setContent(InputStream.class, is);

+        interceptor.handleMessage(msg);

+        Document doc = msg.getContent(Document.class); 

+        assertNotNull(doc);

+        assertEquals("hello", doc.getDocumentElement().getLocalName());

+    }

+    

+}


Added: 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/xml/StaxInInterceptorTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/xml/StaxInInterceptorTest.java?view=auto&rev=450054
==============================================================================
--- 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/xml/StaxInInterceptorTest.java
 (added)
+++ 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/xml/StaxInInterceptorTest.java
 Tue Sep 26 07:11:40 2006
@@ -0,0 +1,50 @@
+/*

+ * Licensed to the Apache Software Foundation (ASF) under one or more

+ * contributor license agreements.  See the NOTICE file distributed with

+ * this work for additional information regarding copyright ownership.

+ * The ASF licenses this file to You 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.apache.servicemix.soap.interceptors.xml;

+

+import java.io.ByteArrayInputStream;

+import java.io.InputStream;

+

+import javax.xml.namespace.QName;

+import javax.xml.stream.XMLStreamReader;

+

+import junit.framework.TestCase;

+

+import org.apache.servicemix.soap.api.Message;

+import org.apache.servicemix.soap.core.MessageImpl;

+

+public class StaxInInterceptorTest extends TestCase {

+

+    private StaxInInterceptor interceptor = new StaxInInterceptor();

+    

+    public void testNullInput() {

+        Message msg = new MessageImpl();

+        interceptor.handleMessage(msg);

+        assertNull(msg.getContent(XMLStreamReader.class));

+    }

+    

+    public void testValidInput() throws Exception {

+        Message msg = new MessageImpl();

+        InputStream is = new ByteArrayInputStream("<hello/>".getBytes());

+        msg.setContent(InputStream.class, is);

+        interceptor.handleMessage(msg);

+        XMLStreamReader reader = msg.getContent(XMLStreamReader.class); 

+        assertNotNull(reader);

+        assertEquals(new QName("hello"), reader.getName());

+    }

+    

+}


Added: 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/xml/StaxOutInterceptorTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/xml/StaxOutInterceptorTest.java?view=auto&rev=450054
==============================================================================
--- 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/xml/StaxOutInterceptorTest.java
 (added)
+++ 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/xml/StaxOutInterceptorTest.java
 Tue Sep 26 07:11:40 2006
@@ -0,0 +1,50 @@
+/*

+ * Licensed to the Apache Software Foundation (ASF) under one or more

+ * contributor license agreements.  See the NOTICE file distributed with

+ * this work for additional information regarding copyright ownership.

+ * The ASF licenses this file to You 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.apache.servicemix.soap.interceptors.xml;

+

+import java.io.ByteArrayOutputStream;

+import java.io.OutputStream;

+

+import javax.xml.stream.XMLStreamWriter;

+

+import junit.framework.TestCase;

+

+import org.apache.servicemix.soap.api.Message;

+import org.apache.servicemix.soap.core.MessageImpl;

+

+public class StaxOutInterceptorTest extends TestCase {

+

+    private StaxOutInterceptor interceptor = new StaxOutInterceptor();

+    

+    public void testNullInput() {

+        try {

+            Message msg = new MessageImpl();

+            interceptor.handleMessage(msg);

+            fail("Interceptor should have thrown an NPE");

+        } catch (NullPointerException e) {

+        }

+    }

+    

+    public void testValidInput() throws Exception {

+        Message msg = new MessageImpl();

+        msg.setContent(OutputStream.class, new ByteArrayOutputStream());

+        interceptor.handleMessage(msg);

+        XMLStreamWriter writer = msg.getContent(XMLStreamWriter.class); 

+        assertNotNull(writer);

+    }

+    

+}


Added: 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/soap/SoapVersionFactoryTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/soap/SoapVersionFactoryTest.java?view=auto&rev=450054
==============================================================================
--- 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/soap/SoapVersionFactoryTest.java
 (added)
+++ 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/soap/SoapVersionFactoryTest.java
 Tue Sep 26 07:11:40 2006
@@ -0,0 +1,79 @@
+/*

+ * Licensed to the Apache Software Foundation (ASF) under one or more

+ * contributor license agreements.  See the NOTICE file distributed with

+ * this work for additional information regarding copyright ownership.

+ * The ASF licenses this file to You 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.apache.servicemix.soap.soap;

+

+import javax.xml.namespace.QName;

+

+import junit.framework.TestCase;

+

+import org.apache.servicemix.soap.bindings.soap.Soap11;

+import org.apache.servicemix.soap.bindings.soap.Soap12;

+import org.apache.servicemix.soap.bindings.soap.SoapVersion;

+import org.apache.servicemix.soap.bindings.soap.SoapVersionFactory;

+

+public class SoapVersionFactoryTest extends TestCase {

+    

+    public void testSoap11() {

+        SoapVersion sv = 
SoapVersionFactory.getInstance().getSoapVersion(Soap11.SOAP_NAMESPACE);

+        assertNotNull(sv);

+        assertEquals(Soap11.SOAP_NAMESPACE, sv.getNamespace());

+        assertEquals(Soap11.SOAP_DEFAULT_PREFIX, sv.getPrefix());

+    }

+

+    public void testSoap12() {

+        SoapVersion sv = 
SoapVersionFactory.getInstance().getSoapVersion(Soap12.SOAP_NAMESPACE);

+        assertNotNull(sv);

+        assertEquals(Soap12.SOAP_NAMESPACE, sv.getNamespace());

+        assertEquals(Soap12.SOAP_DEFAULT_PREFIX, sv.getPrefix());

+    }

+    

+    public void testUnkown() {

+        SoapVersion sv = 
SoapVersionFactory.getInstance().getSoapVersion("urn:soap");

+        assertNull(sv);

+    }

+    

+    public void testDerivedSoap11() {

+        SoapVersion sv = Soap11.getInstance().getDerivedVersion("S");

+        assertNotNull(sv);

+        assertEquals(Soap11.SOAP_NAMESPACE, sv.getNamespace());

+        assertEquals("S", sv.getPrefix());

+    }

+

+    public void testDerivedSoap12() {

+        SoapVersion sv = Soap12.getInstance().getDerivedVersion("S");

+        assertNotNull(sv);

+        assertEquals(Soap12.SOAP_NAMESPACE, sv.getNamespace());

+        assertEquals("S", sv.getPrefix());

+    }

+    

+    public void testDerivedSoap11FromFactory() {

+        SoapVersion sv = SoapVersionFactory.getInstance().getSoapVersion(

+                        new QName(Soap11.SOAP_NAMESPACE, "Envelope", "S"));

+        assertNotNull(sv);

+        assertEquals(Soap11.SOAP_NAMESPACE, sv.getNamespace());

+        assertEquals("S", sv.getPrefix());

+    }

+

+    public void testDerivedSoap12FromFactory() {

+        SoapVersion sv = SoapVersionFactory.getInstance().getSoapVersion(

+                        new QName(Soap12.SOAP_NAMESPACE, "Envelope", "S"));

+        assertNotNull(sv);

+        assertEquals(Soap12.SOAP_NAMESPACE, sv.getNamespace());

+        assertEquals("S", sv.getPrefix());

+    }

+

+}


Added: 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/wsdl/validator/WSIBPValidatorTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/wsdl/validator/WSIBPValidatorTest.java?view=auto&rev=450054
==============================================================================
--- 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/wsdl/validator/WSIBPValidatorTest.java
 (added)
+++ 
incubator/servicemix/trunk/sandbox/servicemix-soap2/src/test/java/org/apache/servicemix/soap/wsdl/validator/WSIBPValidatorTest.java
 Tue Sep 26 07:11:40 2006
@@ -0,0 +1,49 @@
+/*

+ * Licensed to the Apache Software Foundation (ASF) under one or more

+ * contributor license agreements.  See the NOTICE file distributed with

+ * this work for additional information regarding copyright ownership.

+ * The ASF licenses this file to You 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.apache.servicemix.soap.wsdl.validator;

+

+import javax.wsdl.Definition;

+import javax.wsdl.Operation;

+import javax.wsdl.PortType;

+import javax.wsdl.factory.WSDLFactory;

+import javax.xml.namespace.QName;

+

+import org.apache.servicemix.soap.wsdl.validator.WSIBPValidator;

+

+import junit.framework.TestCase;

+

+public class WSIBPValidatorTest extends TestCase {

+

+    public void testR2303() throws Exception {

+        Definition def = WSDLFactory.newInstance().newDefinition();

+        def.setTargetNamespace("urn:test");

+        PortType pt = def.createPortType();

+        pt.setQName(new QName("urn:test", "porttype"));

+        Operation op = def.createOperation();

+        op.setName("operation");

+        def.addPortType(pt);

+        pt.addOperation(op);

+        

+        WSIBPValidator validator = new WSIBPValidator(def);

+        assertFalse(validator.isValid());

+        

+        for (String err : validator.getErrors()) {

+            System.err.println(err);

+        }

+    }

+    

+}



Reply via email to