Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 76318 invoked from network); 20 Nov 2007 07:33:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Nov 2007 07:33:36 -0000 Received: (qmail 37663 invoked by uid 500); 20 Nov 2007 07:33:23 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 37628 invoked by uid 500); 20 Nov 2007 07:33:23 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 37619 invoked by uid 99); 20 Nov 2007 07:33:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Nov 2007 23:33:23 -0800 X-ASF-Spam-Status: No, hits=-98.5 required=10.0 tests=ALL_TRUSTED,WEIRD_PORT X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Nov 2007 07:33:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 1B66F1A9832; Mon, 19 Nov 2007 23:33:01 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r596558 - in /incubator/cxf/trunk: rt/core/src/main/java/org/apache/cxf/interceptor/ systests/src/test/java/org/apache/cxf/systest/ws/addr_feature/ Date: Tue, 20 Nov 2007 07:33:00 -0000 To: cxf-commits@incubator.apache.org From: mmao@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071120073301.1B66F1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mmao Date: Mon Nov 19 23:33:00 2007 New Revision: 596558 URL: http://svn.apache.org/viewvc?rev=596558&view=rev Log: * Add the printWriter into the logging in/out interceptors, if it's not null, log to the writer passed in * Re-Enable the tests Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java?rev=596558&r1=596557&r2=596558&view=diff ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java (original) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java Mon Nov 19 23:33:00 2007 @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.InputStream; +import java.io.PrintWriter; import java.util.logging.Level; import java.util.logging.Logger; @@ -39,7 +40,7 @@ private static final Logger LOG = LogUtils.getL7dLogger(LoggingInInterceptor.class); private int limit = 100 * 1024; - private boolean enabled; + private PrintWriter writer; public LoggingInInterceptor() { @@ -50,9 +51,9 @@ limit = lim; } - public LoggingInInterceptor(boolean b) { + public LoggingInInterceptor(PrintWriter w) { this(); - this.enabled = b; + this.writer = w; } public void setLimit(int lim) { @@ -64,7 +65,7 @@ } public void handleMessage(Message message) throws Fault { - if (enabled || LOG.isLoggable(Level.INFO)) { + if (writer != null || LOG.isLoggable(Level.INFO)) { logging(message); } } @@ -112,7 +113,9 @@ } } - if (LOG.isLoggable(Level.INFO)) { + if (writer != null) { + writer.write(buffer.toString()); + } else if (LOG.isLoggable(Level.INFO)) { LOG.info(buffer.toString()); } } Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java?rev=596558&r1=596557&r2=596558&view=diff ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java (original) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java Mon Nov 19 23:33:00 2007 @@ -20,6 +20,7 @@ package org.apache.cxf.interceptor; import java.io.OutputStream; +import java.io.PrintWriter; import java.util.logging.Level; import java.util.logging.Logger; @@ -39,7 +40,7 @@ private static final Logger LOG = LogUtils.getL7dLogger(LoggingOutInterceptor.class); private int limit = 100 * 1024; - private boolean enabled; + private PrintWriter writer; public LoggingOutInterceptor() { super(Phase.PRE_STREAM); @@ -50,9 +51,9 @@ limit = lim; } - public LoggingOutInterceptor(boolean b) { + public LoggingOutInterceptor(PrintWriter w) { this(); - this.enabled = b; + this.writer = w; } public void setLimit(int lim) { @@ -69,7 +70,7 @@ return; } - if (LOG.isLoggable(Level.INFO) || enabled) { + if (LOG.isLoggable(Level.INFO) || writer != null) { // Write the output while caching it for the log message final CacheAndWriteOutputStream newOut = new CacheAndWriteOutputStream(os); message.setContent(OutputStream.class, newOut); @@ -104,7 +105,9 @@ //ignore } - if (LOG.isLoggable(Level.INFO)) { + if (writer != null) { + writer.write(buffer.toString()); + } else if (LOG.isLoggable(Level.INFO)) { LOG.info(buffer.toString()); } } Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java?rev=596558&r1=596557&r2=596558&view=diff ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java (original) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java Mon Nov 19 23:33:00 2007 @@ -19,6 +19,8 @@ package org.apache.cxf.systest.ws.addr_feature; +import java.io.ByteArrayOutputStream; +import java.io.PrintWriter; import java.net.URL; import javax.xml.namespace.QName; import javax.xml.ws.soap.AddressingFeature; @@ -37,17 +39,9 @@ private final QName serviceName = new QName("http://apache.org/cxf/systest/ws/addr_feature/", "AddNumbersService"); - private LoggingInInterceptor in; - private LoggingOutInterceptor out; - @Before public void setUp() throws Exception { createBus(); - - in = new LoggingInInterceptor(true); - this.bus.getInInterceptors().add(in); - out = new LoggingOutInterceptor(true); - this.bus.getOutInterceptors().add(out); } @BeforeClass @@ -55,8 +49,29 @@ assertTrue("server did not launch correctly", launchServer(Server.class)); } + private ByteArrayOutputStream setupInLogging() { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + PrintWriter writer = new PrintWriter(bos); + LoggingInInterceptor in = new LoggingInInterceptor(writer); + this.bus.getInInterceptors().add(in); + return bos; + } + + private ByteArrayOutputStream setupOutLogging() { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + PrintWriter writer = new PrintWriter(bos); + + LoggingOutInterceptor out = new LoggingOutInterceptor(writer); + this.bus.getOutInterceptors().add(out); + + return bos; + } + @Test public void testNoWsaFeature() throws Exception { + ByteArrayOutputStream input = setupInLogging(); + ByteArrayOutputStream output = setupOutLogging(); + JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(AddNumbersPortType.class); factory.setAddress("http://localhost:9091/jaxws/add"); @@ -64,17 +79,18 @@ assertEquals(3, port.addNumbers(1, 2)); - /* String expectedOut = "
http://www.w3.org/2005/08/addressing/anonymous
"; String expectedIn = ""; - assertTrue(out.getBuffer().getPayload().toString().indexOf(expectedOut) == -1); - assertTrue(in.getBuffer().getPayload().toString().indexOf(expectedIn) == -1); - */ + assertTrue(output.toString().indexOf(expectedOut) == -1); + assertTrue(input.toString().indexOf(expectedIn) == -1); } @Test public void testCxfWsaFeature() throws Exception { + ByteArrayOutputStream input = setupInLogging(); + ByteArrayOutputStream output = setupOutLogging(); + JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(AddNumbersPortType.class); factory.setAddress("http://localhost:9091/jaxws/add"); @@ -82,29 +98,28 @@ AddNumbersPortType port = (AddNumbersPortType) factory.create(); assertEquals(3, port.addNumbers(1, 2)); - - /* + String expectedOut = "
http://www.w3.org/2005/08/addressing/anonymous
"; String expectedIn = ""; - assertTrue(out.getBuffer().getPayload().toString().indexOf(expectedOut) != -1); - assertTrue(in.getBuffer().getPayload().toString().indexOf(expectedIn) != -1); - */ + assertTrue(output.toString().indexOf(expectedOut) == -1); + assertTrue(input.toString().indexOf(expectedIn) == -1); } @Test public void testJaxwsWsaFeature() throws Exception { + ByteArrayOutputStream input = setupInLogging(); + ByteArrayOutputStream output = setupOutLogging(); + AddNumbersPortType port = getPort(); assertEquals(3, port.addNumbers(1, 2)); - /* String expectedOut = "
http://www.w3.org/2005/08/addressing/anonymous
"; String expectedIn = ""; - assertTrue(out.getBuffer().getPayload().toString().indexOf(expectedOut) != -1); - assertTrue(in.getBuffer().getPayload().toString().indexOf(expectedIn) != -1); - */ + assertTrue(output.toString().indexOf(expectedOut) == -1); + assertTrue(input.toString().indexOf(expectedIn) == -1); } private AddNumbersPortType getPort() {