From do-not-reply at jboss.org Thu Sep 10 09:37:41 2009
Content-Type: multipart/mixed; boundary="===============4408822861801774806=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r168 - in
ws/trunk/testframework/src/main/java/org/exoplatform: services and 2 other
directories.
Date: Thu, 10 Sep 2009 09:37:41 -0400
Message-ID: <200909101337.n8ADbf3J024166@svn01.web.mwc.hst.phx2.redhat.com>
--===============4408822861801774806==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: max_shaposhnik
Date: 2009-09-10 09:37:40 -0400 (Thu, 10 Sep 2009)
New Revision: 168
Added:
ws/trunk/testframework/src/main/java/org/exoplatform/services/
ws/trunk/testframework/src/main/java/org/exoplatform/services/test/
ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock/
ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock/=
CaseInsensetiveMap.java
ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock/=
CaseInsensitiveMultivaluedMap.java
ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock/=
MockHttpServletRequest.java
ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock/=
MockHttpServletResponse.java
ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock/=
MockHttpSession.java
ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock/=
MockPrincipal.java
ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock/=
MockServletContext.java
Removed:
ws/trunk/testframework/src/main/java/org/exoplatform/testframework/
Log:
EXOJCR-152
Added: ws/trunk/testframework/src/main/java/org/exoplatform/services/test/m=
ock/CaseInsensetiveMap.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock=
/CaseInsensetiveMap.java (rev 0)
+++ ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock=
/CaseInsensetiveMap.java 2009-09-10 13:37:40 UTC (rev 168)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.test.mock;
+
+/**
+ * @author Andrey Parfonov
+ * @version $Id: CaseInsensetiveMap.java 167 2009-09-10 13:14:45Z max_shap=
oshnik $
+ */
+public class CaseInsensetiveMap extends java.util.HashMap
+{
+
+ private static final long serialVersionUID =3D -8562529039657285360L;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean containsKey(Object key)
+ {
+ return super.containsKey(getKey(key));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public T get(Object key)
+ {
+ return super.get(getKey(key));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public T put(String key, T value)
+ {
+ return super.put(getKey(key), value);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public T remove(Object key)
+ {
+ return super.remove(getKey(key));
+ }
+
+ private String getKey(Object key)
+ {
+ if (key =3D=3D null)
+ {
+ return null;
+ }
+ return key.toString().toLowerCase();
+ }
+
+}
Added: ws/trunk/testframework/src/main/java/org/exoplatform/services/test/m=
ock/CaseInsensitiveMultivaluedMap.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock=
/CaseInsensitiveMultivaluedMap.java (rev 0)
+++ ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock=
/CaseInsensitiveMultivaluedMap.java 2009-09-10 13:37:40 UTC (rev 168)
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.test.mock;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+
+/**
+ * @author Andrey Parfonov
+ * @version $Id: CaseInsensitiveMap.java 2822 2009-08-27 14:14:41Z andrew0=
0x $
+ */
+public class CaseInsensitiveMultivaluedMap extends HashMap>
+{
+
+ private static final long serialVersionUID =3D 6637313979061607685L;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean containsKey(Object key)
+ {
+ return super.containsKey(getKey(key));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List get(Object key)
+ {
+ return getList(getKey(key));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List put(String key, List value)
+ {
+ return super.put(getKey(key), value);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List remove(Object key)
+ {
+ return super.remove(getKey(key));
+ }
+ =
+ public T getFirst(String key)
+ {
+ List l =3D getList(key);
+ if (l.size() =3D=3D 0)
+ return null;
+ return l.get(0);
+ }
+ =
+ private List getList(String key)
+ {
+ List l =3D super.get(getKey(key));
+ if (l =3D=3D null)
+ l =3D new ArrayList();
+ put(key, l);
+ return l;
+ }
+
+ private String getKey(Object key)
+ {
+ if (key =3D=3D null)
+ {
+ return null;
+ }
+ return key.toString().toLowerCase();
+ }
+
+}
\ No newline at end of file
Added: ws/trunk/testframework/src/main/java/org/exoplatform/services/test/m=
ock/MockHttpServletRequest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock=
/MockHttpServletRequest.java (rev 0)
+++ ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock=
/MockHttpServletRequest.java 2009-09-10 13:37:40 UTC (rev 168)
@@ -0,0 +1,720 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.test.mock;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+/**
+ * The Class MockHttpServletRequest.
+ * =
+ * @author Max Shaposh=
nik
+ * @version $Id: $
+ */
+
+(a)SuppressWarnings("unchecked")
+public class MockHttpServletRequest implements HttpServletRequest
+{
+
+ /** HTTP method. */
+ private String method;
+
+ /** Length. */
+ private int length;
+
+ /** Request url. */
+ private String requestURL;
+
+ /** Data. */
+ private InputStream data;
+
+ /** Headers. */
+ private CaseInsensitiveMultivaluedMap headers =3D new CaseInsen=
sitiveMultivaluedMap();
+
+ /** The parameters. */
+ private Map> parameters =3D new HashMap>();
+
+ /** The session. */
+ private HttpSession session;
+
+ /** The locale. */
+ private Locale locale;
+
+ /** The secure. */
+ private boolean secure;
+
+ /** The Constant p. */
+ private static final Pattern p =3D Pattern.compile("http://([^:]+?):([^=
/]+?)/([^/]+?)/(.*?)");
+
+ /** The attributes. */
+ private Map attributes =3D new HashMap(=
);
+
+ private Principal principal;
+
+ /**
+ * Instantiates a new mock http servlet request.
+ * =
+ * @param url
+ * the url
+ * @param data
+ * the data
+ * @param length
+ * the length
+ * @param method
+ * the method
+ * @param headers
+ * the headers
+ */
+ public MockHttpServletRequest(String url, InputStream data, int length,=
String method,
+ Map> headers)
+ {
+ this.requestURL =3D url;
+ this.data =3D data;
+ this.length =3D length;
+ this.method =3D method;
+ if (headers !=3D null)
+ this.headers.putAll(headers);
+ String queryString =3D getQueryString();
+ if (queryString !=3D null)
+ {
+ parameters.putAll(parseQueryString(queryString));
+ }
+ session =3D new MockHttpSession();
+ }
+
+ /**
+ * Reset.
+ */
+ public void reset()
+ {
+ parameters =3D new HashMap();
+ attributes =3D new HashMap();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getAttribute(String name)
+ {
+ return attributes.get(name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Enumeration getAttributeNames()
+ {
+ return new EnumerationImpl(attributes.keySet().iterator());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getAuthType()
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getCharacterEncoding()
+ {
+ return "UTF-8";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getContentLength()
+ {
+ return length;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getContentType()
+ {
+ return headers.getFirst("content-type");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getContextPath()
+ {
+ Matcher m =3D p.matcher(requestURL);
+ if (!m.matches())
+ throw new RuntimeException("Unable determine context path.");
+ return '/' + m.group(3);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Cookie[] getCookies()
+ {
+ return new Cookie[0];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public long getDateHeader(String name)
+ {
+ if (headers.get(name) !=3D null)
+ return Long.valueOf(headers.getFirst(name));
+ return -1L;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getHeader(String name)
+ {
+ return headers.getFirst(name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Enumeration getHeaderNames()
+ {
+ return new EnumerationImpl(headers.keySet().iterator());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Enumeration getHeaders(String name)
+ {
+ ArrayList values =3D (ArrayList)headers.get(name);
+ if (values.size() > 0)
+ return new EnumerationImpl(values.iterator());
+
+ return new EnumerationImpl(Collections.EMPTY_LIST.iterator());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ServletInputStream getInputStream() throws IOException
+ {
+ return new MockServletInputStream(data);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getIntHeader(String name)
+ {
+ if (headers.get(name).size() > 0)
+ return Integer.parseInt(headers.getFirst(name));
+ return -1;
+ }
+
+ /**
+ * Gets the local addr.
+ * =
+ * @return the local addr
+ */
+ public String getLocalAddr()
+ {
+ return "127.0.0.1";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Locale getLocale()
+ {
+ return Locale.US;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Enumeration getLocales()
+ {
+ return null;
+ }
+
+ /**
+ * Gets the local name.
+ * =
+ * @return the local name
+ */
+ public String getLocalName()
+ {
+ return "localhost";
+ }
+
+ /**
+ * Gets the local port.
+ * =
+ * @return the local port
+ */
+ public int getLocalPort()
+ {
+ return 80;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getMethod()
+ {
+ return method;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getParameter(String name)
+ {
+ Iterator it =3D parameters.keySet().iterator();
+ while (it.hasNext())
+ {
+ String key =3D it.next();
+ if (key.equalsIgnoreCase(name))
+ {
+ ArrayList values =3D (ArrayList)parameters.get(key);
+ if (values !=3D null)
+ return (String)values.get(0);
+ }
+ }
+ return (null);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Map getParameterMap()
+ {
+ return parameters;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Enumeration getParameterNames()
+ {
+ return new EnumerationImpl(parameters.keySet().iterator());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String[] getParameterValues(String name)
+ {
+ ArrayList arr =3D new ArrayList();
+ Iterator it =3D parameters.keySet().iterator();
+ while (it.hasNext())
+ {
+
+ String pname =3D (String)it.next();
+ if (pname.equalsIgnoreCase(name))
+ arr.add((String)parameters.get(name).get(0));
+ }
+ return arr.toArray(new String[arr.size()]);
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getPathInfo()
+ {
+ Matcher m =3D p.matcher(requestURL);
+ if (!m.matches())
+ throw new RuntimeException("Unable determine pathInfo.");
+ String p =3D m.group(4);
+ int q =3D p.indexOf('?');
+ if (q > 0)
+ {
+ p =3D p.substring(0, q);
+ }
+ return '/' + p;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getPathTranslated()
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getProtocol()
+ {
+ return "HTTP/1.1";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getQueryString()
+ {
+ if (requestURL =3D=3D null)
+ return null;
+ int sep =3D requestURL.lastIndexOf('?');
+ if (sep =3D=3D -1)
+ return null;
+ return requestURL.substring(sep + 1);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public BufferedReader getReader() throws IOException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getRealPath(String arg0)
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getRemoteAddr()
+ {
+ return "127.0.0.1";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getRemoteHost()
+ {
+ return "localhost";
+ }
+
+ /**
+ * Gets the remote port.
+ * =
+ * @return the remote port
+ */
+ public int getRemotePort()
+ {
+ return 8080;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getRemoteUser()
+ {
+ return "root";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public RequestDispatcher getRequestDispatcher(String s)
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getRequestedSessionId()
+ {
+ return "sessionId";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getRequestURI()
+ {
+ return getContextPath() + getServletPath() + getPathInfo();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public StringBuffer getRequestURL()
+ {
+ if (requestURL =3D=3D null)
+ return null;
+ return new StringBuffer(requestURL);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getScheme()
+ {
+ return "http";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getServerName()
+ {
+ Matcher m =3D p.matcher(requestURL);
+ if (!m.matches())
+ throw new RuntimeException("Unable determine server name.");
+ return m.group(1);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getServerPort()
+ {
+ Matcher m =3D p.matcher(requestURL);
+ if (!m.matches())
+ throw new RuntimeException("Unable determine request URI.");
+ return Integer.valueOf(m.group(2));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getServletPath()
+ {
+ return "";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public HttpSession getSession()
+ {
+ return session;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public HttpSession getSession(boolean b)
+ {
+ return session;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Principal getUserPrincipal()
+ {
+ return principal =3D=3D null ? principal =3D new MockPrincipal("root=
") : principal;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isRequestedSessionIdFromCookie()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isRequestedSessionIdFromUrl()
+ {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isRequestedSessionIdFromURL()
+ {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isRequestedSessionIdValid()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isSecure()
+ {
+ return secure;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isUserInRole(String role)
+ {
+ return "admin".equals(role);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removeAttribute(String name)
+ {
+ attributes.remove(name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setAttribute(String name, Object object)
+ {
+ attributes.put(name, object);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setCharacterEncoding(String enc) throws UnsupportedEncoding=
Exception
+ {
+ }
+
+ /**
+ * Sets the parameter.
+ * =
+ * @param name
+ * the name
+ * @param value
+ * the value
+ */
+ public void setParameter(String name, String value)
+ {
+ ArrayList arr =3D new ArrayList();
+ arr.add(value);
+ parameters.put(name, arr);
+ }
+
+ public static Map> parseQueryString(String rawQuer=
y)
+ {
+ HashMap> m =3D new HashMap=
>();
+ if (rawQuery =3D=3D null || rawQuery.length() =3D=3D 0)
+ return m;
+ int p =3D 0;
+ int n =3D 0;
+ while (n < rawQuery.length())
+ {
+ n =3D rawQuery.indexOf('&', p);
+ if (n =3D=3D -1)
+ n =3D rawQuery.length();
+
+ String pair =3D rawQuery.substring(p, n);
+ if (pair.length() =3D=3D 0)
+ continue;
+
+ String name;
+ String value =3D ""; // default value
+ int eq =3D pair.indexOf('=3D');
+ if (eq =3D=3D -1) // no value, default is ""
+ name =3D pair;
+ else
+ {
+ name =3D pair.substring(0, eq);
+ value =3D pair.substring(eq + 1);
+ }
+
+ if (m.get(name) =3D=3D null)
+ {
+ List arr =3D new ArrayList();
+ arr.add(value);
+ m.put(name, arr);
+ }
+ else
+ {
+ List arr =3D m.get(name);
+ arr.add(value);
+ }
+ p =3D n + 1;
+ }
+ return m;
+ }
+}
+
+(a)SuppressWarnings("unchecked")
+class EnumerationImpl implements Enumeration
+{
+
+ private final Iterator iter;
+
+ public EnumerationImpl(Iterator iter)
+ {
+ this.iter =3D iter;
+ }
+
+ public boolean hasMoreElements()
+ {
+ return iter.hasNext();
+ }
+
+ public Object nextElement()
+ {
+ return iter.next();
+ }
+}
+
+class MockServletInputStream extends ServletInputStream
+{
+
+ private final InputStream data;
+
+ public MockServletInputStream(InputStream data)
+ {
+ this.data =3D data;
+ }
+
+ @Override
+ public int read() throws IOException
+ {
+ return data.read();
+ }
+}
\ No newline at end of file
Added: ws/trunk/testframework/src/main/java/org/exoplatform/services/test/m=
ock/MockHttpServletResponse.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock=
/MockHttpServletResponse.java (rev 0)
+++ ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock=
/MockHttpServletResponse.java 2009-09-10 13:37:40 UTC (rev 168)
@@ -0,0 +1,445 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.test.mock;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * The Class MockHttpServletResponse.
+ * =
+ * @author Max Shaposh=
nik
+ * @version $Id: $
+ */
+
+public class MockHttpServletResponse implements HttpServletResponse
+{
+
+ /** The writer. */
+ private PrintWriter writer;
+
+ /** The stream. */
+ private ByteArrayOutputStream stream;
+
+ /** The output. */
+ private ByteArrayServletOutputStream output;
+
+ /** The buffer. */
+ private byte[] buffer =3D new byte[1024];
+
+ /** The buffer count. */
+ private int bufferCount =3D 0;
+
+ /** The cookies. */
+ private List cookies =3D new ArrayList();
+
+ /** The headers. */
+ private HashMap> headers =3D new CaseInsensitiveMu=
ltivaluedMap();
+
+ /** The status. */
+ private int status =3D HttpServletResponse.SC_OK;
+
+ /** The message. */
+ private String message =3D "";
+
+ /** The locale. */
+ private Locale locale =3D Locale.getDefault();
+
+ /** The content type. */
+ private String contentType =3D null;
+
+ /** The content length. */
+ protected int contentLength =3D -1;
+
+ /** The encoding. */
+ protected String encoding =3D null;
+
+ /** The date format we will use for creating date headers. */
+ protected static final SimpleDateFormat format =3D new SimpleDateFormat=
("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
+ static
+ {
+ format.setTimeZone(TimeZone.getTimeZone("GMT"));
+ };
+
+ /**
+ * Instantiates a new mock http servlet response.
+ */
+ public MockHttpServletResponse()
+ {
+ stream =3D new ByteArrayOutputStream();
+ writer =3D new PrintWriter(stream);
+ output =3D new ByteArrayServletOutputStream(stream);
+ }
+
+ /**
+ * Gets the output content.
+ * =
+ * @return the output content
+ */
+ public String getOutputContent()
+ {
+ return new String(stream.toByteArray());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void flushBuffer() throws IOException
+ {
+ if (bufferCount > 0)
+ {
+ try
+ {
+ output.write(buffer, 0, bufferCount);
+ }
+ finally
+ {
+ bufferCount =3D 0;
+ }
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getBufferSize()
+ {
+ return (buffer.length);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ServletOutputStream getOutputStream() throws IOException
+ {
+ return this.output;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public PrintWriter getWriter() throws IOException
+ {
+ return this.writer;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isCommitted()
+ {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void reset()
+ {
+ bufferCount =3D 0;
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void resetBuffer()
+ {
+ bufferCount =3D 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addCookie(Cookie cookie)
+ {
+ cookies.add(cookie);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addDateHeader(String name, long value)
+ {
+ addHeader(name, format.format(new Date(value)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addHeader(String name, String value)
+ {
+ Iterator it =3D headers.keySet().iterator();
+ while (it.hasNext())
+ {
+ String key =3D (String)it.next();
+ if (key.equals(name))
+ {
+ List values =3D (ArrayList)headers.get(key);
+ if (values !=3D null)
+ {
+ values =3D new ArrayList();
+ headers.put(name, values);
+ }
+ values.add(value);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addIntHeader(String name, int value)
+ {
+ addHeader(name, "" + value);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean containsHeader(String name)
+ {
+ return (headers.get(name) !=3D null);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String encodeRedirectURL(String url)
+ {
+ return url; // TODO encode
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String encodeRedirectUrl(String url)
+ {
+ return url;// TODO encode
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String encodeURL(String url)
+ {
+ return url;// TODO encode
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String encodeUrl(String url)
+ {
+ return url;// TODO encode
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void sendError(int status) throws IOException
+ {
+ sendError(status, "");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void sendError(int status, String message) throws IOException
+ {
+ this.status =3D status;
+ this.message =3D message;
+ resetBuffer();
+ try
+ {
+ flushBuffer();
+ }
+ catch (IOException e)
+ {
+
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void sendRedirect(String location) throws IOException
+ {
+ resetBuffer();
+ setStatus(SC_MOVED_TEMPORARILY);
+ setHeader("Location", location);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setDateHeader(String name, long value)
+ {
+ setHeader(name, format.format(new Date(value)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setHeader(String name, String value)
+ {
+ List values =3D new ArrayList();
+ values.add(value);
+ headers.put(name, values);
+
+ String match =3D name.toLowerCase();
+ if (match.equals("content-length"))
+ {
+ int contentLength =3D -1;
+ contentLength =3D Integer.parseInt(value);
+ if (contentLength >=3D 0)
+ setContentLength(contentLength);
+ }
+ else if (match.equals("content-type"))
+ {
+ setContentType(value);
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setIntHeader(String name, int value)
+ {
+ setHeader(name, "" + value);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setStatus(int status)
+ {
+ this.status =3D status;
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setStatus(int status, String message)
+ {
+ this.status =3D status;
+ this.message =3D message;
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getCharacterEncoding()
+ {
+ if (encoding =3D=3D null)
+ return ("UTF-8");
+ else
+ return (encoding);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setBufferSize(int size)
+ {
+ if (buffer.length >=3D size)
+ return;
+ buffer =3D new byte[size];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setContentLength(int length)
+ {
+ this.contentLength =3D length;
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setContentType(String type)
+ {
+ this.contentType =3D type;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setLocale(Locale locale)
+ {
+ this.locale =3D locale;
+ }
+
+ /**
+ * The Class ByteArrayServletOutputStream.
+ */
+ private static class ByteArrayServletOutputStream extends ServletOutput=
Stream
+ {
+
+ /** The baos. */
+ ByteArrayOutputStream baos;
+
+ /**
+ * Instantiates a new byte array servlet output stream.
+ * =
+ * @param baos
+ * the baos
+ */
+ public ByteArrayServletOutputStream(ByteArrayOutputStream baos)
+ {
+ this.baos =3D baos;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void write(int i) throws IOException
+ {
+ baos.write(i);
+ }
+ }
+
+}
Added: ws/trunk/testframework/src/main/java/org/exoplatform/services/test/m=
ock/MockHttpSession.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock=
/MockHttpSession.java (rev 0)
+++ ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock=
/MockHttpSession.java 2009-09-10 13:37:40 UTC (rev 168)
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.test.mock;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Vector;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionContext;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class MockHttpSession.
+ * =
+ * @author Max Shaposh=
nik
+ * @version $Id: $
+ */
+public class MockHttpSession implements HttpSession
+{
+
+ /** The attributes map. */
+ private Map attributes =3D new HashMap(=
);
+
+ /** The servlet context. */
+ private ServletContext servletContext;
+
+ /** The is valid. */
+ private boolean isValid =3D true;
+
+ /**
+ * {@inheritDoc}
+ */
+ public long getCreationTime()
+ {
+ return 0L;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getId()
+ {
+ return "MockSessionId";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public long getLastAccessedTime()
+ {
+ return 0L;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ServletContext getServletContext()
+ {
+ return servletContext;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setMaxInactiveInterval(int i)
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getMaxInactiveInterval()
+ {
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public HttpSessionContext getSessionContext()
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getAttribute(String s)
+ {
+
+ if (!isValid)
+ {
+ throw new IllegalStateException("Cannot call getAttribute() on in=
validated session");
+ }
+ return attributes.get(s);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getValue(String s)
+ {
+ return getAttribute(s);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Enumeration getAttributeNames()
+ {
+ if (!isValid)
+ {
+ throw new IllegalStateException("Cannot call getAttribute() on in=
validated session");
+ }
+ return new Vector(attributes.keySet()).elements();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String[] getValueNames()
+ {
+ if (!isValid)
+ {
+ throw new IllegalStateException("Cannot call getAttribute() on in=
validated session");
+ }
+ String results[] =3D new String[0];
+ return ((String[])attributes.keySet().toArray(results));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setAttribute(String s, Object o)
+ {
+ attributes.put(s, o);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void putValue(String s, Object o)
+ {
+ setAttribute(s, o);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removeAttribute(String s)
+ {
+ attributes.remove(s);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removeValue(String s)
+ {
+ removeAttribute(s);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void invalidate()
+ {
+ if (!isValid)
+ {
+ throw new IllegalStateException("Cannot call invalidate() on inva=
lidated session");
+ }
+ this.isValid =3D false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isNew()
+ {
+ return false;
+ }
+
+ /**
+ * Checks if is valid.
+ * =
+ * @return true, if is valid
+ */
+ public boolean isValid()
+ {
+ return this.isValid;
+ }
+
+ /**
+ * Sets the valid.
+ * =
+ * @param isValid the new valid
+ */
+ public void setValid(boolean isValid)
+ {
+ this.isValid =3D isValid;
+ }
+}
Added: ws/trunk/testframework/src/main/java/org/exoplatform/services/test/m=
ock/MockPrincipal.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock=
/MockPrincipal.java (rev 0)
+++ ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock=
/MockPrincipal.java 2009-09-10 13:37:40 UTC (rev 168)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.test.mock;
+
+/**
+ * @author Mestrallet Benjamin benjmestrallet(a)users.sourceforge.net
+ */
+public class MockPrincipal implements java.security.Principal
+{
+ =
+ private final String username;
+ =
+ public MockPrincipal(String username)
+ {
+ this.username =3D username;
+ }
+ =
+ /**
+ * {@inheritDoc}
+ */
+ public String getName()
+ {
+ return username;
+ }
+}
Added: ws/trunk/testframework/src/main/java/org/exoplatform/services/test/m=
ock/MockServletContext.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock=
/MockServletContext.java (rev 0)
+++ ws/trunk/testframework/src/main/java/org/exoplatform/services/test/mock=
/MockServletContext.java 2009-09-10 13:37:40 UTC (rev 168)
@@ -0,0 +1,378 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.test.mock;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+
+/**
+ * The Class MockServletContext.
+ * =
+ * @author Max Shaposh=
nik
+ * @version $Id: $
+ */
+public class MockServletContext implements ServletContext
+{
+
+ /** The name. */
+ private String name;
+
+ /** The init params. */
+ private HashMap initParams;
+
+ /** The attributes. */
+ private HashMap attributes;
+
+ /** The context path. */
+ private String contextPath;
+
+ /** The log buffer. */
+ private StringBuffer logBuffer =3D new StringBuffer();
+
+ /**
+ * Instantiates a new mock servlet context.
+ */
+ public MockServletContext()
+ {
+ this("MockServletContext1");
+ }
+
+ /**
+ * Instantiates a new mock servlet context.
+ * =
+ * @param name the name
+ */
+ public MockServletContext(String name)
+ {
+ this.name =3D name;
+ this.initParams =3D new HashMap();
+ this.attributes =3D new HashMap();
+ }
+
+ /**
+ * Instantiates a new mock servlet context.
+ * =
+ * @param name the name
+ * @param path the path
+ */
+ public MockServletContext(String name, String path)
+ {
+ this(name);
+ contextPath =3D path;
+ attributes.put("javax.servlet.context.tempdir", path);
+ }
+
+ /**
+ * Sets the name.
+ * =
+ * @param name the new name
+ */
+ public void setName(String name)
+ {
+ this.name =3D name;
+ }
+
+ /**
+ * Gets the log buffer.
+ * =
+ * @return the log buffer
+ */
+ public String getLogBuffer()
+ {
+ try
+ {
+ return logBuffer.toString();
+ }
+ finally
+ {
+ logBuffer =3D new StringBuffer();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ServletContext getContext(String s)
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getMajorVersion()
+ {
+ return 2;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getMinorVersion()
+ {
+ return 4;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getMimeType(String s)
+ {
+ return "text/html";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set getResourcePaths(String s)
+ {
+
+ if (!s.endsWith("/"))
+ s =3D s + "/";
+
+ Set set =3D new HashSet();
+ set.add("/WEB-INF/");
+
+ try
+ {
+ URL url =3D getResource(s);
+ File dir =3D new File(url.getPath());
+ if (dir.isDirectory())
+ {
+ File[] arr =3D dir.listFiles();
+ for (int i =3D 0; i < arr.length; i++)
+ {
+ File tmp =3D arr[i];
+ if (tmp.isDirectory())
+ set.add(s + "/" + tmp.getName() + "/");
+ else
+ set.add(s + "/" + tmp.getName());
+ }
+ }
+ }
+ catch (MalformedURLException e)
+ {
+ }
+ return set;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public URL getResource(String s) throws MalformedURLException
+ {
+ String path =3D "file:" + contextPath + s;
+ URL url =3D new URL(path);
+ return url;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public InputStream getResourceAsStream(String s)
+ {
+ try
+ {
+ return getResource(s).openStream();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public RequestDispatcher getRequestDispatcher(String s)
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public RequestDispatcher getNamedDispatcher(String s)
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Deprecated
+ public Servlet getServlet(String s) throws ServletException
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Deprecated
+ public Enumeration getServlets()
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Deprecated
+ public Enumeration getServletNames()
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void log(String s)
+ {
+ logBuffer.append(s);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Deprecated
+ public void log(Exception e, String s)
+ {
+ logBuffer.append(s + e.getMessage());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void log(String s, Throwable throwable)
+ {
+ logBuffer.append(s + throwable.getMessage());
+ }
+
+ /**
+ * Sets the context path.
+ * =
+ * @param s the new context path
+ */
+ public void setContextPath(String s)
+ {
+ contextPath =3D s;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getRealPath(String s)
+ {
+ return contextPath + s;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getServerInfo()
+ {
+ return null;
+ }
+
+ /**
+ * Sets the init parameter.
+ * =
+ * @param name the name
+ * @param value the value
+ */
+ public void setInitParameter(String name, String value)
+ {
+ initParams.put(name, value);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getInitParameter(String name)
+ {
+ return (String)initParams.get(name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Enumeration getInitParameterNames()
+ {
+ Vector keys =3D new Vector(initParams.keySet());
+ return keys.elements();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getAttribute(String name)
+ {
+ return attributes.get(name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Enumeration getAttributeNames()
+ {
+ Vector keys =3D new Vector(attributes.keySet());
+ return keys.elements();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setAttribute(String name, Object value)
+ {
+ attributes.put(name, value);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removeAttribute(String name)
+ {
+ attributes.remove(name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getServletContextName()
+ {
+ return name;
+ }
+
+}
--===============4408822861801774806==--