cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1213001 - in /cxf/trunk: rt/core/src/main/java/org/apache/cxf/bus/spring/ rt/core/src/test/java/org/apache/cxf/bus/spring/ rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/ systests/uncategorized/src/test/java/org...
Date Sun, 11 Dec 2011 13:47:29 GMT
Author: dkulp
Date: Sun Dec 11 13:47:28 2011
New Revision: 1213001

URL: http://svn.apache.org/viewvc?rev=1213001&view=rev
Log:
More tests for the lifecyclelisteners
Fix issues if jetty isn't available

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
    cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/BusDefinitionParserTest.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
    cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/wsdl/CrossSchemaImportsTests.java
    cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/wsdl/LifeCycleListenerTester.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java?rev=1213001&r1=1213000&r2=1213001&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java Sun
Dec 11 13:47:28 2011
@@ -84,6 +84,7 @@ public class BusDefinitionParser extends
         } else if (!"cxf".equals(bus)) {
             bean.getRawBeanDefinition().setBeanClass(SpringBus.class);
             bean.getRawBeanDefinition().getPropertyValues().removePropertyValue("bus");
+            bean.setDestroyMethodName("shutdown");
             element.setUserData("ID", bus, null);
         } else {
             addBusWiringAttribute(bean, BusWiringType.PROPERTY, bus, ctx);

Modified: cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/BusDefinitionParserTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/BusDefinitionParserTest.java?rev=1213001&r1=1213000&r2=1213001&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/BusDefinitionParserTest.java
(original)
+++ cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/spring/BusDefinitionParserTest.java
Sun Dec 11 13:47:28 2011
@@ -21,11 +21,14 @@ package org.apache.cxf.bus.spring;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.annotation.PostConstruct;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.CXFBusImpl;
+import org.apache.cxf.buslifecycle.BusLifeCycleListener;
+import org.apache.cxf.buslifecycle.BusLifeCycleManager;
 import org.apache.cxf.feature.AbstractFeature;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.interceptor.LoggingInInterceptor;
@@ -89,6 +92,7 @@ public class BusDefinitionParserTest ext
     @Test
     public void testBusConfigureCreateBus() {
         ClassPathXmlApplicationContext context = null;
+        final AtomicBoolean b = new AtomicBoolean();
         try {
             context = new ClassPathXmlApplicationContext("org/apache/cxf/bus/spring/customerBus2.xml");
             Bus cxf1 = (Bus)context.getBean("cxf1");
@@ -97,13 +101,29 @@ public class BusDefinitionParserTest ext
             assertTrue(cxf1.getInInterceptors().size() == 0);
             
             Bus cxf2 = (Bus)context.getBean("cxf2");
+            
             assertTrue(cxf2.getInInterceptors().size() == 1);
             assertTrue(cxf2.getOutInterceptors().size() == 0);
+            
+            cxf2.getExtension(BusLifeCycleManager.class)
+                .registerLifeCycleListener(new BusLifeCycleListener() {
+                    public void initComplete() {
+                    }
+
+                    public void preShutdown() {
+                    }
+
+                    public void postShutdown() {
+                        b.set(true);
+                    }
+                    
+                });
         } finally {
             if (context != null) {
                 context.close();
             }
         }
+        assertTrue("postShutdown not called", b.get());
     }
     @Test
     public void testLazyInit() {

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java?rev=1213001&r1=1213000&r2=1213001&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
Sun Dec 11 13:47:28 2011
@@ -46,7 +46,7 @@ import org.eclipse.jetty.util.component.
  * caches the JettyHTTPServerEngines so that they may be 
  * retrieved if already previously configured.
  */
-public class JettyHTTPServerEngineFactory implements BusLifeCycleListener {
+public class JettyHTTPServerEngineFactory {
     private static final Logger LOG =
         LogUtils.getL7dLogger(JettyHTTPServerEngineFactory.class);    
     
@@ -134,10 +134,23 @@ public class JettyHTTPServerEngineFactor
             bus.setExtension(this, JettyHTTPServerEngineFactory.class);
             lifeCycleManager = bus.getExtension(BusLifeCycleManager.class);
             if (null != lifeCycleManager) {
-                lifeCycleManager.registerLifeCycleListener(this);
+                lifeCycleManager.registerLifeCycleListener(new JettyBusLifeCycleListener());
             }        
         }
     }
+    private class JettyBusLifeCycleListener implements BusLifeCycleListener {
+        public void initComplete() {
+            JettyHTTPServerEngineFactory.this.initComplete();
+        }
+
+        public void preShutdown() {
+            JettyHTTPServerEngineFactory.this.preShutdown();
+        }
+
+        public void postShutdown() {
+            JettyHTTPServerEngineFactory.this.postShutdown();
+        }
+    }
     
     public Bus getBus() {
         return bus;

Modified: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/wsdl/CrossSchemaImportsTests.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/wsdl/CrossSchemaImportsTests.java?rev=1213001&r1=1213000&r2=1213001&view=diff
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/wsdl/CrossSchemaImportsTests.java
(original)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/wsdl/CrossSchemaImportsTests.java
Sun Dec 11 13:47:28 2011
@@ -29,6 +29,7 @@ import org.apache.cxf.test.TestUtilities
 import org.junit.Assert;
 import org.junit.Test;
 
+import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
 
@@ -53,6 +54,11 @@ public class CrossSchemaImportsTests ext
                          + "xsd:import[@namespace='http://apache.org/type_test/types1']",
wsdl);
         
         Assert.assertEquals(1, LifeCycleListenerTester.getInitCount());
+        
+        Assert.assertEquals(0, LifeCycleListenerTester.getShutdownCount());
+        
+        ((ConfigurableApplicationContext)applicationContext).close();
+        Assert.assertEquals(1, LifeCycleListenerTester.getShutdownCount());        
     }
 
 }

Modified: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/wsdl/LifeCycleListenerTester.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/wsdl/LifeCycleListenerTester.java?rev=1213001&r1=1213000&r2=1213001&view=diff
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/wsdl/LifeCycleListenerTester.java
(original)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/wsdl/LifeCycleListenerTester.java
Sun Dec 11 13:47:28 2011
@@ -31,6 +31,7 @@ import org.apache.cxf.buslifecycle.BusLi
 public class LifeCycleListenerTester implements BusLifeCycleListener {
 
     static int initCount;
+    static int shutdownCount;
     
     public LifeCycleListenerTester() {
     }
@@ -43,6 +44,9 @@ public class LifeCycleListenerTester imp
     public static int getInitCount() {
         return initCount;
     }
+    public static int getShutdownCount() {
+        return shutdownCount;
+    }
     
     /** {@inheritDoc}*/
     public void initComplete() {
@@ -51,7 +55,7 @@ public class LifeCycleListenerTester imp
 
     /** {@inheritDoc}*/
     public void postShutdown() {
-
+        shutdownCount++;
     }
 
     /** {@inheritDoc}*/



Mime
View raw message