title: EasyMock - HttpSession Setting session - method pass via request
body: <p>I'm wondering on a request pass to a method and pulling the HttpSession?</p>
  
  <p>Following from JUnit:</p>
  
  <pre><code>@Test
  public void testSessionPass(){
      HttpServletRequest request = createMock(HttpServletRequest.class);
      HttpSession session = createMock(HttpSession.class);
      expect(session.getAttribute("testAttribute")).andReturn("testValue").anyTimes();
      replay(request);
      replay(session);
  
      CAction cAction = new CAction();
      cAction.test(request);
  
  
  }
  </code></pre>
  
  <p>In the CAction:</p>
  
  <pre><code> public void test (HttpServletRequest request){
          HttpSession session = request.getSession();
          if(session.getAttribute("testAttribute")!=null){
               System.out.println((String)session.getAttribute("testAttribute"));
          }
   }
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Why am I loosing the session from the passed request value at line HttpSession session = request.getSession();  ??</p>