Examples of InterceptorMapping


Examples of com.opensymphony.xwork2.config.entities.InterceptorMapping

        ActionConfig testActionConfig = new ActionConfig.Builder("", "", TestAction.class.getName())
            .addResultConfig(new ResultConfig.Builder(Action.SUCCESS, ServletDispatcherResult.class.getName())
                    .addParam("location", "success.jsp")
                    .build())
            .addInterceptor(new InterceptorMapping("params", new ParametersInterceptor()))
            .build();


        ActionConfig tokenActionConfig = new ActionConfig.Builder("", "", TestAction.class.getName())
            .addInterceptor(new InterceptorMapping("token", new TokenInterceptor()))
            .addResultConfig(new ResultConfig.Builder("invalid.token", MockResult.class.getName()).build())
            .addResultConfig(new ResultConfig.Builder("success", MockResult.class.getName()).build())
            .build();


        // empty results for token session unit test
        ActionConfig tokenSessionActionConfig = new ActionConfig.Builder("", "", TestAction.class.getName())
            .addResultConfig(new ResultConfig.Builder("invalid.token", MockResult.class.getName()).build())
            .addResultConfig(new ResultConfig.Builder("success", MockResult.class.getName()).build())
            .addInterceptor(new InterceptorMapping("tokenSession", new TokenSessionStoreInterceptor()))
            .build();

        PackageConfig defaultPackageConfig = new PackageConfig.Builder("")
            .addActionConfig(EXECUTION_COUNT_ACTION_NAME, executionCountActionConfig)
            .addActionConfig(TEST_ACTION_NAME, testActionConfig)
View Full Code Here

Examples of com.opensymphony.xwork2.config.entities.InterceptorMapping

        defaultInterceptors.add(makeInterceptorConfig("interceptor-2"));
        defaultInterceptors.add(makeInterceptorConfig("interceptor-3"));

        //setup interceptor stacks
        List<InterceptorStackConfig> defaultInterceptorStacks = new ArrayList<InterceptorStackConfig>();
        InterceptorMapping interceptor1 = new InterceptorMapping("interceptor-1", new TestInterceptor());
        InterceptorMapping interceptor2 = new InterceptorMapping("interceptor-2", new TestInterceptor());
        defaultInterceptorStacks.add(makeInterceptorStackConfig("stack-1", interceptor1, interceptor2));

        //setup results
        ResultTypeConfig[] defaultResults = new ResultTypeConfig[]{new ResultTypeConfig.Builder("dispatcher",
                ServletDispatcherResult.class.getName()).defaultResultParam("location").build(),
View Full Code Here

Examples of com.opensymphony.xwork2.config.entities.InterceptorMapping

    private void verifyActionConfigInterceptors(PackageConfig pkgConfig, String actionName, String... refs) {
        ActionConfig ac = pkgConfig.getAllActionConfigs().get(actionName);
        assertNotNull(ac);
        List<InterceptorMapping> interceptorMappings = ac.getInterceptors();
        for (int i = 0; i < interceptorMappings.size(); i++) {
            InterceptorMapping interceptorMapping = interceptorMappings.get(i);
            assertEquals(refs[i], interceptorMapping.getName());
        }
    }
View Full Code Here

Examples of com.opensymphony.xwork2.config.entities.InterceptorMapping

      assertNotNull(actionOneInterceptors);
      assertNotNull(actionTwoInterceptors);
      assertEquals(actionOneInterceptors.size(), 3);
      assertEquals(actionTwoInterceptors.size(), 3);

      InterceptorMapping actionOneInterceptorMapping1 = (InterceptorMapping) actionOneInterceptors.get(0);
      InterceptorMapping actionOneInterceptorMapping2 = (InterceptorMapping) actionOneInterceptors.get(1);
      InterceptorMapping actionOneInterceptorMapping3 = (InterceptorMapping) actionOneInterceptors.get(2);
      InterceptorMapping actionTwoInterceptorMapping1 = (InterceptorMapping) actionTwoInterceptors.get(0);
      InterceptorMapping actionTwoInterceptorMapping2 = (InterceptorMapping) actionTwoInterceptors.get(1);
      InterceptorMapping actionTwoInterceptorMapping3 = (InterceptorMapping) actionTwoInterceptors.get(2);

      assertNotNull(actionOneInterceptorMapping1);
      assertNotNull(actionOneInterceptorMapping2);
      assertNotNull(actionOneInterceptorMapping3);
      assertNotNull(actionTwoInterceptorMapping1);
      assertNotNull(actionTwoInterceptorMapping2);
      assertNotNull(actionTwoInterceptorMapping3);


      assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping1.getInterceptor()).getParamOne(), "i1p1");
    assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping1.getInterceptor()).getParamTwo(), "i1p2");
    assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping2.getInterceptor()).getParamOne(), "i2p1");
    assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping2.getInterceptor()).getParamTwo(), null);
    assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping3.getInterceptor()).getParamOne(), null);
    assertEquals(((InterceptorForTestPurpose)actionOneInterceptorMapping3.getInterceptor()).getParamTwo(), null);

      assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping1.getInterceptor()).getParamOne(), null);
    assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping1.getInterceptor()).getParamTwo(), null);
    assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping2.getInterceptor()).getParamOne(), null);
    assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping2.getInterceptor()).getParamTwo(), "i2p2");
    assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping3.getInterceptor()).getParamOne(), "i3p1");
    assertEquals(((InterceptorForTestPurpose)actionTwoInterceptorMapping3.getInterceptor()).getParamTwo(), "i3p2");

    }
View Full Code Here

Examples of com.opensymphony.xwork2.config.entities.InterceptorMapping

    public void testInvoke() throws Exception {
        List<InterceptorMapping> interceptorMappings = new ArrayList<InterceptorMapping>();
        MockInterceptor mockInterceptor1 = new MockInterceptor();
        mockInterceptor1.setFoo("test1");
        mockInterceptor1.setExpectedFoo("test1");
        interceptorMappings.add(new InterceptorMapping("test1", mockInterceptor1));
        MockInterceptor mockInterceptor2 = new MockInterceptor();
        interceptorMappings.add(new InterceptorMapping("test2", mockInterceptor2));
        mockInterceptor2.setFoo("test2");
        mockInterceptor2.setExpectedFoo("test2");
        MockInterceptor mockInterceptor3 = new MockInterceptor();
        interceptorMappings.add(new InterceptorMapping("test3", mockInterceptor3));
        mockInterceptor3.setFoo("test3");
        mockInterceptor3.setExpectedFoo("test3");

        DefaultActionInvocation defaultActionInvocation = new DefaultActionInvocationTester(interceptorMappings);
        defaultActionInvocation.invoke();
View Full Code Here

Examples of com.opensymphony.xwork2.config.entities.InterceptorMapping

        successParams = new HashMap<String, String>();
        successParams.put("actionName", "bar");
        results.put("success", new ResultConfig.Builder("success", ActionChainResult.class.getName()).addParams(successParams).build());

        List<InterceptorMapping> interceptors = new ArrayList<InterceptorMapping>();
        interceptors.add(new InterceptorMapping("params", new ParametersInterceptor()));

        ActionConfig paramInterceptorActionConfig = new ActionConfig.Builder("defaultPackage", PARAM_INTERCEPTOR_ACTION_NAME, SimpleAction.class.getName())
            .addResultConfig(new ResultConfig.Builder(Action.ERROR, MockResult.class.getName()).build())
            .addInterceptors(interceptors)
            .build();
        defaultPackageContext.addActionConfig(PARAM_INTERCEPTOR_ACTION_NAME, paramInterceptorActionConfig);

        interceptors = new ArrayList<InterceptorMapping>();
        interceptors.add(new InterceptorMapping("model",
                objectFactory.buildInterceptor(new InterceptorConfig.Builder("model", ModelDrivenInterceptor.class.getName()).build(), EMPTY_STRING_MAP)));
        interceptors.add(new InterceptorMapping("params",
                objectFactory.buildInterceptor(new InterceptorConfig.Builder("model", ParametersInterceptor.class.getName()).build(), EMPTY_STRING_MAP)));

        ActionConfig modelParamActionConfig = new ActionConfig.Builder("defaultPackage", MODEL_DRIVEN_PARAM_TEST, ModelDrivenAction.class.getName())
            .addInterceptors(interceptors)
            .addResultConfig(new ResultConfig.Builder(Action.SUCCESS, MockResult.class.getName()).build())
            .build();
        defaultPackageContext.addActionConfig(MODEL_DRIVEN_PARAM_TEST, modelParamActionConfig);
       
        //List paramFilterInterceptor=new ArrayList();
        //paramFilterInterceptor.add(new ParameterFilterInterC)
        //ActionConfig modelParamFilterActionConfig = new ActionConfig(null, ModelDrivenAction.class, null, null, interceptors);
       

        results = new HashMap<String, ResultConfig>();
        successParams = new HashMap<String, String>();
        successParams.put("actionName", "bar");
        results.put("success", new ResultConfig.Builder("success", ActionChainResult.class.getName()).addParams(successParams).build());
        results.put(Action.ERROR, new ResultConfig.Builder(Action.ERROR, MockResult.class.getName()).build());

        interceptors = new ArrayList<InterceptorMapping>();
        interceptors.add(new InterceptorMapping("staticParams",
                objectFactory.buildInterceptor(new InterceptorConfig.Builder("model", StaticParametersInterceptor.class.getName()).build(), EMPTY_STRING_MAP)));
        interceptors.add(new InterceptorMapping("model",
                objectFactory.buildInterceptor(new InterceptorConfig.Builder("model", ModelDrivenInterceptor.class.getName()).build(), EMPTY_STRING_MAP)));
        interceptors.add(new InterceptorMapping("params",
                objectFactory.buildInterceptor(new InterceptorConfig.Builder("model", ParametersInterceptor.class.getName()).build(), EMPTY_STRING_MAP)));
        interceptors.add(new InterceptorMapping("validation",
                objectFactory.buildInterceptor(new InterceptorConfig.Builder("model", ValidationInterceptor.class.getName()).build(), EMPTY_STRING_MAP)));

        //Explicitly set an out-of-range date for DateRangeValidatorTest
        params = new HashMap<String, String>();
        ActionConfig validationActionConfig = new ActionConfig.Builder("defaultPackage", VALIDATION_ACTION_NAME, SimpleAction.class.getName())
View Full Code Here

Examples of com.opensymphony.xwork2.config.entities.InterceptorMapping

        assertNotNull(actionOneInterceptors);
        assertNotNull(actionTwoInterceptors);
        assertEquals(actionOneInterceptors.size(), 3);
        assertEquals(actionTwoInterceptors.size(), 3);

        InterceptorMapping actionOneInterceptorMapping1 = actionOneInterceptors.get(0);
        InterceptorMapping actionOneInterceptorMapping2 = actionOneInterceptors.get(1);
        InterceptorMapping actionOneInterceptorMapping3 = actionOneInterceptors.get(2);
        InterceptorMapping actionTwoInterceptorMapping1 = actionTwoInterceptors.get(0);
        InterceptorMapping actionTwoInterceptorMapping2 = actionTwoInterceptors.get(1);
        InterceptorMapping actionTwoInterceptorMapping3 = actionTwoInterceptors.get(2);

        assertNotNull(actionOneInterceptorMapping1);
        assertNotNull(actionOneInterceptorMapping2);
        assertNotNull(actionOneInterceptorMapping3);
        assertNotNull(actionTwoInterceptorMapping1);
        assertNotNull(actionTwoInterceptorMapping2);
        assertNotNull(actionTwoInterceptorMapping3);

        assertEquals(((InterceptorForTestPurpose) actionOneInterceptorMapping1.getInterceptor()).getParamOne(), "i1p1");
        assertEquals(((InterceptorForTestPurpose) actionOneInterceptorMapping1.getInterceptor()).getParamTwo(), "i1p2");
        assertEquals(((InterceptorForTestPurpose) actionOneInterceptorMapping2.getInterceptor()).getParamOne(), "i2p1");
        assertEquals(((InterceptorForTestPurpose) actionOneInterceptorMapping2.getInterceptor()).getParamTwo(), null);
        assertEquals(((InterceptorForTestPurpose) actionOneInterceptorMapping3.getInterceptor()).getParamOne(), null);
        assertEquals(((InterceptorForTestPurpose) actionOneInterceptorMapping3.getInterceptor()).getParamTwo(), null);

        assertEquals(((InterceptorForTestPurpose) actionTwoInterceptorMapping1.getInterceptor()).getParamOne(), null);
        assertEquals(((InterceptorForTestPurpose) actionTwoInterceptorMapping1.getInterceptor()).getParamTwo(), null);
        assertEquals(((InterceptorForTestPurpose) actionTwoInterceptorMapping2.getInterceptor()).getParamOne(), null);
        assertEquals(((InterceptorForTestPurpose) actionTwoInterceptorMapping2.getInterceptor()).getParamTwo(), "i2p2");
        assertEquals(((InterceptorForTestPurpose) actionTwoInterceptorMapping3.getInterceptor()).getParamOne(), "i3p1");
        assertEquals(((InterceptorForTestPurpose) actionTwoInterceptorMapping3.getInterceptor()).getParamTwo(), "i3p2");

    }
View Full Code Here

Examples of com.opensymphony.xwork2.config.entities.InterceptorMapping

                .methodName("do{2}")
                .addParams(params)
                .addExceptionMapping(new ExceptionMappingConfig.Builder("foo{1}", "java.lang.{2}Exception", "success{1}")
                    .addParams(new HashMap(params))
                    .build())
                .addInterceptor(new InterceptorMapping(null, null))
                .addResultConfig(new ResultConfig.Builder("success{1}", "foo.{2}").addParams(params).build())
                .build();
        map.put("foo/*/*", config);
       
        config = new ActionConfig.Builder("package-{1}", "bar/*/**", "bar")
View Full Code Here

Examples of com.opensymphony.xwork2.config.entities.InterceptorMapping

            parametersInterceptor = new ParametersInterceptor();
            PackageConfig wait = new PackageConfig.Builder("")
                .addActionConfig("action1", new ActionConfig.Builder("", "action1", ExecuteAndWaitDelayAction.class.getName())
                    .addResultConfig(new ResultConfig.Builder(Action.SUCCESS, MockResult.class.getName()).build())
                    .addResultConfig(new ResultConfig.Builder(ExecuteAndWaitInterceptor.WAIT, MockResult.class.getName()).build())
                    .addInterceptor(new InterceptorMapping("params", parametersInterceptor))
                    .addInterceptor(new InterceptorMapping("execAndWait", waitInterceptor))
                .build())
            .build();
            configuration.addPackageConfig("", wait);
        }
View Full Code Here

Examples of com.opensymphony.xwork2.config.entities.InterceptorMapping

    public void testInterceptorDestroy() throws Exception {          
        Mock mockInterceptor = new Mock(Interceptor.class);
        mockInterceptor.matchAndReturn("hashCode", 0);
        mockInterceptor.expect("destroy");
       
        InterceptorMapping interceptorMapping = new InterceptorMapping("test", (Interceptor) mockInterceptor.proxy());
       
        InterceptorStackConfig isc = new InterceptorStackConfig.Builder("test").addInterceptor(interceptorMapping).build();
       
        PackageConfig packageConfig = new PackageConfig.Builder("test").addInterceptorStackConfig(isc).build();
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.