FELIX-4196 Add unit tests and compile for Java 5 to support Mockito

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1515392 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http/sslfilter/pom.xml b/http/sslfilter/pom.xml
index a4bbff9..e62e84d 100644
--- a/http/sslfilter/pom.xml
+++ b/http/sslfilter/pom.xml
@@ -34,6 +34,13 @@
     <build>
         <plugins>
             <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <version>2.3.7</version>
diff --git a/http/sslfilter/src/test/java/org/apache/felix/http/sslfilter/internal/SslFilterRequestTest.java b/http/sslfilter/src/test/java/org/apache/felix/http/sslfilter/internal/SslFilterRequestTest.java
new file mode 100644
index 0000000..0db95a6
--- /dev/null
+++ b/http/sslfilter/src/test/java/org/apache/felix/http/sslfilter/internal/SslFilterRequestTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.felix.http.sslfilter.internal;
+
+import static org.mockito.Mockito.when;
+
+import javax.servlet.http.HttpServletRequest;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class SslFilterRequestTest
+{
+
+    @Test
+    public void test_isSecure()
+    {
+        HttpServletRequest req = Mockito.mock(HttpServletRequest.class);
+        SslFilterRequest sreq = new SslFilterRequest(req);
+
+        when(req.isSecure()).thenReturn(false);
+        TestCase.assertFalse(req.isSecure());
+        TestCase.assertTrue(sreq.isSecure());
+        TestCase.assertFalse(req.isSecure());
+
+        when(req.isSecure()).thenReturn(true);
+        TestCase.assertTrue(req.isSecure());
+        TestCase.assertTrue(sreq.isSecure());
+        TestCase.assertTrue(req.isSecure());
+    }
+
+    @Test
+    public void test_getScheme()
+    {
+        HttpServletRequest req = Mockito.mock(HttpServletRequest.class);
+        SslFilterRequest sreq = new SslFilterRequest(req);
+
+        when(req.getScheme()).thenReturn("http");
+        TestCase.assertEquals("http", req.getScheme());
+        TestCase.assertEquals("https", sreq.getScheme());
+        TestCase.assertEquals("http", req.getScheme());
+
+        when(req.getScheme()).thenReturn("https");
+        TestCase.assertEquals("https", req.getScheme());
+        TestCase.assertEquals("https", sreq.getScheme());
+        TestCase.assertEquals("https", req.getScheme());
+    }
+
+    @Test
+    public void test_getRequestURL()
+    {
+        HttpServletRequest req = Mockito.mock(HttpServletRequest.class);
+        SslFilterRequest sreq = new SslFilterRequest(req);
+
+        when(req.getRequestURL()).thenReturn(new StringBuffer("http://some/page"));
+        TestCase.assertEquals("http://some/page", req.getRequestURL().toString());
+        TestCase.assertEquals("https://some/page", sreq.getRequestURL().toString());
+        TestCase.assertEquals("http://some/page", req.getRequestURL().toString());
+
+        when(req.getRequestURL()).thenReturn(new StringBuffer("https://some/page"));
+        TestCase.assertEquals("https://some/page", req.getRequestURL().toString());
+        TestCase.assertEquals("https://some/page", sreq.getRequestURL().toString());
+        TestCase.assertEquals("https://some/page", req.getRequestURL().toString());
+    }
+}