Author: alessio.soldano(a)jboss.com
Date: 2010-08-09 13:25:09 -0400 (Mon, 09 Aug 2010)
New Revision: 12762
Added:
stack/cxf/trunk/modules/client/src/main/resources/META-INF/bus-extensions.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/ClientServerLifeCycleTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/EndpointOne.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/EndpointOneImpl.java
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
Log:
[JBWS-3098] Install Client/serverLifeCycleManager beans also when running without Spring
and verify custom listeners can be successfully added to the bus and used
Added: stack/cxf/trunk/modules/client/src/main/resources/META-INF/bus-extensions.xml
===================================================================
--- stack/cxf/trunk/modules/client/src/main/resources/META-INF/bus-extensions.xml
(rev 0)
+++
stack/cxf/trunk/modules/client/src/main/resources/META-INF/bus-extensions.xml 2010-08-09
17:25:09 UTC (rev 12762)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<extensions
xmlns="http://cxf.apache.org/bus/extension">
+ <extension class="org.apache.cxf.endpoint.ServerLifeCycleManagerImpl"
interface="org.apache.cxf.endpoint.ServerLifeCycleManager" />
+ <extension class="org.apache.cxf.endpoint.ClientLifeCycleManagerImpl"
interface="org.apache.cxf.endpoint.ClientLifeCycleManager" />
+</extensions>
+
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-08-08
01:41:55 UTC (rev 12761)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2010-08-09
17:25:09 UTC (rev 12762)
@@ -50,6 +50,13 @@
</fileset>
</jar>
+ <!-- jaxws-cxf-jbws3098 -->
+ <jar
destfile="${tests.output.dir}/test-libs/jaxws-cxf-jbws3098.jar">
+ <fileset dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/cxf/jbws3098/EndpointOneImpl.class"/>
+ </fileset>
+ </jar>
+
<!-- jaxws-cxf-logging -->
<jar destfile="${tests.output.dir}/test-libs/jaxws-cxf-logging.jar">
<fileset dir="${tests.output.dir}/test-classes">
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/ClientServerLifeCycleTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/ClientServerLifeCycleTestCase.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/ClientServerLifeCycleTestCase.java 2010-08-09
17:25:09 UTC (rev 12762)
@@ -0,0 +1,107 @@
+/*
+ * 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.jbws3098;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.ClientLifeCycleListener;
+import org.apache.cxf.endpoint.ClientLifeCycleManager;
+import org.apache.cxf.endpoint.ServerLifeCycleManager;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * Verifies the Bus is properly configured with Client/Server LifeCycleManager instances
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 08-Aug-2010
+ *
+ */
+public class ClientServerLifeCycleTestCase extends JBossWSTest
+{
+ private String endpointOneURL = "http://" + getServerHost() +
":8080/jaxws-cxf-jbws3098/EndpointOne";
+ private String targetNS = "http://org.jboss.ws.jaxws.cxf/jbws3098";
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(ClientServerLifeCycleTestCase.class,
"jaxws-cxf-jbws3098.jar");
+ }
+
+ public void testClientLifeCycleManager()
+ {
+ Bus bus = BusFactory.newInstance().createBus();
+ assertNotNull("Cannot find ClientLifeCycleManager impl in current bus",
bus.getExtension(ClientLifeCycleManager.class));
+ bus.shutdown(true);
+ }
+
+ public void testServerLifeCycleManager()
+ {
+ Bus bus = BusFactory.newInstance().createBus();
+ assertNotNull("Cannot find ServerLifeCycleManager impl in current bus",
bus.getExtension(ServerLifeCycleManager.class));
+ bus.shutdown(true);
+ }
+
+ public void testCustomClientLifeCycleListener() throws Exception
+ {
+ URL wsdlOneURL = new URL(endpointOneURL + "?wsdl");
+ QName serviceOneName = new QName(targetNS, "ServiceOne");
+ Service serviceOne = Service.create(wsdlOneURL, serviceOneName);
+ Bus bus = BusFactory.getThreadDefaultBus(false);
+ CustomClientLifeCycleListener listener = new CustomClientLifeCycleListener();
+ bus.getExtension(ClientLifeCycleManager.class).registerListener(listener);
+ assertEquals(0, listener.getCount());
+ EndpointOne portOne = (EndpointOne)serviceOne.getPort(EndpointOne.class);
+ assertEquals(1, listener.getCount());
+ assertEquals("Foo", portOne.echo("Foo"));
+ }
+
+ private class CustomClientLifeCycleListener implements ClientLifeCycleListener
+ {
+ private volatile int count = 0;
+
+ public int getCount()
+ {
+ return count;
+ }
+
+ @Override
+ public void clientCreated(Client client)
+ {
+ count++;
+ }
+
+ @Override
+ public void clientDestroyed(Client client)
+ {
+ //NOOP
+ }
+
+ }
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/EndpointOne.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/EndpointOne.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/EndpointOne.java 2010-08-09
17:25:09 UTC (rev 12762)
@@ -0,0 +1,32 @@
+/*
+ * 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.jbws3098;
+
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+@WebService(name = "EndpointOne", targetNamespace =
"http://org.jboss.ws.jaxws.cxf/jbws3098", serviceName = "ServiceOne")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+public interface EndpointOne
+{
+ String echo(String input);
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/EndpointOneImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/EndpointOneImpl.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/EndpointOneImpl.java 2010-08-09
17:25:09 UTC (rev 12762)
@@ -0,0 +1,42 @@
+/*
+ * 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.jbws3098;
+
+import javax.ejb.Stateless;
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.jboss.logging.Logger;
+
+@WebService(name = "EndpointOne", targetNamespace =
"http://org.jboss.ws.jaxws.cxf/jbws3098", serviceName = "ServiceOne")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+@Stateless
+public class EndpointOneImpl
+{
+ @WebMethod
+ public String echo(String input)
+ {
+ Logger.getLogger(this.getClass()).info("echo: " + input);
+ return input;
+ }
+}