servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eno...@apache.org
Subject svn commit: r781505 - in /servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http: ./ jetty/ packaging/
Date Wed, 03 Jun 2009 18:50:41 GMT
Author: enolan
Date: Wed Jun  3 18:50:41 2009
New Revision: 781505

URL: http://svn.apache.org/viewvc?rev=781505&view=rev
Log:
SMXCOMP-528 - add new test and fix checkstyle errors

Added:
    servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/jetty/JaasUserRealmTest.java   (with props)
Modified:
    servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpBridgeServletTest.java
    servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpConfigurationTest.java
    servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpEndpointTest.java
    servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ManagedContextManagerTest.java
    servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ProxyParametersTest.java
    servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ServerManagerTest.java
    servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/SslParametersTest.java
    servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/jetty/SmxHttpExchangeTest.java
    servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzerTest.java

Modified: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpBridgeServletTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpBridgeServletTest.java?rev=781505&r1=781504&r2=781505&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpBridgeServletTest.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpBridgeServletTest.java Wed Jun  3 18:50:41 2009
@@ -1,3 +1,19 @@
+/*
+ * 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;
@@ -14,188 +30,179 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import junit.framework.TestCase;
+
 import org.mortbay.jetty.Request;
 import org.mortbay.jetty.Response;
 
-import junit.framework.TestCase;
-
 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.
+    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;
         }

Modified: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpConfigurationTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpConfigurationTest.java?rev=781505&r1=781504&r2=781505&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpConfigurationTest.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpConfigurationTest.java Wed Jun  3 18:50:41 2009
@@ -1,77 +1,91 @@
+/*
+ * 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 org.apache.servicemix.util.FileUtil;
-
 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
-		FileUtil.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));
-	}
-	
+    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
+        FileUtil.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));
+    }
+
 }

Modified: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpEndpointTest.java?rev=781505&r1=781504&r2=781505&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpEndpointTest.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/HttpEndpointTest.java Wed Jun  3 18:50:41 2009
@@ -1,72 +1,87 @@
+/*
+ * 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 org.apache.servicemix.common.DefaultServiceUnit;
-
 import junit.framework.TestCase;
 
+import org.apache.servicemix.common.DefaultServiceUnit;
+
 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();
-			assertTrue("Exception should contain the correct error message string", 
-					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();
-			assertTrue("Exception should contain the correct error message string", 
-					errorMsg.contains("Non soap endpoints must have a defined defaultMep"));
-		}
-	}
+    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.
+    // Support class needed for HttpEndpoint tests.
     public class MyServiceUnit extends DefaultServiceUnit {
         public MyServiceUnit() {
             super(new HttpComponent());

Modified: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ManagedContextManagerTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ManagedContextManagerTest.java?rev=781505&r1=781504&r2=781505&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ManagedContextManagerTest.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ManagedContextManagerTest.java Wed Jun  3 18:50:41 2009
@@ -1,89 +1,76 @@
+/*
+ * 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;
 
-import org.mortbay.jetty.HttpURI;
-import org.mortbay.jetty.Request;
-import org.mortbay.jetty.Response;
+public class ManagedContextManagerTest extends TestCase {
 
-import junit.framework.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);
+    }
 
-public class ManagedContextManagerTest extends TestCase {
+    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");
+        }
+    }
 
-	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 void testProcessorProcess() throws Exception {
-		server.init();
-		server.start();
-		
-		Request request = new Request();
-		request.setUri(new HttpURI("/"));
-		request.setMethod("GET");
-		request.setProtocol("http");
-		TestResponse response = new TestResponse();
-		
-		TestHttpProcessor httpProcessor = new TestHttpProcessor();
-		String strUrl = "/path/to/some/resource/";
-		
-		server.createContext(strUrl, httpProcessor);
-		
-		server.getConfiguration().setManaged(true);
-		
-		server.getMainProcessor().process(request, response);
-		
-		assertTrue("", response.getStatus() == HttpServletResponse.SC_NOT_FOUND);
-		
-	}
-*/	
     public static class TestHttpProcessor implements HttpProcessor {
         public SslParameters getSsl() {
             return null;

Modified: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ProxyParametersTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ProxyParametersTest.java?rev=781505&r1=781504&r2=781505&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ProxyParametersTest.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ProxyParametersTest.java Wed Jun  3 18:50:41 2009
@@ -1,47 +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 org.apache.servicemix.expression.PropertyExpression;
-
 import junit.framework.TestCase;
 
+import org.apache.servicemix.expression.PropertyExpression;
+
 public class ProxyParametersTest extends TestCase {
-	
-	private PropertyExpression usernameProp;
-	private PropertyExpression passwordProp;
-	private ProxyParameters proxyParams;
-	private static final String userName = "username";
-	private static final String password = "password";
-	private static final String proxyHost = "hostname";
-	private static final int proxyPort = 80;
-
-	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);		
-	}
+
+    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);
+    }
 
 }

Modified: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ServerManagerTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ServerManagerTest.java?rev=781505&r1=781504&r2=781505&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ServerManagerTest.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ServerManagerTest.java Wed Jun  3 18:50:41 2009
@@ -109,39 +109,39 @@
     
     // 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());
+        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
-    	}
+        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
-    	}
+        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 {
@@ -199,7 +199,7 @@
     }
     
     public static class TestAltHttpProcessor implements HttpProcessor {
-    	public SslParameters getSsl() {
+        public SslParameters getSsl() {
             return null;
         }
 

Modified: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/SslParametersTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/SslParametersTest.java?rev=781505&r1=781504&r2=781505&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/SslParametersTest.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/SslParametersTest.java Wed Jun  3 18:50:41 2009
@@ -1,50 +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));
-	}
+    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));
+    }
 }

Added: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/jetty/JaasUserRealmTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/jetty/JaasUserRealmTest.java?rev=781505&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/jetty/JaasUserRealmTest.java (added)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/jetty/JaasUserRealmTest.java Wed Jun  3 18:50:41 2009
@@ -0,0 +1,114 @@
+/*
+ * 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.security.GeneralSecurityException;
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.common.security.AuthenticationService;
+
+public class JaasUserRealmTest extends TestCase {
+
+    private static transient Log log = LogFactory.getLog(JaasUserRealmTest.class);
+    private static final String USERNAME = "username";
+    private static final String PASSWORD = "password";
+    private JaasUserRealm jaasUserRealm;
+    private AuthenticationService authService;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        jaasUserRealm = new JaasUserRealm();
+        authService = new TestAuthenticationService();
+        jaasUserRealm.setAuthenticationService(authService);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        jaasUserRealm = null;
+        authService = null;
+    }
+
+    // Test authenticate() when username is null
+    public void testAuthenticateUsernameIsNull() throws Exception {
+        assertNull("authenticate() should return null for null username", jaasUserRealm.authenticate(null, null, null));
+    }
+
+    // Test authenticate() when authenticationService's authenticate throws 
+    // a GeneralSecurityException
+    public void testAuthenticateFails() throws Exception {
+        String msg = "authenticate() should return null when authService authenticate fails";
+        assertNull(msg, jaasUserRealm.authenticate(USERNAME, null, null));
+    }
+
+    // Test authenticate() when authenticationService's authenticate is successful.
+    public void testAuthenticateSuccess() throws Exception {
+        Principal userPrincipal = jaasUserRealm.authenticate(USERNAME, PASSWORD, null);
+        assertNotNull("authenticate() should return non-null Principal", userPrincipal);
+    }
+
+    // Test logout() when user logged in
+    public void testLogoutUserLoggedIn() throws Exception {
+        // authenticate the user
+        Principal userPrincipal = jaasUserRealm.authenticate(USERNAME, PASSWORD, null);
+
+        // now log them out
+        jaasUserRealm.logout(userPrincipal);
+
+        // verify the user is not in the map
+        assertNull("logout() should have removed principal: " + USERNAME, jaasUserRealm.getPrincipal(USERNAME));
+    }
+
+    // Test logout() when user not logged in
+    public void testLogoutUserNotLoggedIn() throws Exception {
+        Principal userPrincipal = new JaasJettyPrincipal(USERNAME);
+        // user principal not added to the map via authenticate
+        jaasUserRealm.logout(userPrincipal);
+        // verify the user is not in the map
+        assertNull("logout() should have removed principal: " + USERNAME, jaasUserRealm.getPrincipal(USERNAME));
+    }
+
+    // Test reauthenticate() when user logged in
+    public void testReauthenticateUserLoggedIn() throws Exception {
+        Principal userPrincipal = jaasUserRealm.authenticate(USERNAME, PASSWORD, null);
+
+        assertTrue("reauthenticate() should return true for logged in user", jaasUserRealm.reauthenticate(userPrincipal));
+    }
+
+    // Test reauthenticate() when user not logged in
+    public void testReauthenticateUserNotLoggedIn() throws Exception {
+        Principal userPrincipal = new JaasJettyPrincipal(USERNAME);
+ 
+        assertFalse("reauthenticate() should return false for user not logged in", jaasUserRealm.reauthenticate(userPrincipal));
+    }
+
+    // Mock implementation of an AuthenticationService to help with testing.
+    public static class TestAuthenticationService implements AuthenticationService {
+        public void authenticate(Subject subject, String domain, String user, Object credentials) 
+            throws GeneralSecurityException {
+            if (credentials == null) {
+                throw new GeneralSecurityException("authenticate() failed due to null credentials");
+            }
+            log.info("authenticate() called");
+        }
+    }
+}  

Propchange: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/jetty/JaasUserRealmTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/jetty/SmxHttpExchangeTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/jetty/SmxHttpExchangeTest.java?rev=781505&r1=781504&r2=781505&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/jetty/SmxHttpExchangeTest.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/jetty/SmxHttpExchangeTest.java Wed Jun  3 18:50:41 2009
@@ -1,130 +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;
 
-import junit.framework.TestCase;
-
 public class SmxHttpExchangeTest extends TestCase {
 
-	private static transient Log log = LogFactory.getLog(SmxHttpExchangeTest.class);
-	private SmxHttpExchange httpExchange;
-	private static final String strResponseContent = "valid response content";
-	
-	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);
-	}
+    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);
+    }
 }

Modified: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzerTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzerTest.java?rev=781505&r1=781504&r2=781505&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzerTest.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzerTest.java Wed Jun  3 18:50:41 2009
@@ -1,3 +1,19 @@
+/*
+ * 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;
@@ -7,144 +23,136 @@
 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.DefaultServiceUnit;
 import org.apache.servicemix.common.Endpoint;
 import org.apache.servicemix.common.ServiceUnit;
 import org.apache.servicemix.http.HttpEndpoint;
-import org.w3c.dom.Document;
 
-import junit.framework.TestCase;
 
 public class HttpServiceUnitAnalyzerTest extends TestCase {
 
-	private HttpServiceUnitAnalyzer httpSuAnalyzer;
-	private DefaultServiceUnit su;
-	
-	protected void setUp() throws Exception {
-		super.setUp();
-		httpSuAnalyzer = new HttpServiceUnitAnalyzer();
-		su = new DefaultServiceUnit();
-	}
-
-	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 {
-		TestEndpoint testEp = new TestEndpoint();
-		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 implements Endpoint {
-
-		private String key;
-		
-		public TestEndpoint() {
-			key = "test";
-		}
-		
-		public void activate() throws Exception {
-		}
-
-		public void deactivate() throws Exception {
-		}
-
-		public Document getDescription() {
-			return null;
-		}
-
-		public String getEndpoint() {
-			return null;
-		}
-
-		public QName getInterfaceName() {
-			return null;
-		}
-
-		public String getKey() {
-			return key;
-		}
-
-		public Role getRole() {
-			return null;
-		}
-
-		public QName getService() {
-			return null;
-		}
-
-		public ServiceUnit getServiceUnit() {
-			return null;
-		}
-
-		public boolean isExchangeOkay(MessageExchange exchange) {
-			return false;
-		}
-
-		public void process(MessageExchange exchange) throws Exception {
-			
-		}
-
-		public void setServiceUnit(ServiceUnit serviceUnit) {
-			
-		}
-
-		public void start() throws Exception {
-			
-		}
-
-		public void stop() throws Exception {
-			
-		}
-
-		public void validate() throws DeploymentException {
-			
-		}
-		
-	}
+    private HttpServiceUnitAnalyzer httpSuAnalyzer;
+    private DefaultServiceUnit su;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        httpSuAnalyzer = new HttpServiceUnitAnalyzer();
+        su = new DefaultServiceUnit();
+    }
+
+    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 {
+        TestEndpoint testEp = new TestEndpoint();
+        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 implements Endpoint {
+        private String key;
+
+        public TestEndpoint() {
+            key = "test";
+        }
+
+        public void activate() throws Exception {
+        }
+
+        public void deactivate() throws Exception {
+        }
+
+        public Document getDescription() {
+            return null;
+        }
+
+        public String getEndpoint() {
+            return null;
+        }
+
+        public QName getInterfaceName() {
+            return null;
+        }
+
+        public String getKey() {
+            return key;
+        }
+
+        public Role getRole() {
+            return null;
+        }
+
+        public QName getService() {
+            return null;
+        }
+
+        public ServiceUnit getServiceUnit() {
+            return null;
+        }
+
+        public boolean isExchangeOkay(MessageExchange exchange) {
+            return false;
+        }
+
+        public void process(MessageExchange exchange) throws Exception {
+        }
+
+        public void setServiceUnit(ServiceUnit serviceUnit) {
+        }
+
+        public void start() throws Exception {
+        }
+ 
+        public void stop() throws Exception {
+        }
+
+        public void validate() throws DeploymentException {
+        }
+
+    }
 }



Mime
View raw message