Package org.strecks.interceptor

Examples of org.strecks.interceptor.BeforeInterceptor


  @Test
  public void testHandleWithInterceptors() throws Exception
  {

    ActionForward actionForward = new ActionForward();
    BeforeInterceptor before1 = createStrictMock(BeforeInterceptor.class);
    BeforeInterceptor before2 = createStrictMock(BeforeInterceptor.class);
    Collection<BeforeInterceptor> befores = new ArrayList<BeforeInterceptor>();
    befores.add(before1);
    befores.add(before2);

    BeforeInterceptor actionBefore1 = createStrictMock(BeforeInterceptor.class);
    BeforeInterceptor actionBefore2 = createStrictMock(BeforeInterceptor.class);
    List<BeforeInterceptor> actionBefores = new ArrayList<BeforeInterceptor>();
    actionBefores.add(actionBefore1);
    actionBefores.add(actionBefore2);

    AfterInterceptor after1 = createStrictMock(AfterInterceptor.class);
    AfterInterceptor after2 = createStrictMock(AfterInterceptor.class);
    Collection<AfterInterceptor> afters = new ArrayList<AfterInterceptor>();
    afters.add(after1);
    afters.add(after2);

    AfterInterceptor actionAfter1 = createStrictMock(AfterInterceptor.class);
    AfterInterceptor actionAfter2 = createStrictMock(AfterInterceptor.class);
    List<AfterInterceptor> actionAfters = new ArrayList<AfterInterceptor>();
    actionAfters.add(actionAfter1);
    actionAfters.add(actionAfter2);

    ControllerAction action = createStrictMock(ControllerAction.class);
    HttpServletRequest request = createStrictMock(HttpServletRequest.class);
    TestAction actionBean = createStrictMock(TestAction.class);
    ActionBeanSource beanSource = createStrictMock(ActionBeanSource.class);

    ActionContext actionContext = new TestContextImpl(request);

    // check the expected order of method invocation
    expect(action.getBeanSource()).andReturn(beanSource);
    expect(beanSource.createBean(actionContext)).andReturn(actionBean);
    action.preExecute(actionBean, actionContext);

    before1.beforeExecute(actionBean, actionContext);
    before2.beforeExecute(actionBean, actionContext);

    expect(action.getBeforeInterceptors()).andReturn(actionBefores);
    actionBefore1.beforeExecute(actionBean, actionContext);
    actionBefore2.beforeExecute(actionBean, actionContext);

    expect(action.executeController(actionBean, actionContext)).andReturn(
        new ActionForwardViewAdapter(actionForward));

    expect(action.getAfterInterceptors()).andReturn(actionAfters);
View Full Code Here


  @SuppressWarnings("unchecked")
  @Test
  public void testThrowOnBefore() throws Exception
  {

    BeforeInterceptor before1 = createStrictMock(BeforeInterceptor.class);
    BeforeInterceptor before2 = createStrictMock(BeforeInterceptor.class);
    Collection<BeforeInterceptor> befores = new ArrayList<BeforeInterceptor>();
    befores.add(before1);
    befores.add(before2);

    AfterInterceptor after1 = createStrictMock(AfterInterceptor.class);
View Full Code Here

    Assert.notNull(config);

    Set<String> beforeNames = config.getBeforeInterceptors();
    for (String className : beforeNames)
    {
      BeforeInterceptor interceptor = ReflectHelper.createInstance(className, BeforeInterceptor.class);
      beforeInterceptors.add(interceptor);
    }

    Set<String> afterNames = config.getAfterInterceptors();
    for (String className : afterNames)
View Full Code Here

  void readBeforeInterceptors(BeforeInterceptors interceptors, Class actionBeanClass)
  {
    Class[] classes = interceptors.classes();
    for (Class clazz : classes)
    {
      BeforeInterceptor instance = ReflectHelper.createInstance(clazz, BeforeInterceptor.class);
      addBeforeInterceptor(instance);
    }
  }
View Full Code Here

TOP

Related Classes of org.strecks.interceptor.BeforeInterceptor

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.