Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2016-04-18 12:37:55 +0000
committerThomas Watson2016-04-18 12:45:21 +0000
commit52244550143ecf350f5af6686988fb56b1fb6627 (patch)
tree99da91b96df380a38b5a9441bd6c129ceaae25aa
parenta72c911568b349462d0ae01726950160523cbc45 (diff)
downloadrt.equinox.bundles-52244550143ecf350f5af6686988fb56b1fb6627.tar.gz
rt.equinox.bundles-52244550143ecf350f5af6686988fb56b1fb6627.tar.xz
rt.equinox.bundles-52244550143ecf350f5af6686988fb56b1fb6627.zip
Bug 490273 - Move tests to JUnit 4Y20160421-1000I20160419-0800
Re-enable junit 4 but use Require-Bundle for org.unit Change-Id: I2a8de20f8584235ea9f8b82ed9b41096aaccfc24 Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/META-INF/MANIFEST.MF3
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java21
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/BaseTest.java11
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/DispatchingTest.java27
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java291
5 files changed, 248 insertions, 105 deletions
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.http.servlet.tests/META-INF/MANIFEST.MF
index 2ceb42cd..67bcd499 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/META-INF/MANIFEST.MF
@@ -6,16 +6,15 @@ Bundle-Version: 1.0.100.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Eclipse-BundleShape: dir
Bundle-Activator: org.eclipse.equinox.http.servlet.tests.bundle.Activator
+Require-Bundle: org.junit;bundle-version="4.0"
Import-Package: javax.servlet;version="2.6.0",
javax.servlet.http;version="2.6.0",
- junit.framework;version="4.8.2",
org.apache.commons.fileupload;version="1.2.2",
org.apache.commons.fileupload.disk;version="1.2.2",
org.apache.commons.fileupload.servlet;version="1.2.2",
org.eclipse.equinox.http.servlet;version="1.1.0",
org.eclipse.equinox.http.servlet.context;version="1.0.0",
org.eclipse.osgi.service.urlconversion;version="1.0.0",
- org.junit;version="4.11.0",
org.osgi.framework;version="1.6.0",
org.osgi.framework.hooks.service;version="1.1.0",
org.osgi.service.component,
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java
index 1f30bee6..e0c90736 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java
@@ -3,17 +3,12 @@ package org.eclipse.equinox.http.servlet.testbase;
import org.eclipse.equinox.http.servlet.tests.DispatchingTest;
import org.eclipse.equinox.http.servlet.tests.ServletTest;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllTests extends TestSuite {
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new TestSuite(DispatchingTest.class));
- suite.addTest(new TestSuite(ServletTest.class));
- return suite;
- }
-
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({DispatchingTest.class,ServletTest.class})
+public class AllTests {
+ // see @SuiteClasses
}
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/BaseTest.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/BaseTest.java
index df77ff3f..3c1c0ed4 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/BaseTest.java
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/BaseTest.java
@@ -37,7 +37,8 @@ import org.eclipse.equinox.http.servlet.tests.bundle.Activator;
import org.eclipse.equinox.http.servlet.tests.bundle.BundleAdvisor;
import org.eclipse.equinox.http.servlet.tests.bundle.BundleInstaller;
import org.eclipse.equinox.http.servlet.tests.util.ServletRequestAdvisor;
-
+import org.junit.After;
+import org.junit.Before;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -47,11 +48,9 @@ import org.osgi.framework.ServiceRegistration;
import org.osgi.service.http.HttpService;
import org.osgi.service.http.context.ServletContextHelper;
-import junit.framework.TestCase;
-
-public class BaseTest extends TestCase {
+public class BaseTest {
- @Override
+ @Before
public void setUp() throws Exception {
// Quiet logging for tests
System.setProperty("/.LEVEL", "OFF");
@@ -70,7 +69,7 @@ public class BaseTest extends TestCase {
startJetty();
}
- @Override
+ @After
public void tearDown() throws Exception {
for (ServiceRegistration<? extends Object> serviceRegistration : registrations) {
serviceRegistration.unregister();
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/DispatchingTest.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/DispatchingTest.java
index 36fe3e2a..e609868c 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/DispatchingTest.java
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/DispatchingTest.java
@@ -36,7 +36,7 @@ import org.eclipse.equinox.http.servlet.testbase.BaseTest;
import org.eclipse.equinox.http.servlet.tests.util.BaseServlet;
import org.eclipse.equinox.http.servlet.tests.util.DispatchResultServlet;
import org.junit.Assert;
-
+import org.junit.Test;
import org.osgi.service.http.HttpContext;
import org.osgi.service.http.HttpService;
import org.osgi.service.http.context.ServletContextHelper;
@@ -44,6 +44,7 @@ import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
public class DispatchingTest extends BaseTest {
+ @Test
public void test_crossContextDispatch1() throws Exception {
Servlet servlet1 = new BaseServlet() {
private static final long serialVersionUID = 1L;
@@ -80,6 +81,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals("/a|", response);
}
+ @Test
public void test_forwardDepth1() throws Exception {
Servlet servlet1 = new BaseServlet() {
private static final long serialVersionUID = 1L;
@@ -111,6 +113,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals("/a|/b|u=5|/a/s2/b|/s2|/a|/d|p=1|/a/s1/d|/s1", response);
}
+ @Test
public void test_forwardDepth1_WithRequestFilter() throws Exception {
Servlet servlet1 = new BaseServlet() {
private static final long serialVersionUID = 1L;
@@ -166,6 +169,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertTrue(filter.getCalled());
}
+ @Test
public void test_forwardDepth1_WithRequestAndForwardFilter() throws Exception {
Servlet servlet1 = new BaseServlet() {
private static final long serialVersionUID = 1L;
@@ -221,6 +225,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals(2, filter.getCount());
}
+ @Test
public void test_forwardDepth2() throws Exception {
Servlet servlet1 = new BaseServlet() {
private static final long serialVersionUID = 1L;
@@ -267,6 +272,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals("/c1|/i3|p3=3|/c1/s3/i3|/s3|/c1|/i1|p1=1|/c1/s1/i1|/s1", response);
}
+ @Test
public void test_forwardDepth3() throws Exception {
Servlet servlet1 = new BaseServlet() {
private static final long serialVersionUID = 1L;
@@ -328,6 +334,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals("/c1|/i4|p4=4|/c1/s4/i4|/s4|/c1|/i1|p1=1|/c1/s1/i1|/s1", response);
}
+ @Test
public void test_forwardNamedParameterAggregationAndPrecedence() throws Exception {
Servlet sA = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -385,6 +392,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals("p=1&p=2|null|1|[1, 2]", result);
}
+ @Test
public void test_forwardNamed() throws Exception {
Servlet sA = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -424,6 +432,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals("/c1|/a|p=1&p=2|/c1/s1/a|/s1|null|null|null|null|null", result);
}
+ @Test
public void test_forwardParameterAggregationAndPrecedence() throws Exception {
Servlet sA = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -472,6 +481,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals("p=3&p=4|p=1&p=2|3|[3, 4, 1, 2]", result);
}
+ @Test
public void test_forwardStreamed() throws Exception {
Servlet servlet1 = new BaseServlet() {
private static final long serialVersionUID = 1L;
@@ -503,6 +513,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals("/a|/b|u=5|/a/s2/b|/s2|/a|/d|p=1|/a/s1/d|/s1", response);
}
+ @Test
public void test_forwardStreamed_WithRequestFilter() throws Exception {
Servlet servlet1 = new BaseServlet() {
private static final long serialVersionUID = 1L;
@@ -558,6 +569,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertTrue(filter.getCalled());
}
+ @Test
public void test_forwardStreamed_WithRequestAndForwardFilter() throws Exception {
Servlet servlet1 = new BaseServlet() {
private static final long serialVersionUID = 1L;
@@ -613,6 +625,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals(2, filter.getCount());
}
+ @Test
public void test_includeBasic() throws Exception {
Servlet servlet8 = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -651,6 +664,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals("s8target", requestAdvisor.request("S8"));
}
+ @Test
public void test_includeDepth1() throws Exception {
Servlet servlet1 = new BaseServlet() {
private static final long serialVersionUID = 1L;
@@ -682,6 +696,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals("/a|/d|p=1|/a/s1/d|/s1|/a|/b|u=5|/a/s2/b|/s2", response);
}
+ @Test
public void test_includeDepth1_WithRequestFilter() throws Exception {
Servlet servlet1 = new BaseServlet() {
private static final long serialVersionUID = 1L;
@@ -737,6 +752,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertTrue(filter.getCalled());
}
+ @Test
public void test_includeDepth1_WithRequestAndIncludeFilter() throws Exception {
Servlet servlet1 = new BaseServlet() {
private static final long serialVersionUID = 1L;
@@ -792,6 +808,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals(2, filter.getCount());
}
+ @Test
public void test_includeDepth2() throws Exception {
Servlet servlet1 = new BaseServlet() {
private static final long serialVersionUID = 1L;
@@ -838,6 +855,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals("/c1|/i1|p1=1|/c1/s1/i1|/s1|/c1|/i3|p3=3|/c1/s3/i3|/s3", response);
}
+ @Test
public void test_includeDepth3() throws Exception {
Servlet servlet1 = new BaseServlet() {
private static final long serialVersionUID = 1L;
@@ -899,6 +917,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals("/c1|/i1|p1=1|/c1/s1/i1|/s1|/c1|/i4|p4=4|/c1/s4/i4|/s4", response);
}
+ @Test
public void test_includeNamedParameterAggregationAndPrecedence() throws Exception {
Servlet sA = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -956,6 +975,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals("p=1&p=2|null|1|[1, 2]", result);
}
+ @Test
public void test_includeNamed() throws Exception {
Servlet sA = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -995,6 +1015,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals("/c1|/a|p=1&p=2|/c1/s1/a|/s1|null|null|null|null|null", result);
}
+ @Test
public void test_includeParameterAggregationAndPrecedence() throws Exception {
Servlet sA = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -1043,6 +1064,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals("p=1&p=2|p=3&p=4|3|[3, 4, 1, 2]", result);
}
+ @Test
public void test_includeStreamed() throws Exception {
Servlet servlet1 = new BaseServlet() {
private static final long serialVersionUID = 1L;
@@ -1074,6 +1096,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals("/a|/d|p=1|/a/s1/d|/s1|/a|/b|u=5|/a/s2/b|/s2", response);
}
+ @Test
public void test_includeStreamed_WithRequestFilter() throws Exception {
Servlet servlet1 = new BaseServlet() {
private static final long serialVersionUID = 1L;
@@ -1129,6 +1152,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertTrue(filter.getCalled());
}
+ @Test
public void test_includeStreamed_WithRequestAndIncludeFilter() throws Exception {
Servlet servlet1 = new BaseServlet() {
private static final long serialVersionUID = 1L;
@@ -1184,6 +1208,7 @@ public class DispatchingTest extends BaseTest {
Assert.assertEquals(2, filter.getCount());
}
+ @Test
public void test_Bug479115() throws Exception {
Servlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java
index c3e91d81..09913040 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java
@@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.equinox.http.servlet.tests;
+import static org.junit.Assert.*;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -86,7 +88,9 @@ import org.eclipse.equinox.http.servlet.tests.util.BaseServletRequestAttributeLi
import org.eclipse.equinox.http.servlet.tests.util.BaseServletRequestListener;
import org.eclipse.equinox.http.servlet.tests.util.BufferedServlet;
import org.junit.Assert;
-
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
@@ -105,7 +109,11 @@ import org.osgi.service.http.runtime.dto.ServletDTO;
import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
public class ServletTest extends BaseTest {
-
+ @Rule
+ public TestName testName = new TestName();
+
+
+ @Test
public void test_ErrorPage1() throws Exception {
String expected = "403 ERROR :";
String actual = null;
@@ -126,6 +134,7 @@ public class ServletTest extends BaseTest {
"Expected <" + expected + "*> but got <" + actual + ">", actual.startsWith(expected));
}
+ @Test
public void test_ErrorPage2() throws Exception {
String expected = "org.eclipse.equinox.http.servlet.tests.tb1.TestErrorPage2$MyException ERROR :";
String actual = null;
@@ -146,6 +155,7 @@ public class ServletTest extends BaseTest {
"Expected <" + expected + "*> but got <" + actual + ">", actual.startsWith(expected));
}
+ @Test
public void test_ErrorPage3() throws Exception {
String expected = "400 ERROR :";
String actual = null;
@@ -170,6 +180,7 @@ public class ServletTest extends BaseTest {
* This case should NOT hit the error servlet because the response is already
* committed. However, setting the response code is perfectly allowed.
*/
+ @Test
public void test_ErrorPage4() throws Exception {
String actual = null;
Map<String, List<String>> response = Collections.emptyMap();
@@ -188,6 +199,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals("", actual);
}
+ @Test
public void test_ErrorPage5() throws Exception {
Dictionary<String, Object> errorProps = new Hashtable<String, Object>();
errorProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "E5.4xx");
@@ -213,6 +225,7 @@ public class ServletTest extends BaseTest {
* This test should also not hit the error servlet as we've only set the
* status. As per the Servlet spec this should not trigger error handling.
*/
+ @Test
public void test_ErrorPage6() throws Exception {
Servlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -250,6 +263,7 @@ public class ServletTest extends BaseTest {
* This test should also not hit the error servlet as we've only set the
* status. As per the Servlet spec this should not trigger error handling.
*/
+ @Test
public void test_ErrorPage7() throws Exception {
final int status = 422;
@@ -293,6 +307,7 @@ public class ServletTest extends BaseTest {
Assert.assertNotEquals(status + " : " + status + " : ERROR : /TestErrorPage7/a", responseBody);
}
+ @Test
public void test_ErrorPage8() throws Exception {
Servlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -324,6 +339,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals("500 : 500 : ERROR : /TestErrorPage8/a", responseBody);
}
+ @Test
public void test_ErrorPage9() throws Exception {
Servlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -355,6 +371,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals("500 : 500 : ERROR : /TestErrorPage9/a", responseBody);
}
+ @Test
public void test_ErrorPage10() throws Exception {
Servlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -388,6 +405,7 @@ public class ServletTest extends BaseTest {
Assert.fail("Expecting java.io.IOException: Premature EOF");
}
+ @Test
public void test_ErrorPage11() throws Exception {
Servlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -415,6 +433,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Filter1() throws Exception {
String expected = "bab";
String actual;
@@ -428,6 +447,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter2() throws Exception {
String expected = "cbabc";
String actual;
@@ -441,6 +461,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter3() throws Exception {
String expected = "cbdadbc";
String actual;
@@ -454,6 +475,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter4() throws Exception {
String expected = "dcbabcd";
String actual;
@@ -467,6 +489,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter5() throws Exception {
String expected = "bab";
String actual;
@@ -480,6 +503,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter6() throws Exception {
String expected = "cbabc";
String actual;
@@ -493,6 +517,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter7() throws Exception {
String expected = "cbdadbc";
String actual;
@@ -506,6 +531,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter8() throws Exception {
String expected = "dcbabcd";
String actual;
@@ -519,6 +545,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter9() throws Exception {
String expected = "bab";
String actual;
@@ -532,6 +559,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter10() throws Exception {
String expected = "cbabc";
String actual;
@@ -545,6 +573,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter11() throws Exception {
String expected = "cbdadbc";
String actual;
@@ -558,6 +587,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter12() throws Exception {
String expected = "dcbabcd";
String actual;
@@ -571,6 +601,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter13() throws Exception {
String expected = "bab";
String actual;
@@ -584,6 +615,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter14() throws Exception {
String expected = "cbabc";
String actual;
@@ -597,6 +629,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter15() throws Exception {
String expected = "cbdadbc";
String actual;
@@ -610,6 +643,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter16() throws Exception {
String expected = "dcbabcd";
String actual;
@@ -623,6 +657,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter17() throws Exception {
String expected = "ebcdadcbe";
String actual;
@@ -636,6 +671,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter18() throws Exception {
String expected = "dbcacbd";
String actual;
@@ -649,6 +685,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter19() throws Exception {
String expected = "dfbcacbfd";
String actual;
@@ -662,6 +699,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Filter20() throws Exception {
// Make sure legacy filter registrations match against all controllers that are for legacy HttpContext
// Make sure legacy filter registrations match as if they are prefix matching with wildcards
@@ -687,6 +725,7 @@ public class ServletTest extends BaseTest {
Assert.assertTrue("testFilter2 did not get called.", testFilter2.getCalled());
}
+ @Test
public void test_Filter21() throws Exception {
// Make sure exact path matching is honored by filters registrations
String expected = "a";
@@ -793,42 +832,52 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, response);
}
+ @Test
public void test_Filter22a() throws Exception {
basicFilterTest22 ( "/f22/*", "*.jsp", "/f22/*", "a", new String[] {"REQUEST"} );
}
+ @Test
public void test_Filter22b() throws Exception {
basicFilterTest22 ( "/*", "*.jsp", "/*", "a", new String[] {"REQUEST"} );
}
+ @Test
public void test_Filter22c() throws Exception {
basicFilterTest22 ( "/f22/*", "*.jsp", "*.jsp", "a", new String[] {"REQUEST"} );
}
+ @Test
public void test_Filter22d() throws Exception {
basicFilterTest22 ( "/f22/*", "*.jsp", "/f22/*", "bab", new String[] {"FORWARD"} );
}
+ @Test
public void test_Filter22e() throws Exception {
basicFilterTest22 ( "/*", "*.jsp", "/*", "bab", new String[] {"FORWARD"} );
}
+ @Test
public void test_Filter22f() throws Exception {
basicFilterTest22 ( "/f22/*", "*.jsp", "*.jsp", "bab", new String[] {"FORWARD"} );
}
+ @Test
public void test_Filter22g() throws Exception {
basicFilterTest22 ( "/f22/*", "*.jsp", "/f22/*", "bab", new String[] {"REQUEST", "FORWARD"} );
}
+ @Test
public void test_Filter22h() throws Exception {
basicFilterTest22 ( "/*", "*.jsp", "/*", "bab", new String[] {"REQUEST", "FORWARD"} );
}
+ @Test
public void test_Filter22i() throws Exception {
basicFilterTest22 ( "/f22/*", "*.jsp", "*.jsp", "bab", new String[] {"REQUEST", "FORWARD"} );
}
+ @Test
public void test_Filter23a() throws Exception {
// Make sure legacy filter registrations match as if they are prefix matching with extension matching
String expected = "a";
@@ -858,6 +907,7 @@ public class ServletTest extends BaseTest {
Assert.assertTrue("testFilter3 did not get called.", testFilter3.getCalled());
}
+ @Test
public void test_Filter23b() throws Exception {
// Make sure legacy filter registrations match as if they are prefix matching wildcard, but make sure the prefix is checked
String expected = "a";
@@ -880,6 +930,7 @@ public class ServletTest extends BaseTest {
Assert.assertTrue("testFilter2 did not get called.", testFilter2.getCalled());
}
+ @Test
public void test_Filter23c() throws Exception {
// Test WB servlet with default servlet pattern "/" and filter matching against it.
String expected = "a";
@@ -902,6 +953,7 @@ public class ServletTest extends BaseTest {
Assert.assertTrue("testFilter2 did not get called.", testFilter2.getCalled());
}
+ @Test
public void test_Filter24() throws Exception {
// Test WB servlet and WB testfilter matching against it.
// Test filter gets called.
@@ -933,7 +985,7 @@ public class ServletTest extends BaseTest {
}
}
-
+ @Test
public void test_Registration1() throws Exception {
String expected = "Alias cannot be null";
try {
@@ -951,6 +1003,7 @@ public class ServletTest extends BaseTest {
Assert.fail();
}
+ @Test
public void test_Registration2() throws Exception {
String pattern = "blah";
String expected = "Invalid pattern '" + pattern + "'";
@@ -969,6 +1022,7 @@ public class ServletTest extends BaseTest {
Assert.fail();
}
+ @Test
public void test_Registration3() throws Exception {
String pattern = "/blah/";
String expected = "Invalid pattern '" + pattern + "'";
@@ -987,6 +1041,7 @@ public class ServletTest extends BaseTest {
Assert.fail();
}
+ @Test
public void test_Registration4() throws Exception {
String pattern = "/blah";
String expected = "Pattern already in use: " + pattern;
@@ -1007,6 +1062,7 @@ public class ServletTest extends BaseTest {
Assert.fail();
}
+ @Test
public void test_Registration5() throws Exception {
String alias = "/blah";
String expected = "Servlet cannot be null";
@@ -1025,6 +1081,7 @@ public class ServletTest extends BaseTest {
Assert.fail();
}
+ @Test
public void test_Registration6() throws Exception {
String expected = "Servlet has already been registered:";
try {
@@ -1044,6 +1101,7 @@ public class ServletTest extends BaseTest {
Assert.fail();
}
+ @Test
public void test_unregister() throws Exception {
ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService();
@@ -1059,6 +1117,7 @@ public class ServletTest extends BaseTest {
extendedHttpService.unregister("/r1");
}
+ @Test
public void test_Registration11() throws Exception {
ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService();
@@ -1088,6 +1147,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Registration12() throws Exception {
Bundle bundle = installBundle(TEST_BUNDLE_1);
try {
@@ -1111,6 +1171,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Registration13() throws Exception {
ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService();
@@ -1137,6 +1198,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Registration14() throws Exception {
Servlet initError = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -1157,6 +1219,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Registration15() throws Exception {
Servlet initError = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -1177,6 +1240,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Registration16() throws Exception {
Filter initError = new Filter() {
@@ -1206,6 +1270,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Registration17() throws Exception {
Filter initError = new Filter() {
@@ -1235,6 +1300,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Registration18_WhiteboardServletByNameOnly() throws Exception {
String expected = "a";
final String servletName = "hello_servlet";
@@ -1263,6 +1329,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_RegistrationTCCL1() {
final Set<String> filterTCCL = Collections.synchronizedSet(new HashSet<String>());
final Set<String> servletTCCL = Collections.synchronizedSet(new HashSet<String>());
@@ -1340,6 +1407,7 @@ public class ServletTest extends BaseTest {
}
+ @Test
public void test_Sessions01() {
final AtomicBoolean valueBound = new AtomicBoolean(false);
final AtomicBoolean valueUnbound = new AtomicBoolean(false);
@@ -1445,6 +1513,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Sessions02() {
final AtomicReference<HttpSession> sessionReference = new AtomicReference<HttpSession>();
@@ -1506,6 +1575,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Resource1() throws Exception {
String expected = "a";
String actual;
@@ -1519,6 +1589,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Resource2() throws Exception {
String expected = "cbdadbc";
String actual;
@@ -1532,6 +1603,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Resource3() throws Exception {
String expected = "a";
String actual;
@@ -1545,6 +1617,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Resource4() throws Exception {
String expected = "dcbabcd";
String actual;
@@ -1558,6 +1631,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Resource5() throws Exception {
String expected = "dcbabcd";
String actual;
@@ -1571,6 +1645,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Runtime() throws Exception {
Bundle bundle = installBundle(TEST_BUNDLE_1);
try {
@@ -1593,6 +1668,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Servlet1() throws Exception {
String expected = STATUS_OK;
String actual;
@@ -1606,6 +1682,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Servlet2() throws Exception {
String expected = "3";
String actual;
@@ -1620,6 +1697,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Servlet3() throws Exception {
String expected = STATUS_OK;
String actual;
@@ -1633,6 +1711,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Servlet4() throws Exception {
String expected = System.getProperty(JETTY_PROPERTY_PREFIX + "context.path", "");
String actual;
@@ -1646,6 +1725,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Servlet5() throws Exception {
String expected = "Equinox Jetty-based Http Service";
String actual;
@@ -1659,6 +1739,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Servlet6() throws Exception {
String expected = "a";
String actual;
@@ -1672,6 +1753,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Servlet7() throws Exception {
String expected = "a";
String actual;
@@ -1685,6 +1767,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Servlet9() throws Exception {
String expected = "Equinox Jetty-based Http Service";
String actual;
@@ -1698,6 +1781,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Servlet10() throws Exception {
String expected = "a";
String actual;
@@ -1711,6 +1795,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Servlet11() throws Exception {
String expected = "a";
String actual;
@@ -1724,6 +1809,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_Servlet12() throws Exception {
Servlet sA = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -1759,6 +1845,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals("b", requestAdvisor.request("files/help.txt"));
}
+ @Test
public void test_Servlet13() throws Exception {
Servlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -1787,6 +1874,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals("p=1&p=2|1|[1, 2]", result);
}
+ @Test
public void test_ServletExactMatchPrecidence() throws Exception {
Servlet sA = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -1835,6 +1923,7 @@ public class ServletTest extends BaseTest {
/*
* 3.1 file uploads
*/
+ @Test
public void test_Servlet16() throws Exception {
Servlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -1878,6 +1967,7 @@ public class ServletTest extends BaseTest {
/*
* 3.0 file uploads
*/
+ @Test
public void test_Servlet17() throws Exception {
Servlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -1918,6 +2008,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals("blue.png|image/png|292", result.get("responseBody").get(0));
}
+ @Test
public void test_commonsFileUpload() throws Exception {
Servlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -1978,6 +2069,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals("blue.png|image/png|292", result.get("responseBody").get(0));
}
+ @Test
public void test_ServletContext1() throws Exception {
String expected = "/org/eclipse/equinox/http/servlet/tests/tb1/resource1.txt";
String actual;
@@ -1992,6 +2084,7 @@ public class ServletTest extends BaseTest {
}
+ @Test
public void test_ServletContext1_2() throws Exception {
String expected = "/org/eclipse/equinox/http/servlet/tests/tb1/resource1.txt";
String actual;
@@ -2012,6 +2105,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_ServletContext2() throws Exception {
Servlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -2038,6 +2132,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals("200", responseCode);
}
+ @Test
public void testServletContextUnsupportedOperations() {
final AtomicReference<ServletContext> contextHolder = new AtomicReference<ServletContext>();
Servlet unsupportedServlet = new HttpServlet() {
@@ -2096,6 +2191,7 @@ public class ServletTest extends BaseTest {
return methods;
}
+ @Test
public void test_ServletContextHelper1() throws Exception {
BundleContext bundleContext = getBundleContext();
Bundle bundle = bundleContext.getBundle();
@@ -2142,6 +2238,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(0, runtimeDTO.failedServletContextDTOs.length);
}
+ @Test
public void test_ServletContextHelper7() throws Exception {
String expected = "a";
@@ -2175,6 +2272,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_ServletContextHelper8() throws Exception {
String expected = "b";
@@ -2207,6 +2305,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_ServletContextHelper9() throws Exception {
String expected1 = "c";
String expected2 = "d";
@@ -2251,6 +2350,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_ServletContextHelperVisibility() throws Exception {
String expected1 = "c";
@@ -2298,6 +2398,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_ServletContextHelper10() throws Exception {
String expected = "cac";
String actual;
@@ -2313,6 +2414,7 @@ public class ServletTest extends BaseTest {
private static final String HTTP_CONTEXT_TEST_ROOT = "http.context.test";
+ @Test
public void test_ServletContextHelper11() throws Exception {
BaseHttpContext ctx1 = new BaseHttpContext(true, HTTP_CONTEXT_TEST_ROOT + "/1", getBundleContext().getBundle());
BaseHttpContext ctx2 = new BaseHttpContext(true, HTTP_CONTEXT_TEST_ROOT + "/2", getBundleContext().getBundle());
@@ -2335,6 +2437,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_ServletContextHelper12() throws Exception {
String expected1 = "a,b,1";
@@ -2385,6 +2488,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_ServletContextHelper13() throws Exception {
BundleContext bundleContext = getBundleContext();
Bundle bundle = bundleContext.getBundle();
@@ -2394,7 +2498,7 @@ public class ServletTest extends BaseTest {
@Override
public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) throws IOException {
- request.setAttribute(getName(), Boolean.TRUE);
+ request.setAttribute(testName.getMethodName(), Boolean.TRUE);
return super.handleSecurity(request, response);
}
@@ -2408,8 +2512,8 @@ public class ServletTest extends BaseTest {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
- if (request.getAttribute(getName()) == Boolean.TRUE) {
- request.setAttribute(getName() + ".fromFilter", Boolean.TRUE);
+ if (request.getAttribute(testName.getMethodName()) == Boolean.TRUE) {
+ request.setAttribute(testName.getMethodName() + ".fromFilter", Boolean.TRUE);
}
chain.doFilter(request, response);
}
@@ -2423,7 +2527,7 @@ public class ServletTest extends BaseTest {
private static final long serialVersionUID = 1L;
@Override
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
- res.getWriter().print(req.getAttribute(getName() + ".fromFilter"));
+ res.getWriter().print(req.getAttribute(testName.getMethodName() + ".fromFilter"));
}
};
@@ -2457,6 +2561,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Listener1() throws Exception {
BaseServletContextListener scl1 =
new BaseServletContextListener();
@@ -2471,6 +2576,7 @@ public class ServletTest extends BaseTest {
Assert.assertTrue(scl1.destroyed.get());
}
+ @Test
public void test_Listener2() throws Exception {
BundleContext bundleContext = getBundleContext();
Bundle bundle = bundleContext.getBundle();
@@ -2501,6 +2607,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Listener3() throws Exception {
BundleContext bundleContext = getBundleContext();
Bundle bundle = bundleContext.getBundle();
@@ -2529,6 +2636,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Listener4() throws Exception {
BaseServletContextAttributeListener scal1 =
@@ -2572,6 +2680,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Listener5() throws Exception {
BaseServletRequestListener srl1 = new BaseServletRequestListener();
@@ -2601,6 +2710,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Listener6() throws Exception {
BaseServletRequestAttributeListener sral1 = new BaseServletRequestAttributeListener();
@@ -2631,6 +2741,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Listener7() throws Exception {
BaseHttpSessionAttributeListener hsal1 =
@@ -2692,6 +2803,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Listener8() throws Exception {
BaseHttpSessionIdListener hsil1 = new BaseHttpSessionIdListener();
@@ -2719,6 +2831,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Listener9() throws Exception {
Servlet sA = new HttpServlet() {
private static final long serialVersionUID = 1L;
@@ -2776,6 +2889,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_Listener10() throws Exception {
BaseServletContextListener scl1 = new BaseServletContextListener();
BaseServletContextListener scl2 = new BaseServletContextListener();
@@ -2825,6 +2939,7 @@ public class ServletTest extends BaseTest {
Assert.assertNotEquals(servletContext2.hashCode(), servletContext3.hashCode());
}
+ @Test
public void test_Async1() throws Exception {
Servlet s1 = new BaseAsyncServlet("test_Listener8");
@@ -2847,6 +2962,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void test_WBServlet1() throws Exception {
String expected = "a";
String actual;
@@ -2860,6 +2976,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_WBServlet2() throws Exception {
String expected = "bab";
String actual;
@@ -2873,6 +2990,7 @@ public class ServletTest extends BaseTest {
Assert.assertEquals(expected, actual);
}
+ @Test
public void test_BufferedOutput() throws Exception {
Collection<ServiceRegistration<?>> registrations = new ArrayList<ServiceRegistration<?>>();
try {
@@ -2894,114 +3012,118 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void testWBServletChangeInitParams() throws Exception{
String actual;
Map<String, String> params = new HashMap<String, String>();
- params.put(TEST_PROTOTYPE_NAME, getName());
- params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + getName());
- params.put(STATUS_PARAM, getName());
+ params.put(TEST_PROTOTYPE_NAME, testName.getMethodName());
+ params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + testName.getMethodName());
+ params.put(STATUS_PARAM, testName.getMethodName());
actual = doRequest(CONFIGURE, params);
- Assert.assertEquals(getName(), actual);
- actual = requestAdvisor.request(getName());
- Assert.assertEquals(getName(), actual);
+ Assert.assertEquals(testName.getMethodName(), actual);
+ actual = requestAdvisor.request(testName.getMethodName());
+ Assert.assertEquals(testName.getMethodName(), actual);
// change the init param
params.put(STATUS_PARAM, "changed");
doRequest(CONFIGURE, params);
- actual = requestAdvisor.request(getName());
+ actual = requestAdvisor.request(testName.getMethodName());
Assert.assertEquals("changed", actual);
}
+ @Test
public void testWBServletChangePattern() throws Exception{
String actual;
Map<String, String> params = new HashMap<String, String>();
- params.put(TEST_PROTOTYPE_NAME, getName());
- params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + getName());
- params.put(STATUS_PARAM, getName());
+ params.put(TEST_PROTOTYPE_NAME, testName.getMethodName());
+ params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + testName.getMethodName());
+ params.put(STATUS_PARAM, testName.getMethodName());
actual = doRequest(CONFIGURE, params);
- Assert.assertEquals(getName(), actual);
- actual = requestAdvisor.request(getName());
- Assert.assertEquals(getName(), actual);
+ Assert.assertEquals(testName.getMethodName(), actual);
+ actual = requestAdvisor.request(testName.getMethodName());
+ Assert.assertEquals(testName.getMethodName(), actual);
// change the pattern
params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/changed");
doRequest(CONFIGURE, params);
actual = requestAdvisor.request("changed");
- Assert.assertEquals(getName(), actual);
+ Assert.assertEquals(testName.getMethodName(), actual);
}
+ @Test
public void testWBServletChangeRanking() throws Exception{
String actual;
// Configure two servlets with the second one registered ranking higher
Map<String, String> params1 = new HashMap<String, String>();
- params1.put(TEST_PROTOTYPE_NAME, getName() + 1);
+ params1.put(TEST_PROTOTYPE_NAME, testName.getMethodName() + 1);
params1.put(Constants.SERVICE_RANKING, "1");
- params1.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + getName());
- params1.put(STATUS_PARAM, getName() + 1);
+ params1.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + testName.getMethodName());
+ params1.put(STATUS_PARAM, testName.getMethodName() + 1);
actual = doRequest(CONFIGURE, params1);
- Assert.assertEquals(getName() + 1, actual);
+ Assert.assertEquals(testName.getMethodName() + 1, actual);
Map<String, String> params2 = new HashMap<String, String>();
- params2.put(TEST_PROTOTYPE_NAME, getName() + 2);
+ params2.put(TEST_PROTOTYPE_NAME, testName.getMethodName() + 2);
params2.put(Constants.SERVICE_RANKING, "2");
- params2.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + getName());
- params2.put(STATUS_PARAM, getName() + 2);
+ params2.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + testName.getMethodName());
+ params2.put(STATUS_PARAM, testName.getMethodName() + 2);
actual = doRequest(CONFIGURE, params2);
- Assert.assertEquals(getName() + 2, actual);
+ Assert.assertEquals(testName.getMethodName() + 2, actual);
// Confirm the second registered (higher ranked) gets used
- actual = requestAdvisor.request(getName());
- Assert.assertEquals(getName() + 2, actual);
+ actual = requestAdvisor.request(testName.getMethodName());
+ Assert.assertEquals(testName.getMethodName() + 2, actual);
// change the ranking to use the first servlet registered
params2.put(Constants.SERVICE_RANKING, "0");
doRequest(CONFIGURE, params2);
- actual = requestAdvisor.request(getName());
- Assert.assertEquals(getName() + 1, actual);
+ actual = requestAdvisor.request(testName.getMethodName());
+ Assert.assertEquals(testName.getMethodName() + 1, actual);
// Unregister the first servlet should cause the second servlet to be used
- actual = doRequest(UNREGISTER, Collections.singletonMap(TEST_PROTOTYPE_NAME, getName() + 1));
- Assert.assertEquals(getName() + 1, actual);
+ actual = doRequest(UNREGISTER, Collections.singletonMap(TEST_PROTOTYPE_NAME, testName.getMethodName() + 1));
+ Assert.assertEquals(testName.getMethodName() + 1, actual);
// Confirm the second registered is used
- actual = requestAdvisor.request(getName());
- Assert.assertEquals(getName() + 2, actual);
+ actual = requestAdvisor.request(testName.getMethodName());
+ Assert.assertEquals(testName.getMethodName() + 2, actual);
}
+ @Test
public void testWBServletDefaultContextAdaptor1() throws Exception{
Dictionary<String, String> helperProps = new Hashtable<String, String>();
- helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "testContext" + getName());
+ helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "testContext" + testName.getMethodName());
helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/testContext");
- helperProps.put(TEST_PATH_CUSTOMIZER_NAME, getName());
+ helperProps.put(TEST_PATH_CUSTOMIZER_NAME, testName.getMethodName());
ServiceRegistration<ServletContextHelper> helperReg = getBundleContext().registerService(ServletContextHelper.class, new TestServletContextHelperFactory(), helperProps);
ServiceRegistration<ContextPathCustomizer> pathAdaptorReg = null;
try {
Map<String, String> params = new HashMap<String, String>();
- params.put(TEST_PROTOTYPE_NAME, getName());
- params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + getName());
- params.put(STATUS_PARAM, getName());
- params.put("servlet.init." + TEST_PATH_CUSTOMIZER_NAME, getName());
+ params.put(TEST_PROTOTYPE_NAME, testName.getMethodName());
+ params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + testName.getMethodName());
+ params.put(STATUS_PARAM, testName.getMethodName());
+ params.put("servlet.init." + TEST_PATH_CUSTOMIZER_NAME, testName.getMethodName());
String actual = doRequest(CONFIGURE, params);
- Assert.assertEquals(getName(), actual);
+ Assert.assertEquals(testName.getMethodName(), actual);
- actual = requestAdvisor.request(getName());
- Assert.assertEquals(getName(), actual);
+ actual = requestAdvisor.request(testName.getMethodName());
+ Assert.assertEquals(testName.getMethodName(), actual);
- ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor("(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + "testContext" + getName() + ")", null, getName());
+ ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor("(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + "testContext" + testName.getMethodName() + ")", null, testName.getMethodName());
pathAdaptorReg = getBundleContext().registerService(ContextPathCustomizer.class, pathAdaptor, null);
- actual = requestAdvisor.request("testContext/" + getName());
- Assert.assertEquals(getName(), actual);
+ actual = requestAdvisor.request("testContext/" + testName.getMethodName());
+ Assert.assertEquals(testName.getMethodName(), actual);
pathAdaptorReg.unregister();
pathAdaptorReg = null;
- actual = requestAdvisor.request(getName());
- Assert.assertEquals(getName(), actual);
+ actual = requestAdvisor.request(testName.getMethodName());
+ Assert.assertEquals(testName.getMethodName(), actual);
} finally {
helperReg.unregister();
if (pathAdaptorReg != null) {
@@ -3010,38 +3132,39 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void testWBServletDefaultContextAdaptor2() throws Exception{
Dictionary<String, String> helperProps = new Hashtable<String, String>();
- helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "testContext" + getName());
+ helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "testContext" + testName.getMethodName());
helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/testContext");
- helperProps.put(TEST_PATH_CUSTOMIZER_NAME, getName());
+ helperProps.put(TEST_PATH_CUSTOMIZER_NAME, testName.getMethodName());
ServiceRegistration<ServletContextHelper> helperReg = getBundleContext().registerService(ServletContextHelper.class, new TestServletContextHelperFactory(), helperProps);
ServiceRegistration<ContextPathCustomizer> pathAdaptorReg = null;
try {
Map<String, String> params = new HashMap<String, String>();
- params.put(TEST_PROTOTYPE_NAME, getName());
- params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + getName());
- params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + "testContext" + getName() + ")");
- params.put(STATUS_PARAM, getName());
- params.put("servlet.init." + TEST_PATH_CUSTOMIZER_NAME, getName());
+ params.put(TEST_PROTOTYPE_NAME, testName.getMethodName());
+ params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + testName.getMethodName());
+ params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + "testContext" + testName.getMethodName() + ")");
+ params.put(STATUS_PARAM, testName.getMethodName());
+ params.put("servlet.init." + TEST_PATH_CUSTOMIZER_NAME, testName.getMethodName());
String actual = doRequest(CONFIGURE, params);
- Assert.assertEquals(getName(), actual);
+ Assert.assertEquals(testName.getMethodName(), actual);
- actual = requestAdvisor.request("testContext/" + getName());
- Assert.assertEquals(getName(), actual);
+ actual = requestAdvisor.request("testContext/" + testName.getMethodName());
+ Assert.assertEquals(testName.getMethodName(), actual);
- ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor(null, "testPrefix", getName());
+ ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor(null, "testPrefix", testName.getMethodName());
pathAdaptorReg = getBundleContext().registerService(ContextPathCustomizer.class, pathAdaptor, null);
- actual = requestAdvisor.request("testPrefix/testContext/" + getName());
- Assert.assertEquals(getName(), actual);
+ actual = requestAdvisor.request("testPrefix/testContext/" + testName.getMethodName());
+ Assert.assertEquals(testName.getMethodName(), actual);
pathAdaptorReg.unregister();
pathAdaptorReg = null;
- actual = requestAdvisor.request("testContext/" + getName());
- Assert.assertEquals(getName(), actual);
+ actual = requestAdvisor.request("testContext/" + testName.getMethodName());
+ Assert.assertEquals(testName.getMethodName(), actual);
} finally {
helperReg.unregister();
if (pathAdaptorReg != null) {
@@ -3050,39 +3173,40 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void testWBServletDefaultContextAdaptor3() throws Exception{
// test the ContextPathCustomizer with a ServletContextHelper that has a '/' context path
Dictionary<String, String> helperProps = new Hashtable<String, String>();
- helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "testContext" + getName());
+ helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "testContext" + testName.getMethodName());
helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/");
- helperProps.put(TEST_PATH_CUSTOMIZER_NAME, getName());
+ helperProps.put(TEST_PATH_CUSTOMIZER_NAME, testName.getMethodName());
ServiceRegistration<ServletContextHelper> helperReg = getBundleContext().registerService(ServletContextHelper.class, new TestServletContextHelperFactory(), helperProps);
ServiceRegistration<ContextPathCustomizer> pathAdaptorReg = null;
try {
Map<String, String> params = new HashMap<String, String>();
- params.put(TEST_PROTOTYPE_NAME, getName());
- params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + getName());
- params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + "testContext" + getName() + ")");
- params.put(STATUS_PARAM, getName());
- params.put("servlet.init." + TEST_PATH_CUSTOMIZER_NAME, getName());
+ params.put(TEST_PROTOTYPE_NAME, testName.getMethodName());
+ params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + testName.getMethodName());
+ params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + "testContext" + testName.getMethodName() + ")");
+ params.put(STATUS_PARAM, testName.getMethodName());
+ params.put("servlet.init." + TEST_PATH_CUSTOMIZER_NAME, testName.getMethodName());
String actual = doRequest(CONFIGURE, params);
- Assert.assertEquals(getName(), actual);
+ Assert.assertEquals(testName.getMethodName(), actual);
- actual = requestAdvisor.request(getName());
- Assert.assertEquals(getName(), actual);
+ actual = requestAdvisor.request(testName.getMethodName());
+ Assert.assertEquals(testName.getMethodName(), actual);
- ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor(null, "testPrefix", getName());
+ ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor(null, "testPrefix", testName.getMethodName());
pathAdaptorReg = getBundleContext().registerService(ContextPathCustomizer.class, pathAdaptor, null);
- actual = requestAdvisor.request("testPrefix/" + getName());
- Assert.assertEquals(getName(), actual);
+ actual = requestAdvisor.request("testPrefix/" + testName.getMethodName());
+ Assert.assertEquals(testName.getMethodName(), actual);
pathAdaptorReg.unregister();
pathAdaptorReg = null;
- actual = requestAdvisor.request(getName());
- Assert.assertEquals(getName(), actual);
+ actual = requestAdvisor.request(testName.getMethodName());
+ Assert.assertEquals(testName.getMethodName(), actual);
} finally {
helperReg.unregister();
if (pathAdaptorReg != null) {
@@ -3091,6 +3215,7 @@ public class ServletTest extends BaseTest {
}
}
+ @Test
public void testHttpContextSetUser() throws ServletException, NamespaceException, IOException {
ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService();
@@ -3125,10 +3250,10 @@ public class ServletTest extends BaseTest {
}
};
- extendedHttpService.registerServlet("/" + getName(), testServlet, null, testContext);
+ extendedHttpService.registerServlet("/" + testName.getMethodName(), testServlet, null, testContext);
String expected = "USER: TEST AUTH_TYPE: Basic";
- String actual = requestAdvisor.request(getName());
+ String actual = requestAdvisor.request(testName.getMethodName());
Assert.assertEquals(expected, actual);
}

Back to the top