FELIX-4060 : Implement HTTP Service Update (RFC-189) - unify request and request attribute listener handling
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1660289 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http/base/src/test/java/org/apache/felix/http/base/internal/context/ServletContextImplTest.java b/http/base/src/test/java/org/apache/felix/http/base/internal/context/ServletContextImplTest.java
index 737e601..0a3cf91 100644
--- a/http/base/src/test/java/org/apache/felix/http/base/internal/context/ServletContextImplTest.java
+++ b/http/base/src/test/java/org/apache/felix/http/base/internal/context/ServletContextImplTest.java
@@ -62,16 +62,19 @@
private Object value;
+ @Override
public void attributeAdded(ServletContextAttributeEvent scab)
{
setData(1, scab);
}
+ @Override
public void attributeRemoved(ServletContextAttributeEvent scab)
{
setData(2, scab);
}
+ @Override
public void attributeReplaced(ServletContextAttributeEvent scab)
{
setData(3, scab);
@@ -125,243 +128,293 @@
private Dictionary attributes = new Hashtable();
+ @Override
public FilterRegistration.Dynamic addFilter(String name, Class<? extends Filter> type)
{
return null;
}
+ @Override
public FilterRegistration.Dynamic addFilter(String name, Filter filter)
{
return null;
}
+ @Override
public FilterRegistration.Dynamic addFilter(String name, String className)
{
return null;
}
+ @Override
public void addListener(Class<? extends EventListener> listener)
{
}
+ @Override
public void addListener(String className)
{
}
+ @Override
public <T extends EventListener> void addListener(T listener)
{
}
+ @Override
public ServletRegistration.Dynamic addServlet(String name, Class<? extends Servlet> type)
{
return null;
}
+ @Override
public ServletRegistration.Dynamic addServlet(String name, Servlet servlet)
{
return null;
}
+ @Override
public ServletRegistration.Dynamic addServlet(String name, String className)
{
return null;
}
+ @Override
public <T extends Filter> T createFilter(Class<T> type) throws ServletException
{
return null;
}
+ @Override
public <T extends EventListener> T createListener(Class<T> type) throws ServletException
{
return null;
}
+ @Override
public <T extends Servlet> T createServlet(Class<T> type) throws ServletException
{
return null;
}
+ @Override
public void declareRoles(String... roleNames)
{
}
+ @Override
public String getVirtualServerName() {
return null;
}
+ @Override
public Object getAttribute(String name)
{
return attributes.get(name);
}
+ @Override
public Enumeration getAttributeNames()
{
return attributes.keys();
}
+ @Override
public ClassLoader getClassLoader()
{
return ServletContextImplTest.class.getClassLoader();
}
+ @Override
public ServletContext getContext(String uripath)
{
return null;
}
+ @Override
public String getContextPath()
{
return null;
}
+ @Override
public Set<SessionTrackingMode> getDefaultSessionTrackingModes()
{
return null;
}
+ @Override
public int getEffectiveMajorVersion()
{
return 0;
}
+ @Override
public int getEffectiveMinorVersion()
{
return 0;
}
+ @Override
public Set<SessionTrackingMode> getEffectiveSessionTrackingModes()
{
return null;
}
+ @Override
public FilterRegistration getFilterRegistration(String name)
{
return null;
}
+ @Override
public Map<String, ? extends FilterRegistration> getFilterRegistrations()
{
return null;
}
+ @Override
public String getInitParameter(String name)
{
return null;
}
+ @Override
public Enumeration getInitParameterNames()
{
return Collections.enumeration(Collections.emptyList());
}
+ @Override
public JspConfigDescriptor getJspConfigDescriptor()
{
return null;
}
+ @Override
public int getMajorVersion()
{
return 0;
}
+ @Override
public String getMimeType(String file)
{
return null;
}
+ @Override
public int getMinorVersion()
{
return 0;
}
+ @Override
public RequestDispatcher getNamedDispatcher(String name)
{
return null;
}
+ @Override
public String getRealPath(String path)
{
return null;
}
+ @Override
public RequestDispatcher getRequestDispatcher(String path)
{
return null;
}
+ @Override
public URL getResource(String path)
{
return null;
}
+ @Override
public InputStream getResourceAsStream(String path)
{
return null;
}
+ @Override
public Set getResourcePaths(String path)
{
return null;
}
+ @Override
public String getServerInfo()
{
return null;
}
+ @Override
public Servlet getServlet(String name)
{
return null;
}
+ @Override
public String getServletContextName()
{
return null;
}
+ @Override
public Enumeration getServletNames()
{
return Collections.enumeration(Collections.emptyList());
}
+ @Override
public ServletRegistration getServletRegistration(String name)
{
return null;
}
+ @Override
public Map<String, ? extends ServletRegistration> getServletRegistrations()
{
return null;
}
+ @Override
public Enumeration getServlets()
{
return Collections.enumeration(Collections.emptyList());
}
+ @Override
public SessionCookieConfig getSessionCookieConfig()
{
return null;
}
+ @Override
public void log(Exception exception, String msg)
{
}
+ @Override
public void log(String msg)
{
}
+ @Override
public void log(String message, Throwable throwable)
{
}
+ @Override
public void removeAttribute(String name)
{
attributes.remove(name);
}
+ @Override
public void setAttribute(String name, Object object)
{
if (object != null)
@@ -374,11 +427,13 @@
}
}
+ @Override
public boolean setInitParameter(String name, String value)
{
return false;
}
+ @Override
public void setSessionTrackingModes(Set<SessionTrackingMode> modes)
{
}
@@ -396,7 +451,8 @@
ServletContext globalContext = new MockServletContext();
this.httpContext = Mockito.mock(HttpContext.class);
this.listener = new AttributeListener();
- this.context = new ServletContextImpl(this.bundle, globalContext, this.httpContext, this.listener, false);
+ this.context = new ServletContextImpl(this.bundle, globalContext, this.httpContext, this.listener, false,
+ null, null, null, null);
}
@Test
@@ -530,8 +586,10 @@
public void testGetSharedAttribute()
{
ServletContext globalContext = new MockServletContext();
- ServletContext ctx1 = new ServletContextImpl(bundle, globalContext, httpContext, listener, true);
- ServletContext ctx2 = new ServletContextImpl(bundle, globalContext, httpContext, listener, true);
+ ServletContext ctx1 = new ServletContextImpl(bundle, globalContext, httpContext, listener, true,
+ null, null, null, null);
+ ServletContext ctx2 = new ServletContextImpl(bundle, globalContext, httpContext, listener, true,
+ null, null, null, null);
Assert.assertNull(ctx1.getAttribute("key1"));
Assert.assertNull(ctx2.getAttribute("key1"));
@@ -639,8 +697,10 @@
public void testGetSharedAttributeNames()
{
ServletContext globalContext = new MockServletContext();
- ServletContext ctx1 = new ServletContextImpl(bundle, globalContext, httpContext, listener, true);
- ServletContext ctx2 = new ServletContextImpl(bundle, globalContext, httpContext, listener, true);
+ ServletContext ctx1 = new ServletContextImpl(bundle, globalContext, httpContext, listener, true,
+ null, null, null, null);
+ ServletContext ctx2 = new ServletContextImpl(bundle, globalContext, httpContext, listener, true,
+ null, null, null, null);
Enumeration e = ctx1.getAttributeNames();
Assert.assertNotNull(e);
@@ -675,8 +735,10 @@
public void testGetUnsharedAttribute()
{
ServletContext globalContext = new MockServletContext();
- ServletContext ctx1 = new ServletContextImpl(bundle, globalContext, httpContext, listener, false);
- ServletContext ctx2 = new ServletContextImpl(bundle, globalContext, httpContext, listener, false);
+ ServletContext ctx1 = new ServletContextImpl(bundle, globalContext, httpContext, listener, false,
+ null, null, null, null);
+ ServletContext ctx2 = new ServletContextImpl(bundle, globalContext, httpContext, listener, false,
+ null, null, null, null);
Assert.assertNull(ctx1.getAttribute("key1"));
Assert.assertNull(ctx2.getAttribute("key1"));
@@ -721,8 +783,10 @@
public void testGetUnsharedAttributeNames()
{
ServletContext globalContext = new MockServletContext();
- ServletContext ctx1 = new ServletContextImpl(bundle, globalContext, httpContext, listener, false);
- ServletContext ctx2 = new ServletContextImpl(bundle, globalContext, httpContext, listener, false);
+ ServletContext ctx1 = new ServletContextImpl(bundle, globalContext, httpContext, listener, false,
+ null, null, null, null);
+ ServletContext ctx2 = new ServletContextImpl(bundle, globalContext, httpContext, listener, false,
+ null, null, null, null);
Enumeration e = ctx1.getAttributeNames();
Assert.assertNotNull(e);
diff --git a/http/base/src/test/java/org/apache/felix/http/base/internal/context/ServletContextManagerTest.java b/http/base/src/test/java/org/apache/felix/http/base/internal/context/ServletContextManagerTest.java
index 16d8bfd..2ea84f5 100644
--- a/http/base/src/test/java/org/apache/felix/http/base/internal/context/ServletContextManagerTest.java
+++ b/http/base/src/test/java/org/apache/felix/http/base/internal/context/ServletContextManagerTest.java
@@ -16,15 +16,15 @@
*/
package org.apache.felix.http.base.internal.context;
+import javax.servlet.ServletContext;
+
import org.apache.felix.http.base.internal.service.ServletContextManager;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import org.junit.Assert;
+import org.mockito.Mockito;
import org.osgi.framework.Bundle;
import org.osgi.service.http.HttpContext;
-import org.mockito.Mockito;
-
-import javax.servlet.ServletContext;
public class ServletContextManagerTest
{
@@ -35,7 +35,8 @@
{
Bundle bundle = Mockito.mock(Bundle.class);
ServletContext globalContext = Mockito.mock(ServletContext.class);
- this.manager = new ServletContextManager(bundle, globalContext, null, false);
+ this.manager = new ServletContextManager(bundle, globalContext, null, false,
+ null, null);
}
@Test