Bug 460720 - test
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 9dd2544..3f30d3e 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
@@ -51,6 +51,7 @@
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;
import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionIdListener;
import javax.servlet.http.HttpSessionListener;
import junit.framework.TestCase;
@@ -61,8 +62,10 @@
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.BaseAsyncServlet;
+import org.eclipse.equinox.http.servlet.tests.util.BaseChangeSessionIdServlet;
import org.eclipse.equinox.http.servlet.tests.util.BaseHttpContext;
import org.eclipse.equinox.http.servlet.tests.util.BaseHttpSessionAttributeListener;
+import org.eclipse.equinox.http.servlet.tests.util.BaseHttpSessionIdListener;
import org.eclipse.equinox.http.servlet.tests.util.BaseServlet;
import org.eclipse.equinox.http.servlet.tests.util.BaseServletContextAttributeListener;
import org.eclipse.equinox.http.servlet.tests.util.BaseServletContextListener;
@@ -1673,6 +1676,33 @@
}
}
+ public void test_Listener8() throws Exception {
+ BaseHttpSessionIdListener hsil1 = new BaseHttpSessionIdListener();
+
+ Servlet s1 = new BaseChangeSessionIdServlet("test_Listener8");
+
+ Collection<ServiceRegistration<?>> registrations = new ArrayList<ServiceRegistration<?>>();
+ try {
+ Dictionary<String, String> listenerProps = new Hashtable<String, String>();
+ listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true");
+ registrations.add(getBundleContext().registerService(HttpSessionIdListener.class, hsil1, listenerProps));
+
+ Dictionary<String, String> servletProps1 = new Hashtable<String, String>();
+ servletProps1.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "S8");
+ servletProps1.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s");
+ registrations.add(getBundleContext().registerService(Servlet.class, s1, servletProps1));
+
+ requestAdvisor.request("s");
+
+ Assert.assertTrue(hsil1.changed.get());
+ }
+ finally {
+ for (ServiceRegistration<?> registration : registrations) {
+ registration.unregister();
+ }
+ }
+ }
+
public void test_Async1() throws Exception {
Servlet s1 = new BaseAsyncServlet("test_Listener8");
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseChangeSessionIdServlet.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseChangeSessionIdServlet.java
new file mode 100644
index 0000000..dce79cc
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseChangeSessionIdServlet.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Raymond Augé and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Raymond Augé <raymond.auge@liferay.com> - Bug 460720
+ ******************************************************************************/
+
+package org.eclipse.equinox.http.servlet.tests.util;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+public class BaseChangeSessionIdServlet extends BaseServlet {
+
+ public BaseChangeSessionIdServlet(String content) {
+ super(content);
+ }
+
+ @Override
+ protected void service(
+ HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ request.getSession(true);
+
+ request.changeSessionId();
+
+ response.getWriter().print(content);
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseHttpSessionIdListener.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseHttpSessionIdListener.java
new file mode 100644
index 0000000..ce62039
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseHttpSessionIdListener.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Raymond Augé and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Raymond Augé <raymond.auge@liferay.com> - Bug 460720
+ ******************************************************************************/
+
+package org.eclipse.equinox.http.servlet.tests.util;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionIdListener;
+
+public class BaseHttpSessionIdListener implements HttpSessionIdListener {
+
+ public AtomicBoolean changed = new AtomicBoolean(false);
+
+ @Override
+ public void sessionIdChanged(HttpSessionEvent event, String oldSessionId) {
+ changed.set(true);
+ }
+
+}