Author: dvaleri
Date: Thu Apr 8 14:45:50 2010
New Revision: 931959
URL: http://svn.apache.org/viewvc?rev=931959&view=rev
Log:
Merged revisions 931644 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r931644 | dvaleri | 2010-04-07 15:05:50 -0400 (Wed, 07 Apr 2010) | 1 line
[CXF-2740] Tweaked Server lifecycle methods to allow for clean/complete
shutdown of JAX-WS endpoints through API and JMX.
........
Modified:
cxf/branches/2.2.x-fixes/ (props changed)
cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/endpoint/Server.java
cxf/branches/2.2.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/JCABusFactory.java
cxf/branches/2.2.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/InboundEndpoint.java
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/BareServiceTest.java
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/ClientTest.java
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/UserServiceTest.java
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/MtomTest.java
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/wrapped/WrappedServiceTest.java
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java
cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/endpoint/DummyServer.java
cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/ExplicitPrefixTest.java
cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/PublishedEndpointUrlTest.java
cxf/branches/2.2.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/management/ManagedClientServerTest.java
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Apr 8 14:45:50 2010
@@ -1 +1 @@
-/cxf/trunk:931758,931765
+/cxf/trunk:931644,931758,931765
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/endpoint/Server.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/endpoint/Server.java?rev=931959&r1=931958&r2=931959&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/endpoint/Server.java
(original)
+++
cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/endpoint/Server.java
Thu Apr 8 14:45:50 2010
@@ -27,6 +27,8 @@ public interface Server {
void stop();
+ void destroy();
+
Destination getDestination();
Endpoint getEndpoint();
Modified:
cxf/branches/2.2.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/JCABusFactory.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/JCABusFactory.java?rev=931959&r1=931958&r2=931959&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/JCABusFactory.java
(original)
+++
cxf/branches/2.2.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/JCABusFactory.java
Thu Apr 8 14:45:50 2010
@@ -174,7 +174,7 @@ public class JCABusFactory {
synchronized (servantsCache) {
for (Server servant : servantsCache) {
//REVISIT: seems using server.stop() doesn't release resource
properly.
- servant.stop();
+ servant.destroy();
LOG.info("Shutdown the EJB Endpoint: " +
servant.getEndpoint().getEndpointInfo().getName());
}
servantsCache.clear();
Modified:
cxf/branches/2.2.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/InboundEndpoint.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/InboundEndpoint.java?rev=931959&r1=931958&r2=931959&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/InboundEndpoint.java
(original)
+++
cxf/branches/2.2.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/InboundEndpoint.java
Thu Apr 8 14:45:50 2010
@@ -86,7 +86,7 @@ public class InboundEndpoint {
invoker = null;
if (server != null) {
- server.stop();
+ server.destroy();
server = null;
}
}
Modified:
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/BareServiceTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/BareServiceTest.java?rev=931959&r1=931958&r2=931959&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/BareServiceTest.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/BareServiceTest.java
Thu Apr 8 14:45:50 2010
@@ -164,7 +164,7 @@ public class BareServiceTest extends Abs
String ct = c.getContentType();
assertTrue(ct.startsWith("text/plain"));
- svr.stop();
+ svr.destroy();
}
@Test
@@ -193,7 +193,7 @@ public class BareServiceTest extends Abs
Message msg = new Message("SIMPLE_TYPE", IriDecoderHelper.BUNDLE);
assertValid("//*[text()='" + msg.toString() + "']", doc);
- svr.stop();
+ svr.destroy();
}
@Test
@@ -222,6 +222,6 @@ public class BareServiceTest extends Abs
addNamespace("b", "http://bare.http.binding.cxf.apache.org/");
assertValid("//b:getDataResponse", doc);
- svr.stop();
+ svr.destroy();
}
}
Modified:
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/ClientTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/ClientTest.java?rev=931959&r1=931958&r2=931959&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/ClientTest.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/ClientTest.java
Thu Apr 8 14:45:50 2010
@@ -80,7 +80,7 @@ public class ClientTest extends Abstract
// customer.getId());
// assertTrue(objects == null || objects.length == 0);
//
- svr.stop();
+ svr.destroy();
}
}
Modified:
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/UserServiceTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/UserServiceTest.java?rev=931959&r1=931958&r2=931959&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/UserServiceTest.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/bare/UserServiceTest.java
Thu Apr 8 14:45:50 2010
@@ -57,7 +57,7 @@ public class UserServiceTest extends Abs
addNamespace("c", "http://bare.http.binding.cxf.apache.org/");
assertValid("/c:loginResponse/return", res);
- svr.stop();
+ svr.destroy();
}
}
Modified:
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/MtomTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/MtomTest.java?rev=931959&r1=931958&r2=931959&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/MtomTest.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/mtom/MtomTest.java
Thu Apr 8 14:45:50 2010
@@ -85,7 +85,7 @@ public class MtomTest extends AbstractRe
assertEquals(2, impl.getPeople().getPerson().size());
- svr.stop();
+ svr.destroy();
}
}
Modified:
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/wrapped/WrappedServiceTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/wrapped/WrappedServiceTest.java?rev=931959&r1=931958&r2=931959&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/wrapped/WrappedServiceTest.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/bindings/http/src/test/java/org/apache/cxf/binding/http/wrapped/WrappedServiceTest.java
Thu Apr 8 14:45:50 2010
@@ -124,7 +124,7 @@ public class WrappedServiceTest extends
assertValid("/c:getCustomerResponse/c:customer/c:id[text()='123']",
res);
assertValid("/c:getCustomerResponse/c:customer/c:name[text()='Danno
Manno']", res);
- svr.stop();
+ svr.destroy();
}
}
Modified:
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java?rev=931959&r1=931958&r2=931959&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java
Thu Apr 8 14:45:50 2010
@@ -62,6 +62,11 @@ public class ManagedEndpoint implements
public void stop() {
server.stop();
}
+
+ @ManagedOperation
+ public void destroy() {
+ server.destroy();
+ }
@ManagedAttribute(description = "Address Attribute", currencyTimeLimit =
60)
public String getAddress() {
Modified:
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java?rev=931959&r1=931958&r2=931959&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
Thu Apr 8 14:45:50 2010
@@ -43,9 +43,11 @@ public class ServerImpl implements Serve
private Endpoint endpoint;
private ServerRegistry serverRegistry;
private Bus bus;
- private ServerLifeCycleManager mgr;
+ private ServerLifeCycleManager slcMgr;
+ private InstrumentationManager iMgr;
private BindingFactory bindingFactory;
private MessageObserver messageObserver;
+ private ManagedEndpoint mep;
public ServerImpl(Bus bus,
Endpoint endpoint,
@@ -90,17 +92,18 @@ public class ServerImpl implements Serve
destination = destinationFactory.getDestination(ei);
LOG.info("Setting the server's publish address to be " +
ei.getAddress());
serverRegistry = bus.getExtension(ServerRegistry.class);
-
- ManagedEndpoint mep = new ManagedEndpoint(bus, endpoint, this);
- mgr = bus.getExtension(ServerLifeCycleManager.class);
- if (mgr != null) {
- mgr.registerListener(mep);
+
+ mep = new ManagedEndpoint(bus, endpoint, this);
+
+ slcMgr = bus.getExtension(ServerLifeCycleManager.class);
+ if (slcMgr != null) {
+ slcMgr.registerListener(mep);
}
- InstrumentationManager manager =
bus.getExtension(InstrumentationManager.class);
- if (manager != null) {
+ iMgr = bus.getExtension(InstrumentationManager.class);
+ if (iMgr != null) {
try {
- manager.register(mep);
+ iMgr.register(mep);
} catch (JMException jmex) {
LOG.log(Level.WARNING, "Registering ManagedEndpoint failed.",
jmex);
}
@@ -116,6 +119,8 @@ public class ServerImpl implements Serve
}
public void start() {
+ LOG.fine("Server is starting.");
+
if (messageObserver != null) {
destination.setMessageObserver(messageObserver);
} else {
@@ -127,16 +132,22 @@ public class ServerImpl implements Serve
LOG.fine("register the server to serverRegistry ");
serverRegistry.register(this);
}
- mgr = bus.getExtension(ServerLifeCycleManager.class);
- if (mgr != null) {
- mgr.startServer(this);
+
+ if (slcMgr != null) {
+ slcMgr.startServer(this);
}
}
public void stop() {
LOG.fine("Server is stopping.");
- if (mgr != null) {
- mgr.stopServer(this);
+
+ if (slcMgr != null) {
+ slcMgr.stopServer(this);
+ }
+
+ if (null != serverRegistry) {
+ LOG.fine("unregister the server to serverRegistry ");
+ serverRegistry.unregister(this);
}
MessageObserver mo = getDestination().getMessageObserver();
@@ -148,11 +159,19 @@ public class ServerImpl implements Serve
}
getDestination().setMessageObserver(null);
getDestination().shutdown();
-
- if (null != serverRegistry) {
- LOG.fine("unregister the server to serverRegistry ");
- serverRegistry.unregister(this);
+ }
+
+ public void destroy() {
+ stop();
+
+ if (iMgr != null) {
+ try {
+ iMgr.unregister(mep);
+ } catch (JMException jmex) {
+ LOG.log(Level.WARNING, "Unregistering ManagedEndpoint
failed.", jmex);
+ }
}
+
}
public Endpoint getEndpoint() {
Modified:
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java?rev=931959&r1=931958&r2=931959&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java
Thu Apr 8 14:45:50 2010
@@ -84,7 +84,7 @@ public class ServerRegistryImpl implemen
Object[] servers = serversList.toArray();
for (int i = 0; i < servers.length; i++) {
Server server = (Server) servers[i];
- server.stop();
+ server.destroy();
}
}
Modified:
cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/endpoint/DummyServer.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/endpoint/DummyServer.java?rev=931959&r1=931958&r2=931959&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/endpoint/DummyServer.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/endpoint/DummyServer.java
Thu Apr 8 14:45:50 2010
@@ -47,6 +47,10 @@ public class DummyServer implements Serv
}
+ public void destroy() {
+ stop();
+ }
+
public MessageObserver getMessageObserver() {
return null;
}
Modified:
cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/ExplicitPrefixTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/ExplicitPrefixTest.java?rev=931959&r1=931958&r2=931959&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/ExplicitPrefixTest.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/ExplicitPrefixTest.java
Thu Apr 8 14:45:50 2010
@@ -171,6 +171,6 @@ public class ExplicitPrefixTest extends
String testPrefix = lookupPrefix(servicePrefixes,
URN_AEGIS_NAMESPACE_TEST);
assertEquals(AEGIS_TEST_NAMESPACE_PREFIX_XYZZY, testPrefix);
- serviceAndMapping.getServer().stop();
+ serviceAndMapping.getServer().destroy();
}
}
Modified:
cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?rev=931959&r1=931958&r2=931959&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
Thu Apr 8 14:45:50 2010
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.cxf.jaxws;
import java.security.AccessController;
@@ -104,6 +103,13 @@ public class EndpointImpl extends javax.
private List<Interceptor> outFault = new
ModCountCopyOnWriteArrayList<Interceptor>();
private List<Interceptor> inFault = new
ModCountCopyOnWriteArrayList<Interceptor>();
private List<Handler> handlers = new
ModCountCopyOnWriteArrayList<Handler>();
+
+ /**
+ * Flag indicating internal state of this instance. If true,
+ * the instance can have {...@link #publish(String, Object)} called
+ * and/or settings changed.
+ */
+ private boolean publishable = true;
public EndpointImpl(Object implementor) {
this(BusFactory.getThreadDefaultBus(), implementor);
@@ -201,6 +207,11 @@ public class EndpointImpl extends javax.
return server != null;
}
+ /**
+ * {...@inheritdoc}
+ * <p/>
+ * This implementation performs no action except to check the publish
permission.
+ */
@Override
public void publish(Object arg0) {
// Since this does not do anything now, just check the permission
@@ -217,6 +228,7 @@ public class EndpointImpl extends javax.
}
public void setMetadata(List<Source> metadata) {
+ checkPublishable();
this.metadata = metadata;
}
@@ -232,7 +244,7 @@ public class EndpointImpl extends javax.
@Override
public void stop() {
if (null != server) {
- server.stop();
+ server.destroy();
server = null;
}
}
@@ -255,11 +267,28 @@ public class EndpointImpl extends javax.
}
}
+ /**
+ * Performs the publication action by setting up a {...@link Server}
+ * instance based on this endpoint's configuration.
+ *
+ * @param addr the optional endpoint address.
+ *
+ * @throws IllegalStateException if the endpoint cannot be
published/republished
+ * @throws SecurityException if permission checking is enabled and policy
forbids publishing
+ * @throws WebServiceException if there is an error publishing the endpoint
+ *
+ * @see #checkPublishPermission()
+ * @see #checkPublishable()
+ * @see #getServer(String)
+ */
protected void doPublish(String addr) {
checkPublishPermission();
+ checkPublishable();
+
+ ServerImpl serv = null;
try {
- ServerImpl serv = getServer(addr);
+ serv = getServer(addr);
if (addr != null) {
EndpointInfo endpointInfo =
serv.getEndpoint().getEndpointInfo();
if (!endpointInfo.getAddress().contains(addr)) {
@@ -272,9 +301,14 @@ public class EndpointImpl extends javax.
this.address = endpointInfo.getAddress();
}
serv.start();
- } catch (WebServiceException ex) {
- throw ex;
+ publishable = false;
} catch (Exception ex) {
+ try {
+ stop();
+ } catch (Exception e) {
+ // Nothing we can do.
+ }
+
throw new WebServiceException(ex);
}
}
@@ -282,6 +316,7 @@ public class EndpointImpl extends javax.
public ServerImpl getServer() {
return getServer(null);
}
+
public synchronized ServerImpl getServer(String addr) {
if (server == null) {
checkProperties();
@@ -402,6 +437,19 @@ public class EndpointImpl extends javax.
AccessController.checkPermission(PUBLISH_PERMISSION);
}
}
+
+ /**
+ * Checks the value of {...@link #publishable} and throws
+ * an {...@link IllegalStateException} if the value is {...@code false}.
+ *
+ * @throws IllegalStateException if {...@link #publishable} is false
+ */
+ protected void checkPublishable() {
+ if (!this.publishable) {
+ throw new IllegalStateException("Cannot invoke method "
+ + "after endpoint has been published.");
+ }
+ }
public void publish() {
publish(getAddress());
Modified:
cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java?rev=931959&r1=931958&r2=931959&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
Thu Apr 8 14:45:50 2010
@@ -22,6 +22,9 @@ package org.apache.cxf.jaxws;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.ArrayList;
+
+import javax.xml.transform.Source;
import javax.xml.ws.WebServiceContext;
import org.apache.cxf.Bus;
@@ -49,14 +52,15 @@ public class EndpointImplTest extends Ab
@Test
- public void testEndpoint() throws Exception {
+ public void testEndpoint() throws Exception {
+ String address = "http://localhost:8080/test";
+
GreeterImpl greeter = new GreeterImpl();
EndpointImpl endpoint = new EndpointImpl(getBus(), greeter,
(String)null);
WebServiceContext ctx = greeter.getContext();
assertNull(ctx);
try {
- String address = "http://localhost:8080/test";
endpoint.publish(address);
} catch (IllegalArgumentException ex) {
assertTrue(ex.getCause() instanceof BusException);
@@ -66,17 +70,33 @@ public class EndpointImplTest extends Ab
assertNotNull(ctx);
+ // Test that we can't change settings through the JAX-WS API after
publishing
+
+ try {
+ endpoint.publish(address);
+ fail("republished an already published endpoint.");
+ } catch (IllegalStateException e) {
+ // expected
+ }
+
+ try {
+ endpoint.setMetadata(new ArrayList<Source>(0));
+ fail("set metadata on an already published endpoint.");
+ } catch (IllegalStateException e) {
+ // expected
+ }
}
@Test
public void testEndpointStop() throws Exception {
+ String address = "http://localhost:8080/test";
+
GreeterImpl greeter = new GreeterImpl();
EndpointImpl endpoint = new EndpointImpl(getBus(), greeter,
(String)null);
WebServiceContext ctx = greeter.getContext();
assertNull(ctx);
try {
- String address = "http://localhost:8080/test";
endpoint.publish(address);
} catch (IllegalArgumentException ex) {
assertTrue(ex.getCause() instanceof BusException);
@@ -91,6 +111,14 @@ public class EndpointImplTest extends Ab
endpoint.stop();
assertFalse(endpoint.isPublished());
+ // Test that the Endpoint cannot be restarted.
+ try {
+ endpoint.publish(address);
+ fail("stopped endpoint restarted.");
+ } catch (IllegalStateException e) {
+ // expected.
+ }
+
}
Modified:
cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/PublishedEndpointUrlTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/PublishedEndpointUrlTest.java?rev=931959&r1=931958&r2=931959&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/PublishedEndpointUrlTest.java
(original)
+++
cxf/branches/2.2.x-fixes/systests/transports/src/test/java/org/apache/cxf/systest/http/PublishedEndpointUrlTest.java
Thu Apr 8 14:45:50 2010
@@ -86,7 +86,7 @@ public class PublishedEndpointUrlTest ex
}
}
- server.stop();
+ server.destroy();
}
Modified:
cxf/branches/2.2.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/management/ManagedClientServerTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/management/ManagedClientServerTest.java?rev=931959&r1=931958&r2=931959&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/management/ManagedClientServerTest.java
(original)
+++
cxf/branches/2.2.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/management/ManagedClientServerTest.java
Thu Apr 8 14:45:50 2010
@@ -21,6 +21,7 @@ package org.apache.cxf.systest.managemen
import java.util.Set;
+import javax.management.InstanceNotFoundException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.xml.namespace.QName;
@@ -131,7 +132,14 @@ public class ManagedClientServerTest ext
reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response, reply);
-
+
+ mbs.invoke(name, "destroy", new Object[0], new String[0]);
+
+ try {
+ mbs.getMBeanInfo(name);
+ fail("destroy failed to unregister MBean.");
+ } catch (InstanceNotFoundException e) {
+ // Expected
+ }
}
-
}