|
Struts example source code file (XmlConfigurationProviderActionsTest.java)
The Struts XmlConfigurationProviderActionsTest.java source code/* * Copyright 2002-2003,2009 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.opensymphony.xwork2.config.providers; import com.opensymphony.xwork2.ObjectFactory; import com.opensymphony.xwork2.SimpleAction; import com.opensymphony.xwork2.config.ConfigurationException; import com.opensymphony.xwork2.config.ConfigurationProvider; import com.opensymphony.xwork2.config.entities.*; import com.opensymphony.xwork2.interceptor.TimerInterceptor; import com.opensymphony.xwork2.mock.MockInterceptor; import com.opensymphony.xwork2.mock.MockResult; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author Mike * @author Rainer Hermanns */ public class XmlConfigurationProviderActionsTest extends ConfigurationTestBase { private List<InterceptorMapping> interceptors; private List<ExceptionMappingConfig> exceptionMappings; private Map<String, String> params; private Map<String, ResultConfig> results; private ObjectFactory objectFactory; public void testActions() throws Exception { final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-actions.xml"; ConfigurationProvider provider = buildConfigurationProvider(filename); // setup expectations // bar action is very simple, just two params params.put("foo", "17"); params.put("bar", "23"); params.put("testXW412", "foo.jspa?fooID=${fooID}&something=bar"); params.put("testXW412Again", "something"); ActionConfig barAction = new ActionConfig.Builder("", "Bar", SimpleAction.class.getName()) .addParams(params).build(); // foo action is a little more complex, two params, a result and an interceptor stack results = new HashMap<String, ResultConfig>(); params = new HashMap<String, String>(); params.put("foo", "18"); params.put("bar", "24"); results.put("success", new ResultConfig.Builder("success", MockResult.class.getName()).build()); InterceptorConfig timerInterceptorConfig = new InterceptorConfig.Builder("timer", TimerInterceptor.class.getName()).build(); interceptors.add(new InterceptorMapping("timer", objectFactory.buildInterceptor(timerInterceptorConfig, new HashMap<String, String>()))); ActionConfig fooAction = new ActionConfig.Builder("", "Foo", SimpleAction.class.getName()) .addParams(params) .addResultConfigs(results) .addInterceptors(interceptors) .build(); // wildcard action is simple wildcard example results = new HashMap<String, ResultConfig>(); results.put("*", new ResultConfig.Builder("*", MockResult.class.getName()).build()); ActionConfig wildcardAction = new ActionConfig.Builder("", "WildCard", SimpleAction.class.getName()) .addResultConfigs(results) .addInterceptors(interceptors) .build(); // fooBar action is a little more complex, two params, a result and an interceptor stack params = new HashMap<String, String>(); params.put("foo", "18"); params.put("bar", "24"); results = new HashMap<String, ResultConfig>(); results.put("success", new ResultConfig.Builder("success", MockResult.class.getName()).build()); ExceptionMappingConfig exceptionConfig = new ExceptionMappingConfig.Builder("runtime", "java.lang.RuntimeException", "exception") .build(); exceptionMappings.add(exceptionConfig); ActionConfig fooBarAction = new ActionConfig.Builder("", "FooBar", SimpleAction.class.getName()) .addParams(params) .addResultConfigs(results) .addInterceptors(interceptors) .addExceptionMappings(exceptionMappings) .build(); // TestInterceptorParam action tests that an interceptor worked HashMap<String, String> interceptorParams = new HashMap Other Struts examples (source code examples)Here is a short list of links related to this Struts XmlConfigurationProviderActionsTest.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.