cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1348174 - in /cxf/branches/2.5.x-fixes: rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/ rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/ rt/ws/security/src/main/resources/META-INF/cxf/ systests/ws-security/src...
Date Fri, 08 Jun 2012 18:21:23 GMT
Author: dkulp
Date: Fri Jun  8 18:21:22 2012
New Revision: 1348174

URL: http://svn.apache.org/viewvc?rev=1348174&view=rev
Log:
Merged revisions 1347723 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1347723 | dkulp | 2012-06-07 13:33:28 -0400 (Thu, 07 Jun 2012) | 3 lines

  [CXF-4366] Make sure the token/replay stores are cleaned up when
  endpoints and bus's are stopped.

........

Added:
    cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/CacheCleanupListener.java
  (with props)
Modified:
    cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheManagerHolder.java
    cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java
    cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCacheFactory.java
    cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java
    cxf/branches/2.5.x-fixes/rt/ws/security/src/main/resources/META-INF/cxf/bus-extensions.txt
    cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java
    cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java
    cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java
    cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/WSSCTest.java
    cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/server/Server.java
    cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec10/server/Server.java
    cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/AbstractServer.java
    cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/Server11.java
    cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/Server12.java
    cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/server/Server.java

Added: cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/CacheCleanupListener.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/CacheCleanupListener.java?rev=1348174&view=auto
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/CacheCleanupListener.java
(added)
+++ cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/CacheCleanupListener.java
Fri Jun  8 18:21:22 2012
@@ -0,0 +1,82 @@
+/**
+ * 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.
+ */
+
+package org.apache.cxf.ws.security.cache;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.ClientLifeCycleListener;
+import org.apache.cxf.endpoint.ClientLifeCycleManager;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.endpoint.ServerLifeCycleListener;
+import org.apache.cxf.endpoint.ServerLifeCycleManager;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.ws.security.SecurityConstants;
+import org.apache.ws.security.cache.ReplayCache;
+
+/**
+ * 
+ */
+public class CacheCleanupListener implements ServerLifeCycleListener, ClientLifeCycleListener
{
+    
+    public CacheCleanupListener(Bus b) {
+        ServerLifeCycleManager m = b.getExtension(ServerLifeCycleManager.class);
+        if (m != null) {
+            m.registerListener(this);
+        }
+        ClientLifeCycleManager cm = b.getExtension(ClientLifeCycleManager.class);
+        if (cm != null) {
+            cm.registerListener(this);
+        }
+    }
+    public void clientCreated(Client client) {
+    }
+    public void startServer(Server server) {
+    }
+
+    public void clientDestroyed(Client client) {
+        shutdownResources(client.getEndpoint().getEndpointInfo());
+    }
+    public void stopServer(Server server) {
+        shutdownResources(server.getEndpoint().getEndpointInfo());
+    }
+    
+    
+    protected void shutdownResources(EndpointInfo info) {
+        ReplayCache rc = (ReplayCache)info.getProperty(SecurityConstants.NONCE_CACHE_INSTANCE);
+        if (rc instanceof Closeable) {
+            close((Closeable)rc);
+        }
+        rc = (ReplayCache)info.getProperty(SecurityConstants.TIMESTAMP_CACHE_INSTANCE);
+        if (rc instanceof Closeable) {
+            close((Closeable)rc);
+        }
+    }
+    
+    private void close(Closeable ts) {
+        try {
+            ts.close();
+        } catch (IOException ex) {
+            //ignore, we're shutting down and nothing we can do
+        }
+    }
+}

Propchange: cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/CacheCleanupListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/CacheCleanupListener.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheManagerHolder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheManagerHolder.java?rev=1348174&r1=1348173&r2=1348174&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheManagerHolder.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheManagerHolder.java
Fri Jun  8 18:21:22 2012
@@ -19,11 +19,19 @@
 
 package org.apache.cxf.ws.security.cache;
 
+import java.io.IOException;
 import java.net.URL;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.config.CacheConfiguration;
+import net.sf.ehcache.config.Configuration;
+import net.sf.ehcache.config.ConfigurationFactory;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.resource.ResourceManager;
 
 /**
  * We need to reference count the EHCacheManager things
@@ -36,25 +44,99 @@ public final class EHCacheManagerHolder 
         //utility
     }
     
-    public static CacheManager getCacheManager(URL configFileURL) {
-        CacheManager cacheManager;
-        if (configFileURL == null) {
-            cacheManager = CacheManager.create();
+    
+    public static CacheConfiguration getCacheConfiguration(String key,
+                                                           CacheManager cacheManager) {
+        CacheConfiguration cc = cacheManager.getConfiguration().getCacheConfigurations().get(key);
+        if (cc == null && key.contains("-")) {
+            cc = cacheManager.getConfiguration().getCacheConfigurations().get(key.substring(0,
key.indexOf('-')));
+        }
+        if (cc == null) {
+            cc = cacheManager.getConfiguration().getDefaultCacheConfiguration();
+        }
+        if (cc == null) {
+            cc = new CacheConfiguration();
         } else {
-            cacheManager = CacheManager.create(configFileURL);
+            cc = (CacheConfiguration)cc.clone();
+        }
+        cc.setName(key);
+        return cc;
+    }
+    
+    public static CacheManager getCacheManager(Bus bus, URL configFileURL) {
+        CacheManager cacheManager = null;
+        if (configFileURL == null) {
+            //using the default
+            cacheManager = findDefaultCacheManager(bus);
+        }
+        if (cacheManager == null) {
+            if (configFileURL == null) {
+                cacheManager = CacheManager.create();
+            } else {
+                cacheManager = CacheManager.create(configFileURL);
+            }
         }
         AtomicInteger a = COUNTS.get(cacheManager.getName());
         if (a == null) {
             COUNTS.putIfAbsent(cacheManager.getName(), new AtomicInteger());
             a = COUNTS.get(cacheManager.getName());
         }
-        a.incrementAndGet();
+        if (a.incrementAndGet() == 1) {
+            //System.out.println("Create!! " + cacheManager.getName());
+        }
         return cacheManager;
     }
     
+    private static CacheManager findDefaultCacheManager(Bus bus) {
+
+        String defaultConfigFile = "cxf-ehcache.xml";
+        URL configFileURL = null;
+        if (bus != null) {
+            ResourceManager rm = bus.getExtension(ResourceManager.class);
+            configFileURL = rm.resolveResource(defaultConfigFile, URL.class);
+        }
+        try {
+            if (configFileURL == null) {
+                configFileURL = 
+                    ClassLoaderUtils.getResource(defaultConfigFile, EHCacheReplayCacheFactory.class);
+            }
+            if (configFileURL == null) {
+                configFileURL = new URL(defaultConfigFile);
+            }
+        } catch (IOException e) {
+            // Do nothing
+        }
+        try {
+            Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
+            /*
+            String perBus = (String)bus.getProperty("ws-security.cachemanager.per.bus");
+            if (perBus == null) {
+                perBus = "true";
+            }
+            if (Boolean.parseBoolean(perBus)) {
+                conf.setName(bus.getId());
+                if ("java.io.tmpdir".equals(conf.getDiskStoreConfiguration().getOriginalPath()))
{
+                    
+                    String path = conf.getDiskStoreConfiguration().getPath() + File.separator
+                        + bus.getId();
+                    conf.getDiskStoreConfiguration().setPath(path);
+                }
+            }
+            */
+            return CacheManager.create(conf);
+        } catch (Throwable t) {
+            return null;
+        }
+    }
+
+
     public static void releaseCacheManger(CacheManager cacheManager) {
         AtomicInteger a = COUNTS.get(cacheManager.getName());
+        if (a == null) {
+            return;
+        }
         if (a.decrementAndGet() == 0) {
+            //System.out.println("Shutdown!! " + cacheManager.getName());
             cacheManager.shutdown();
         }
     }

Modified: cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java?rev=1348174&r1=1348173&r2=1348174&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java
Fri Jun  8 18:21:22 2012
@@ -20,7 +20,6 @@
 package org.apache.cxf.ws.security.cache;
 
 import java.io.Closeable;
-import java.io.IOException;
 import java.net.URL;
 
 import net.sf.ehcache.Cache;
@@ -28,22 +27,30 @@ import net.sf.ehcache.CacheManager;
 import net.sf.ehcache.Ehcache;
 import net.sf.ehcache.Element;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.buslifecycle.BusLifeCycleListener;
+import org.apache.cxf.buslifecycle.BusLifeCycleManager;
 import org.apache.ws.security.cache.ReplayCache;
 
 /**
  * An in-memory EHCache implementation of the ReplayCache interface. The default TTL is 60
minutes and the
  * max TTL is 12 hours.
  */
-public class EHCacheReplayCache implements ReplayCache, Closeable {
+public class EHCacheReplayCache implements ReplayCache, Closeable, BusLifeCycleListener {
     
     public static final long DEFAULT_TTL = 3600L;
     public static final long MAX_TTL = DEFAULT_TTL * 12L;
     private Ehcache cache;
     private CacheManager cacheManager;
+    private Bus bus;
     private long ttl = DEFAULT_TTL;
     
-    public EHCacheReplayCache(String key, URL configFileURL) {
-        cacheManager = EHCacheManagerHolder.getCacheManager(configFileURL);
+    public EHCacheReplayCache(String key, Bus b, URL configFileURL) {
+        bus = b;
+        if (bus != null) {
+            bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(this);
+        }
+        cacheManager = EHCacheManagerHolder.getCacheManager(bus, configFileURL);
         
         Ehcache newCache = new Cache(key, 50000, true, false, DEFAULT_TTL, DEFAULT_TTL);
         cache = cacheManager.addCacheIfAbsent(newCache);
@@ -112,12 +119,25 @@ public class EHCacheReplayCache implemen
         return false;
     }
 
-    public void close() throws IOException {
+    public synchronized void close() {
         if (cacheManager != null) {
             EHCacheManagerHolder.releaseCacheManger(cacheManager);
             cacheManager = null;
             cache = null;
+            if (bus != null) {
+                bus.getExtension(BusLifeCycleManager.class).unregisterLifeCycleListener(this);
+            }
         }
+        
+    }
+
+    public void initComplete() {
+    }
+    public void preShutdown() {
+        close();
+    }
+    public void postShutdown() {
+        close();
     }
     
 }

Modified: cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCacheFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCacheFactory.java?rev=1348174&r1=1348173&r2=1348174&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCacheFactory.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCacheFactory.java
Fri Jun  8 18:21:22 2012
@@ -19,14 +19,9 @@
 
 package org.apache.cxf.ws.security.cache;
 
-import java.io.IOException;
 import java.net.URL;
 
-import org.apache.cxf.Bus;
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.message.Message;
-import org.apache.cxf.resource.ResourceManager;
-import org.apache.cxf.ws.security.SecurityConstants;
 import org.apache.ws.security.cache.ReplayCache;
 
 /**
@@ -36,26 +31,7 @@ public class EHCacheReplayCacheFactory e
     
     public ReplayCache newReplayCache(String key, Message message) {
         URL configFileURL = getConfigFileURL(message);
-        if (configFileURL == null) {
-            String defaultConfigFile = "cxf-ehcache.xml";
-            ResourceManager rm = message.getExchange().get(Bus.class).getExtension(ResourceManager.class);
-            configFileURL = rm.resolveResource(defaultConfigFile, URL.class);
-            try {
-                if (configFileURL == null) {
-                    configFileURL = 
-                        ClassLoaderUtils.getResource(defaultConfigFile, EHCacheReplayCacheFactory.class);
-                }
-                if (configFileURL == null) {
-                    configFileURL = new URL(defaultConfigFile);
-                }
-            } catch (IOException e) {
-                // Do nothing
-            }
-        }
-        if (configFileURL != null) {
-            message.setContextualProperty(SecurityConstants.CACHE_CONFIG_FILE, configFileURL);
-        }
-        return new EHCacheReplayCache(key, configFileURL);
+        return new EHCacheReplayCache(key, message.getExchange().getBus(), configFileURL);
     }
     
 }

Modified: cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java?rev=1348174&r1=1348173&r2=1348174&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java
Fri Jun  8 18:21:22 2012
@@ -19,8 +19,6 @@
 
 package org.apache.cxf.ws.security.policy;
 
-import java.io.Closeable;
-import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
 
@@ -28,20 +26,12 @@ import javax.xml.namespace.QName;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.injection.NoJSR250Annotations;
-import org.apache.cxf.endpoint.Client;
-import org.apache.cxf.endpoint.ClientLifeCycleListener;
-import org.apache.cxf.endpoint.ClientLifeCycleManager;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.endpoint.ServerLifeCycleListener;
-import org.apache.cxf.endpoint.ServerLifeCycleManager;
-import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.ws.policy.AssertionBuilderLoader;
 import org.apache.cxf.ws.policy.AssertionBuilderRegistry;
 import org.apache.cxf.ws.policy.PolicyBuilder;
 import org.apache.cxf.ws.policy.PolicyInterceptorProviderLoader;
 import org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry;
 import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertionBuilder;
-import org.apache.cxf.ws.security.SecurityConstants;
 import org.apache.cxf.ws.security.policy.builders.AlgorithmSuiteBuilder;
 import org.apache.cxf.ws.security.policy.builders.AsymmetricBindingBuilder;
 import org.apache.cxf.ws.security.policy.builders.ContentEncryptedElementsBuilder;
@@ -87,7 +77,6 @@ import org.apache.cxf.ws.security.policy
 import org.apache.cxf.ws.security.policy.interceptors.UsernameTokenInterceptorProvider;
 import org.apache.cxf.ws.security.policy.interceptors.WSSecurityInterceptorProvider;
 import org.apache.cxf.ws.security.policy.interceptors.WSSecurityPolicyInterceptorProvider;
-import org.apache.ws.security.cache.ReplayCache;
 
 @NoJSR250Annotations
 public final class WSSecurityPolicyLoader implements PolicyInterceptorProviderLoader, AssertionBuilderLoader
{
@@ -104,45 +93,8 @@ public final class WSSecurityPolicyLoade
             //and error out at that point.  If nothing uses ws-securitypolicy
             //no warnings/errors will display
         }
-        ServerLifeCycleManager m = b.getExtension(ServerLifeCycleManager.class);
-        if (m != null) {
-            m.registerListener(new ServerLifeCycleListener() {
-                public void startServer(Server server) {
-                }
-                public void stopServer(Server server) {
-                    shutdownResources(server.getEndpoint().getEndpointInfo());
-                }
-            });
-        }
-        ClientLifeCycleManager cm = b.getExtension(ClientLifeCycleManager.class);
-        if (cm != null) {
-            cm.registerListener(new ClientLifeCycleListener() {
-                public void clientCreated(Client client) {
-                }
-                public void clientDestroyed(Client client) {
-                    shutdownResources(client.getEndpoint().getEndpointInfo());
-                }
-            });
-        }
-    }
-    protected void shutdownResources(EndpointInfo info) {
-        ReplayCache rc = (ReplayCache)info.getProperty(SecurityConstants.NONCE_CACHE_INSTANCE);
-        if (rc instanceof Closeable) {
-            close((Closeable)rc);
-        }
-        rc = (ReplayCache)info.getProperty(SecurityConstants.TIMESTAMP_CACHE_INSTANCE);
-        if (rc instanceof Closeable) {
-            close((Closeable)rc);
-        }
     }
     
-    private void close(Closeable ts) {
-        try {
-            ts.close();
-        } catch (IOException ex) {
-            //ignore, we're shutting down and nothing we can do
-        }
-    }
     public void registerBuilders() {
         AssertionBuilderRegistry reg = bus.getExtension(AssertionBuilderRegistry.class);
         if (reg == null) {

Modified: cxf/branches/2.5.x-fixes/rt/ws/security/src/main/resources/META-INF/cxf/bus-extensions.txt
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/ws/security/src/main/resources/META-INF/cxf/bus-extensions.txt?rev=1348174&r1=1348173&r2=1348174&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/ws/security/src/main/resources/META-INF/cxf/bus-extensions.txt
(original)
+++ cxf/branches/2.5.x-fixes/rt/ws/security/src/main/resources/META-INF/cxf/bus-extensions.txt
Fri Jun  8 18:21:22 2012
@@ -1 +1,2 @@
-org.apache.cxf.ws.security.policy.WSSecurityPolicyLoader::true
+org.apache.cxf.ws.security.policy.WSSecurityPolicyLoader::true:true
+org.apache.cxf.ws.security.cache.CacheCleanupListener::true:true

Modified: cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java?rev=1348174&r1=1348173&r2=1348174&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java
(original)
+++ cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/FaultTest.java
Fri Jun  8 18:21:22 2012
@@ -33,6 +33,7 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.jaxws.DispatchImpl;
@@ -98,13 +99,12 @@ public class FaultTest extends AbstractB
         } catch (Exception ex) {
             assertTrue(ex.getMessage().contains("This is a fault"));
         }
-        
+        ((java.io.Closeable)utPort).close();
         bus.shutdown(true);
     }
     
     @org.junit.Test
     public void testSoap12() throws Exception {
-
         SpringBusFactory bf = new SpringBusFactory();
         URL busFile = FaultTest.class.getResource("client/client.xml");
 
@@ -132,13 +132,14 @@ public class FaultTest extends AbstractB
         } catch (Exception ex) {
             assertTrue(ex.getMessage().contains("This is a fault"));
         }
-        
+        ((java.io.Closeable)utPort).close();
         bus.shutdown(true);
     }
     
     @org.junit.Test
     public void testSoap12Dispatch() throws Exception {
-        
+        createBus();
+        BusFactory.setDefaultBus(getBus());
         URL wsdl = FaultTest.class.getResource("DoubleItFault.wsdl");
         Service service = Service.create(wsdl, SERVICE_QNAME);
         QName portQName = new QName(NAMESPACE, "DoubleItSoap12DispatchPort");
@@ -186,6 +187,8 @@ public class FaultTest extends AbstractB
         } catch (Exception ex) {
             assertTrue(ex.getMessage().contains("This is a fault"));
         }
+        
+        client.destroy();
     }
     
     

Modified: cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java?rev=1348174&r1=1348173&r2=1348174&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java
(original)
+++ cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java
Fri Jun  8 18:21:22 2012
@@ -45,6 +45,7 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.helpers.XPathUtils;
@@ -200,7 +201,6 @@ public class SecurityPolicyTest extends 
     @org.junit.AfterClass
     public static void cleanup() throws Exception {
         SecurityTestUtil.cleanup();
-        getStaticBus().shutdown(true);
         stopAllServers();
     }
     
@@ -449,6 +449,8 @@ public class SecurityPolicyTest extends 
                                                       getClass().getResource("bob.properties"));
         assertEquals(10, pt.doubleIt(5));
         
+        
+        ((java.io.Closeable)pt).close();
         bus.shutdown(true);
     }
 
@@ -476,7 +478,7 @@ public class SecurityPolicyTest extends 
         ((BindingProvider)pt).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,

                                                       getClass().getResource("alice.properties"));
         assertEquals(10, pt.doubleIt(5));
-        
+        ((java.io.Closeable)pt).close();
         bus.shutdown(true);
     }
     
@@ -507,7 +509,7 @@ public class SecurityPolicyTest extends 
         DoubleIt di = new DoubleIt();
         di.setNumberToDouble(5);
         assertEquals(10, pt.doubleIt(di, 1).getDoubledNumber());
-        
+        ((java.io.Closeable)pt).close();
         bus.shutdown(true);
     }
     
@@ -549,12 +551,14 @@ public class SecurityPolicyTest extends 
                        || errorMessage.contains("Certificate revocation")
                        || errorMessage.contains("Error during certificate path validation"));
         }
-        
+        ((java.io.Closeable)pt).close();
         bus.shutdown(true);
     }
     
     @Test
     public void testCXF4122() throws Exception {
+        Bus epBus = BusFactory.newInstance().createBus();
+        BusFactory.setDefaultBus(epBus);
         URL wsdl = SecurityPolicyTest.class.getResource("DoubleIt.wsdl");
         EndpointImpl ep = (EndpointImpl)Endpoint.create(new DoubleItImpl());
         ep.setEndpointName(
@@ -598,7 +602,9 @@ public class SecurityPolicyTest extends 
                        || errorMessage.contains("Certificate revocation")
                        || errorMessage.contains("Error during certificate path validation"));
         }
-
+        ((java.io.Closeable)pt).close();
+        ep.stop();
+        epBus.shutdown(true);
         bus.shutdown(true);
     }
 }

Modified: cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java?rev=1348174&r1=1348173&r2=1348174&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java
(original)
+++ cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java
Fri Jun  8 18:21:22 2012
@@ -42,6 +42,7 @@ import javax.xml.ws.soap.AddressingFeatu
 import javax.xml.ws.soap.SOAPBinding;
 import javax.xml.ws.soap.SOAPFaultException;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.endpoint.Client;
@@ -102,6 +103,7 @@ public class WSSecurityClientTest extend
             // set this to false to fork
             launchServer(Server.class, true)
         );
+        createStaticBus();
     }
     
     @org.junit.AfterClass
@@ -144,15 +146,15 @@ public class WSSecurityClientTest extend
         } catch (Exception ex) {
             //expected
         }
+        
+        ((java.io.Closeable)greeter).close();
     }
 
     @Test
     public void testTimestampSignEncrypt() throws Exception {
-        BusFactory.setDefaultBus(
-            new SpringBusFactory().createBus(
-                "org/apache/cxf/systest/ws/security/client.xml"
-            )
-        );
+        Bus b = new SpringBusFactory()
+            .createBus("org/apache/cxf/systest/ws/security/client.xml");
+        BusFactory.setDefaultBus(b);
         final javax.xml.ws.Service svc = javax.xml.ws.Service.create(
             WSDL_LOC,
             GREETER_SERVICE_QNAME
@@ -178,7 +180,10 @@ public class WSSecurityClientTest extend
         assertTrue("expected Handler.handleMessage() to be called", 
                    handler.handleMessageCalledOutbound);
         assertFalse("expected Handler.handleFault() not to be called", 
-                    handler.handleFaultCalledOutbound); 
+                    handler.handleFaultCalledOutbound);
+        ((java.io.Closeable)greeter).close();
+        b.shutdown(true);
+        BusFactory.setDefaultBus(getStaticBus());
     }
 
     @Test

Modified: cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/WSSCTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/WSSCTest.java?rev=1348174&r1=1348173&r2=1348174&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/WSSCTest.java
(original)
+++ cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/WSSCTest.java
Fri Jun  8 18:21:22 2012
@@ -216,6 +216,7 @@ public class WSSCTest extends AbstractBu
             } catch (Exception ex) {
                 throw new Exception("Error doing " + portPrefix, ex);
             }
+            ((java.io.Closeable)port).close();
         }
     }
 

Modified: cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/server/Server.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/server/Server.java?rev=1348174&r1=1348173&r2=1348174&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/server/Server.java
(original)
+++ cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssc/server/Server.java
Fri Jun  8 18:21:22 2012
@@ -85,11 +85,11 @@ public class Server extends AbstractBusT
     
     protected void run()  {
         try {
-            new Server("http://localhost:" + PORT + "/");
             Bus busLocal = new SpringBusFactory().createBus(
-                    "org/apache/cxf/systest/ws/wssc/server/server.xml");
+                "org/apache/cxf/systest/ws/wssc/server/server.xml");
             BusFactory.setDefaultBus(busLocal);
             setBus(busLocal);
+            new Server("http://localhost:" + PORT + "/");
         } catch (Exception e) {
             e.printStackTrace();
         }

Modified: cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec10/server/Server.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec10/server/Server.java?rev=1348174&r1=1348173&r2=1348174&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec10/server/Server.java
(original)
+++ cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec10/server/Server.java
Fri Jun  8 18:21:22 2012
@@ -51,8 +51,7 @@ public class Server extends AbstractBusT
     }
 
     public static void main(String args[]) throws Exception {
-        new Server();
-        new SpringBusFactory().createBus(configFileName);
+        new Server().run();
         System.out.println("Server ready...");
 
         Thread.sleep(60 * 60 * 1000);

Modified: cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/AbstractServer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/AbstractServer.java?rev=1348174&r1=1348173&r2=1348174&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/AbstractServer.java
(original)
+++ cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/AbstractServer.java
Fri Jun  8 18:21:22 2012
@@ -25,10 +25,11 @@ import org.apache.cxf.testutil.common.Ab
 import org.apache.cxf.ws.security.SecurityConstants;
 
 abstract class AbstractServer extends AbstractBusTestServerBase {
-    
+    String baseUrl;
     protected AbstractServer(String baseUrl) throws Exception {
-        
-        
+        this.baseUrl = baseUrl;
+    }
+    protected void run() {
         doPublish(baseUrl + "/APingService", new APingService());
         doPublish(baseUrl + "/A-NoTimestampPingService", new ANoTimestampPingService());
         doPublish(baseUrl + "/ADPingService", new ADPingService());

Modified: cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/Server11.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/Server11.java?rev=1348174&r1=1348173&r2=1348174&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/Server11.java
(original)
+++ cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/Server11.java
Fri Jun  8 18:21:22 2012
@@ -38,17 +38,11 @@ public class Server11 extends AbstractSe
             "org/apache/cxf/systest/ws/wssec11/server/server.xml");
         BusFactory.setDefaultBus(busLocal);
         setBus(busLocal);
-
-        try {
-            new Server11("http://localhost:" + PORT);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
+        super.run();
     }
     
     public static void main(String args[]) throws Exception {
-        new SpringBusFactory().createBus("org/apache/cxf/systest/ws/wssec11/server/server.xml");
-        new Server11("http://localhost:" + PORT);
+        new Server11("http://localhost:" + PORT).run();
         System.out.println("Server ready...");
 
         Thread.sleep(60 * 60 * 10000);

Modified: cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/Server12.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/Server12.java?rev=1348174&r1=1348173&r2=1348174&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/Server12.java
(original)
+++ cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/wssec11/server/Server12.java
Fri Jun  8 18:21:22 2012
@@ -38,17 +38,11 @@ public class Server12 extends AbstractSe
             "org/apache/cxf/systest/ws/wssec11/server/server.xml");
         BusFactory.setDefaultBus(busLocal);
         setBus(busLocal);
-
-        try {
-            new Server12("http://localhost:" + PORT);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
+        super.run();
     }
     
     public static void main(String args[]) throws Exception {
-        new SpringBusFactory().createBus("org/apache/cxf/systest/ws/wssec11/server/server.xml");
-        new Server12("http://localhost:" + PORT);
+        new Server12("http://localhost:" + PORT).run();
         System.out.println("Server ready...");
 
         Thread.sleep(60 * 60 * 10000);

Modified: cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/server/Server.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/server/Server.java?rev=1348174&r1=1348173&r2=1348174&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/server/Server.java
(original)
+++ cxf/branches/2.5.x-fixes/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/server/Server.java
Fri Jun  8 18:21:22 2012
@@ -37,11 +37,5 @@ public class Server extends AbstractBusT
         Bus busLocal = new SpringBusFactory().createBus(busFile);
         BusFactory.setDefaultBus(busLocal);
         setBus(busLocal);
-
-        try {
-            new Server();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
     }
 }



Mime
View raw message