[jboss-cvs] jboss-portal/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer ...

Chris Laprun chris.laprun at jboss.com
Tue Aug 8 00:29:27 EDT 2006


  User: claprun 
  Date: 06/08/08 00:29:27

  Modified:    wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer         
                        MarkupTestCase.java V1ConsumerBaseTest.java
  Added:       wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer         
                        MockHttpServletRequest.java
                        TestInvocationContext.java
                        MockHttpServletResponse.java
                        BasicSecurityContext.java BasicInstanceContext.java
                        BasicUserContext.java MockHttpSession.java
  Log:
  - Refactored Consumer tests.
  - Improved support infrastructure.
  
  Revision  Changes    Path
  1.21      +5 -396    jboss-portal/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: MarkupTestCase.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-portal/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MarkupTestCase.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -b -r1.20 -r1.21
  --- MarkupTestCase.java	2 Aug 2006 23:48:24 -0000	1.20
  +++ MarkupTestCase.java	8 Aug 2006 04:29:27 -0000	1.21
  @@ -22,59 +22,22 @@
   
   package org.jboss.portal.test.wsrp.v1.consumer;
   
  -import org.jboss.portal.Mode;
  -import org.jboss.portal.WindowState;
  -import org.jboss.portal.common.MediaType;
  -import org.jboss.portal.common.util.Tools;
  -import org.jboss.portal.portlet.Parameters;
  -import org.jboss.portal.portlet.PortletURL;
  -import org.jboss.portal.portlet.StateString;
  -import org.jboss.portal.portlet.impl.spi.AbstractInvocationContext;
  -import org.jboss.portal.portlet.info.CapabilitiesInfo;
   import org.jboss.portal.portlet.invocation.ActionInvocation;
   import org.jboss.portal.portlet.invocation.PortletInvocation;
   import org.jboss.portal.portlet.invocation.RenderInvocation;
   import org.jboss.portal.portlet.result.FragmentResult;
   import org.jboss.portal.portlet.result.RenderResult;
   import org.jboss.portal.portlet.result.Result;
  -import org.jboss.portal.portlet.spi.ActionContext;
  -import org.jboss.portal.portlet.spi.InstanceContext;
  -import org.jboss.portal.portlet.spi.InvocationContext;
  -import org.jboss.portal.portlet.spi.RenderContext;
  -import org.jboss.portal.portlet.spi.SecurityContext;
  -import org.jboss.portal.portlet.spi.UserContext;
   import org.jboss.portal.portlet.spi.WindowContext;
  -import org.jboss.portal.portlet.state.AccessMode;
  -import org.jboss.portal.server.util.HTTPStreamInfo;
   import org.jboss.portal.test.wsrp.TestWSRPProducerImpl;
  -import org.jboss.portal.wsrp.WSRPConstants;
   import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
   import org.jboss.portal.wsrp.core.CookieProtocol;
   
  -import javax.servlet.http.Cookie;
  -import javax.servlet.http.HttpServletRequest;
  -import javax.servlet.http.HttpServletResponse;
   import javax.servlet.http.HttpSession;
  -import java.io.BufferedReader;
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.io.Serializable;
  -import java.lang.reflect.InvocationHandler;
  -import java.lang.reflect.Method;
  -import java.lang.reflect.Proxy;
  -import java.security.Principal;
  -import java.util.Collections;
  -import java.util.Enumeration;
  -import java.util.HashMap;
  -import java.util.HashSet;
  -import java.util.List;
  -import java.util.Locale;
  -import java.util.Map;
  -import java.util.Set;
   
   /**
    * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
  - * @version $Revision: 1.20 $
  + * @version $Revision: 1.21 $
    * @since 2.4 (May 4, 2006)
    */
   public class MarkupTestCase extends V1ConsumerBaseTest
  @@ -82,6 +45,7 @@
      public MarkupTestCase()
         throws Exception
      {
  +      super();
      }
   
      public void testRender() throws Exception
  @@ -156,7 +120,9 @@
         ProducerSessionInformation sessionInfo = consumer.getProducerSessionInformationFrom(session);
         assertFalse(sessionInfo.isPerGroupCookies());
         assertTrue(sessionInfo.isUserCookiesInitialized());
  -      assertEquals(TestWSRPProducerImpl.USER_COOKIE, sessionInfo.getUserCookie());
  +      String userCookie = sessionInfo.getUserCookie();
  +      assertNotNull(userCookie);
  +      assertEquals(TestWSRPProducerImpl.USER_COOKIE, userCookie);
      }
   
      private FragmentResult checkRenderResult(RenderInvocation render, String markup)
  @@ -188,361 +154,4 @@
         });
         return render;
      }
  -
  -   private static class TestInvocationContext extends AbstractInvocationContext implements InvocationContext, RenderContext, ActionContext
  -   {
  -      String ns;
  -      HttpServletRequest mockRequest;
  -      HttpServletResponse mockResponse;
  -
  -      public TestInvocationContext()
  -      {
  -         ClassLoader classLoader = getClass().getClassLoader();
  -         HttpSession session = (HttpSession)Proxy.newProxyInstance(classLoader, new Class[]{HttpSession.class},
  -            new MockHttpSession());
  -         mockRequest = (HttpServletRequest)Proxy.newProxyInstance(classLoader, new Class[]{HttpServletRequest.class},
  -            new MockHttpServletRequest(session));
  -         mockResponse = (HttpServletResponse)Proxy.newProxyInstance(classLoader, new Class[]{HttpServletResponse.class},
  -            new MockHttpServletResponse());
  -      }
  -
  -      public StateString getNavigationalState()
  -      {
  -         return StateString.createFrom(ns);
  -      }
  -
  -      public Mode getMode()
  -      {
  -         return Mode.VIEW;
  -      }
  -
  -      public WindowState getWindowState()
  -      {
  -         return WindowState.MAXIMIZED;
  -      }
  -
  -      public HTTPStreamInfo getStreamInfo()
  -      {
  -         return new HTTPStreamInfo(MediaType.HTML, WSRPConstants.DEFAULT_CHARACTER_SET);
  -      }
  -
  -      public HttpServletRequest getClientRequest()
  -      {
  -         return mockRequest;
  -      }
  -
  -      public HttpServletResponse getClientResponse()
  -      {
  -         return mockResponse;
  -      }
  -
  -      public String encodeURL(String url)
  -      {
  -         return null;
  -      }
  -
  -      public String encodeURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
  -      {
  -         return null;
  -      }
  -
  -      public String getCharacterEncoding()
  -      {
  -         return null;
  -      }
  -
  -      public int getContentLength()
  -      {
  -         return 0;
  -      }
  -
  -      public BufferedReader getReader() throws IOException
  -      {
  -         return null;
  -      }
  -
  -      public InputStream getInputStream() throws IOException
  -      {
  -         return null;
  -      }
  -
  -      public String getContentType()
  -      {
  -         return null;
  -      }
  -
  -      public StateString getInteractionState()
  -      {
  -         return null;
  -      }
  -
  -      public Parameters getForm()
  -      {
  -         return null;
  -      }
  -   }
  -
  -   private static class MinimalCapabilitiesInfo implements CapabilitiesInfo
  -   {
  -      private static Set MODES = new HashSet(3);
  -      private static Set WINDOW_STATES = new HashSet(3);
  -      private static final String MIME_TYPE = "text/html";
  -
  -      static
  -      {
  -         MODES.add(Mode.EDIT);
  -         MODES.add(Mode.HELP);
  -         MODES.add(Mode.VIEW);
  -         MODES = Collections.unmodifiableSet(MODES);
  -
  -         WINDOW_STATES.add(WindowState.MAXIMIZED);
  -         WINDOW_STATES.add(WindowState.MINIMIZED);
  -         WINDOW_STATES.add(WindowState.NORMAL);
  -         WINDOW_STATES = Collections.unmodifiableSet(WINDOW_STATES);
  -      }
  -
  -
  -      public Set getMimeTypes()
  -      {
  -         return Collections.singleton(MIME_TYPE);
  -      }
  -
  -      public Set getAllModes()
  -      {
  -         return MODES;
  -      }
  -
  -      public Set getModes(String mimeType)
  -      {
  -         if (MIME_TYPE.equals(mimeType))
  -         {
  -            return MODES;
  -         }
  -
  -         return Collections.EMPTY_SET;
  -      }
  -
  -      public Set getAllWindowStates()
  -      {
  -         return WINDOW_STATES;
  -      }
  -
  -      public Set getWindowStates(String mimeType)
  -      {
  -         if (MIME_TYPE.equals(mimeType))
  -         {
  -            return WINDOW_STATES;
  -         }
  -
  -         return Collections.EMPTY_SET;
  -      }
  -
  -      public Set getAllLocales()
  -      {
  -         return Collections.singleton(Locale.ENGLISH);
  -      }
  -
  -      public Set getLocales(String mimeType)
  -      {
  -         if (MIME_TYPE.equals(mimeType))
  -         {
  -            return Collections.singleton(Locale.ENGLISH);
  -         }
  -         return Collections.EMPTY_SET;
  -      }
  -   }
  -
  -   private static class BasicInstanceContext implements InstanceContext
  -   {
  -      String id;
  -
  -      public BasicInstanceContext(String id)
  -      {
  -         this.id = id;
  -      }
  -
  -      public String getId()
  -      {
  -         return id;
  -      }
  -
  -      public void portletCloned(String cloneId)
  -      {
  -         //nothing
  -      }
  -
  -      public void portletCloned(byte[] bytes)
  -      {
  -         //nothing
  -      }
  -
  -      public AccessMode getAccessMode()
  -      {
  -         return AccessMode.READ_ONLY;
  -      }
  -   }
  -
  -   private static class BasicSecurityContext implements SecurityContext
  -   {
  -      public String getAuthType()
  -      {
  -         return null;
  -      }
  -
  -      public String getRemoteUser()
  -      {
  -         return null;
  -      }
  -
  -      public Principal getUserPrincipal()
  -      {
  -         return null;
  -      }
  -
  -      public boolean isUserInRole(String roleName)
  -      {
  -         return false;
  -      }
  -
  -      public boolean isSecure()
  -      {
  -         return false;
  -      }
  -   }
  -
  -   private static class BasicUserContext implements UserContext
  -   {
  -
  -      public String getId()
  -      {
  -         return null;
  -      }
  -
  -      public Map getInformations()
  -      {
  -         return Collections.EMPTY_MAP;
  -      }
  -
  -      public Locale getLocale()
  -      {
  -         return Locale.ENGLISH;
  -      }
  -
  -      public List getLocales()
  -      {
  -         return Collections.singletonList(getLocale());
  -      }
  -   }
  -
  -   private static class MockHttpServletRequest implements InvocationHandler, Serializable
  -   {
  -      private HttpSession session;
  -
  -      public MockHttpServletRequest(HttpSession session)
  -      {
  -         this.session = session;
  -      }
  -
  -      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
  -      {
  -         String methodName = method.getName();
  -         if ("getSession".equals(methodName))
  -         {
  -            return session;
  -         }
  -         if ("getHeader".equals(methodName))
  -         {
  -            if ("User-Agent".equals(args[0]))
  -            {
  -               return "Mock Client User Agent";
  -            }
  -            return null;
  -         }
  -         if ("toString".equals(methodName))
  -         {
  -            return "MockHttpServletResponse";
  -         }
  -         throw new UnsupportedOperationException("MockHttpServletRequest does not support: " + method);
  -      }
  -   }
  -
  -   private static class MockHttpServletResponse implements InvocationHandler, Serializable
  -   {
  -      Cookie cookie;
  -
  -      public MockHttpServletResponse()
  -      {
  -      }
  -
  -      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
  -      {
  -         String methodName = method.getName();
  -         if ("addCookie".equals(methodName))
  -         {
  -            cookie = (Cookie)args[0];
  -            return null;
  -         }
  -         else if ("toString".equals(methodName))
  -         {
  -            return "MockHttpServletResponse";
  -         }
  -         throw new UnsupportedOperationException("MockHttpServletResponse does not support: " + method);
  -      }
  -   }
  -
  -   private static class MockHttpSession implements InvocationHandler, Serializable
  -   {
  -      private final Map map = new HashMap();
  -
  -      public void setAttribute(String name, Object object)
  -      {
  -         map.put(name, object);
  -      }
  -
  -      public void removeAttribute(String name)
  -      {
  -         map.remove(name);
  -      }
  -
  -      public Object getAttribute(String name)
  -      {
  -         return map.get(name);
  -      }
  -
  -      public Enumeration getAttributeNames()
  -      {
  -         return Tools.toEnumeration(map.keySet().iterator());
  -      }
  -
  -      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
  -      {
  -         String methodName = method.getName();
  -         if ("setAttribute".equals(methodName))
  -         {
  -            setAttribute((String)args[0], args[1]);
  -            return null;
  -         }
  -         else if ("removeAttribute".equals(methodName))
  -         {
  -            removeAttribute((String)args[0]);
  -            return null;
  -         }
  -         else if ("getAttribute".equals(methodName))
  -         {
  -            return getAttribute((String)args[0]);
  -         }
  -         else if ("getAttributeNames".equals(methodName))
  -         {
  -            return getAttributeNames();
  -         }
  -         else if ("toString".equals(methodName))
  -         {
  -            return "MockHttpSession";
  -         }
  -         else
  -         {
  -            throw new UnsupportedOperationException("MockHttpSession does not support: " + method);
  -         }
  -      }
  -   }
   }
  
  
  
  1.4       +3 -3      jboss-portal/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: V1ConsumerBaseTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-portal/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/V1ConsumerBaseTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- V1ConsumerBaseTest.java	4 May 2006 23:47:54 -0000	1.3
  +++ V1ConsumerBaseTest.java	8 Aug 2006 04:29:27 -0000	1.4
  @@ -27,7 +27,7 @@
   
   /**
    * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class V1ConsumerBaseTest extends WSRPConsumerBaseTest
   {
  @@ -46,9 +46,9 @@
         assertEquals(SOF.SAMPLE_KEYWORD + suffix, SOF.extractString(meta.getMetaValue(MetaInfo.KEYWORDS)));
      }
   
  -   protected void setUp() throws Exception
  +   protected void tearDown() throws Exception
      {
  -      super.setUp();
         producer.reset();
  +      super.tearDown();
      }
   }
  
  
  
  1.1      date: 2006/08/08 04:29:27;  author: claprun;  state: Exp;jboss-portal/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MockHttpServletRequest.java
  
  Index: MockHttpServletRequest.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * 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.jboss.portal.test.wsrp.v1.consumer;
  
  import javax.servlet.http.HttpSession;
  import java.io.Serializable;
  import java.lang.reflect.InvocationHandler;
  import java.lang.reflect.Method;
  
  /**
   * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.test.wsrp.v1.consumer.MockHttpServletRequest">Chris
   *         Laprun</a>
   * @version $Revision: 1.1 $
   * @since 2.4
   */
  class MockHttpServletRequest implements InvocationHandler, Serializable
  {
     private HttpSession session;
  
     public MockHttpServletRequest(HttpSession session)
     {
        this.session = session;
     }
  
     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
     {
        String methodName = method.getName();
        if ("getSession".equals(methodName))
        {
           return session;
        }
        if ("getHeader".equals(methodName))
        {
           if ("User-Agent".equals(args[0]))
           {
              return "Mock Client User Agent";
           }
           return null;
        }
        if ("toString".equals(methodName))
        {
           return "MockHttpServletResponse";
        }
        throw new UnsupportedOperationException("MockHttpServletRequest does not support: " + method);
     }
  }
  
  
  
  1.1      date: 2006/08/08 04:29:27;  author: claprun;  state: Exp;jboss-portal/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/TestInvocationContext.java
  
  Index: TestInvocationContext.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * 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.jboss.portal.test.wsrp.v1.consumer;
  
  import org.jboss.portal.Mode;
  import org.jboss.portal.WindowState;
  import org.jboss.portal.common.MediaType;
  import org.jboss.portal.portlet.Parameters;
  import org.jboss.portal.portlet.PortletURL;
  import org.jboss.portal.portlet.StateString;
  import org.jboss.portal.portlet.impl.spi.AbstractInvocationContext;
  import org.jboss.portal.portlet.spi.ActionContext;
  import org.jboss.portal.portlet.spi.InvocationContext;
  import org.jboss.portal.portlet.spi.RenderContext;
  import org.jboss.portal.server.util.HTTPStreamInfo;
  import org.jboss.portal.wsrp.WSRPConstants;
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.http.HttpSession;
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStream;
  import java.lang.reflect.Proxy;
  
  /**
   * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.test.wsrp.v1.consumer.TestInvocationContext">Chris
   *         Laprun</a>
   * @version $Revision: 1.1 $
   * @since 2.4
   */
  class TestInvocationContext extends AbstractInvocationContext implements InvocationContext, RenderContext, ActionContext
  {
     String ns;
     HttpServletRequest mockRequest;
     HttpServletResponse mockResponse;
  
     public TestInvocationContext()
     {
        ClassLoader classLoader = getClass().getClassLoader();
        HttpSession session = (HttpSession)Proxy.newProxyInstance(classLoader, new Class[]{HttpSession.class},
           new MockHttpSession());
        mockRequest = (HttpServletRequest)Proxy.newProxyInstance(classLoader, new Class[]{HttpServletRequest.class},
           new MockHttpServletRequest(session));
        mockResponse = (HttpServletResponse)Proxy.newProxyInstance(classLoader, new Class[]{HttpServletResponse.class},
           new MockHttpServletResponse());
     }
  
     public StateString getNavigationalState()
     {
        return StateString.createFrom(ns);
     }
  
     public Mode getMode()
     {
        return Mode.VIEW;
     }
  
     public WindowState getWindowState()
     {
        return WindowState.MAXIMIZED;
     }
  
     public HTTPStreamInfo getStreamInfo()
     {
        return new HTTPStreamInfo(MediaType.HTML, WSRPConstants.DEFAULT_CHARACTER_SET);
     }
  
     public HttpServletRequest getClientRequest()
     {
        return mockRequest;
     }
  
     public HttpServletResponse getClientResponse()
     {
        return mockResponse;
     }
  
     public String encodeURL(String url)
     {
        return null;
     }
  
     public String encodeURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
     {
        return null;
     }
  
     public String getCharacterEncoding()
     {
        return null;
     }
  
     public int getContentLength()
     {
        return 0;
     }
  
     public BufferedReader getReader() throws IOException
     {
        return null;
     }
  
     public InputStream getInputStream() throws IOException
     {
        return null;
     }
  
     public String getContentType()
     {
        return null;
     }
  
     public StateString getInteractionState()
     {
        return null;
     }
  
     public Parameters getForm()
     {
        return null;
     }
  }
  
  
  
  1.1      date: 2006/08/08 04:29:27;  author: claprun;  state: Exp;jboss-portal/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MockHttpServletResponse.java
  
  Index: MockHttpServletResponse.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * 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.jboss.portal.test.wsrp.v1.consumer;
  
  import java.io.Serializable;
  import java.lang.reflect.InvocationHandler;
  import java.lang.reflect.Method;
  
  /**
   * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.test.wsrp.v1.consumer.MockHttpServletResponse">Chris
   *         Laprun</a>
   * @version $Revision: 1.1 $
   * @since 2.4
   */
  class MockHttpServletResponse implements InvocationHandler, Serializable
  {
     Object cookie;
  
     public MockHttpServletResponse()
     {
     }
  
     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
     {
        String methodName = method.getName();
        if ("addCookie".equals(methodName))
        {
           cookie = args[0];
           return null;
        }
        else if ("reset".equals(methodName))
        {
           cookie = null;
           return null;
        }
        else if ("toString".equals(methodName))
        {
           return "MockHttpServletResponse";
        }
        throw new UnsupportedOperationException("MockHttpServletResponse does not support: " + method);
     }
  }
  
  
  
  1.1      date: 2006/08/08 04:29:27;  author: claprun;  state: Exp;jboss-portal/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/BasicSecurityContext.java
  
  Index: BasicSecurityContext.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * 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.jboss.portal.test.wsrp.v1.consumer;
  
  import org.jboss.portal.portlet.support.spi.SecurityContextSupport;
  
  /**
   * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.test.wsrp.v1.consumer.BasicSecurityContext">Chris
   *         Laprun</a>
   * @version $Revision: 1.1 $
   * @since 2.4
   */
  class BasicSecurityContext extends SecurityContextSupport
  {
     public String getAuthType()
     {
        return null;
     }
  
     public boolean isSecure()
     {
        return false;
     }
  }
  
  
  
  1.1      date: 2006/08/08 04:29:27;  author: claprun;  state: Exp;jboss-portal/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/BasicInstanceContext.java
  
  Index: BasicInstanceContext.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * 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.jboss.portal.test.wsrp.v1.consumer;
  
  import org.jboss.portal.portlet.state.AccessMode;
  import org.jboss.portal.portlet.support.spi.InstanceContextSupport;
  
  /**
   * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.test.wsrp.v1.consumer.BasicInstanceContext">Chris
   *         Laprun</a>
   * @version $Revision: 1.1 $
   * @since 2.4
   */
  class BasicInstanceContext extends InstanceContextSupport
  {
     String id;
  
     public BasicInstanceContext(String id)
     {
        this.id = id;
     }
  
     public String getId()
     {
        return id;
     }
  
     public AccessMode getAccessMode()
     {
        return AccessMode.READ_ONLY;
     }
  }
  
  
  
  1.1      date: 2006/08/08 04:29:27;  author: claprun;  state: Exp;jboss-portal/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/BasicUserContext.java
  
  Index: BasicUserContext.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * 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.jboss.portal.test.wsrp.v1.consumer;
  
  import org.jboss.portal.portlet.support.spi.UserContextSupport;
  
  import java.util.Collections;
  import java.util.List;
  import java.util.Locale;
  
  /**
   * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.test.wsrp.v1.consumer.BasicUserContext">Chris
   *         Laprun</a>
   * @version $Revision: 1.1 $
   * @since 2.4
   */
  class BasicUserContext extends UserContextSupport
  {
  
     public String getId()
     {
        return null;
     }
  
     public Locale getLocale()
     {
        return Locale.ENGLISH;
     }
  
     public List getLocales()
     {
        return Collections.singletonList(getLocale());
     }
  }
  
  
  
  1.1      date: 2006/08/08 04:29:27;  author: claprun;  state: Exp;jboss-portal/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/MockHttpSession.java
  
  Index: MockHttpSession.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * 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.jboss.portal.test.wsrp.v1.consumer;
  
  import org.jboss.portal.common.util.Tools;
  
  import java.io.Serializable;
  import java.lang.reflect.InvocationHandler;
  import java.lang.reflect.Method;
  import java.util.HashMap;
  import java.util.Map;
  
  /**
   * @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.test.wsrp.v1.consumer.MockHttpSession">Chris
   *         Laprun</a>
   * @version $Revision: 1.1 $
   * @since 2.4
   */
  class MockHttpSession implements InvocationHandler, Serializable
  {
     private final Map map = new HashMap();
  
     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
     {
        String methodName = method.getName();
        if ("setAttribute".equals(methodName))
        {
           map.put(args[0], args[1]);
           return null;
        }
        else if ("removeAttribute".equals(methodName))
        {
           map.remove(args[0]);
           return null;
        }
        else if ("getAttribute".equals(methodName))
        {
           return map.get(args[0]);
        }
        else if ("getAttributeNames".equals(methodName))
        {
           return Tools.toEnumeration(map.keySet().iterator());
        }
        else if ("toString".equals(methodName))
        {
           return "MockHttpSession";
        }
        else
        {
           throw new UnsupportedOperationException("MockHttpSession does not support: " + method);
        }
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list