You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ni...@apache.org on 2012/07/05 05:38:54 UTC
svn commit: r1357456 - in /cxf/branches/2.6.x-fixes: ./
api/src/main/java/org/apache/cxf/endpoint/
systests/transports/src/test/java/org/apache/cxf/systest/servlet/
Author: ningjiang
Date: Thu Jul 5 03:38:54 2012
New Revision: 1357456
URL: http://svn.apache.org/viewvc?rev=1357456&view=rev
Log:
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.6.x-fixes/ (props changed)
cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletClientTest.java
cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java
Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
Merged /cxf/trunk:r1357455
Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/endpoint/ServerImpl.java?rev=1357456&r1=1357455&r2=1357456&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/endpoint/ServerImpl.java (original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/endpoint/ServerImpl.java Thu Jul 5 03:38:54 2012
@@ -173,13 +173,14 @@ public class ServerImpl implements Serve
return;
}
}
- getDestination().shutdown();
getDestination().setMessageObserver(null);
stopped = true;
}
public void destroy() {
stop();
+ // we should shutdown the destination here
+ getDestination().shutdown();
if (null != serverRegistry) {
LOG.fine("unregister the server to serverRegistry ");
Modified: cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletClientTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletClientTest.java?rev=1357456&r1=1357455&r2=1357456&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletClientTest.java (original)
+++ cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletClientTest.java Thu Jul 5 03:38:54 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,14 +46,24 @@ 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();
createStaticBus();
}
+
+ @AfterClass
+ public static void shutdownServer() throws Exception {
+ if (server != null) {
+ server.tearDown();
+ }
+ }
@Test
public void testBasicConnection() throws Exception {
@@ -75,6 +91,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.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java?rev=1357456&r1=1357455&r2=1357456&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java (original)
+++ cxf/branches/2.6.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java Thu Jul 5 03:38:54 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 {