Sophie

Sophie

distrib > Fedora > 20 > x86_64 > by-pkgid > 57b99cd81fe87689326d977e0e316586 > files > 3

owasp-esapi-java-2.1.0-2.fc20.src.rpm

From bbf2f6b3eb63dd615e7d6b266346be292f23a533 Mon Sep 17 00:00:00 2001
From: Marek Goldmann <goldmann@fedoraproject.org>
Date: Wed, 14 Nov 2012 10:06:36 +0100
Subject: [PATCH] Implement missing servlet 3.0 methods in mock

---
 .../owasp/esapi/http/MockHttpServletRequest.java   |  73 ++++++++++-
 .../owasp/esapi/http/MockHttpServletResponse.java  |   8 +-
 .../org/owasp/esapi/http/MockServletContext.java   | 143 +++++++++++++++++++++
 3 files changed, 221 insertions(+), 3 deletions(-)

diff --git a/src/test/java/org/owasp/esapi/http/MockHttpServletRequest.java b/src/test/java/org/owasp/esapi/http/MockHttpServletRequest.java
index 87cb92f..7a6c6dd 100644
--- a/src/test/java/org/owasp/esapi/http/MockHttpServletRequest.java
+++ b/src/test/java/org/owasp/esapi/http/MockHttpServletRequest.java
@@ -24,6 +24,7 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.Enumeration;
@@ -33,11 +34,19 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Vector;
 
+import javax.servlet.AsyncContext;
+import javax.servlet.DispatcherType;
 import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
 import javax.servlet.ServletInputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
+import javax.servlet.http.Part;
 
 /**
  * The Class MockHttpServletRequest.
@@ -434,7 +443,32 @@ public class MockHttpServletRequest implements HttpServletRequest
 		return false;
 	}
 
-	/**
+    @Override
+    public boolean authenticate(HttpServletResponse httpServletResponse) throws IOException, ServletException {
+        return false;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public void login(String s, String s1) throws ServletException {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public void logout() throws ServletException {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public Collection<Part> getParts() throws IOException, IllegalStateException, ServletException {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public Part getPart(String s) throws IOException, IllegalStateException, ServletException {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    /**
 	 * {@inheritDoc}
 	 * @return
 	 */
@@ -536,7 +570,42 @@ public class MockHttpServletRequest implements HttpServletRequest
 		return 80;
 	}
 
-	/**
+    @Override
+    public ServletContext getServletContext() {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public AsyncContext startAsync() {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public boolean isAsyncStarted() {
+        return false;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public boolean isAsyncSupported() {
+        return false;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public AsyncContext getAsyncContext() {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public DispatcherType getDispatcherType() {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    /**
 	 * {@inheritDoc}
 	 * @return
 	 */
diff --git a/src/test/java/org/owasp/esapi/http/MockHttpServletResponse.java b/src/test/java/org/owasp/esapi/http/MockHttpServletResponse.java
index 43b4a7e..dccb653 100644
--- a/src/test/java/org/owasp/esapi/http/MockHttpServletResponse.java
+++ b/src/test/java/org/owasp/esapi/http/MockHttpServletResponse.java
@@ -18,6 +18,7 @@ package org.owasp.esapi.http;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
@@ -151,7 +152,12 @@ public class MockHttpServletResponse implements HttpServletResponse {
 		return null;
 	}
 
-	/**
+    @Override
+    public Collection<String> getHeaders(String s) {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    /**
 	 * Gets the header names.
 	 * 
 	 * @return the header names
diff --git a/src/test/java/org/owasp/esapi/http/MockServletContext.java b/src/test/java/org/owasp/esapi/http/MockServletContext.java
index 8c2c4f2..1a0c0d2 100644
--- a/src/test/java/org/owasp/esapi/http/MockServletContext.java
+++ b/src/test/java/org/owasp/esapi/http/MockServletContext.java
@@ -19,13 +19,21 @@ import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Enumeration;
+import java.util.EventListener;
+import java.util.Map;
 import java.util.Set;
 
+import javax.servlet.Filter;
+import javax.servlet.FilterRegistration;
 import javax.servlet.RequestDispatcher;
 import javax.servlet.Servlet;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
+import javax.servlet.ServletRegistration;
+import javax.servlet.SessionCookieConfig;
+import javax.servlet.SessionTrackingMode;
+import javax.servlet.descriptor.JspConfigDescriptor;
 
 import org.owasp.esapi.ESAPI;
 import org.owasp.esapi.Logger;
@@ -83,6 +91,11 @@ public class MockServletContext implements ServletContext {
     	return null;
     }
 
+    @Override
+    public String getContextPath() {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
     /**
      * Returns the major version of the Java Servlet API that this
      * servlet container supports. All implementations that comply
@@ -105,6 +118,16 @@ public class MockServletContext implements ServletContext {
     	return 4;
     }
 
+    @Override
+    public int getEffectiveMajorVersion() {
+        return 0;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public int getEffectiveMinorVersion() {
+        return 0;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
     /**
      * Returns the MIME type of the specified file, or <code>null</code> if
      * the MIME type is not known. The MIME type is determined
@@ -451,6 +474,11 @@ public class MockServletContext implements ServletContext {
     	return null;
     }
 
+    @Override
+    public boolean setInitParameter(String s, String s1) {
+        return false;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
 
     /**
      * Returns the servlet container attribute with the given name,
@@ -546,4 +574,119 @@ public class MockServletContext implements ServletContext {
     public String getServletContextName() {
     	return null;
     }
+
+    @Override
+    public ServletRegistration.Dynamic addServlet(String s, String s1) {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public ServletRegistration.Dynamic addServlet(String s, Servlet servlet) {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public ServletRegistration.Dynamic addServlet(String s, Class<? extends Servlet> aClass) {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public <T extends Servlet> T createServlet(Class<T> tClass) throws ServletException {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public ServletRegistration getServletRegistration(String s) {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public Map<String, ? extends ServletRegistration> getServletRegistrations() {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public FilterRegistration.Dynamic addFilter(String s, String s1) {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public FilterRegistration.Dynamic addFilter(String s, Filter filter) {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public FilterRegistration.Dynamic addFilter(String s, Class<? extends Filter> aClass) {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public <T extends Filter> T createFilter(Class<T> tClass) throws ServletException {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public FilterRegistration getFilterRegistration(String s) {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public Map<String, ? extends FilterRegistration> getFilterRegistrations() {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public SessionCookieConfig getSessionCookieConfig() {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes) throws IllegalStateException, IllegalArgumentException {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public Set<SessionTrackingMode> getDefaultSessionTrackingModes() {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public Set<SessionTrackingMode> getEffectiveSessionTrackingModes() {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public void addListener(Class<? extends EventListener> aClass) {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public void addListener(String s) {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public <T extends EventListener> void addListener(T t) {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public <T extends EventListener> T createListener(Class<T> tClass) throws ServletException {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public void declareRoles(String... strings) {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public ClassLoader getClassLoader() {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public JspConfigDescriptor getJspConfigDescriptor() {
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
 }
\ No newline at end of file