Author: mmao
Date: Tue Dec 11 20:31:39 2007
New Revision: 603457
URL: http://svn.apache.org/viewvc?rev=603457&view=rev
Log:
CXF-1196
@BindingType(SOAP11HTTP_MTOM_BINDING) is not activating MTOM
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_bindingtype/
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_bindingtype/HelloImpl.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_bindingtype/MTOMBindingTypeTest.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_bindingtype/Server.java
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_bindingtype/HelloImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_bindingtype/HelloImpl.java?rev=603457&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_bindingtype/HelloImpl.java
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_bindingtype/HelloImpl.java
Tue Dec 11 20:31:39 2007
@@ -0,0 +1,37 @@
+/**
+ * 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.cxf.systest.mtom_bindingtype;
+
+import java.awt.Image;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.Holder;
+
+import org.apache.cxf.systest.mtom_feature.Hello;
+
[EMAIL PROTECTED](value = javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_MTOM_BINDING)
+public class HelloImpl implements Hello {
+ public void detail(Holder<byte[]> photo, Holder<Image> image) {
+ // echo through Holder
+ }
+
+ public void echoData(Holder<byte[]> data) {
+ // echo through Holder
+ }
+}
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_bindingtype/MTOMBindingTypeTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_bindingtype/MTOMBindingTypeTest.java?rev=603457&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_bindingtype/MTOMBindingTypeTest.java
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_bindingtype/MTOMBindingTypeTest.java
Tue Dec 11 20:31:39 2007
@@ -0,0 +1,126 @@
+/**
+ * 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.cxf.systest.mtom_bindingtype;
+
+import java.awt.Image;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.net.URL;
+import javax.imageio.ImageIO;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Holder;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.systest.mtom_feature.Hello;
+import org.apache.cxf.systest.mtom_feature.HelloService;
+import org.apache.cxf.systest.mtom_feature.ImageHelper;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class MTOMBindingTypeTest extends AbstractBusClientServerTestBase {
+
+ private final QName serviceName = new
QName("http://apache.org/cxf/systest/mtom_feature",
+ "HelloService");
+ //private Hello port = getPort();
+
+ @Before
+ public void setUp() throws Exception {
+ createBus();
+ }
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue("server did not launch correctly",
launchServer(Server.class));
+ }
+
+ protected ByteArrayOutputStream setupInLogging() {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ PrintWriter writer = new PrintWriter(bos, true);
+ LoggingInInterceptor in = new LoggingInInterceptor(writer);
+ this.bus.getInInterceptors().add(in);
+ return bos;
+ }
+
+ protected ByteArrayOutputStream setupOutLogging() {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ PrintWriter writer = new PrintWriter(bos, true);
+
+ LoggingOutInterceptor out = new LoggingOutInterceptor(writer);
+ this.bus.getOutInterceptors().add(out);
+
+ return bos;
+ }
+
+ @Test
+ public void testDetail() throws Exception {
+ ByteArrayOutputStream input = setupInLogging();
+ ByteArrayOutputStream output = setupOutLogging();
+
+ Holder<byte[]> photo = new Holder<byte[]>("CXF".getBytes());
+ Holder<Image> image = new Holder<Image>(getImage("/java.jpg"));
+
+ Hello port = getPort();
+
+ SOAPBinding binding = (SOAPBinding)
((BindingProvider)port).getBinding();
+ binding.setMTOMEnabled(true);
+
+
+ port.detail(photo, image);
+
+ String expected = "<xop:Include xmlns:xop=";
+ assertTrue(output.toString().indexOf(expected) != -1);
+ assertTrue(input.toString().indexOf(expected) != -1);
+
+ assertEquals("CXF", new String(photo.value));
+ assertNotNull(image.value);
+ }
+
+ @Test
+ @org.junit.Ignore
+ public void testEcho() throws Exception {
+ byte[] bytes = ImageHelper.getImageBytes(getImage("/java.jpg"),
"image/jpeg");
+ Holder<byte[]> image = new Holder<byte[]>(bytes);
+
+ Hello port = getPort();
+ SOAPBinding binding = (SOAPBinding)
((BindingProvider)port).getBinding();
+ binding.setMTOMEnabled(true);
+
+ port.echoData(image);
+ assertNotNull(image);
+ }
+
+ private Image getImage(String name) throws Exception {
+ return ImageIO.read(getClass().getResource(name));
+ }
+
+ private Hello getPort() {
+ URL wsdl = getClass().getResource("/wsdl/mtom.wsdl");
+ assertNotNull("WSDL is null", wsdl);
+
+ HelloService service = new HelloService(wsdl, serviceName);
+ assertNotNull("Service is null ", service);
+ return service.getHelloPort();
+ }
+}
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_bindingtype/Server.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_bindingtype/Server.java?rev=603457&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_bindingtype/Server.java
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom_bindingtype/Server.java
Tue Dec 11 20:31:39 2007
@@ -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.cxf.systest.mtom_bindingtype;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class Server extends AbstractBusTestServerBase {
+
+ protected void run() {
+ Object implementor = new HelloImpl();
+ String address = "http://localhost:9090/jaxws-mtom/hello";
+ Endpoint.publish(address, implementor);
+ }
+
+ public static void main(String[] args) {
+ try {
+ Server s = new Server();
+ s.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(-1);
+ } finally {
+ System.out.println("done!");
+ }
+ }
+}