Author: ningjiang Date: Thu Jul 5 07:10:13 2012 New Revision: 1357477 URL: http://svn.apache.org/viewvc?rev=1357477&view=rev Log: Merged revisions 1357461 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes
................ r1357461 | ningjiang | 2012-07-05 13:01:22 +0800 (Thu, 05 Jul 2012) | 16 lines Merged revisions 1357456 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes ................ r1357456 | ningjiang | 2012-07-05 11:38:54 +0800 (Thu, 05 Jul 2012) | 9 lines Merged revisions 1357455 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r1357455 | ningjiang | 2012-07-05 11:30:32 +0800 (Thu, 05 Jul 2012) | 1 line CXF-4407 Fix the issue of Server.start() ........ ................ ................ Modified: cxf/branches/2.4.x-fixes/ (props changed) cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java cxf/branches/2.4.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletClientTest.java cxf/branches/2.4.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java Propchange: cxf/branches/2.4.x-fixes/ ------------------------------------------------------------------------------ Merged /cxf/branches/2.5.x-fixes:r1357461 Merged /cxf/trunk:r1357455 Merged /cxf/branches/2.6.x-fixes:r1357456 Propchange: cxf/branches/2.4.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java?rev=1357477&r1=1357476&r2=1357477&view=diff ============================================================================== --- cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java (original) +++ cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java Thu Jul 5 07:10:13 2012 @@ -157,11 +157,6 @@ public class ServerImpl implements Serve if (slcMgr != null) { slcMgr.stopServer(this); } - - if (null != serverRegistry) { - LOG.fine("unregister the server to serverRegistry "); - serverRegistry.unregister(this); - } MessageObserver mo = getDestination().getMessageObserver(); if (mo instanceof MultipleEndpointObserver) { @@ -170,7 +165,7 @@ public class ServerImpl implements Serve return; } } - getDestination().shutdown(); + getDestination().setMessageObserver(null); stopped = true; } @@ -178,6 +173,14 @@ public class ServerImpl implements Serve public void destroy() { stop(); + // we should shutdown the destination here + getDestination().shutdown(); + + if (null != serverRegistry) { + LOG.fine("unregister the server to serverRegistry "); + serverRegistry.unregister(this); + } + if (iMgr != null) { try { iMgr.unregister(mep); Modified: cxf/branches/2.4.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletClientTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletClientTest.java?rev=1357477&r1=1357476&r2=1357477&view=diff ============================================================================== --- cxf/branches/2.4.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletClientTest.java (original) +++ cxf/branches/2.4.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletClientTest.java Thu Jul 5 07:10:13 2012 @@ -21,6 +21,7 @@ package org.apache.cxf.systest.servlet; import java.lang.reflect.UndeclaredThrowableException; import java.net.URL; import java.util.HashSet; +import java.util.List; import java.util.Set; import javax.xml.namespace.QName; @@ -29,10 +30,15 @@ import com.meterware.httpunit.WebConvers import com.meterware.httpunit.WebLink; import com.meterware.httpunit.WebResponse; +import org.apache.cxf.Bus; +import org.apache.cxf.endpoint.Server; +import org.apache.cxf.endpoint.ServerRegistry; import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; import org.apache.hello_world_soap_http.Greeter; import org.apache.hello_world_soap_http.SOAPService; + +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -40,12 +46,22 @@ import org.junit.Test; public class NoSpringServletClientTest extends AbstractBusClientServerTestBase { private static final String PORT = NoSpringServletServer.PORT; - + private static Bus serverBus; + private static NoSpringServletServer server; private final QName portName = new QName("http://apache.org/hello_world_soap_http", "SoapPort"); private final String serviceURL = "http://localhost:" + PORT + "/soap/"; @BeforeClass public static void startServers() throws Exception { - assertTrue("server did not launch correctly", launchServer(NoSpringServletServer.class)); + server = new NoSpringServletServer(); + server.run(); + serverBus = server.getBus(); + } + + @AfterClass + public static void shutdownServer() throws Exception { + if (server != null) { + server.tearDown(); + } } @Test @@ -74,6 +90,37 @@ public class NoSpringServletClientTest e String reply = hello.sayHi(" Willem"); assertEquals("Get the wrongreply ", reply, "get Willem"); } + + @Test + public void testStartAndStopServer() throws Exception { + stopServer(); + // we should not invoke the server this time + try { + testHelloService(); + fail("Expect Exception here."); + } catch (Exception ex) { + // do nothing here + } + startServer(); + testHelloService(); + } + + private void stopServer() { + ServerRegistry reg = serverBus.getExtension(ServerRegistry.class); + List<Server> servers = reg.getServers(); + for (Server serv : servers) { + System.out.println("expect to get a server here!"); + serv.stop(); + } + } + + private void startServer() { + ServerRegistry reg = serverBus.getExtension(ServerRegistry.class); + List<Server> servers = reg.getServers(); + for (Server serv : servers) { + serv.start(); + } + } @Test public void testGetServiceList() throws Exception { Modified: cxf/branches/2.4.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java?rev=1357477&r1=1357476&r2=1357477&view=diff ============================================================================== --- cxf/branches/2.4.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java (original) +++ cxf/branches/2.4.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java Thu Jul 5 07:10:13 2012 @@ -33,9 +33,8 @@ import org.eclipse.jetty.servlet.Servlet public class NoSpringServletServer extends AbstractBusTestServerBase { public static final String PORT = allocatePort(NoSpringServletServer.class); - - Server httpServer; + Bus bus; @Override protected void run() { // setup the system properties @@ -48,7 +47,7 @@ public class NoSpringServletServer exten ServletContextHandler root = new ServletContextHandler(contexts, "/", ServletContextHandler.SESSIONS); - Bus bus = BusFactory.getDefaultBus(true); + bus = BusFactory.getDefaultBus(true); CXFServlet cxf = new CXFServlet(); cxf.setBus(bus); ServletHolder servlet = new ServletHolder(cxf); @@ -83,6 +82,11 @@ public class NoSpringServletServer exten httpServer.stop(); } } + + public Bus getBus() { + return bus; + } + public static void main(String[] args) { try {
