You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by en...@apache.org on 2009/06/04 16:24:17 UTC

svn commit: r781749 - in /servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src: main/java/org/apache/servicemix/http/ test/java/org/apache/servicemix/http/ test/java/org/apache/servicemix/http/endpoints/ test/java/o...

Author: enolan
Date: Thu Jun  4 14:24:16 2009
New Revision: 781749

URL: http://svn.apache.org/viewvc?rev=781749&view=rev
Log:
SMXCOMP-528 - improve test coverage

Added:
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpBridgeServletTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpConfigurationTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpEndpointTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ManagedContextManagerTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ProxyParametersTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/SslParametersTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/DefaultHttpProviderMarshalerTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpointTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/HttpSoapProviderEndpointTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/jetty/
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/jetty/SmxHttpExchangeTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/packaging/
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzerTest.java   (with props)
Modified:
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/ManagedContextManager.java
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ServerManagerTest.java

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/ManagedContextManager.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/ManagedContextManager.java?rev=781749&r1=781748&r2=781749&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/ManagedContextManager.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/ManagedContextManager.java Thu Jun  4 14:24:16 2009
@@ -35,13 +35,13 @@
 public class ManagedContextManager implements ContextManager {
 
     private HttpConfiguration configuration;
-    private Map managedContexts;
+    private Map<String, HttpProcessor> managedContexts;
 
     public void init() throws Exception {
         if (configuration == null) {
             configuration = new HttpConfiguration();
         }
-        managedContexts = new ConcurrentHashMap();
+        managedContexts = new ConcurrentHashMap<String, HttpProcessor>();
     }
 
     public void shutDown() throws Exception {
@@ -58,7 +58,7 @@
         URI uri = new URI(strUrl);
         String path = uri.getPath();
         if (!path.startsWith("/")) {
-            path = path + "/";
+            path = "/" + path;
         }
         if (!path.endsWith("/")) {
             path = path + "/";
@@ -107,8 +107,8 @@
                 displayServices(request, response);
                 return;
             }
-            Set urls = managedContexts.keySet();
-            for (Iterator iter = urls.iterator(); iter.hasNext();) {
+            Set<String> urls = managedContexts.keySet();
+            for (Iterator<String> iter = urls.iterator(); iter.hasNext();) {
                 String url = (String) iter.next();
                 if (uri.startsWith(request.getContextPath() + mapping + url)) {
                     HttpProcessor proc = (HttpProcessor) managedContexts.get(url);
@@ -134,8 +134,8 @@
             writer.write("No service matched or handled this request.<BR>");
             writer.write("Known services are: <ul>");
 
-            Set servers = ManagedContextManager.this.managedContexts.keySet();
-            for (Iterator iter = servers.iterator(); iter.hasNext();) {
+            Set<String> servers = ManagedContextManager.this.managedContexts.keySet();
+            for (Iterator<String> iter = servers.iterator(); iter.hasNext();) {
                 String context = (String) iter.next();
                 if (!context.endsWith("/")) {
                     context += "/";

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java?rev=781749&r1=781748&r2=781749&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java Thu Jun  4 14:24:16 2009
@@ -150,6 +150,50 @@
         }
     }
 
+    public void testHttpInOutWithTimeout() throws Exception {
+        EchoComponent echo = null;
+        HttpComponent http = new HttpComponent();
+        HttpConsumerEndpoint ep = new HttpConsumerEndpoint();
+        ep.setService(new QName("urn:test", "svc"));
+        ep.setEndpoint("ep");
+        ep.setTargetService(new QName("urn:test", "echo"));
+        ep.setLocationURI("http://localhost:8192/ep1/");
+        ep.setDefaultMep(MessageExchangeSupport.IN_OUT);
+        ep.setTimeout(1000);
+        http.setEndpoints(new HttpEndpointType[] {ep});
+        container.activateComponent(http, "http");
+            
+        echo = new EchoComponent() {
+            public void onMessageExchange(MessageExchange exchange) throws MessagingException {
+                super.onMessageExchange(exchange);
+            }
+            protected boolean transform(MessageExchange ex, NormalizedMessage in, NormalizedMessage out) 
+                throws MessagingException {                    
+                try {
+                    Thread.sleep(1500);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                } 
+                return super.transform(ex, in, out);
+            }
+        };
+        echo.setService(new QName("urn:test", "echo"));
+        echo.setEndpoint("endpoint");
+        container.activateComponent(echo, "echo");
+
+        container.start();
+
+        PostMethod post = new PostMethod("http://localhost:8192/ep1/");
+        post.setRequestEntity(new StringRequestEntity("<hello>world</hello>"));
+        new HttpClient().executeMethod(post);
+        String res = post.getResponseBodyAsString();
+        log.info(res);
+        if (post.getStatusCode() != 500) {
+            throw new InvalidStatusResponseException(post.getStatusCode());
+        }
+        Thread.sleep(1000);
+    }
+    
     protected void initSoapEndpoints(boolean useJbiWrapper) throws Exception {
         HttpComponent http = new HttpComponent();
         HttpSoapConsumerEndpoint ep1 = new HttpSoapConsumerEndpoint();

Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpBridgeServletTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpBridgeServletTest.java?rev=781749&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpBridgeServletTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpBridgeServletTest.java Thu Jun  4 14:24:16 2009
@@ -0,0 +1,218 @@
+/*
+ * 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.http;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Set;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import junit.framework.TestCase;
+
+//import org.mortbay.jetty.Request;
+//import org.mortbay.jetty.Response;
+
+public class HttpBridgeServletTest extends TestCase {
+
+    private HttpBridgeServlet httpBridgeServlet;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        httpBridgeServlet = new HttpBridgeServlet();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        httpBridgeServlet = null;
+    }
+
+    // Test init() when HttpProcessor is null.
+    public void testInitProcessorNull() throws Exception {
+        httpBridgeServlet.setProcessor(null);
+        TestServletConfig config = new TestServletConfig();
+        
+        try {
+            httpBridgeServlet.init(config);
+            fail("init() should fail when HttpProcessor is null");
+        } catch (ServletException se) {
+            String errorMsg = se.getMessage();
+            assertTrue("ServletException does not contain the expected error message", errorMsg.contains("No binding property available"));
+        }
+    }
+
+    // Test service() method - check for exceptions, fail if any are thrown.
+    /*public void testService() throws Exception {
+        TestHttpProcessor processor = new TestHttpProcessor();
+        httpBridgeServlet.setProcessor(processor);
+        TestServletConfig config = new TestServletConfig();
+
+        httpBridgeServlet.init(config);
+
+        Request request = new Request();
+        Response response = null;
+
+        try {
+            httpBridgeServlet.service(request, response);
+        } catch (Exception e) {
+            fail("service() should not throw an exception");
+        }
+    }*/
+
+    // Dummy ServletConfig implementation for testing.  
+    public static class TestServletConfig implements ServletConfig {
+
+        public String getInitParameter(String name) {
+            return null;
+        }
+
+        public Enumeration<String> getInitParameterNames() {
+            return null;
+        }
+
+        public ServletContext getServletContext() {
+            return new TestServletContext();
+        }
+
+        public String getServletName() {
+            return null;
+        }
+    }
+
+    // Dummy ServletContext implementation for testing.
+    public static class TestServletContext implements ServletContext {
+
+        public Object getAttribute(String name) {
+            return null;
+        }
+
+        public Enumeration<Object> getAttributeNames() {
+            return null;
+        }
+
+        public ServletContext getContext(String uripath) {
+            return this;
+        }
+
+        public String getContextPath() {
+            return null;
+        }
+
+        public String getInitParameter(String name) {
+            return null;
+        }
+
+        public Enumeration<String> getInitParameterNames() {
+            return null;
+        }
+
+        public int getMajorVersion() {
+            return 0;
+        }
+
+        public String getMimeType(String file) {
+            return null;
+        }
+
+        public int getMinorVersion() {
+            return 0;
+        }
+
+        public RequestDispatcher getNamedDispatcher(String name) {
+            return null;
+        }
+
+        public String getRealPath(String path) {
+            return null;
+        }
+
+        public RequestDispatcher getRequestDispatcher(String path) {
+            return null;
+        }
+
+        public URL getResource(String path) throws MalformedURLException {
+            return null;
+        }
+
+        public InputStream getResourceAsStream(String path) {
+            return null;
+        }
+
+        public Set<String> getResourcePaths(String path) {
+            return null;
+        }
+
+        public String getServerInfo() {
+            return null;
+        }
+
+        public String getServletContextName() {
+            return null;
+        }
+
+        public void log(String message, Throwable throwable) {
+        }
+
+        public void log(String msg) {
+        }
+
+        public void removeAttribute(String name) {
+        }
+
+        public void setAttribute(String name, Object object) {
+        }
+
+        public Servlet getServlet(String name) throws ServletException {
+            return null;
+        }
+
+        public Enumeration<Servlet> getServletNames() {
+            return null;
+        }
+
+        public Enumeration<Servlet> getServlets() {
+            return null;
+        }
+
+        public void log(Exception exception, String msg) {
+        }
+    }
+
+    // Dummy HttpProcessor implementation for testing.
+    public static class TestHttpProcessor implements HttpProcessor {
+
+        public SslParameters getSsl() {   
+            return null;
+        }
+
+        public String getAuthMethod() {
+            return null;
+        }
+
+        public void process(HttpServletRequest request, HttpServletResponse response) throws Exception {
+        }
+
+    }
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpBridgeServletTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpConfigurationTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpConfigurationTest.java?rev=781749&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpConfigurationTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpConfigurationTest.java Thu Jun  4 14:24:16 2009
@@ -0,0 +1,124 @@
+/*
+ * 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.http;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+//import org.apache.servicemix.util.FileUtil;
+
+public class HttpConfigurationTest extends TestCase {
+
+    private HttpConfiguration httpConfig;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        httpConfig = new HttpConfiguration();
+    }
+
+    protected void tearDown() throws Exception {
+        httpConfig = null;
+    }
+
+    // Test load() when rootDir is not set.
+    public void testLoadNoRootDir() throws Exception {
+        boolean isLoaded = httpConfig.load();
+        assertTrue("HTTP Config should NOT be loaded with no root dir", !isLoaded);
+    }
+
+    // Test load() when config file does not exist.
+    public void testLoadNoConfigFile() throws Exception {
+        httpConfig.setRootDir("src/test/resources");
+        assertTrue("HTTP Config should NOT be loaded with no config file", !httpConfig.load());
+    }
+
+    // Test save() (to config file) and load() (from config file).
+    public void testSaveAndLoad() throws Exception {
+        File rootDir = new File("target/httpConfig-test");
+        if (!rootDir.exists()) {
+            rootDir.mkdirs(); 
+        }
+        httpConfig.setRootDir(rootDir.getAbsolutePath());
+
+        // Save the HTTP Config (mostly default values)
+        httpConfig.save();
+
+        File configFile = new File(rootDir, HttpConfiguration.CONFIG_FILE);
+        assertTrue("HTTP Config file should exist", configFile.exists());
+        boolean isLoaded = httpConfig.load();
+        assertTrue("HTTP Config should be loaded", isLoaded);
+
+        // clean up
+        deleteFile(new File(httpConfig.getRootDir()));
+    }
+
+    // Test setMapping when input string does not begin with "/"
+    public void testSetMappingBeginsNoSlash() throws Exception {
+        String strMap = "pathHasNoSlash";
+        httpConfig.setMapping(strMap);
+
+        String actMap = httpConfig.getMapping();
+
+        assertTrue("HTTP Config Mapping should begin with /", actMap.equals("/" + strMap));
+    }
+
+    // Test setMapping when input string ends with "/"
+    public void testSetMappingEndsWithSlash() throws Exception {
+        String strMap1 = "/pathEndsWithSlash";
+        String strMap2 = "/";
+        httpConfig.setMapping(strMap1 + strMap2);
+ 
+        String actMap = httpConfig.getMapping();
+
+        assertTrue("HTTP Config Mapping should not end with /", actMap.equals(strMap1));
+    }
+
+    /**
+     * Delete a file
+     * 
+     * @param fileToDelete
+     * @return true if the File is deleted
+     */
+    public static boolean deleteFile(File fileToDelete) {
+        if (fileToDelete == null || !fileToDelete.exists()) {
+            return true;
+        }
+        boolean result = true;
+        if (fileToDelete.isDirectory()) {
+            File[] files = fileToDelete.listFiles();
+            if (files == null) {
+                result = false;
+            } else {
+                for (int i = 0; i < files.length; i++) {
+                    File file = files[i];
+                    if (file.getName().equals(".") || file.getName().equals("..")) {
+                        continue;
+                    }
+                    if (file.isDirectory()) {
+                        result &= deleteFile(file);
+                    } else {
+                        result &= file.delete();
+                    }
+                }
+            }
+        }
+        result &= fileToDelete.delete();
+        return result;
+    }
+
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpConfigurationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpEndpointTest.java?rev=781749&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpEndpointTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpEndpointTest.java Thu Jun  4 14:24:16 2009
@@ -0,0 +1,90 @@
+/*
+ * 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.http;
+
+import javax.jbi.management.DeploymentException;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.common.ServiceUnit;
+
+public class HttpEndpointTest extends TestCase {
+
+    private HttpEndpoint httpEndpoint;
+    private MyServiceUnit httpSU;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        httpEndpoint = new HttpEndpoint();
+        httpSU = new MyServiceUnit();
+        httpEndpoint.setServiceUnit(httpSU);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        httpEndpoint = null;
+    }
+
+    // Test validate() when getRole() returns null.
+    public void testValidateRoleNull() throws Exception {
+        try {
+            httpEndpoint.validate();
+            fail("validate() should fail when Role is null");
+        } catch (DeploymentException de) {
+            String errorMsg = de.getMessage();
+            assertTrue("Exception should contain the correct error message string", errorMsg.contains("Endpoint must have a defined role"));
+        }
+    }
+
+    // Test validate() when location URI is null.
+    public void testValidateLocationUriNull() throws Exception {
+        httpEndpoint.setRoleAsString("consumer");
+
+        try {
+            httpEndpoint.validate();
+            fail("validate() should fail when Location URI is null");
+        } catch (DeploymentException de) {
+            String errorMsg = de.getMessage();
+            String msg = "Exception should contain the correct error message string";
+            assertTrue(msg, errorMsg.contains("Endpoint must have a defined locationURI"));
+        }
+    }
+
+    // Test validate() for non-SOAP endpoint when default MEP is not set.
+    public void testValidateNonSoapNoMep() throws Exception {
+        httpEndpoint.setRoleAsString("consumer");
+        httpEndpoint.setSoap(false);
+        httpEndpoint.setLocationURI("http://webhost:8080/someService");
+        httpEndpoint.setDefaultMep(null);
+
+        try {
+            httpEndpoint.validate();
+            fail("validate() should fail for non-SOAP endpoint with no default MEP");
+        } catch (DeploymentException de) {
+            String errorMsg = de.getMessage();
+            String msg = "Exception should contain the correct error message string";
+            assertTrue(msg, errorMsg.contains("Non soap endpoints must have a defined defaultMep"));
+        }
+    }
+
+    // Support class needed for HttpEndpoint tests.
+    public class MyServiceUnit extends ServiceUnit {
+        public MyServiceUnit() {
+            super(new HttpComponent());
+        }
+    }
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/HttpEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ManagedContextManagerTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ManagedContextManagerTest.java?rev=781749&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ManagedContextManagerTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ManagedContextManagerTest.java Thu Jun  4 14:24:16 2009
@@ -0,0 +1,89 @@
+/*
+ * 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.http;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class ManagedContextManagerTest extends TestCase {
+
+    private static transient Log log = LogFactory.getLog(ManagedContextManagerTest.class);
+    private ManagedContextManager server;
+    private HttpConfiguration config;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        config = new HttpConfiguration();
+        server = new ManagedContextManager();
+        server.setConfiguration(config);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        server.shutDown();
+        server = null;
+        config = null;
+    }
+
+    // Test createContext with a path that does not begin with a / and
+    // does not end with a /.
+    public void testCreateContext() throws Exception {
+        server.init();
+        server.start();
+
+        TestHttpProcessor httpProcessor = new TestHttpProcessor();
+        String strUrl = "path/to/some/resource";
+
+        String returnedPath = (String)server.createContext(strUrl, httpProcessor);
+        assertTrue("Context path should have / at end and at the beginning", returnedPath.equals("/" + strUrl + "/"));
+    }
+
+    // Test getMainProcessor with an unmanaged config - should throw IllegalStateException
+    public void testGetMainProcessorUnmanagedConfig() throws Exception {
+        server.init();
+        server.start();
+
+        try {
+            server.getMainProcessor();
+            fail("getMainProcessor() should fail for unmanaged config.");
+        } catch (IllegalStateException ise) {
+            // test succeeds
+            log.info("testGetMainProcessorUnmanagedConfig() threw the expected exception");
+        }
+    }
+
+    public static class TestHttpProcessor implements HttpProcessor {
+        public SslParameters getSsl() {
+            return null;
+        }
+
+        public String getAuthMethod() {
+            return null;
+        }
+
+        public void process(HttpServletRequest request, HttpServletResponse response) throws Exception {
+            log.info(request);
+        }
+
+    }
+    
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ManagedContextManagerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ProxyParametersTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ProxyParametersTest.java?rev=781749&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ProxyParametersTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ProxyParametersTest.java Thu Jun  4 14:24:16 2009
@@ -0,0 +1,62 @@
+/*
+ * 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.http;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.expression.PropertyExpression;
+
+public class ProxyParametersTest extends TestCase {
+
+    private static final String USERNAME = "username";
+    private static final String PASSWORD = "password";
+    private static final String PROXYHOST = "hostname";
+    private static final int PROXYPORT = 80;
+    private PropertyExpression usernameProp;
+    private PropertyExpression passwordProp;
+    private ProxyParameters proxyParams;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        usernameProp = new PropertyExpression(USERNAME);
+        passwordProp = new PropertyExpression(PASSWORD);
+    }
+ 
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        usernameProp = null;
+        passwordProp = null;
+        proxyParams = null;
+    }
+
+    public void testProxyParams() throws Exception {
+        BasicAuthCredentials bac = new BasicAuthCredentials();
+        bac.setUsername(usernameProp);
+        bac.setPassword(passwordProp);
+
+        // Create the Proxy Parameters
+        proxyParams = new ProxyParameters();
+        proxyParams.setProxyCredentials(bac);
+        proxyParams.setProxyHost(PROXYHOST);
+        proxyParams.setProxyPort(PROXYPORT);
+
+        assertTrue("Proxy Parameters should have non-null authentication credentials", proxyParams.getProxyCredentials() != null);
+        assertTrue("Proxy Host should be: " + PROXYHOST, proxyParams.getProxyHost().equals(PROXYHOST));
+        assertTrue("Proxy Port should be: " + PROXYPORT, proxyParams.getProxyPort() == PROXYPORT);
+    }
+
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ProxyParametersTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ServerManagerTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ServerManagerTest.java?rev=781749&r1=781748&r2=781749&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ServerManagerTest.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ServerManagerTest.java Thu Jun  4 14:24:16 2009
@@ -30,6 +30,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.servicemix.components.http.InvalidStatusResponseException;
 import org.apache.servicemix.http.jetty.JettyContextManager;
+import org.mortbay.jetty.handler.ContextHandler;
 import org.mortbay.thread.QueuedThreadPool;
 
 public class ServerManagerTest extends TestCase {
@@ -105,6 +106,43 @@
             // ok
         }
     }
+    
+    // Test create context when an authorization method is set on the HTTP processor.
+    public void testContextWithAuth() throws Exception {
+        server.init();
+        server.start();
+
+        Object contextObj = server.createContext("http://localhost:8192/Service1/test", new TestAltHttpProcessor());
+   
+        assertNotNull("Context should not be null", contextObj);
+        assertTrue("Context should be started", ((ContextHandler)contextObj).isStarted());
+    }
+    
+    // Test when https protocol used but SSL params is null.
+    public void testHttpsNoSslParams() throws Exception {
+        server.init();
+        server.start();
+ 
+        try {
+            server.createContext("https://localhost:8143/Service/test", new TestHttpProcessor());
+            fail("Context for https URL with no SSL Params should not be created");
+        } catch (IllegalArgumentException iae) {
+            // test passes
+        }
+    }
+    
+    // Test invalid protocol
+    public void testContextWithInvalidProtocol() throws Exception {
+        server.init();
+        server.start();
+ 
+        try {
+            server.createContext("file://localhost:8192/Service/test", new TestHttpProcessor());
+            fail("Context for invalid protocol should not be created.");
+        } catch (UnsupportedOperationException uoe) {
+            // test passes
+        }
+    }
 
     public void testSetMaxThreads() throws Exception {
         int maxThreads = 512;
@@ -159,4 +197,18 @@
         }
 
     }
+    
+    public static class TestAltHttpProcessor implements HttpProcessor {
+        public SslParameters getSsl() {
+            return null;
+        }
+
+        public String getAuthMethod() {
+            return "usernameToken";
+        }
+
+        public void process(HttpServletRequest request, HttpServletResponse response) throws Exception {
+            log.info(request);
+        }
+    }
 }

Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/SslParametersTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/SslParametersTest.java?rev=781749&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/SslParametersTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/SslParametersTest.java Thu Jun  4 14:24:16 2009
@@ -0,0 +1,66 @@
+/*
+ * 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.http;
+
+import junit.framework.TestCase;
+
+public class SslParametersTest extends TestCase {
+
+    private SslParameters sslParams;
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        sslParams = null;
+    }
+
+    // Test to verify that keyManagerFactoryAlgorithm and trustManagerFactoryAlgorithm
+    // are set up at object construction.
+    public void testSslParamsKeyAndTrustManagerAlgorithms() throws Exception {
+        sslParams = new SslParameters();
+        assertTrue("Ssl Parameters keyManagerFactoryAlgorithm should not be null", sslParams.getKeyManagerFactoryAlgorithm() != null);
+        assertTrue("Ssl Parameters trustManagerFactoryAlgorithm should not be null", sslParams.getTrustManagerFactoryAlgorithm() != null);
+    }
+
+    // SSL Parameters equals test - same object
+    public void testSslParamsObjectsEqualSameObject() throws Exception {
+        sslParams = new SslParameters();
+        SslParameters sslParamsSame = sslParams;
+        assertTrue("SSL Parameters objects should be equal (same)", sslParams.equals(sslParamsSame));
+    }
+
+    // Test SSL Parameters 2 separate objects equal
+    public void testSslParamsObjectsEquals() throws Exception {
+        sslParams = new SslParameters();
+        SslParameters sslParams2 = new SslParameters();
+        assertTrue("SSL Parameters objects should be equal", sslParams.equals(sslParams2));
+    }
+
+    // Test SSL Parameters 2 objects not equal
+    public void testSslParamsObjectsNotEqual() throws Exception {
+        sslParams = new SslParameters();
+        SslParameters sslParams2 = new SslParameters();
+        sslParams2.setKeyPassword("bogus");
+        assertTrue("SSL Parameters objects should NOT be equal", !sslParams.equals(sslParams2));
+    }
+
+    // Test SSL Parameters object not equal to another object type
+    public void testSslParamsObjectNotEqualOtherObjectType() throws Exception {
+        sslParams = new SslParameters();
+        String nonSslParamObj = "some string";
+        assertTrue("SSL Parameters object should NOT equal another object type", !sslParams.equals(nonSslParamObj));
+    }
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/SslParametersTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/DefaultHttpProviderMarshalerTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/DefaultHttpProviderMarshalerTest.java?rev=781749&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/DefaultHttpProviderMarshalerTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/DefaultHttpProviderMarshalerTest.java Thu Jun  4 14:24:16 2009
@@ -0,0 +1,158 @@
+/*
+ * 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.http.endpoints;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.expression.PropertyExpression;
+import org.apache.servicemix.http.jetty.SmxHttpExchange;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.tck.mock.MockExchangeFactory;
+import org.mortbay.jetty.HttpMethods;
+
+public class DefaultHttpProviderMarshalerTest extends TestCase {
+
+    private DefaultHttpProviderMarshaler defHttpProviderMarshaler;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        defHttpProviderMarshaler = new DefaultHttpProviderMarshaler();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        defHttpProviderMarshaler = null;
+    }
+
+    // Test getLocationUri when URI on message exchange is null.
+    public void testGetLocationUriNull() throws Exception {
+        MockExchangeFactory mef = new MockExchangeFactory();
+        MessageExchange me = mef.createInOnlyExchange();
+        NormalizedMessage msg = me.createMessage();
+        msg.setContent(new StringSource("<input>input message</input>"));
+        
+        defHttpProviderMarshaler.setLocationURI(null);
+        
+        try {
+            defHttpProviderMarshaler.getLocationUri(me, msg);
+            fail("getLocationUri() should throw an exception for null URI");
+        } catch (IllegalStateException ise) {
+            // test succeeds
+        }
+    }
+    
+    // Test getLocationUri when LocationURIExpression is set.
+    public void testGetLocationUriExpression() throws Exception {
+        MockExchangeFactory mef = new MockExchangeFactory();
+        MessageExchange me = mef.createInOnlyExchange();
+        me.setProperty("uri", "someOperation");
+        NormalizedMessage msg = me.createMessage();
+        msg.setContent(new StringSource("<input>input message</input>"));
+        
+        PropertyExpression uriExp = new PropertyExpression("uri");
+        
+        defHttpProviderMarshaler.setLocationURIExpression(uriExp);
+        
+        String uriReturned = defHttpProviderMarshaler.getLocationUri(me, msg);
+        
+        assertTrue("getLocationUri() should return the string value set on the exchange", "someOperation".equals(uriReturned));
+    }
+
+    // Test getMethod when in msg has no content.  Method should be HTTP GET. 
+    public void testGetMethodInMsgContentNull() throws Exception {
+        MockExchangeFactory mef = new MockExchangeFactory();
+        MessageExchange me = mef.createInOnlyExchange();
+        NormalizedMessage msg = me.createMessage();
+        String httpMethod = defHttpProviderMarshaler.getMethod(me, msg);
+        assertTrue("getMethod() with null in msg contents should return GET", httpMethod.equals(HttpMethods.GET));
+    }
+
+    // Test getMethod when a methodExpression is set on the message exchange.
+    public void testGetMethodWithMethodExpression() throws Exception {
+        MockExchangeFactory mef = new MockExchangeFactory();
+        MessageExchange me = mef.createInOnlyExchange();
+        me.setProperty("method", "POST");
+        NormalizedMessage msg = me.createMessage();
+        msg.setContent(new StringSource("<input>input message</input>"));
+        
+        PropertyExpression methodExp = new PropertyExpression("method");
+        
+        defHttpProviderMarshaler.setMethodExpression(methodExp);
+        
+        String httpMethod = defHttpProviderMarshaler.getMethod(me, msg);
+        
+        assertTrue("getMethod() with method expression should return the value set on the exchange", httpMethod.equals(HttpMethods.POST));
+    }
+
+    // Test getContentType when content type is null.
+    public void testGetContentTypeNull() throws Exception {
+        MockExchangeFactory mef = new MockExchangeFactory();
+        MessageExchange me = mef.createInOnlyExchange();
+        NormalizedMessage msg = me.createMessage();
+
+        // Must explicitly set contentType to null.  It is set by default.
+        defHttpProviderMarshaler.setContentType(null);
+        
+        try {
+            defHttpProviderMarshaler.getContentType(me, msg);
+            fail("getContentType() should throw an exception when contentType is null");
+        } catch (IllegalStateException ise) {
+            // test passes
+        }
+    }
+
+    // Test getContentType when contentTypeExpression is set on the exchange.
+    public void testGetContentTypeExpression() throws Exception {
+        MockExchangeFactory mef = new MockExchangeFactory();
+        MessageExchange me = mef.createInOnlyExchange();
+        me.setProperty("contentType", "text/plain");
+        NormalizedMessage msg = me.createMessage();
+        msg.setContent(new StringSource("<input>input message</input>"));
+        PropertyExpression contentTypeExp = new PropertyExpression("contentType");
+        defHttpProviderMarshaler.setContentTypeExpression(contentTypeExp);
+        String contentType = defHttpProviderMarshaler.getContentType(me, msg);
+        assertTrue("getContentType() should return the value set on the exchange", "text/plain".equals(contentType));        
+    }
+
+    // Test createRequest when headers are set.
+    public void testCreateRequestWithHeaders() throws Exception {
+        // Create a header to add to the exchange.
+        Map<String, String> headers = new HashMap<String, String>();
+        headers.put("Cache-Control", "no-cache");
+        
+        MockExchangeFactory mef = new MockExchangeFactory();
+        MessageExchange me = mef.createInOnlyExchange();
+        me.setProperty("uri", "http://localhost:8192/Service1/someOperation");
+        NormalizedMessage msg = me.createMessage();
+        msg.setContent(new StringSource("<input>input message</input>"));
+        SmxHttpExchange httpExchange = new SmxHttpExchange();
+        
+        PropertyExpression uriExp = new PropertyExpression("uri");
+        defHttpProviderMarshaler.setHeaders(headers);
+        defHttpProviderMarshaler.setLocationURIExpression(uriExp);
+        defHttpProviderMarshaler.createRequest(me, msg, httpExchange);
+        
+        // Create request sets the request content on the httpExchange.
+        assertNotNull("createRequest() should set the http exchange's request content", httpExchange.getRequestContent());
+    }
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/DefaultHttpProviderMarshalerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpointTest.java?rev=781749&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpointTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpointTest.java Thu Jun  4 14:24:16 2009
@@ -0,0 +1,99 @@
+/*
+ * 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.http.endpoints;
+
+//import javax.jbi.JBIException;
+import javax.jbi.component.ComponentContext;
+import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.Fault;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.common.ServiceUnit;
+import org.apache.servicemix.http.HttpComponent;
+
+public class HttpSoapConsumerEndpointTest extends TestCase {
+
+    private HttpSoapConsumerEndpoint httpSoapConsEp;        
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        httpSoapConsEp = new HttpSoapConsumerEndpoint();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        httpSoapConsEp = null;
+    }
+
+    // Test activate() when target endpoint WSDL is null.
+    /*public void testActivateTargetEndpointWsdlNull() throws Exception {
+        TestServiceUnit serviceUnit = new TestServiceUnit();        
+        httpSoapConsEp.setServiceUnit(serviceUnit);
+        
+        try {
+            httpSoapConsEp.activate();
+            fail("activate() should fail if target endpoint WSDL is null");
+        } catch (JBIException jbie) {
+            // test passes
+        }
+    }*/
+
+    // Test validate() when an invalid marshaler is set.
+    public void testValidateInvalidMarshaler() throws Exception {
+        httpSoapConsEp.setMarshaler(new TestHttpConsumerMarshaler());
+        
+        try {
+            httpSoapConsEp.validate();
+            fail("validate() should fail when marshaler is not an HttpSoapConsumerMarshaler");
+        } catch (DeploymentException de) {
+            // test succeeds
+        }
+    } 
+
+    // TestServiceUnit needed to create a service unit associated with the HTTP component.
+    public static class TestServiceUnit extends ServiceUnit {
+        public TestServiceUnit() {
+           super(new HttpComponent());           
+        }
+    }
+
+    // TestHttpConsumerMarshaler needed for invalid marshaler test.
+    public static class TestHttpConsumerMarshaler implements HttpConsumerMarshaler {
+        public void sendOut(MessageExchange exchange, NormalizedMessage outMsg, HttpServletRequest request, HttpServletResponse response) {
+        }
+
+        public void sendFault(MessageExchange exchange, Fault fault, HttpServletRequest request, HttpServletResponse response) {
+        }
+
+        public void sendError(MessageExchange exchange, Exception error, HttpServletRequest request, HttpServletResponse response) {
+        }
+
+        public void sendAccepted(MessageExchange exchange, HttpServletRequest request, HttpServletResponse response) {
+        }
+        
+        public MessageExchange createExchange(HttpServletRequest request, ComponentContext context) {
+            return null;
+        }        
+    }
+    
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/HttpSoapProviderEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/HttpSoapProviderEndpointTest.java?rev=781749&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/HttpSoapProviderEndpointTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/HttpSoapProviderEndpointTest.java Thu Jun  4 14:24:16 2009
@@ -0,0 +1,89 @@
+/*
+ * 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.http.endpoints;
+
+import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.http.jetty.SmxHttpExchange;
+import org.springframework.core.io.FileSystemResource;
+
+
+public class HttpSoapProviderEndpointTest extends TestCase {
+
+    private HttpSoapProviderEndpoint soapProviderEp;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        soapProviderEp = new HttpSoapProviderEndpoint();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        soapProviderEp = null;
+    }
+
+    // Test for validate() when WSDL is null.
+    public void testValidateWsdlNull() throws Exception {
+        try {
+            soapProviderEp.validate();
+            fail("validate() should fail when WSDL is null");
+        } catch (DeploymentException de) {
+            // test passes
+        }
+    }
+
+    public void testValidateInvalidMarshaler() throws Exception {
+        FileSystemResource wsdl = new FileSystemResource("provider/http.wsdl");
+        soapProviderEp.setWsdl(wsdl);
+        soapProviderEp.setMarshaler(new TestHttpProviderMarshaler());
+
+        try {
+            soapProviderEp.validate();
+            fail("validate() should fail when an invalid marshaler is used");
+        } catch (DeploymentException de) {
+            // test passes
+        }
+    }
+ 
+    public void testValidateNonexistentWsdl() throws Exception {
+        FileSystemResource wsdl = new FileSystemResource("provider/noexist.wsdl");
+        soapProviderEp.setWsdl(wsdl);
+ 
+        try {
+            soapProviderEp.validate();
+            fail("validate() should fail for non-existent WSDL");
+        } catch (DeploymentException de) {
+            // test succeeds
+        }
+    }
+
+    // Dummy implementation of a marshaler for the invalid marshaler test.
+    public static class TestHttpProviderMarshaler implements HttpProviderMarshaler {
+        public void createRequest(MessageExchange exchange, NormalizedMessage inMsg, SmxHttpExchange httpExchange) {
+        }
+
+        public void handleResponse(MessageExchange exchange, SmxHttpExchange httpExchange) {
+        }
+
+        public void handleException(MessageExchange exchange, SmxHttpExchange httpExchange, Throwable ex) {
+        }
+    }
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/HttpSoapProviderEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/jetty/SmxHttpExchangeTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/jetty/SmxHttpExchangeTest.java?rev=781749&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/jetty/SmxHttpExchangeTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/jetty/SmxHttpExchangeTest.java Thu Jun  4 14:24:16 2009
@@ -0,0 +1,140 @@
+/*
+ * 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.http.jetty;
+
+import java.io.InputStream;
+import java.io.Reader;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.mortbay.io.ByteArrayBuffer;
+
+public class SmxHttpExchangeTest extends TestCase {
+
+    private static transient Log log = LogFactory.getLog(SmxHttpExchangeTest.class);
+    private static final String STRRESPONSECONTENT = "valid response content";
+    private SmxHttpExchange httpExchange;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        httpExchange = new SmxHttpExchange();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        httpExchange = null;
+    }
+
+    // Test getResponseStatus when it throws an IllegalStateException
+    public void testGetResponseStatusException() throws Exception {
+        // set the response status
+        httpExchange.onResponseStatus(null, 0, null);
+
+        try {
+            httpExchange.getResponseStatus();
+            fail("getResponseStatus() should fail with IllegalStateException");
+        } catch (IllegalStateException ise) {
+            log.info("testGetResponseStatusException() got the expected exception");
+        }
+    }
+
+    // Test getResponseFields when it throws an IllegalStateException
+    public void testGetResponseFieldsException() throws Exception {
+
+        // set the response status
+        httpExchange.onResponseStatus(null, 0, null);
+
+        try {
+            httpExchange.getResponseFields();
+            fail("getResponseFields() should fail with IllegalStateException");
+        } catch (IllegalStateException ise) {
+            log.info("testGetResponseFieldsException() got the expected exception");
+        }
+    }
+
+    // Test getResponseContent when responseContent is null.
+    public void testGetResponseContentNull() throws Exception {
+
+        assertNull("getResponseContent() should return null", httpExchange.getResponseContent());
+    }
+
+    // Test getResponseContent when responseContent is returned as a string.
+    public void testGetResponseContentString() throws Exception {
+
+        // set the response content
+        setResponseContent();
+
+        String returnedContent = httpExchange.getResponseContent();
+        assertTrue("", returnedContent.equalsIgnoreCase(STRRESPONSECONTENT));
+    }
+
+    // Test getResponseReader when responseContent is null.
+    public void testGetResponseReaderNull() throws Exception {
+        assertNull("getResponseReader() should return null", httpExchange.getResponseReader());
+    }
+
+    // Test getResponseReader when responseContent is returned as a reader.
+    public void testGetResponseReader() throws Exception {
+
+        // set the response content
+        setResponseContent();
+        Reader inReader = httpExchange.getResponseReader();
+        assertNotNull("getResponseReader() should return a Reader", inReader);
+    }
+
+    // Test getResponseStream when responseContent is null.
+    public void testGetResponseStreamNull() throws Exception {
+
+        assertNull("getResponseStream() should return null", httpExchange.getResponseStream());
+    }
+
+    // Test getResponseStream when responseContent is returned as an InputStream.
+    public void testGetResponseStream() throws Exception {
+
+        // set the response content
+        setResponseContent();
+        InputStream inStream = httpExchange.getResponseStream();
+
+        assertNotNull("getResponseStream() should return an InputStream", inStream);
+    }
+
+    // Test getResponseData when responseContent is null.
+    public void testGetResponseDataNull() throws Exception {
+
+        assertNull("getResponseData() should return null", httpExchange.getResponseData());
+    }
+
+    // Test getResponseData when responseContent is returned as a byte array.
+    public void testGetResponseData() throws Exception {
+
+        // set the response content
+        setResponseContent();
+        byte[] byteArray = httpExchange.getResponseData();
+        assertTrue("getResponseData() should return more than 0 bytes", byteArray.length > 0);
+    }
+
+    // Method used for test setup to set the exchange's responseContent 
+    //for getResponse<type> tests.
+    private void setResponseContent() throws Exception {
+        ByteArrayBuffer contentBuffer = new ByteArrayBuffer(STRRESPONSECONTENT);
+
+        // set the exchange's responseContent
+        httpExchange.onResponseContent(contentBuffer);
+    }
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/jetty/SmxHttpExchangeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzerTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzerTest.java?rev=781749&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzerTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzerTest.java Thu Jun  4 14:24:16 2009
@@ -0,0 +1,149 @@
+/*
+ * 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.http.packaging;
+
+import java.util.List;
+
+//import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessageExchange.Role;
+import javax.xml.namespace.QName;
+
+//import org.w3c.dom.Document;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.common.DefaultComponent;
+import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.ExchangeProcessor;
+import org.apache.servicemix.common.ServiceUnit;
+import org.apache.servicemix.http.HttpEndpoint;
+
+
+public class HttpServiceUnitAnalyzerTest extends TestCase {
+
+    private HttpServiceUnitAnalyzer httpSuAnalyzer;
+    private ServiceUnit su;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        httpSuAnalyzer = new HttpServiceUnitAnalyzer();
+        su = new ServiceUnit();
+        su.setComponent(new MyComponent());
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        su = null;
+        httpSuAnalyzer = null;
+    }
+
+    // Test isValidEndpoint() for valid HttpEndpoint on ServiceUnit.
+    public void testIsValidEndpointTrue() throws Exception {
+        HttpEndpoint httpEp = new HttpEndpoint();
+        httpEp.setService(new QName("urn:test", "service"));
+        httpEp.setEndpoint("http://localhost:8080/someService");
+        su.addEndpoint(httpEp);
+
+        // Create the key that was used by the addEndpoint method.
+        String epKey = "{urn:test}service:http://localhost:8080/someService";
+        assertTrue("", httpSuAnalyzer.isValidEndpoint(su.getEndpoint(epKey)));
+    }
+
+    // Test isValidEndpoint() for non-HttpEndpoint on Service Unit.
+    public void testIsValidEndpointFalse() throws Exception {
+        QName serviceName = new QName("http://localhost:8080/someService", "someService");
+        TestEndpoint testEp = new TestEndpoint(su, serviceName, "test");
+        System.out.println("key == " + testEp.getKey());
+        su.addEndpoint(testEp);
+        assertFalse("isValidEndpoint() should return false for non-HttpEndpoint", httpSuAnalyzer.isValidEndpoint(su.getEndpoint("test")));
+    }
+
+    // Test getConsumes() when endpoint has proper target setup.
+    public void testGetConsumesUsingTargets() throws Exception {
+        HttpEndpoint httpEp = new HttpEndpoint();
+        httpEp.setRoleAsString("consumer");
+        httpEp.setTargetService(new QName("urn:test", "service"));
+        httpEp.setTargetEndpoint("http://localhost:8080/someService");
+        httpEp.setTargetInterfaceName(new QName("urn:test", "portType"));
+
+        List consumeList = httpSuAnalyzer.getConsumes(httpEp);
+
+        assertNotNull("getConsumes() should not return null list", consumeList);
+    }
+
+    // Test getConsumes() when endpoint does not have target setup.
+    public void testGetConsumesInvalidList() throws Exception {
+        HttpEndpoint httpEp = new HttpEndpoint();
+        httpEp.setRoleAsString("consumer");
+        httpEp.setService(new QName("urn:test", "service"));
+        httpEp.setEndpoint("http://localhost:8080/someService");
+        httpEp.setInterfaceName(new QName("urn:test", "portType"));
+        List consumeList = httpSuAnalyzer.getConsumes(httpEp);
+        assertNotNull("getConsumes() should not return null list", consumeList);
+    }
+
+    // Dummy Endpoint implementation for testing.
+    public static class TestEndpoint extends Endpoint {
+        //private String key;
+
+        public TestEndpoint() {
+            //key = "test";
+        }
+        
+        public TestEndpoint(ServiceUnit serviceUnit, QName service, String endpoint) {
+           super(serviceUnit, service, endpoint);
+        }
+
+        public String getKey() { 
+            return super.getKey();
+        }
+
+        public void activate() throws Exception {
+        }
+
+        public void deactivate() throws Exception {
+        }
+
+        public ExchangeProcessor getProcessor() {
+            return null;
+        }
+
+        public Role getRole() {
+            return null;
+        }
+
+        public boolean isExchangeOkay(MessageExchange exchange) {
+            return false;
+        }
+
+    }
+
+    protected class MyComponent extends DefaultComponent {
+        public MyComponent() {
+            super();
+        }
+
+        public List getConfiguredEndpoints() {
+            return null;
+        }
+
+        public Class[] getEndpointClasses() {
+            return new Class[1];
+        }
+    }
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native