コード例 #1
0
  @SuppressWarnings({"unchecked"})
  @Test
  public void testExpandStack2() {
    InjectorsManager injectorsManager = new InjectorsManager();
    injectorsManager.scopeDataResolver = new ScopeDataResolver();
    injectorsManager.madvocConfig = new MadvocConfig();
    injectorsManager.madpc = new PetiteContainer();
    injectorsManager.createInjectors();

    InterceptorsManager im = new InterceptorsManager();
    im.contextInjectorComponent = new ContextInjectorComponent();
    im.contextInjectorComponent.injectorsManager = injectorsManager;
    im.contextInjectorComponent.madvocController = new MadvocController();
    im.contextInjectorComponent.scopeDataResolver = injectorsManager.scopeDataResolver;
    im.contextInjectorComponent.madpc = injectorsManager.madpc;
    im.madvocConfig = injectorsManager.madvocConfig;
    im.madvocConfig.defaultInterceptors =
        new Class[] {EchoInterceptor.class, ServletConfigInterceptor.class, Test2Stack.class};

    Class<? extends ActionInterceptor>[] in =
        new Class[] {
          DefaultWebAppInterceptors.class,
        };

    Class<? extends ActionInterceptor>[] out = im.replaceSpecialActionWrapper(in);
    assertEquals(4, out.length);
    assertEquals(EchoInterceptor.class, out[0]);
    assertEquals(ServletConfigInterceptor.class, out[1]);

    assertEquals(AnnotatedPropertyInterceptor.class, out[2]);
    assertEquals(LogEchoInterceptor.class, out[3]);
  }
コード例 #2
0
  @SuppressWarnings({"unchecked"})
  @Test
  public void testExpandConfigurableStack() {
    InjectorsManager injectorsManager = new InjectorsManager();
    injectorsManager.scopeDataResolver = new ScopeDataResolver();
    injectorsManager.madvocConfig = new MadvocConfig();
    injectorsManager.madpc = new PetiteContainer();

    InterceptorsManager im = new InterceptorsManager();
    im.contextInjectorComponent = new ContextInjectorComponent();
    im.contextInjectorComponent.injectorsManager = injectorsManager;
    im.contextInjectorComponent.madvocController = new MadvocController();
    im.contextInjectorComponent.scopeDataResolver = injectorsManager.scopeDataResolver;
    im.contextInjectorComponent.madpc = injectorsManager.madpc;
    im.madvocConfig = injectorsManager.madvocConfig;
    im.madvocConfig.defaultInterceptors =
        new Class[] {EchoInterceptor.class, ServletConfigInterceptor.class};

    injectorsManager.madpc.defineParameter(
        TestConfigurableStack.class.getName() + ".interceptors",
        AnnotatedPropertyInterceptor.class.getName()
            + ","
            + ServletConfigInterceptor.class.getName()
            + ","
            + LogEchoInterceptor.class.getName());

    injectorsManager.createInjectors();

    Class<? extends ActionInterceptor>[] in =
        new Class[] {
          TestConfigurableStack.class, TestConfigurableStack2.class, EchoInterceptor.class
        };

    Class<? extends ActionInterceptor>[] out = im.replaceSpecialActionWrapper(in);
    assertEquals(6, out.length); // 3 + 2 + 1

    // assert: TestConfigurableStack => defined in madpc
    assertEquals(AnnotatedPropertyInterceptor.class, out[0]);
    assertEquals(ServletConfigInterceptor.class, out[1]);
    assertEquals(LogEchoInterceptor.class, out[2]);

    // assert: TestConfigurableStack2 => madvocConfig.defaultInterceptors
    assertEquals(EchoInterceptor.class, out[3]);
    assertEquals(ServletConfigInterceptor.class, out[4]);
    assertEquals(EchoInterceptor.class, out[5]);
  }