You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bi...@apache.org on 2007/10/19 01:47:01 UTC

svn commit: r586183 - in /incubator/cxf/trunk: systests/src/test/java/org/apache/cxf/systest/http_jetty/ testutils/src/main/java/org/apache/cxf/jaxb_element_test/

Author: bimargulies
Date: Thu Oct 18 16:47:01 2007
New Revision: 586183

URL: http://svn.apache.org/viewvc?rev=586183&view=rev
Log:
Add test case that shows more problems with server lifecycle to the EngineLifecycleTest.

Modified:
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/jaxb_element_test/JaxbElementTestImpl.java

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java?rev=586183&r1=586182&r2=586183&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java Thu Oct 18 16:47:01 2007
@@ -18,8 +18,6 @@
  */
 package org.apache.cxf.systest.http_jetty;
 
-
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
@@ -29,19 +27,25 @@
 import java.util.Properties;
 
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.ServerImpl;
+import org.apache.cxf.endpoint.ServerRegistry;
 import org.apache.cxf.helpers.IOUtils;
 
 import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.transport.http_jetty.JettyHTTPDestination;
+import org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine;
 import org.junit.Assert;
+import org.junit.Ignore;
 import org.junit.Test;
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.webapp.WebAppContext;
 import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 import org.springframework.context.support.GenericApplicationContext;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.Resource;
 
-
-
 /**
  * This class tests starting up and shutting down the embedded server when there
  * is extra jetty configuration.
@@ -54,14 +58,16 @@
         reader.loadBeanDefinitions(beanResource);
     }
     
-    public void setUpBus() throws Exception {
+    public void setUpBus(boolean includeService) throws Exception {
         applicationContext = new GenericApplicationContext();
         readBeans(new ClassPathResource("META-INF/cxf/cxf.xml"));
         readBeans(new ClassPathResource("META-INF/cxf/cxf-extension-soap.xml"));
         readBeans(new ClassPathResource("META-INF/cxf/cxf-extension-http.xml"));
         readBeans(new ClassPathResource("META-INF/cxf/cxf-extension-http-jetty.xml"));
         readBeans(new ClassPathResource("jetty-engine.xml", getClass()));
-        
+        if (includeService) {
+            readBeans(new ClassPathResource("server-lifecycle-beans.xml", getClass()));
+        }
         
         // bring in some property values from a Properties file
         PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
@@ -112,9 +118,6 @@
         html.close();
         
         assertEquals("Can't get the right test html", html.toString(), response.toString());
-        
-        
-        
     }
     
     public String getStaticResourceURL() throws Exception {
@@ -130,9 +133,36 @@
         applicationContext.close();        
     }
 
+    @Ignore
+    @Test
+    public void testUpDownWithServlets() throws Exception {
+        setUpBus(true);
+
+        Bus bus = (Bus)applicationContext.getBean("cxf");
+        ServerRegistry sr = bus.getExtension(ServerRegistry.class);
+        ServerImpl si = (ServerImpl) sr.getServers().get(0);
+        JettyHTTPDestination jhd = (JettyHTTPDestination) si.getDestination();
+        JettyHTTPServerEngine e = (JettyHTTPServerEngine) jhd.getEngine();
+        org.mortbay.jetty.Server jettyServer = e.getServer();
+
+        Handler[] contexts = jettyServer.getChildHandlersByClass(WebAppContext.class);
+        WebAppContext servletContext = null;
+        for (Handler h : contexts) {
+            WebAppContext wac = (WebAppContext) h;
+            if (wac.getContextPath().equals("/jsunit")) {
+                servletContext = wac;
+                break;
+            }
+        }
+        servletContext.addServlet("org.mortbay.jetty.servlet.DefaultServlet", "/bloop");
+        getTestHtml();
+        invokeService();        
+        shutdownService();
+    }
+
     @Test
     public void testServerUpDownUp() throws Exception {        
-        setUpBus();
+        setUpBus(false);
         launchService();           
         getTestHtml();
         invokeService();        

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml?rev=586183&r1=586182&r2=586183&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml Thu Oct 18 16:47:01 2007
@@ -35,14 +35,30 @@
  <httpj:engine-factory bus="cxf">
   <httpj:engine port="8808">
    <httpj:handlers>
-    <bean class="org.mortbay.jetty.handler.ResourceHandler">
-     <property name="baseResource">
-      <bean class="org.mortbay.resource.FileResource">
-       <constructor-arg value="${staticResourceURL}" />
+       <bean class="org.mortbay.jetty.handler.RequestLogHandler">
+      <property name="requestLog">
+        <bean class="org.mortbay.jetty.NCSARequestLog">
+         <property name="filename" value="jetty.log"/>
+        </bean>
+      </property>
+    </bean>
+    <bean class="org.mortbay.jetty.webapp.WebAppContext">
+      <constructor-arg value="."/>
+      <constructor-arg value="/jsunit"/>
+    </bean>
+    <bean class="org.mortbay.jetty.handler.ContextHandler">
+     <property name="contextPath" value="/" />
+     <property name="handler">
+      <bean class="org.mortbay.jetty.handler.ResourceHandler">
+       <property name="baseResource">
+        <bean class="org.mortbay.resource.FileResource">
+         <constructor-arg value="${staticResourceURL}" />
+        </bean>
+        </property>
       </bean>
      </property>
     </bean>
-     <bean class="org.mortbay.jetty.handler.DefaultHandler"/>
+    <bean class="org.mortbay.jetty.handler.DefaultHandler"/>
    </httpj:handlers>
   </httpj:engine>
  </httpj:engine-factory>

Modified: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/jaxb_element_test/JaxbElementTestImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/jaxb_element_test/JaxbElementTestImpl.java?rev=586183&r1=586182&r2=586183&view=diff
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/jaxb_element_test/JaxbElementTestImpl.java (original)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/jaxb_element_test/JaxbElementTestImpl.java Thu Oct 18 16:47:01 2007
@@ -29,8 +29,6 @@
 public class JaxbElementTestImpl implements JaxbElementTest {
 
     public String newOperation(String in) {
-        // TODO Auto-generated method stub
-
         if (in == null) {
             return "in=null";
         } else {