You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2006/02/10 15:51:25 UTC
svn commit: r376715 - in
/struts/action/trunk/src/test/org/apache/struts/config:
TestActionConfig.java TestActionConfigMatcher.java TestFormBeanConfig.java
TestFormPropertyConfig.java TestForwardConfig.java TestModuleConfig.java
Author: husted
Date: Fri Feb 10 06:51:24 2006
New Revision: 376715
URL: http://svn.apache.org/viewcvs?rev=376715&view=rev
Log:
Checkstyle Roundup
* Action package reformatted with latest Jalopy settings. Stylistic changes only.
Modified:
struts/action/trunk/src/test/org/apache/struts/config/TestActionConfig.java
struts/action/trunk/src/test/org/apache/struts/config/TestActionConfigMatcher.java
struts/action/trunk/src/test/org/apache/struts/config/TestFormBeanConfig.java
struts/action/trunk/src/test/org/apache/struts/config/TestFormPropertyConfig.java
struts/action/trunk/src/test/org/apache/struts/config/TestForwardConfig.java
struts/action/trunk/src/test/org/apache/struts/config/TestModuleConfig.java
Modified: struts/action/trunk/src/test/org/apache/struts/config/TestActionConfig.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/test/org/apache/struts/config/TestActionConfig.java?rev=376715&r1=376714&r2=376715&view=diff
==============================================================================
--- struts/action/trunk/src/test/org/apache/struts/config/TestActionConfig.java (original)
+++ struts/action/trunk/src/test/org/apache/struts/config/TestActionConfig.java Fri Feb 10 06:51:24 2006
@@ -61,8 +61,7 @@
* Set up instance variables required by this test case.
*/
public void setUp() {
- ModuleConfigFactory factoryObject =
- ModuleConfigFactory.createFactory();
+ ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory();
config = factoryObject.createModuleConfig("");
@@ -72,8 +71,8 @@
baseConfig.setType("org.apache.struts.actions.DummyAction");
// set up success and failure forward
- ForwardConfig forward = new ForwardConfig("success", "/success.jsp",
- false);
+ ForwardConfig forward =
+ new ForwardConfig("success", "/success.jsp", false);
baseConfig.addForwardConfig(forward);
@@ -132,7 +131,7 @@
config.addActionConfig(grandChild);
assertTrue("Circular inheritance shouldn't have been detected",
- !grandChild.checkCircularInheritance(config));
+ !grandChild.checkCircularInheritance(config));
}
/**
@@ -156,7 +155,7 @@
config.addActionConfig(grandChild);
assertTrue("Circular inheritance should've been detected",
- grandChild.checkCircularInheritance(config));
+ grandChild.checkCircularInheritance(config));
}
/**
@@ -164,7 +163,7 @@
* extension has been processed.
*/
public void testProcessExtendsActionExtends()
- throws Exception {
+ throws Exception {
CustomActionConfig first = new CustomActionConfig();
first.setPath("/first");
@@ -183,9 +182,9 @@
baseConfig.processExtends(config);
assertTrue("The first action's processExtends() wasn't called",
- first.processExtendsCalled);
+ first.processExtendsCalled);
assertTrue("The second action's processExtends() wasn't called",
- second.processExtendsCalled);
+ second.processExtendsCalled);
}
/**
@@ -193,18 +192,16 @@
* found.
*/
public void testProcessExtendsMissingAction()
- throws Exception {
+ throws Exception {
baseConfig.setExtends("/someMissingAction");
try {
baseConfig.processExtends(config);
fail(
- "An exception should be thrown if a super form can't be found.");
- }
- catch (NullPointerException e) {
+ "An exception should be thrown if a super form can't be found.");
+ } catch (NullPointerException e) {
// succeed
- }
- catch (InstantiationException e) {
+ } catch (InstantiationException e) {
fail("Unrecognized exception thrown.");
}
}
@@ -215,7 +212,7 @@
* method checks all the subelements.
*/
public void testInheritFrom()
- throws Exception {
+ throws Exception {
// create a basic subform
ActionConfig subConfig = new ActionConfig();
String subConfigPath = "subConfig";
@@ -247,13 +244,13 @@
// check that our subConfig is still the one in the config
assertSame("subConfig no longer in ModuleConfig", subConfig,
- config.findActionConfig("subConfig"));
+ config.findActionConfig("subConfig"));
// check our configured sub config
assertNotNull("Action type was not inherited", subConfig.getType());
assertEquals("Wrong config path", subConfigPath, subConfig.getPath());
assertEquals("Wrong config type", baseConfig.getType(),
- subConfig.getType());
+ subConfig.getType());
// check our forwards
ForwardConfig[] forwards = subConfig.findForwardConfigs();
@@ -263,7 +260,7 @@
forward = subConfig.findForwardConfig("success");
assertNotNull("'success' forward was not found", forward);
assertEquals("Wrong path for success", "/newSuccess.jsp",
- forward.getPath());
+ forward.getPath());
forward = subConfig.findForwardConfig("failure");
@@ -271,10 +268,10 @@
assertNotNull("'failure' forward was not inherited", forward);
assertEquals("Wrong type for 'failure'", origForward.getPath(),
- forward.getPath());
+ forward.getPath());
assertEquals("Arbitrary property not copied",
- origForward.getProperty("forwardCount"),
- forward.getProperty("forwardCount"));
+ origForward.getProperty("forwardCount"),
+ forward.getProperty("forwardCount"));
// check our exceptions
ExceptionConfig[] handlers = subConfig.findExceptionConfigs();
@@ -283,30 +280,30 @@
handler = subConfig.findExceptionConfig("java.sql.SQLException");
- ExceptionConfig origHandler = baseConfig.findExceptionConfig(
- "java.sql.SQLException");
+ ExceptionConfig origHandler =
+ baseConfig.findExceptionConfig("java.sql.SQLException");
assertNotNull("'SQLException' handler was not found", handler);
assertEquals("Wrong key for 'SQLException'", origHandler.getKey(),
- handler.getKey());
+ handler.getKey());
assertEquals("Arbitrary property not copied",
- origHandler.getProperty("exceptionCount"),
- handler.getProperty("exceptionCount"));
+ origHandler.getProperty("exceptionCount"),
+ handler.getProperty("exceptionCount"));
- handler = subConfig.findExceptionConfig(
- "java.lang.NullPointerException");
+ handler =
+ subConfig.findExceptionConfig("java.lang.NullPointerException");
assertNotNull("'NullPointerException' handler disappeared", handler);
// check the arbitrary properties
String version = subConfig.getProperty("version");
assertEquals("Arbitrary property 'version' wasn't inherited", "1a",
- version);
+ version);
String label = subConfig.getProperty("label");
assertEquals("Arbitrary property 'label' shouldn't have changed",
- "sub", label);
+ "sub", label);
}
/**
@@ -316,7 +313,7 @@
boolean processExtendsCalled = false;
public void processExtends(ModuleConfig moduleConfig)
- throws ClassNotFoundException, IllegalAccessException,
+ throws ClassNotFoundException, IllegalAccessException,
InstantiationException, InvocationTargetException {
super.processExtends(moduleConfig);
processExtendsCalled = true;
Modified: struts/action/trunk/src/test/org/apache/struts/config/TestActionConfigMatcher.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/test/org/apache/struts/config/TestActionConfigMatcher.java?rev=376715&r1=376714&r2=376715&view=diff
==============================================================================
--- struts/action/trunk/src/test/org/apache/struts/config/TestActionConfigMatcher.java (original)
+++ struts/action/trunk/src/test/org/apache/struts/config/TestActionConfigMatcher.java Fri Feb 10 06:51:24 2006
@@ -19,6 +19,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.mock.TestMockBase;
@@ -36,9 +37,9 @@
}
public static void main(String[] args) {
- junit.awtui.TestRunner.main(new String[]{
+ junit.awtui.TestRunner.main(new String[] {
TestActionConfigMatcher.class.getName()
- });
+ });
}
public static Test suite() {
@@ -65,8 +66,7 @@
ActionConfigMatcher matcher = new ActionConfigMatcher(configs);
- assertNull("ActionConfig shouldn't be matched",
- matcher.match("/test"));
+ assertNull("ActionConfig shouldn't be matched", matcher.match("/test"));
}
public void testNoWildcardMatch() {
@@ -77,8 +77,7 @@
ActionConfigMatcher matcher = new ActionConfigMatcher(configs);
- assertNull("ActionConfig shouldn't be matched",
- matcher.match("/fooBar"));
+ assertNull("ActionConfig shouldn't be matched", matcher.match("/fooBar"));
}
public void testShouldMatch() {
@@ -93,11 +92,11 @@
assertNotNull("ActionConfig should be matched", matched);
assertTrue("ActionConfig should have two action forward",
- matched.findForwardConfigs().length == 2);
+ matched.findForwardConfigs().length == 2);
assertTrue("ActionConfig should have two exception forward",
- matched.findExceptionConfigs().length == 2);
+ matched.findExceptionConfigs().length == 2);
assertTrue("ActionConfig should have properties",
- matched.getProperties().size() == 2);
+ matched.getProperties().size() == 2);
}
public void testCheckSubstitutionsMatch() {
@@ -109,35 +108,33 @@
ActionConfigMatcher matcher = new ActionConfigMatcher(configs);
ActionConfig m = matcher.match("/fooBar");
- assertTrue("Name hasn't been replaced",
- "name,Bar".equals(m.getName()));
- assertTrue("Path hasn't been replaced",
- "/fooBar".equals(m.getPath()));
+ assertTrue("Name hasn't been replaced", "name,Bar".equals(m.getName()));
+ assertTrue("Path hasn't been replaced", "/fooBar".equals(m.getPath()));
assertTrue("Scope isn't correct", "request".equals(m.getScope()));
assertTrue("Unknown isn't correct", !m.getUnknown());
assertTrue("Validate isn't correct", m.getValidate());
assertTrue("Prefix hasn't been replaced",
- "foo,Bar".equals(m.getPrefix()));
+ "foo,Bar".equals(m.getPrefix()));
assertTrue("Suffix hasn't been replaced",
- "bar,Bar".equals(m.getSuffix()));
+ "bar,Bar".equals(m.getSuffix()));
assertTrue("Type hasn't been replaced",
- "foo.bar.BarAction".equals(m.getType()));
+ "foo.bar.BarAction".equals(m.getType()));
assertTrue("Roles hasn't been replaced",
- "public,Bar".equals(m.getRoles()));
+ "public,Bar".equals(m.getRoles()));
assertTrue("Parameter hasn't been replaced",
- "param,Bar".equals(m.getParameter()));
+ "param,Bar".equals(m.getParameter()));
assertTrue("Attribute hasn't been replaced",
- "attrib,Bar".equals(m.getAttribute()));
+ "attrib,Bar".equals(m.getAttribute()));
assertTrue("Forward hasn't been replaced",
- "fwd,Bar".equals(m.getForward()));
+ "fwd,Bar".equals(m.getForward()));
assertTrue("Include hasn't been replaced",
- "include,Bar".equals(m.getInclude()));
+ "include,Bar".equals(m.getInclude()));
assertTrue("Input hasn't been replaced",
- "input,Bar".equals(m.getInput()));
+ "input,Bar".equals(m.getInput()));
assertTrue("ActionConfig property not replaced",
- "testBar".equals(m.getProperty("testprop2")));
+ "testBar".equals(m.getProperty("testprop2")));
ForwardConfig[] fConfigs = m.findForwardConfigs();
boolean found = false;
@@ -148,9 +145,9 @@
if ("name".equals(cfg.getName())) {
found = true;
assertTrue("Path hasn't been replaced",
- "path,Bar".equals(cfg.getPath()));
+ "path,Bar".equals(cfg.getPath()));
assertTrue("Property foo hasn't been replaced",
- "bar,Bar".equals(cfg.getProperty("foo")));
+ "bar,Bar".equals(cfg.getProperty("foo")));
}
}
@@ -168,7 +165,7 @@
ActionConfig m = matcher.match("/fooBar");
assertTrue("Name hasn't been replaced correctly: " + m.getName(),
- "name,Bar-Bar".equals(m.getName()));
+ "name,Bar-Bar".equals(m.getName()));
}
private ActionConfig buildActionConfig(String path) {
Modified: struts/action/trunk/src/test/org/apache/struts/config/TestFormBeanConfig.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/test/org/apache/struts/config/TestFormBeanConfig.java?rev=376715&r1=376714&r2=376715&view=diff
==============================================================================
--- struts/action/trunk/src/test/org/apache/struts/config/TestFormBeanConfig.java (original)
+++ struts/action/trunk/src/test/org/apache/struts/config/TestFormBeanConfig.java Fri Feb 10 06:51:24 2006
@@ -61,8 +61,7 @@
* Set up instance variables required by this test case.
*/
public void setUp() {
- ModuleConfigFactory factoryObject =
- ModuleConfigFactory.createFactory();
+ ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory();
config = factoryObject.createModuleConfig("");
@@ -133,7 +132,7 @@
config.addFormBeanConfig(grandChild);
assertTrue("Circular inheritance shouldn't have been detected",
- !grandChild.checkCircularInheritance(config));
+ !grandChild.checkCircularInheritance(config));
}
/**
@@ -157,7 +156,7 @@
config.addFormBeanConfig(grandChild);
assertTrue("Circular inheritance should've been detected",
- grandChild.checkCircularInheritance(config));
+ grandChild.checkCircularInheritance(config));
}
/**
@@ -165,7 +164,7 @@
* has been processed.
*/
public void testProcessExtendsBaseFormExtends()
- throws Exception {
+ throws Exception {
CustomFormBeanConfig first = new CustomFormBeanConfig();
first.setName("first");
@@ -184,9 +183,9 @@
baseForm.processExtends(config);
assertTrue("The first form's processExtends() wasn't called",
- first.processExtendsCalled);
+ first.processExtendsCalled);
assertTrue("The second form's processExtends() wasn't called",
- second.processExtendsCalled);
+ second.processExtendsCalled);
}
/**
@@ -194,18 +193,16 @@
* found.
*/
public void testProcessExtendsMissingBaseForm()
- throws Exception {
+ throws Exception {
baseForm.setExtends("someMissingForm");
try {
baseForm.processExtends(config);
fail(
- "An exception should be thrown if a super form can't be found.");
- }
- catch (NullPointerException e) {
+ "An exception should be thrown if a super form can't be found.");
+ } catch (NullPointerException e) {
// succeed
- }
- catch (InstantiationException e) {
+ } catch (InstantiationException e) {
fail("Unrecognized exception thrown.");
}
}
@@ -216,7 +213,7 @@
* all the properties.
*/
public void testInheritFrom()
- throws Exception {
+ throws Exception {
// give baseForm some arbitrary parameters
String baseFormCount = "1";
@@ -256,18 +253,18 @@
// check that our subForm is still the one in the config
assertSame("subForm no longer in ModuleConfig", subForm,
- config.findFormBeanConfig("subForm"));
+ config.findFormBeanConfig("subForm"));
// check our configured sub form
assertNotNull("Form bean type was not inherited", subForm.getType());
assertEquals("Wrong form bean name", subFormName, subForm.getName());
assertEquals("Wrong form bean type", baseForm.getType(),
- subForm.getType());
+ subForm.getType());
assertEquals("Wrong restricted value", baseForm.isRestricted(),
- subForm.isRestricted());
+ subForm.isRestricted());
- FormPropertyConfig[] formPropertyConfigs = subForm
- .findFormPropertyConfigs();
+ FormPropertyConfig[] formPropertyConfigs =
+ subForm.findFormPropertyConfigs();
assertEquals("Wrong prop count", 4, formPropertyConfigs.length);
@@ -279,51 +276,49 @@
assertNotNull("'name' property was not inherited", property);
assertEquals("Wrong type for name", original.getType(),
- property.getType());
+ property.getType());
assertEquals("Wrong initial value for name", original.getInitial(),
- property.getInitial());
+ property.getInitial());
assertEquals("Wrong size value for name", original.getSize(),
- property.getSize());
+ property.getSize());
property = subForm.findFormPropertyConfig("id");
original = baseForm.findFormPropertyConfig("id");
assertNotNull("'id' property was not found", property);
- assertEquals("Wrong type for id",
- original.getType(),
- property.getType());
+ assertEquals("Wrong type for id", original.getType(), property.getType());
assertEquals("Wrong initial value for id", "unknown",
- property.getInitial());
+ property.getInitial());
assertEquals("Wrong size value for id", original.getSize(),
- property.getSize());
+ property.getSize());
property = subForm.findFormPropertyConfig("score");
original = baseForm.findFormPropertyConfig("score");
assertNotNull("'score' property was not found", property);
assertEquals("Wrong type for score", "java.lang.Integer",
- property.getType());
+ property.getType());
assertEquals("Wrong initial value for score", original.getInitial(),
- property.getInitial());
+ property.getInitial());
assertEquals("Wrong size value for score", original.getSize(),
- property.getSize());
+ property.getSize());
property = subForm.findFormPropertyConfig("message");
original = baseForm.findFormPropertyConfig("message");
assertNotNull("'message' property was not found", property);
assertEquals("Wrong type for message", original.getType(),
- property.getType());
+ property.getType());
assertEquals("Wrong initial value for message", original.getInitial(),
- property.getInitial());
+ property.getInitial());
assertEquals("Wrong size value for message", 10, property.getSize());
property = subForm.findFormPropertyConfig("name");
original = baseForm.findFormPropertyConfig("name");
assertEquals("Arbitrary property not found",
- original.getProperty("count"), property.getProperty("count"));
+ original.getProperty("count"), property.getProperty("count"));
String count = subForm.getProperty("count");
assertEquals("Arbitrary property was not inherited", baseFormCount,
- count);
+ count);
}
/**
@@ -333,7 +328,7 @@
boolean processExtendsCalled = false;
public void processExtends(ModuleConfig moduleConfig)
- throws ClassNotFoundException, IllegalAccessException,
+ throws ClassNotFoundException, IllegalAccessException,
InstantiationException, InvocationTargetException {
super.processExtends(moduleConfig);
processExtendsCalled = true;
Modified: struts/action/trunk/src/test/org/apache/struts/config/TestFormPropertyConfig.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/test/org/apache/struts/config/TestFormPropertyConfig.java?rev=376715&r1=376714&r2=376715&view=diff
==============================================================================
--- struts/action/trunk/src/test/org/apache/struts/config/TestFormPropertyConfig.java (original)
+++ struts/action/trunk/src/test/org/apache/struts/config/TestFormPropertyConfig.java Fri Feb 10 06:51:24 2006
@@ -28,9 +28,9 @@
*/
public class TestFormPropertyConfig extends TestCase {
public void testBasicInherit()
- throws Exception {
- FormPropertyConfig base = new FormPropertyConfig("base",
- "java.lang.String[]", "", 10);
+ throws Exception {
+ FormPropertyConfig base =
+ new FormPropertyConfig("base", "java.lang.String[]", "", 10);
String baseCount = "10";
base.setProperty("count", baseCount);
@@ -42,18 +42,16 @@
sub.inheritFrom(base);
assertEquals("Type was not inherited", base.getType(), sub.getType());
- assertEquals("Initial is incorrect",
- base.getInitial(),
- sub.getInitial());
+ assertEquals("Initial is incorrect", base.getInitial(), sub.getInitial());
assertEquals("Size was not inherited", base.getSize(), sub.getSize());
assertEquals("Arbitrary config property was not inherited", baseCount,
- sub.getProperty("count"));
+ sub.getProperty("count"));
}
public void testInheritWithInitialOverride()
- throws Exception {
- FormPropertyConfig base = new FormPropertyConfig("base",
- "java.lang.String", "value");
+ throws Exception {
+ FormPropertyConfig base =
+ new FormPropertyConfig("base", "java.lang.String", "value");
FormPropertyConfig sub = new FormPropertyConfig();
@@ -71,9 +69,9 @@
}
public void testInheritWithTypeOverride()
- throws Exception {
- FormPropertyConfig base = new FormPropertyConfig("base",
- "java.lang.String", "");
+ throws Exception {
+ FormPropertyConfig base =
+ new FormPropertyConfig("base", "java.lang.String", "");
FormPropertyConfig sub = new FormPropertyConfig();
@@ -83,16 +81,14 @@
sub.inheritFrom(base);
assertEquals("Type is incorrect", "java.lang.Integer", sub.getType());
- assertEquals("Initial is incorrect",
- base.getInitial(),
- sub.getInitial());
+ assertEquals("Initial is incorrect", base.getInitial(), sub.getInitial());
assertEquals("Size is incorrect", base.getSize(), sub.getSize());
}
public void testInheritWithTypeOverride2()
- throws Exception {
- FormPropertyConfig base = new FormPropertyConfig("base",
- "java.lang.String", "");
+ throws Exception {
+ FormPropertyConfig base =
+ new FormPropertyConfig("base", "java.lang.String", "");
FormPropertyConfig sub = new FormPropertyConfig();
@@ -107,16 +103,14 @@
sub.inheritFrom(base);
assertEquals("Type is incorrect", type, sub.getType());
- assertEquals("Initial is incorrect",
- base.getInitial(),
- sub.getInitial());
+ assertEquals("Initial is incorrect", base.getInitial(), sub.getInitial());
assertEquals("Size is incorrect", size, sub.getSize());
}
public void testInheritWithSizeOverride()
- throws Exception {
- FormPropertyConfig base = new FormPropertyConfig("base",
- "java.lang.String[]", "", 20);
+ throws Exception {
+ FormPropertyConfig base =
+ new FormPropertyConfig("base", "java.lang.String[]", "", 20);
FormPropertyConfig sub = new FormPropertyConfig();
@@ -129,9 +123,7 @@
sub.inheritFrom(base);
assertEquals("Type was not inherited", base.getType(), sub.getType());
- assertEquals("Initial is incorrect",
- base.getInitial(),
- sub.getInitial());
+ assertEquals("Initial is incorrect", base.getInitial(), sub.getInitial());
assertEquals("Size is incorrect", size, sub.getSize());
}
}
Modified: struts/action/trunk/src/test/org/apache/struts/config/TestForwardConfig.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/test/org/apache/struts/config/TestForwardConfig.java?rev=376715&r1=376714&r2=376715&view=diff
==============================================================================
--- struts/action/trunk/src/test/org/apache/struts/config/TestForwardConfig.java (original)
+++ struts/action/trunk/src/test/org/apache/struts/config/TestForwardConfig.java Fri Feb 10 06:51:24 2006
@@ -75,8 +75,7 @@
* Set up instance variables required by this test case.
*/
public void setUp() {
- ModuleConfigFactory factoryObject =
- ModuleConfigFactory.createFactory();
+ ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory();
moduleConfig = factoryObject.createModuleConfig("");
@@ -129,7 +128,7 @@
moduleConfig.addForwardConfig(baseConfig);
boolean result =
- baseConfig.checkCircularInheritance(moduleConfig, null);
+ baseConfig.checkCircularInheritance(moduleConfig, null);
assertTrue("Incorrect result", !result);
}
@@ -142,8 +141,7 @@
moduleConfig.addForwardConfig(baseConfig);
moduleConfig.addForwardConfig(subConfig);
- boolean result =
- subConfig.checkCircularInheritance(moduleConfig, null);
+ boolean result = subConfig.checkCircularInheritance(moduleConfig, null);
assertTrue("Incorrect result", !result);
}
@@ -159,8 +157,7 @@
// set the baseConfig to extend subConfig
baseConfig.setExtends("subConfig");
- boolean result =
- subConfig.checkCircularInheritance(moduleConfig, null);
+ boolean result = subConfig.checkCircularInheritance(moduleConfig, null);
assertTrue("Circular inheritance not detected.", result);
}
@@ -195,8 +192,8 @@
actionConfig.addForwardConfig(baseConfig);
actionConfig.addForwardConfig(subConfig);
- boolean result = subConfig.checkCircularInheritance(moduleConfig,
- actionConfig);
+ boolean result =
+ subConfig.checkCircularInheritance(moduleConfig, actionConfig);
assertTrue("Incorrect result", !result);
}
@@ -212,8 +209,8 @@
// set base to extend sub
baseConfig.setExtends("subConfig");
- boolean result = subConfig.checkCircularInheritance(moduleConfig,
- actionConfig);
+ boolean result =
+ subConfig.checkCircularInheritance(moduleConfig, actionConfig);
assertTrue("Circular inheritance not detected.", result);
}
@@ -226,8 +223,8 @@
actionConfig.addForwardConfig(subConfig);
moduleConfig.addForwardConfig(baseConfig);
- boolean result = subConfig.checkCircularInheritance(moduleConfig,
- actionConfig);
+ boolean result =
+ subConfig.checkCircularInheritance(moduleConfig, actionConfig);
assertTrue("Incorrect result", !result);
}
@@ -242,8 +239,7 @@
actionConfig.addForwardConfig(actionBaseConfig);
boolean result =
- actionBaseConfig.checkCircularInheritance(moduleConfig,
- actionConfig);
+ actionBaseConfig.checkCircularInheritance(moduleConfig, actionConfig);
assertTrue("Incorrect result", !result);
}
@@ -253,16 +249,15 @@
* configured.
*/
public void testProcessExtendsConfigured()
- throws Exception {
+ throws Exception {
baseConfig.configured = true;
moduleConfig.addForwardConfig(baseConfig);
try {
baseConfig.processExtends(moduleConfig, null);
fail(
- "processExtends should not succeed when object is already configured");
- }
- catch (IllegalStateException e) {
+ "processExtends should not succeed when object is already configured");
+ } catch (IllegalStateException e) {
// success
}
}
@@ -271,7 +266,7 @@
* Test processExtends() when nothing is extended.
*/
public void testProcessExtendsNoExtension()
- throws Exception {
+ throws Exception {
String path = baseConfig.getPath();
String module = baseConfig.getModule();
String name = baseConfig.getName();
@@ -281,25 +276,21 @@
moduleConfig.addForwardConfig(baseConfig);
baseConfig.processExtends(moduleConfig, null);
- assertEquals("Path shouldn't have changed",
- path,
- baseConfig.getPath());
+ assertEquals("Path shouldn't have changed", path, baseConfig.getPath());
assertEquals("Module shouldn't have changed", module,
- baseConfig.getModule());
- assertEquals("Name shouldn't have changed",
- name,
- baseConfig.getName());
+ baseConfig.getModule());
+ assertEquals("Name shouldn't have changed", name, baseConfig.getName());
assertEquals("Extends shouldn't have changed", inherit,
- baseConfig.getExtends());
+ baseConfig.getExtends());
assertEquals("Redirect shouldn't have changed", redirect,
- baseConfig.getRedirect());
+ baseConfig.getRedirect());
}
/**
* Test processExtends() with a basic extension.
*/
public void testProcessExtendsBasicExtension()
- throws Exception {
+ throws Exception {
String baseCount = "10";
baseConfig.setProperty("count", baseCount);
@@ -324,20 +315,16 @@
subConfig.processExtends(moduleConfig, null);
assertEquals("Path wasn't inherited", path, subConfig.getPath());
- assertEquals("Module wasn't inherited",
- module,
- subConfig.getModule());
- assertEquals("Name shouldn't have changed",
- name,
- subConfig.getName());
+ assertEquals("Module wasn't inherited", module, subConfig.getModule());
+ assertEquals("Name shouldn't have changed", name, subConfig.getName());
assertEquals("Extends shouldn't have changed", inherit,
- subConfig.getExtends());
+ subConfig.getExtends());
assertEquals("Redirect shouldn't have changed", redirect,
- subConfig.getRedirect());
+ subConfig.getRedirect());
assertEquals("Arbitrary config property was not inherited", baseCount,
- subConfig.getProperty("count"));
+ subConfig.getProperty("count"));
assertEquals("Overridden config property was not retained", subLabel,
- subConfig.getProperty("label"));
+ subConfig.getProperty("label"));
}
/**
@@ -345,7 +332,7 @@
* and a global config.
*/
public void testProcessExtendsBasicGlobalExtension()
- throws Exception {
+ throws Exception {
String path = baseConfig.getPath();
String module = baseConfig.getModule();
@@ -358,16 +345,12 @@
subConfig.processExtends(moduleConfig, actionConfig);
assertEquals("Path wasn't inherited", path, subConfig.getPath());
- assertEquals("Module wasn't inherited",
- module,
- subConfig.getModule());
- assertEquals("Name shouldn't have changed",
- name,
- subConfig.getName());
+ assertEquals("Module wasn't inherited", module, subConfig.getModule());
+ assertEquals("Name shouldn't have changed", name, subConfig.getName());
assertEquals("Extends shouldn't have changed", inherit,
- subConfig.getExtends());
+ subConfig.getExtends());
assertEquals("Redirect shouldn't have changed", redirect,
- subConfig.getRedirect());
+ subConfig.getRedirect());
}
/**
@@ -375,16 +358,15 @@
* attempts to extend an action config.
*/
public void testProcessExtendsGlobalExtendingAction()
- throws Exception {
+ throws Exception {
moduleConfig.addForwardConfig(subConfig);
actionConfig.addForwardConfig(baseConfig);
try {
subConfig.processExtends(moduleConfig, actionConfig);
fail(
- "Should not find config from actionConfig when *this* is global");
- }
- catch (NullPointerException npe) {
+ "Should not find config from actionConfig when *this* is global");
+ } catch (NullPointerException npe) {
// succeed
}
}
@@ -394,7 +376,7 @@
* config with the same name.
*/
public void testProcessExtendsSameNames()
- throws Exception {
+ throws Exception {
String path = baseConfig.getPath();
boolean redirect = baseConfig.getRedirect();
@@ -407,17 +389,15 @@
actionBaseConfig.processExtends(moduleConfig, actionConfig);
- assertEquals("Path wasn't inherited",
- path,
- actionBaseConfig.getPath());
+ assertEquals("Path wasn't inherited", path, actionBaseConfig.getPath());
assertEquals("Module shouldn't have changed", module,
- actionBaseConfig.getModule());
+ actionBaseConfig.getModule());
assertEquals("Name shouldn't have changed", name,
- actionBaseConfig.getName());
+ actionBaseConfig.getName());
assertEquals("Extends shouldn't have changed", inherit,
- actionBaseConfig.getExtends());
+ actionBaseConfig.getExtends());
assertEquals("Redirect shouldn't have changed", redirect,
- actionBaseConfig.getRedirect());
+ actionBaseConfig.getRedirect());
}
/**
@@ -426,7 +406,7 @@
* same name.
*/
public void testProcessExtendsActionExtendsActionExtendsGlobalWithSameName()
- throws Exception {
+ throws Exception {
String path = baseConfig.getPath();
String module = actionBaseConfig.getModule();
@@ -442,20 +422,16 @@
subConfig.processExtends(moduleConfig, actionConfig);
assertTrue("baseConfig's processExtends() should've been called",
- baseConfig.extensionProcessed);
+ baseConfig.extensionProcessed);
assertTrue("actionBaseConfig's processExtends() should've been called",
- actionBaseConfig.extensionProcessed);
+ actionBaseConfig.extensionProcessed);
assertEquals("Path wasn't inherited", path, subConfig.getPath());
- assertEquals("Module wasn't inherited",
- module,
- subConfig.getModule());
- assertEquals("Name shouldn't have changed",
- name,
- subConfig.getName());
+ assertEquals("Module wasn't inherited", module, subConfig.getModule());
+ assertEquals("Name shouldn't have changed", name, subConfig.getName());
assertEquals("Extends shouldn't have changed", inherit,
- subConfig.getExtends());
+ subConfig.getExtends());
assertEquals("Redirect shouldn't have changed", redirect,
- subConfig.getRedirect());
+ subConfig.getRedirect());
}
}
Modified: struts/action/trunk/src/test/org/apache/struts/config/TestModuleConfig.java
URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/test/org/apache/struts/config/TestModuleConfig.java?rev=376715&r1=376714&r2=376715&view=diff
==============================================================================
--- struts/action/trunk/src/test/org/apache/struts/config/TestModuleConfig.java (original)
+++ struts/action/trunk/src/test/org/apache/struts/config/TestModuleConfig.java Fri Feb 10 06:51:24 2006
@@ -20,6 +20,7 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+
import org.apache.commons.digester.Digester;
import java.io.InputStream;
@@ -55,8 +56,7 @@
* Set up instance variables required by this test case.
*/
public void setUp() {
- ModuleConfigFactory factoryObject =
- ModuleConfigFactory.createFactory();
+ ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory();
config = factoryObject.createModuleConfig("");
}
@@ -77,7 +77,7 @@
// ------------------------------------------------ Individual Test Methods
private void parseConfig(String publicId, String entityURL,
- String strutsConfig) {
+ String strutsConfig) {
// Prepare a Digester for parsing a struts-config.xml file
Digester digester = new Digester();
@@ -86,18 +86,17 @@
digester.setValidating(true);
digester.addRuleSet(new ConfigRuleSet());
digester.register(publicId,
- this.getClass().getResource(entityURL).toString());
+ this.getClass().getResource(entityURL).toString());
// Parse the test struts-config.xml file
try {
InputStream input =
- this.getClass().getResourceAsStream(strutsConfig);
+ this.getClass().getResourceAsStream(strutsConfig);
assertNotNull("Got an input stream for " + strutsConfig, input);
digester.parse(input);
input.close();
- }
- catch (Throwable t) {
+ } catch (Throwable t) {
t.printStackTrace(System.out);
fail("Parsing threw exception: " + t);
}
@@ -107,21 +106,19 @@
* Test parsing of a struts-config.xml file.
*/
public void testParse() {
- testParseBase(
- "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN",
- "/org/apache/struts/resources/struts-config_1_2.dtd",
- "/org/apache/struts/config/struts-config.xml");
+ testParseBase("-//Apache Software Foundation//DTD Struts Configuration 1.2//EN",
+ "/org/apache/struts/resources/struts-config_1_2.dtd",
+ "/org/apache/struts/config/struts-config.xml");
}
public void testParse1_1() {
- testParseBase(
- "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN",
- "/org/apache/struts/resources/struts-config_1_1.dtd",
- "/org/apache/struts/config/struts-config-1.1.xml");
+ testParseBase("-//Apache Software Foundation//DTD Struts Configuration 1.1//EN",
+ "/org/apache/struts/resources/struts-config_1_1.dtd",
+ "/org/apache/struts/config/struts-config-1.1.xml");
}
public void testParseBase(String publicId, String entityURL,
- String strutsConfig) {
+ String strutsConfig) {
parseConfig(publicId, entityURL, strutsConfig);
// Perform assertion tests on the parsed information
@@ -139,7 +136,7 @@
assertNotNull("Found logon action configuration", logon);
assertEquals("Found correct logon configuration", "logonForm",
- logon.getName());
+ logon.getName());
}
/**
@@ -147,10 +144,9 @@
*/
public void testCustomMappingParse() {
// Prepare a Digester for parsing a struts-config.xml file
- testCustomMappingParseBase(
- "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN",
- "/org/apache/struts/resources/struts-config_1_2.dtd",
- "/org/apache/struts/config/struts-config-custom-mapping.xml");
+ testCustomMappingParseBase("-//Apache Software Foundation//DTD Struts Configuration 1.2//EN",
+ "/org/apache/struts/resources/struts-config_1_2.dtd",
+ "/org/apache/struts/config/struts-config-custom-mapping.xml");
}
/**
@@ -158,47 +154,46 @@
*/
public void testCustomMappingParse1_1() {
// Prepare a Digester for parsing a struts-config.xml file
- testCustomMappingParseBase(
- "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN",
- "/org/apache/struts/resources/struts-config_1_1.dtd",
- "/org/apache/struts/config/struts-config-custom-mapping.xml");
+ testCustomMappingParseBase("-//Apache Software Foundation//DTD Struts Configuration 1.1//EN",
+ "/org/apache/struts/resources/struts-config_1_1.dtd",
+ "/org/apache/struts/config/struts-config-custom-mapping.xml");
}
/**
* Tests a struts-config.xml that contains a custom mapping and property.
*/
private void testCustomMappingParseBase(String publicId, String entityURL,
- String strutsConfig) {
+ String strutsConfig) {
parseConfig(publicId, entityURL, strutsConfig);
// Perform assertion tests on the parsed information
- CustomMappingTest map = (CustomMappingTest) config.findActionConfig(
- "/editRegistration");
+ CustomMappingTest map =
+ (CustomMappingTest) config.findActionConfig("/editRegistration");
assertNotNull("Cannot find editRegistration mapping", map);
assertTrue("The custom mapping attribute has not been set",
- map.getPublic());
+ map.getPublic());
}
/**
* Test order of action mappings defined perserved.
*/
public void testPreserveActionMappingsOrder() {
- parseConfig(
- "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN",
- "/org/apache/struts/resources/struts-config_1_2.dtd",
- "/org/apache/struts/config/struts-config.xml");
+ parseConfig("-//Apache Software Foundation//DTD Struts Configuration 1.2//EN",
+ "/org/apache/struts/resources/struts-config_1_2.dtd",
+ "/org/apache/struts/config/struts-config.xml");
- String[] paths = new String[]{
+ String[] paths =
+ new String[] {
"/editRegistration", "/editSubscription", "/logoff", "/logon",
"/saveRegistration", "/saveSubscription", "/tour"
- };
+ };
ActionConfig[] actions = config.findActionConfigs();
for (int x = 0; x < paths.length; x++) {
assertTrue("Action config out of order:" + actions[x].getPath(),
- paths[x].equals(actions[x].getPath()));
+ paths[x].equals(actions[x].getPath()));
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org