Package org.strecks.injection.handler.impl

Examples of org.strecks.injection.handler.impl.RequestSessionAction


  @Test
  public void testAutoCreateSession()
  {

    InjectionAnnotationReader c = new InjectionAnnotationReader();
    RequestSessionAction action = new RequestSessionAction();

    c.readAnnotations(action.getClass());
    Map<String, InjectionWrapper> inputs = c.getInjectionMap();

    HttpServletRequest request = createMock(HttpServletRequest.class);
    HttpSession session = createNiceMock(HttpSession.class);

    expect(request.getSession(false)).andReturn(session);
    expect(session.getAttribute("autoCreateSession")).andReturn(null);

    replay(request);
    replay(session);

    InjectionWrapper inputWrapper = inputs.get("autoCreateSession");

    ActionContext injectionContext = new TestContextImpl(request);
    inputWrapper.inject(action, injectionContext);

    verify(request);
    verify(session);

    assert action.getAutoCreateSession() != null;
    assert action.getAutoCreateSession() instanceof QueryResults;

  }
View Full Code Here


  @Test
  public void testNonAutoCreateSession()
  {

    InjectionAnnotationReader c = new InjectionAnnotationReader();
    RequestSessionAction action = new RequestSessionAction();

    c.readAnnotations(action.getClass());
    Map<String, InjectionWrapper> inputs = c.getInjectionMap();

    HttpServletRequest request = EasyMock.createMock(HttpServletRequest.class);
    HttpSession session = EasyMock.createMock(HttpSession.class);

    expect(request.getSession(false)).andReturn(session);
    expect(session.getAttribute("nonAutoCreateSession")).andReturn(null);

    replay(request);
    replay(session);

    InjectionWrapper inputWrapper = inputs.get("nonAutoCreateSession");

    ActionContext injectionContext = new TestContextImpl(request);
    inputWrapper.inject(action, injectionContext);

    verify(request);
    verify(session);

    assert action.getAutoCreateSession() == null;

  }
View Full Code Here

  @Test
  public void testAutoCreateWithNoSession()
  {

    InjectionAnnotationReader c = new InjectionAnnotationReader();
    RequestSessionAction action = new RequestSessionAction();

    c.readAnnotations(action.getClass());
    Map<String, InjectionWrapper> inputs = c.getInjectionMap();

    HttpServletRequest request = EasyMock.createMock(HttpServletRequest.class);
    HttpSession session = EasyMock.createMock(HttpSession.class);

    expect(request.getSession(false)).andReturn(null);
    expect(request.getSession()).andReturn(session);
    session.setAttribute(eq("autoCreateSession"), anyObject());

    replay(request);
    replay(session);

    InjectionWrapper inputWrapper = inputs.get("autoCreateSession");

    ActionContext injectionContext = new TestContextImpl(request);
    inputWrapper.inject(action, injectionContext);

    verify(request);
    verify(session);

    assert action.getAutoCreateSession() != null;

  }
View Full Code Here

  @Test(expectedExceptions=StaleSessionException.class)
  public void testRequiredSession()
  {

    InjectionAnnotationReader c = new InjectionAnnotationReader();
    RequestSessionAction action = new RequestSessionAction();

    c.readAnnotations(action.getClass());
    Map<String, InjectionWrapper> inputs = c.getInjectionMap();

    HttpServletRequest request = EasyMock.createMock(HttpServletRequest.class);
    HttpSession session = EasyMock.createMock(HttpSession.class);
View Full Code Here

  @Test(expectedExceptions=StaleSessionException.class)
  public void testRequiredAutoCreateSession()
  {

    InjectionAnnotationReader c = new InjectionAnnotationReader();
    RequestSessionAction action = new RequestSessionAction();

    c.readAnnotations(action.getClass());
    Map<String, InjectionWrapper> inputs = c.getInjectionMap();

    HttpServletRequest request = EasyMock.createMock(HttpServletRequest.class);
    HttpSession session = EasyMock.createMock(HttpSession.class);
View Full Code Here

  @Test
  public void testAutoCreateRequest()
  {

    InjectionAnnotationReader c = new InjectionAnnotationReader();
    RequestSessionAction action = new RequestSessionAction();

    c.readAnnotations(action.getClass());
    Map<String, InjectionWrapper> inputs = c.getInjectionMap();

    HttpServletRequest request = EasyMock.createNiceControl().createMock(HttpServletRequest.class);

    expect(request.getAttribute("autoCreateRequest")).andReturn(null);

    replay(request);

    InjectionWrapper inputWrapper = inputs.get("autoCreateRequest");

    ActionContext injectionContext = new TestContextImpl(request);
    inputWrapper.inject(action, injectionContext);

    verify(request);

    assert action.getAutoCreateRequest() != null;
    assert action.getAutoCreateRequest() instanceof QueryResults;

  }
View Full Code Here

  @Test
  public void testNonAutoCreateRequest()
  {

    InjectionAnnotationReader c = new InjectionAnnotationReader();
    RequestSessionAction action = new RequestSessionAction();

    c.readAnnotations(action.getClass());
    Map<String, InjectionWrapper> inputs = c.getInjectionMap();

    HttpServletRequest request = EasyMock.createMock(HttpServletRequest.class);

    expect(request.getAttribute("nonAutoCreateRequest")).andReturn(null);

    replay(request);

    InjectionWrapper inputWrapper = inputs.get("nonAutoCreateRequest");

    ActionContext injectionContext = new TestContextImpl(request);
    inputWrapper.inject(action, injectionContext);

    verify(request);

    assert action.getAutoCreateRequest() == null;

  }
View Full Code Here

  @Test
  public void testRedirectParameter()
  {

    InjectionAnnotationReader c = new InjectionAnnotationReader();
    RequestSessionAction action = new RequestSessionAction();

    c.readAnnotations(action.getClass());
    Map<String, InjectionWrapper> inputs = c.getInjectionMap();

    HttpServletRequest request = EasyMock.createStrictMock(HttpServletRequest.class);
    HttpSession session = EasyMock.createStrictMock(HttpSession.class);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("redirectParam", new Integer(1));

    expect(request.getSession(false)).andReturn(session);
    expect(session.getAttribute(InfrastructureKeys.REDIRECT_PARAMETERS)).andReturn(map);

    replay(request);
    replay(session);

    InjectionWrapper inputWrapper = inputs.get("redirectParameter");

    ActionContext injectionContext = new TestContextImpl(request);
    inputWrapper.inject(action, injectionContext);

    verify(request);
    verify(session);

    assert action.getRedirectParameter() != null;

  }
View Full Code Here

  @Test
  public void testNoMap()
  {

    InjectionAnnotationReader c = new InjectionAnnotationReader();
    RequestSessionAction action = new RequestSessionAction();

    c.readAnnotations(action.getClass());
    Map<String, InjectionWrapper> inputs = c.getInjectionMap();

    HttpServletRequest request = EasyMock.createStrictMock(HttpServletRequest.class);
    HttpSession session = EasyMock.createStrictMock(HttpSession.class);

    expect(request.getSession(false)).andReturn(session);
    expect(session.getAttribute(InfrastructureKeys.REDIRECT_PARAMETERS)).andReturn(null);

    replay(request);
    replay(session);

    InjectionWrapper inputWrapper = inputs.get("redirectParameter");

    ActionContext injectionContext = new TestContextImpl(request);
    inputWrapper.inject(action, injectionContext);

    verify(request);
    verify(session);

    assert action.getRedirectParameter() == null;

  }
View Full Code Here

  @Test
  public void testNoSession()
  {

    InjectionAnnotationReader c = new InjectionAnnotationReader();
    RequestSessionAction action = new RequestSessionAction();

    c.readAnnotations(action.getClass());
    Map<String, InjectionWrapper> inputs = c.getInjectionMap();

    HttpServletRequest request = EasyMock.createStrictMock(HttpServletRequest.class);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("redirectParam", new Integer(1));

    expect(request.getSession(false)).andReturn(null);

    replay(request);

    InjectionWrapper inputWrapper = inputs.get("redirectParameter");

    ActionContext injectionContext = new TestContextImpl(request);
    inputWrapper.inject(action, injectionContext);

    verify(request);

    assert action.getRedirectParameter() == null;

  }
View Full Code Here

TOP

Related Classes of org.strecks.injection.handler.impl.RequestSessionAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.