From do-not-reply at jboss.org Thu Sep 10 07:21:01 2009 Content-Type: multipart/mixed; boundary="===============0419368686468254430==" 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: r165 - ws/trunk/testframework/src/main/java/org/exoplatform/testframework. Date: Thu, 10 Sep 2009 07:21:01 -0400 Message-ID: <200909101121.n8ABL1uf001139@svn01.web.mwc.hst.phx2.redhat.com> --===============0419368686468254430== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: aparfonov Date: 2009-09-10 07:21:01 -0400 (Thu, 10 Sep 2009) New Revision: 165 Added: ws/trunk/testframework/src/main/java/org/exoplatform/testframework/CaseI= nsensetiveMap.java ws/trunk/testframework/src/main/java/org/exoplatform/testframework/CaseI= nsensitiveMultivaluedMap.java Removed: ws/trunk/testframework/src/main/java/org/exoplatform/testframework/CaseI= nsensitiveMap.java Modified: ws/trunk/testframework/src/main/java/org/exoplatform/testframework/MockH= ttpServletRequest.java ws/trunk/testframework/src/main/java/org/exoplatform/testframework/MockH= ttpServletResponse.java ws/trunk/testframework/src/main/java/org/exoplatform/testframework/MockP= rincipal.java Log: EXOJCR-152 : = Added: ws/trunk/testframework/src/main/java/org/exoplatform/testframework/C= aseInsensetiveMap.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/testframework/Case= InsensetiveMap.java (rev 0) +++ ws/trunk/testframework/src/main/java/org/exoplatform/testframework/Case= InsensetiveMap.java 2009-09-10 11:21:01 UTC (rev 165) @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2003-2008 eXo Platform SAS. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * = + * This program 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 General Public License for more details. + * = + * You should have received a copy of the GNU General Public License + * along with this program; if not, see. + */ + +package org.exoplatform.testframework; + +/** + * @author Andrey Parfonov + * @version $Id$ + */ +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(); + } + +} Property changes on: ws/trunk/testframework/src/main/java/org/exoplatform/t= estframework/CaseInsensetiveMap.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Deleted: ws/trunk/testframework/src/main/java/org/exoplatform/testframework= /CaseInsensitiveMap.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/testframework/Case= InsensitiveMap.java 2009-09-10 10:56:44 UTC (rev 164) +++ ws/trunk/testframework/src/main/java/org/exoplatform/testframework/Case= InsensitiveMap.java 2009-09-10 11:21:01 UTC (rev 165) @@ -1,78 +0,0 @@ -/* - * 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.testframework; - -import java.util.HashMap; - - -/** - * @author Andrey Parfonov - * @version $Id: CaseInsensitiveMap.java 2822 2009-08-27 14:14:41Z andrew0= 0x $ - */ -public class CaseInsensitiveMap extends HashMap -{ - - private static final long serialVersionUID =3D 6637313979061607685L; - - /** - * {@inheritDoc} - */ - @Override - public boolean containsKey(Object key) - { - return super.containsKey(getKey(key)); - } - - /** - * {@inheritDoc} - */ - @Override - public String get(Object key) - { - return super.get(getKey(key)); - } - - /** - * {@inheritDoc} - */ - @Override - public String put(String key, String value) - { - return super.put(getKey(key), value); - } - - /** - * {@inheritDoc} - */ - @Override - public String remove(Object key) - { - return super.remove(getKey(key)); - } - - private String getKey(Object key) - { - if (key =3D=3D null) - { - return null; - } - return key.toString().toLowerCase(); - } - -} \ No newline at end of file Copied: ws/trunk/testframework/src/main/java/org/exoplatform/testframework/= CaseInsensitiveMultivaluedMap.java (from rev 160, ws/trunk/testframework/sr= c/main/java/org/exoplatform/testframework/CaseInsensitiveMap.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/testframework/Case= InsensitiveMultivaluedMap.java (rev 0) +++ ws/trunk/testframework/src/main/java/org/exoplatform/testframework/Case= InsensitiveMultivaluedMap.java 2009-09-10 11:21:01 UTC (rev 165) @@ -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.testframework; + +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(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 Modified: ws/trunk/testframework/src/main/java/org/exoplatform/testframewor= k/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/testframework/Mock= HttpServletRequest.java 2009-09-10 10:56:44 UTC (rev 164) +++ ws/trunk/testframework/src/main/java/org/exoplatform/testframework/Mock= HttpServletRequest.java 2009-09-10 11:21:01 UTC (rev 165) @@ -1,18 +1,20 @@ -/** - * Copyright (C) 2003-2009 eXo Platform SAS. +/* + * Copyright (C) 2009 eXo Platform SAS. * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * = - * This program is distributed in the hope that it will be useful, + * 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 General Public License for more details. - * = - * You should have received a copy of the GNU General Public License - * along with this program; if not, see. + * 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.testframework; @@ -63,10 +65,10 @@ private InputStream data; = /** Headers. */ - private Map headers =3D new CaseInsensitiveMap(); + private Map> headers =3D new CaseInsensitiveMultiv= aluedMap(); = /** The parameters. */ - private Map parameters =3D new HashMap(); + private Map> parameters =3D new HashMap>(); = /** The session. */ private HttpSession session; @@ -83,6 +85,8 @@ /** The attributes. */ private Map attributes =3D new HashMap(= ); = + private Principal principal; + /** * Instantiates a new mock http servlet request. * = @@ -97,18 +101,21 @@ * @param headers * the headers */ - public MockHttpServletRequest(String url, InputStream data, int length,= String method, HashMap 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; - this.headers =3D headers; + if (headers !=3D null) + this.headers.putAll(headers); String queryString =3D getQueryString(); if (queryString !=3D null) { parameters.putAll(parseQueryString(queryString)); } + session =3D new MockHttpSession(); } = /** @@ -165,12 +172,8 @@ */ public String getContentType() { - // return headers.getFirst("content-type"); - synchronized (headers) - { - if (headers.get("content-type") !=3D null) - return (String)headers.get("content-type"); - } + if (headers.get("content-type") !=3D null) + return headers.get("content-type").get(0); return (null); } = @@ -198,12 +201,8 @@ */ public long getDateHeader(String name) { - // return Long.valueOf(headers.get(name)); - synchronized (headers) - { - if (headers.get(name) !=3D null) - return (Long)headers.get(0); - } + if (headers.get(name) !=3D null) + return Long.valueOf(headers.get(name).get(0)); return -1L; } = @@ -212,12 +211,8 @@ */ public String getHeader(String name) { - // return headers.get(name); - synchronized (headers) - { - if (headers.get(name) !=3D null) - return (String)headers.get(name); - } + if (headers.get(name) !=3D null) + return headers.get(name).get(0); return (null); } = @@ -265,18 +260,8 @@ */ public int getIntHeader(String name) { - // return Integer.valueOf(headers.get(name)); - synchronized (headers) - { - if (headers.get(name) !=3D null) - try - { - return Integer.parseInt((String)headers.get(name)); - } - catch (NumberFormatException e) - { - } - } + if (headers.get(name) !=3D null) + return Integer.parseInt(headers.get(name).get(0)); return -1; } = @@ -565,7 +550,7 @@ */ public HttpSession getSession() { - return null; + return session; } = /** @@ -573,7 +558,7 @@ */ public HttpSession getSession(boolean b) { - return null; + return session; } = /** @@ -581,14 +566,7 @@ */ public Principal getUserPrincipal() { - return new Principal() - { - - public String getName() - { - return "root"; - } - }; + return principal =3D=3D null ? principal =3D new MockPrincipal("root= ") : principal; } = /** @@ -628,7 +606,7 @@ */ public boolean isSecure() { - return false; + return secure; } = /** @@ -677,9 +655,9 @@ parameters.put(name, arr); } = - public static Map parseQueryString(String rawQuery) + public static Map> parseQueryString(String rawQuer= y) { - HashMap m =3D new HashMap(); + HashMap> m =3D new HashMap= >(); if (rawQuery =3D=3D null || rawQuery.length() =3D=3D 0) return m; int p =3D 0; @@ -707,13 +685,13 @@ = if (m.get(name) =3D=3D null) { - ArrayList arr =3D new ArrayList(); + List arr =3D new ArrayList(); arr.add(value); m.put(name, arr); } else { - ArrayList arr =3D m.get(name); + List arr =3D m.get(name); arr.add(value); } p =3D n + 1; Modified: ws/trunk/testframework/src/main/java/org/exoplatform/testframewor= k/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/testframework/Mock= HttpServletResponse.java 2009-09-10 10:56:44 UTC (rev 164) +++ ws/trunk/testframework/src/main/java/org/exoplatform/testframework/Mock= HttpServletResponse.java 2009-09-10 11:21:01 UTC (rev 165) @@ -26,6 +26,7 @@ import java.util.Date; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Locale; import java.util.TimeZone; = @@ -60,10 +61,10 @@ private int bufferCount =3D 0; = /** The cookies. */ - private ArrayList cookies =3D new ArrayList(); + private List cookies =3D new ArrayList(); = /** The headers. */ - private HashMap headers =3D new CaseInsensitiveMap(); + private HashMap> headers =3D new CaseInsensitiveMu= ltivaluedMap(); = /** The status. */ private int status =3D HttpServletResponse.SC_OK; Modified: ws/trunk/testframework/src/main/java/org/exoplatform/testframewor= k/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/testframework/Mock= Principal.java 2009-09-10 10:56:44 UTC (rev 164) +++ ws/trunk/testframework/src/main/java/org/exoplatform/testframework/Mock= Principal.java 2009-09-10 11:21:01 UTC (rev 165) @@ -23,11 +23,19 @@ */ public class MockPrincipal implements java.security.Principal { + = + private final String username; + = + public MockPrincipal(String username) + { + this.username =3D username; + } + = /** * {@inheritDoc} */ public String getName() { - return "PrincipalMackName"; + return username; } } --===============0419368686468254430==--