Author: dkulp Date: Thu Nov 11 21:00:22 2010 New Revision: 1034119 URL: http://svn.apache.org/viewvc?rev=1034119&view=rev Log: Merged revisions 1030831 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.3.x-fixes
................ r1030831 | ema | 2010-11-04 00:21:57 -0400 (Thu, 04 Nov 2010) | 9 lines Merged revisions 1029537 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r1029537 | ema | 2010-11-01 11:24:42 +0800 (Mon, 01 Nov 2010) | 1 line [CXF-3104]:Enable threshold value configuration via @MTOM and @MTOMFeature ........ ................ Modified: cxf/branches/2.2.x-fixes/ (props changed) cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java cxf/branches/2.2.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom_feature/MtomFeatureClientServerTest.java Propchange: cxf/branches/2.2.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?rev=1034119&r1=1034118&r2=1034119&view=diff ============================================================================== --- cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java (original) +++ cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java Thu Nov 11 21:00:22 2010 @@ -181,6 +181,9 @@ public class JaxWsServiceFactoryBean ext s.put(ENDPOINT_CLASS, implInfo.getEndpointClass()); + if (s.getDataBinding() != null) { + setMTOMThreshold(s.getDataBinding()); + } return s; } @@ -632,6 +635,17 @@ public class JaxWsServiceFactoryBean ext return Collections.emptySet(); } + private void setMTOMThreshold(DataBinding databinding) { + if (this.wsFeatures != null) { + for (WebServiceFeature wsf : this.wsFeatures) { + if (wsf instanceof MTOMFeature && ((MTOMFeature)wsf).getThreshold() > 0) { + databinding.setMtomThreshold(((MTOMFeature)wsf).getThreshold()); + } + + } + } + } + @Override protected void buildServiceFromClass() { super.buildServiceFromClass(); Modified: cxf/branches/2.2.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom_feature/MtomFeatureClientServerTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom_feature/MtomFeatureClientServerTest.java?rev=1034119&r1=1034118&r2=1034119&view=diff ============================================================================== --- cxf/branches/2.2.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom_feature/MtomFeatureClientServerTest.java (original) +++ cxf/branches/2.2.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom_feature/MtomFeatureClientServerTest.java Thu Nov 11 21:00:22 2010 @@ -20,6 +20,8 @@ package org.apache.cxf.systest.mtom_feature; 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; @@ -29,8 +31,11 @@ import javax.xml.ws.Holder; import javax.xml.ws.Service; import javax.xml.ws.soap.MTOMFeature; +import org.apache.cxf.interceptor.LoggingOutInterceptor; import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; import org.apache.cxf.transport.local.LocalConduit; + +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -44,6 +49,11 @@ public class MtomFeatureClientServerTest public static void startServers() throws Exception { assertTrue("server did not launch correctly", launchServer(Server.class, true)); } + + @Before + public void setUp() throws Exception { + this.createBus(); + } @Test public void testDetail() throws Exception { @@ -112,19 +122,57 @@ public class MtomFeatureClientServerTest assertEquals("CXF", new String(photo.value)); assertNotNull(image.value); } + + @Test + public void testEchoWithLowThreshold() throws Exception { + ByteArrayOutputStream bout = this.setupOutLogging(); + byte[] bytes = ImageHelper.getImageBytes(getImage("/java.jpg"), "image/jpeg"); + Holder<byte[]> image = new Holder<byte[]>(bytes); + Hello hello = this.getPort(500); + hello.echoData(image); + assertTrue("MTOM should be enabled", bout.toString().indexOf("<xop:Include") > -1); + } + + @Test + public void testEchoWithHighThreshold() throws Exception { + ByteArrayOutputStream bout = this.setupOutLogging(); + byte[] bytes = ImageHelper.getImageBytes(getImage("/java.jpg"), "image/jpeg"); + Holder<byte[]> image = new Holder<byte[]>(bytes); + Hello hello = this.getPort(2000); + hello.echoData(image); + assertTrue("MTOM should not be enabled", bout.toString().indexOf("<xop:Include") == -1); + } + + private ByteArrayOutputStream setupOutLogging() { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + PrintWriter writer = new PrintWriter(bos, true); + + LoggingOutInterceptor out = new LoggingOutInterceptor(writer); + this.bus.getOutInterceptors().add(out); + + return bos; + } private Image getImage(String name) throws Exception { return ImageIO.read(getClass().getResource(name)); } private Hello getPort() { + return getPort(0); + } + private Hello getPort(int threshold) { URL wsdl = getClass().getResource("/wsdl_systest/mtom.wsdl"); assertNotNull("WSDL is null", wsdl); HelloService service = new HelloService(wsdl, serviceName); assertNotNull("Service is null ", service); - //return service.getHelloPort(); - Hello hello = service.getHelloPort(new MTOMFeature()); + //return service.getHelloPort(); + MTOMFeature mtomFeature = new MTOMFeature(); + if (threshold > 0) { + mtomFeature = new MTOMFeature(true, threshold); + } + Hello hello = service.getHelloPort(mtomFeature); + try { updateAddressPort(hello, PORT); } catch (Exception e) {
