Author: alessio.soldano(a)jboss.com
Date: 2010-07-08 13:28:34 -0400 (Thu, 08 Jul 2010)
New Revision: 12607
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/CustomInInterceptor.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/LoggingEndpoint.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/LoggingFeatureEndpointImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/LoggingInterceptorsEndpointImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/MessageLoggingTestCase.java
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
Log:
[JBWS-3085] Adding message logging sample
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2010-07-08
13:50:00 UTC (rev 12606)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2010-07-08
17:28:34 UTC (rev 12607)
@@ -50,6 +50,15 @@
</fileset>
</jar>
+ <!-- jaxws-cxf-logging -->
+ <jar destfile="${tests.output.dir}/test-libs/jaxws-cxf-logging.jar">
+ <fileset dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/cxf/logging/LoggingFeatureEndpointImpl.class"/>
+ <include
name="org/jboss/test/ws/jaxws/cxf/logging/LoggingInterceptorsEndpointImpl.class"/>
+ <include
name="org/jboss/test/ws/jaxws/cxf/logging/CustomInInterceptor.class"/>
+ </fileset>
+ </jar>
+
<!-- jaxws-cxf-management -->
<war warfile="${tests.output.dir}/test-libs/jaxws-cxf-management.war"
webxml="${tests.output.dir}/test-resources/jaxws/cxf/management/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/CustomInInterceptor.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/CustomInInterceptor.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/CustomInInterceptor.java 2010-07-08
17:28:34 UTC (rev 12607)
@@ -0,0 +1,21 @@
+package org.jboss.test.ws.jaxws.cxf.logging;
+
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.message.Message;
+
+public class CustomInInterceptor extends LoggingInInterceptor
+{
+ private static volatile int count = 0;
+
+ public void handleMessage(Message message) throws Fault {
+ count++;
+ super.handleMessage(message);
+ }
+
+ public static int getCount()
+ {
+ System.out.println("COUNT = "+count);
+ return count;
+ }
+}
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/CustomInInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/LoggingEndpoint.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/LoggingEndpoint.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/LoggingEndpoint.java 2010-07-08
17:28:34 UTC (rev 12607)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.cxf.logging;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
+@WebService
+public interface LoggingEndpoint
+{
+ @WebMethod
+ public String echo(String input);
+
+}
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/LoggingEndpoint.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/LoggingFeatureEndpointImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/LoggingFeatureEndpointImpl.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/LoggingFeatureEndpointImpl.java 2010-07-08
17:28:34 UTC (rev 12607)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.cxf.logging;
+
+import javax.annotation.Resource;
+import javax.ejb.Stateless;
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.xml.ws.WebServiceContext;
+
+import org.apache.cxf.feature.Features;
+import org.jboss.logging.Logger;
+
+@WebService(name = "LoggingFeatureEndpoint", targetNamespace =
"http://logging.cxf.jaxws.ws.test.jboss.org/", serviceName =
"LoggingFeatureService")
+@Stateless
+@Features(features = "org.apache.cxf.feature.LoggingFeature")
+public class LoggingFeatureEndpointImpl
+{
+ @Resource
+ WebServiceContext ctx;
+
+ @WebMethod
+ public String echo(String input)
+ {
+ Logger.getLogger(this.getClass()).info("echo: " + input);
+ return input;
+ }
+
+}
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/LoggingFeatureEndpointImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/LoggingInterceptorsEndpointImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/LoggingInterceptorsEndpointImpl.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/LoggingInterceptorsEndpointImpl.java 2010-07-08
17:28:34 UTC (rev 12607)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.cxf.logging;
+
+import javax.ejb.Stateless;
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
+import org.apache.cxf.interceptor.InInterceptors;
+import org.apache.cxf.interceptor.OutInterceptors;
+import org.jboss.logging.Logger;
+
+@WebService(name = "LoggingInterceptorsEndpoint", targetNamespace =
"http://logging.cxf.jaxws.ws.test.jboss.org/", serviceName =
"LoggingInterceptorsService")
+@Stateless
+@InInterceptors(interceptors =
"org.jboss.test.ws.jaxws.cxf.logging.CustomInInterceptor")
+//@InInterceptors(interceptors =
"org.apache.cxf.interceptor.LoggingInInterceptor")
+@OutInterceptors(interceptors =
"org.apache.cxf.interceptor.LoggingOutInterceptor")
+public class LoggingInterceptorsEndpointImpl
+{
+ @WebMethod
+ public String echo(String input)
+ {
+ Logger.getLogger(this.getClass()).info("echo: " + input);
+ return CustomInInterceptor.getCount() > 0 ? input : "Interceptor not
called";
+ }
+}
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/LoggingInterceptorsEndpointImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/MessageLoggingTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/MessageLoggingTestCase.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/MessageLoggingTestCase.java 2010-07-08
17:28:34 UTC (rev 12607)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.cxf.logging;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * Tests configuration of message exchange logging using API
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 08-Jul-2010
+ */
+public class MessageLoggingTestCase extends JBossWSTest
+{
+ private String loggingFeatureEndpointURL = "http://" + getServerHost() +
":8080/jaxws-cxf-logging/LoggingFeatureEndpoint";
+ private String loggingInterceptorsEndpointURL = "http://" + getServerHost()
+ ":8080/jaxws-cxf-logging/LoggingInterceptorsEndpoint";
+
+ private LoggingEndpoint port;
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(MessageLoggingTestCase.class,
"jaxws-cxf-logging.jar");
+ }
+
+ public void testLoggingFeature() throws Exception
+ {
+ URL wsdlURL = new URL(loggingFeatureEndpointURL + "?wsdl");
+ QName serviceName = new
QName("http://logging.cxf.jaxws.ws.test.jboss.org/",
"LoggingFeatureService");
+ Service service = Service.create(wsdlURL, serviceName);
+ QName portQName = new
QName("http://logging.cxf.jaxws.ws.test.jboss.org/",
"LoggingFeatureEndpointPort");
+ port = (LoggingEndpoint)service.getPort(portQName, LoggingEndpoint.class);
+ //This is actually just a sample, the test does not actually assert the logs are
written for the exchanges message
+ //The CXF @Feature on the endpoint ensures exchanged messages are written to the
server log
+ assertEquals("foo", port.echo("foo"));
+ }
+
+ public void testLoggingWithCustomInterceptors() throws Exception
+ {
+ URL wsdlURL = new URL(loggingInterceptorsEndpointURL + "?wsdl");
+ QName serviceName = new
QName("http://logging.cxf.jaxws.ws.test.jboss.org/",
"LoggingInterceptorsService");
+ Service service = Service.create(wsdlURL, serviceName);
+ QName portQName = new
QName("http://logging.cxf.jaxws.ws.test.jboss.org/",
"LoggingInterceptorsEndpointPort");
+ port = (LoggingEndpoint)service.getPort(portQName, LoggingEndpoint.class);
+ assertEquals("foo", port.echo("foo"));
+ }
+
+}
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/logging/MessageLoggingTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF