You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ge...@apache.org on 2008/12/22 10:35:07 UTC

svn commit: r728632 - in /servicemix/smx3/trunk/distributions/apache-servicemix-web: ./ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/servicemix/ src/test/java/org/apache/servicemix/web/ src/test/java/or...

Author: gertv
Date: Mon Dec 22 01:35:07 2008
New Revision: 728632

URL: http://svn.apache.org/viewvc?rev=728632&view=rev
Log:
SM-1742: Move the HttpManagedServlet from servicemix-http to apache-servicemix-web

Added:
    servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/
    servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/java/
    servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/java/org/
    servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/java/org/apache/
    servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/java/org/apache/servicemix/
    servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/java/org/apache/servicemix/web/
    servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/java/org/apache/servicemix/web/http/
    servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/java/org/apache/servicemix/web/http/HttpManagedServletTest.java   (with props)
    servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/resources/
    servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/resources/org/
    servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/resources/org/apache/
    servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/resources/org/apache/servicemix/
    servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/resources/org/apache/servicemix/web/
    servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/resources/org/apache/servicemix/web/http/
    servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/resources/org/apache/servicemix/web/http/spring-web.xml   (with props)
Modified:
    servicemix/smx3/trunk/distributions/apache-servicemix-web/pom.xml

Modified: servicemix/smx3/trunk/distributions/apache-servicemix-web/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/distributions/apache-servicemix-web/pom.xml?rev=728632&r1=728631&r2=728632&view=diff
==============================================================================
--- servicemix/smx3/trunk/distributions/apache-servicemix-web/pom.xml (original)
+++ servicemix/smx3/trunk/distributions/apache-servicemix-web/pom.xml Mon Dec 22 01:35:07 2008
@@ -128,6 +128,29 @@
       <artifactId>mail</artifactId>
       <version>1.4</version>
     </dependency>
+    <dependency>
+      <groupId>commons-httpclient</groupId>
+      <artifactId>commons-httpclient</artifactId>
+      <version>3.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jetty</artifactId>
+      <version>${jetty-version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.mortbay.jetty</groupId>
+          <artifactId>servlet-api-2.5</artifactId>
+        </exclusion>
+      </exclusions>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicemix</groupId>
+      <artifactId>servicemix-http</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

Added: servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/java/org/apache/servicemix/web/http/HttpManagedServletTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/java/org/apache/servicemix/web/http/HttpManagedServletTest.java?rev=728632&view=auto
==============================================================================
--- servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/java/org/apache/servicemix/web/http/HttpManagedServletTest.java (added)
+++ servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/java/org/apache/servicemix/web/http/HttpManagedServletTest.java Mon Dec 22 01:35:07 2008
@@ -0,0 +1,97 @@
+/*
+ * 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.servicemix.web.http;
+
+import java.util.EventListener;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.xbean.spring.context.XmlWebApplicationContext;
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.ContextHandler;
+import org.mortbay.jetty.handler.ContextHandlerCollection;
+import org.mortbay.jetty.handler.HandlerCollection;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.servlet.ServletHandler;
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.mortbay.jetty.servlet.ServletMapping;
+import org.springframework.web.context.ContextLoaderListener;
+
+public class HttpManagedServletTest extends TestCase {
+    private static Log logger = LogFactory.getLog(HttpManagedServletTest.class);
+
+    private Server server;
+
+    protected void tearDown() throws Exception {
+        if (server != null) {
+            server.stop();
+        }
+    }
+
+    public void test() throws Exception {
+        ContextHandler context = new ContextHandler();
+        context.setContextPath("/test");
+        context.setEventListeners(new EventListener[] {new ContextLoaderListener()});
+        Map initParams = new HashMap();
+        initParams.put("contextConfigLocation", "classpath:org/apache/servicemix/web/http/spring-web.xml");
+        initParams.put("contextClass", XmlWebApplicationContext.class.getName());
+        context.setInitParams(initParams);
+        ServletHolder holder = new ServletHolder();
+        holder.setName("jbiServlet");
+        holder.setClassName(HttpManagedServlet.class.getName());
+        ServletHandler handler = new ServletHandler();
+        handler.setServlets(new ServletHolder[] {holder});
+        ServletMapping mapping = new ServletMapping();
+        mapping.setServletName("jbiServlet");
+        mapping.setPathSpec("/*");
+        handler.setServletMappings(new ServletMapping[] {mapping});
+        context.setHandler(handler);
+
+        ContextHandlerCollection contexts = new ContextHandlerCollection();
+        HandlerCollection handlers = new HandlerCollection();
+        handlers.setHandlers(new Handler[] {contexts});
+        contexts.addHandler(context);
+
+        SelectChannelConnector connector = new SelectChannelConnector();
+        connector.setHost("localhost");
+        connector.setPort(8190);
+
+        server = new Server();
+        server.setConnectors(new Connector[] {connector});
+        server.setHandler(handlers);
+        server.start();
+
+        logger.info("Started");
+
+        PostMethod post = new PostMethod("http://localhost:8190/test/jbi/Service/");
+        post.setRequestEntity(new StringRequestEntity(
+                        "<soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope'>"
+                                        + "<soap:Body><hello>world</hello></soap:Body>" + "</soap:Envelope>"));
+        new HttpClient().executeMethod(post);
+        assertEquals(200, post.getStatusCode());
+        logger.info(post.getResponseBodyAsString());
+    }
+}

Propchange: servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/java/org/apache/servicemix/web/http/HttpManagedServletTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/resources/org/apache/servicemix/web/http/spring-web.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/resources/org/apache/servicemix/web/http/spring-web.xml?rev=728632&view=auto
==============================================================================
--- servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/resources/org/apache/servicemix/web/http/spring-web.xml (added)
+++ servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/resources/org/apache/servicemix/web/http/spring-web.xml Mon Dec 22 01:35:07 2008
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0" 
+	   xmlns:http="http://servicemix.apache.org/http/1.0"
+	   xmlns:test="http://servicemix.org/test/">
+
+  <!-- the JBI container -->
+  <sm:container id="jbi" embedded="true">
+    <sm:activationSpecs>
+
+      <!-- output using a POJO -->
+      <sm:activationSpec componentName="servicemix-http">
+      	<sm:component>
+          <http:component>
+            <http:configuration managed="true" />
+        	<http:endpoints>
+        	  
+        	  <http:endpoint service="test:Hello"
+        	                 endpoint="testService"
+        	                 role="consumer" 
+        	                 locationURI="http://localhost:8193/Service/"
+                             defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
+                             wsdlResource="classpath:org/apache/servicemix/http/test.wsdl"
+                             soap="true" />
+
+        	</http:endpoints>
+          </http:component>
+        </sm:component>
+      </sm:activationSpec>
+      
+      <sm:activationSpec service="test:Hello" endpoint="testService">
+        <sm:component>
+          <bean class="org.apache.servicemix.components.util.EchoComponent" />
+        </sm:component>
+      </sm:activationSpec>
+
+    </sm:activationSpecs>
+  </sm:container>
+
+</beans>

Propchange: servicemix/smx3/trunk/distributions/apache-servicemix-web/src/test/resources/org/apache/servicemix/web/http/spring-web.xml
------------------------------------------------------------------------------
    svn:eol-style = native