You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by hu...@apache.org on 2006/11/06 16:02:22 UTC

svn commit: r471756 [22/31] - in /struts/struts2/trunk: apps/blank/ apps/blank/src/main/java/example/ apps/blank/src/test/java/example/ apps/mailreader/src/main/java/mailreader2/ apps/portlet/src/main/java/org/apache/struts2/portlet/example/ apps/portl...

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/components/UIBeanTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/components/UIBeanTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/components/UIBeanTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/components/UIBeanTest.java Mon Nov  6 07:01:43 2006
@@ -1,19 +1,22 @@
 /*
  * $Id$
  *
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
  *
- * 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
  *
- *      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.
+ * 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 org.apache.struts2.components;
 
@@ -25,40 +28,40 @@
 import com.opensymphony.xwork2.util.ValueStackFactory;
 
 /**
- * 
+ *
  * @version $Date$ $Id$
  */
 public class UIBeanTest extends StrutsTestCase {
-	
-	public void testPopulateComponentHtmlId1() throws Exception {
-		ValueStack stack = ValueStackFactory.getFactory().createValueStack();
-		MockHttpServletRequest req = new MockHttpServletRequest();
-		MockHttpServletResponse res = new MockHttpServletResponse();
-		
-		Form form = new Form(stack, req, res);
-		form.getParameters().put("id", "formId");
-		
-		TextField txtFld = new TextField(stack, req, res);
-		txtFld.setId("txtFldId");
-		
-		txtFld.populateComponentHtmlId(form);
-		
-		assertEquals("txtFldId", txtFld.getParameters().get("id"));
-	}
-	
-	public void testPopulateComponentHtmlId2() throws Exception {
-		ValueStack stack = ValueStackFactory.getFactory().createValueStack();
-		MockHttpServletRequest req = new MockHttpServletRequest();
-		MockHttpServletResponse res = new MockHttpServletResponse();
-		
-		Form form = new Form(stack, req, res);
-		form.getParameters().put("id", "formId");
-		
-		TextField txtFld = new TextField(stack, req, res);
-		txtFld.setName("txtFldName");
-		
-		txtFld.populateComponentHtmlId(form);
-		
-		assertEquals("formId_txtFldName", txtFld.getParameters().get("id"));
-	}
+
+    public void testPopulateComponentHtmlId1() throws Exception {
+        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
+        MockHttpServletRequest req = new MockHttpServletRequest();
+        MockHttpServletResponse res = new MockHttpServletResponse();
+
+        Form form = new Form(stack, req, res);
+        form.getParameters().put("id", "formId");
+
+        TextField txtFld = new TextField(stack, req, res);
+        txtFld.setId("txtFldId");
+
+        txtFld.populateComponentHtmlId(form);
+
+        assertEquals("txtFldId", txtFld.getParameters().get("id"));
+    }
+
+    public void testPopulateComponentHtmlId2() throws Exception {
+        ValueStack stack = ValueStackFactory.getFactory().createValueStack();
+        MockHttpServletRequest req = new MockHttpServletRequest();
+        MockHttpServletResponse res = new MockHttpServletResponse();
+
+        Form form = new Form(stack, req, res);
+        form.getParameters().put("id", "formId");
+
+        TextField txtFld = new TextField(stack, req, res);
+        txtFld.setName("txtFldName");
+
+        txtFld.populateComponentHtmlId(form);
+
+        assertEquals("formId_txtFldName", txtFld.getParameters().get("id"));
+    }
 }

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/components/UIComponentTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/components/UIComponentTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/components/UIComponentTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/components/UIComponentTest.java Mon Nov  6 07:01:43 2006
@@ -1,19 +1,22 @@
 /*
  * $Id$
  *
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
  *
- * 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
  *
- *      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.
+ * 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 org.apache.struts2.components;
 
@@ -93,7 +96,7 @@
         }
     }
 
-    //	 Anchor
+    //   Anchor
     public void testAnchorComponentDisposeItselfFromComponentStack() throws Exception {
 
         TextFieldTag t = new TextFieldTag();

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/components/template/BaseTemplateEngineTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/components/template/BaseTemplateEngineTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/components/template/BaseTemplateEngineTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/components/template/BaseTemplateEngineTest.java Mon Nov  6 07:01:43 2006
@@ -1,19 +1,22 @@
 /*
  * $Id$
  *
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
  *
- * 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
  *
- *      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.
+ * 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 org.apache.struts2.components.template;
 
@@ -29,55 +32,55 @@
 public class BaseTemplateEngineTest extends TestCase {
 
 public void testGetThemePropsThroughFileSystem() throws Exception {
-		
-		URL dummyResourceUrl = getClass().getResource("dummy.properties");
-		File dummyResourceFile = new File(dummyResourceUrl.getFile());
-		String themePropertiesDir = dummyResourceFile.getParent();
-		
-		System.out.println("dummy resource url="+dummyResourceUrl);
-		System.out.println("resource file="+dummyResourceFile);
-		System.out.println("theme properties dir="+themePropertiesDir);
-		
-		assertTrue(dummyResourceFile.exists());
-		assertNotNull(themePropertiesDir);
-		
-		Template template = new Template(themePropertiesDir, "theme1", "template1");
-		
-		TemplateEngine templateEngine = new InnerBaseTemplateEngine("themeThroughFileSystem.properties");
-		Map propertiesMap = templateEngine.getThemeProps(template);
-		
-		assertNotNull(propertiesMap);
-		assertTrue(propertiesMap.size() > 0);
-		
-	}
-	
-	public void testGetThemePropsThroughClasspath() throws Exception {
-		
-		Template template = new Template("org/apache/struts2/components/template", "theme1", "template2");
-		TemplateEngine templateEngine = new InnerBaseTemplateEngine("themeThroughClassPath.properties");
-		Map propertiesMap = templateEngine.getThemeProps(template);
-		
-		assertNotNull(propertiesMap);
-		assertTrue(propertiesMap.size() > 0);
-	}
-	
-	public class InnerBaseTemplateEngine extends BaseTemplateEngine {
-		
-		private String themePropertiesFileName;
-		
-		public InnerBaseTemplateEngine(String themePropertiesFileName) {
-			this.themePropertiesFileName = themePropertiesFileName;
-		}
-		
-		protected String getSuffix() {
-			return "ftl";
-		}
-
-		public void renderTemplate(TemplateRenderingContext templateContext) throws Exception {
-		}
-		
-		protected String getThemePropertiesFileName() {
-			return this.themePropertiesFileName;
-		}
-	}
+
+        URL dummyResourceUrl = getClass().getResource("dummy.properties");
+        File dummyResourceFile = new File(dummyResourceUrl.getFile());
+        String themePropertiesDir = dummyResourceFile.getParent();
+
+        System.out.println("dummy resource url="+dummyResourceUrl);
+        System.out.println("resource file="+dummyResourceFile);
+        System.out.println("theme properties dir="+themePropertiesDir);
+
+        assertTrue(dummyResourceFile.exists());
+        assertNotNull(themePropertiesDir);
+
+        Template template = new Template(themePropertiesDir, "theme1", "template1");
+
+        TemplateEngine templateEngine = new InnerBaseTemplateEngine("themeThroughFileSystem.properties");
+        Map propertiesMap = templateEngine.getThemeProps(template);
+
+        assertNotNull(propertiesMap);
+        assertTrue(propertiesMap.size() > 0);
+
+    }
+
+    public void testGetThemePropsThroughClasspath() throws Exception {
+
+        Template template = new Template("org/apache/struts2/components/template", "theme1", "template2");
+        TemplateEngine templateEngine = new InnerBaseTemplateEngine("themeThroughClassPath.properties");
+        Map propertiesMap = templateEngine.getThemeProps(template);
+
+        assertNotNull(propertiesMap);
+        assertTrue(propertiesMap.size() > 0);
+    }
+
+    public class InnerBaseTemplateEngine extends BaseTemplateEngine {
+
+        private String themePropertiesFileName;
+
+        public InnerBaseTemplateEngine(String themePropertiesFileName) {
+            this.themePropertiesFileName = themePropertiesFileName;
+        }
+
+        protected String getSuffix() {
+            return "ftl";
+        }
+
+        public void renderTemplate(TemplateRenderingContext templateContext) throws Exception {
+        }
+
+        protected String getThemePropertiesFileName() {
+            return this.themePropertiesFileName;
+        }
+    }
 }

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java Mon Nov  6 07:01:43 2006
@@ -1,19 +1,22 @@
 /*
- * $Id: DefaultSettings.java 439747 2006-09-03 09:22:46Z mrdon $
+ * $Id: $
  *
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
  *
- * 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
  *
- *      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.
+ * 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 org.apache.struts2.config;
 
@@ -35,7 +38,7 @@
 
     ClasspathConfigurationProvider provider;
     Configuration config;
-    
+
     public void setUp() {
         provider = new ClasspathConfigurationProvider(new String[]{"org.apache.struts2.config"});
         config = new DefaultConfiguration();
@@ -48,7 +51,7 @@
         config.addPackageConfig("custom-package", customPackage);
         provider.init(config);
     }
-    
+
     public void testFoundRootPackages() {
         assertEquals(5, config.getPackageConfigs().size());
         PackageConfig pkg = config.getPackageConfig("org.apache.struts2.config");
@@ -58,7 +61,7 @@
         assertEquals(1, configs.size());
         assertNotNull(configs.get("customParentPackage"));
     }
-    
+
     public void testParentPackage() {
         PackageConfig pkg = config.getPackageConfig("org.apache.struts2.config");
         assertEquals(2, pkg.getParents().size());
@@ -67,7 +70,7 @@
         assertNotNull(config);
         assertEquals("/custom", pkg.getNamespace());
     }
-    
+
     public void testCustomNamespace() {
         PackageConfig pkg = config.getPackageConfig("org.apache.struts2.config.CustomNamespaceAction");
         Map configs = pkg.getAllActionConfigs();
@@ -77,7 +80,7 @@
         assertEquals("/mynamespace", pkg.getNamespace());
         assertNotNull(configs.get("customParentPackage"));
     }
-    
+
     public void testResultAnnotations() {
         PackageConfig pkg = config.getPackageConfig("org.apache.struts2.config.cltest");
         assertEquals("/cltest", pkg.getNamespace());
@@ -85,7 +88,7 @@
         assertNotNull(acfg);
         assertEquals(3, acfg.getResults().size());
     }
-    
+
     public void testDynamicResults() {
         PackageConfig pkg = config.getPackageConfig("org.apache.struts2.config.cltest");
         ActionConfig config = pkg.getActionConfigs().get("twoResult");

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/CustomNamespaceAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/CustomNamespaceAction.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/CustomNamespaceAction.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/CustomNamespaceAction.java Mon Nov  6 07:01:43 2006
@@ -1,19 +1,22 @@
 /*
- * $Id: DefaultSettings.java 439747 2006-09-03 09:22:46Z mrdon $
+ * $Id: $
  *
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
  *
- * 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
  *
- *      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.
+ * 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 org.apache.struts2.config;
 

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/CustomParentPackageAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/CustomParentPackageAction.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/CustomParentPackageAction.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/CustomParentPackageAction.java Mon Nov  6 07:01:43 2006
@@ -1,19 +1,22 @@
 /*
- * $Id: DefaultSettings.java 439747 2006-09-03 09:22:46Z mrdon $
+ * $Id: $
  *
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
  *
- * 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
  *
- *      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.
+ * 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 org.apache.struts2.config;
 

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/SettingsTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/SettingsTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/SettingsTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/SettingsTest.java Mon Nov  6 07:01:43 2006
@@ -1,19 +1,22 @@
 /*
  * $Id$
  *
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
  *
- * 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
  *
- *      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.
+ * 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 org.apache.struts2.config;
 
@@ -56,7 +59,7 @@
 
     public void testReplaceDefaultMessages() {
         Locale.setDefault(Locale.US); // force to US locale as we also have _de and _da properties
-        
+
         LocalizedTextUtil.clearDefaultResourceBundles();
         LocalizedTextUtil.addDefaultResourceBundle("org/apache/struts2/struts-messages");
         assertEquals("The form has already been processed or no token was supplied, please try again.", LocalizedTextUtil.findDefaultText("struts.messages.invalid.token", Locale.getDefault()));
@@ -68,7 +71,7 @@
 
     public void testSetSettings() {
         Settings.setInstance(new TestSettings());
-        
+
         String keyName = "a.long.property.key.name";
         assertEquals(keyName, Settings.get(keyName));
         assertEquals(2, getKeyCount());
@@ -79,7 +82,7 @@
         Iterator keyNames = Settings.list();
 
         while (keyNames.hasNext()) {
-        	keyNames.next();
+            keyNames.next();
             count++;
         }
 

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/TestSettings.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/TestSettings.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/TestSettings.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/TestSettings.java Mon Nov  6 07:01:43 2006
@@ -1,19 +1,22 @@
 /*
  * $Id$
  *
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
  *
- * 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
  *
- *      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.
+ * 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 org.apache.struts2.config;
 

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/cltest/OneResultAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/cltest/OneResultAction.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/cltest/OneResultAction.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/cltest/OneResultAction.java Mon Nov  6 07:01:43 2006
@@ -1,19 +1,22 @@
 /*
- * $Id: DefaultSettings.java 439747 2006-09-03 09:22:46Z mrdon $
+ * $Id: $
  *
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
  *
- * 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
  *
- *      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.
+ * 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 org.apache.struts2.config.cltest;
 

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/cltest/TwoResultAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/cltest/TwoResultAction.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/cltest/TwoResultAction.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/cltest/TwoResultAction.java Mon Nov  6 07:01:43 2006
@@ -1,19 +1,22 @@
 /*
- * $Id: DefaultSettings.java 439747 2006-09-03 09:22:46Z mrdon $
+ * $Id: $
  *
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
  *
- * 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
  *
- *      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.
+ * 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 org.apache.struts2.config.cltest;
 

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ActionContextCleanUpTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ActionContextCleanUpTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ActionContextCleanUpTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/ActionContextCleanUpTest.java Mon Nov  6 07:01:43 2006
@@ -1,19 +1,22 @@
 /*
- * $Id: FilterDispatcherTest.java 449367 2006-09-24 06:49:04Z mrdon $
+ * $Id: $
  *
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
  *
- * 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
  *
- *      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.
+ * 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 org.apache.struts2.dispatcher;
 
@@ -42,164 +45,164 @@
  * @version $Date$ $Id$
  */
 public class ActionContextCleanUpTest extends TestCase {
-	
-	
-	protected MockFilterConfig filterConfig;
-	protected MockHttpServletRequest request;
-	protected MockHttpServletResponse response;
-	protected MockFilterChain filterChain;
-	protected MockFilterChain filterChain2;
-	protected MockServletContext servletContext;
-	
-	protected Counter counter;
-	protected Map<String, Integer> _tmpStore;
-	protected InnerDispatcher _dispatcher;
-	protected InnerDispatcher _dispatcher2;
-	protected ActionContextCleanUp cleanUp;
-	protected ActionContextCleanUp cleanUp2;
-	
-	
-	@Override
-	protected void tearDown() throws Exception {
-		filterConfig = null;
-		request = null;
-		response = null;
-		filterChain = null;
-		filterChain2 = null;
-		servletContext = null;
-		counter = null;
-		_tmpStore = null;
-		_dispatcher = null;
-		_dispatcher2 = null;
-		cleanUp = null;
-		cleanUp2 = null;
-	}
-	
-	@Override
-	protected void setUp() throws Exception {
-		Dispatcher.setInstance(null);
-		
-		counter = new Counter();
-		_tmpStore = new LinkedHashMap<String, Integer>();
-		
-		filterConfig = new MockFilterConfig();
-		request = new MockHttpServletRequest();
-		response = new MockHttpServletResponse();
-		servletContext = new MockServletContext();
-		_dispatcher = new InnerDispatcher(servletContext) {
-			@Override
-			public String toString() {
-				return "dispatcher";
-			}
-		};
-		_dispatcher2 = new InnerDispatcher(servletContext){
-			@Override
-			public String toString() {
-				return "dispatcher2";
-			}
-		};
-		
-		
-		filterChain = new MockFilterChain() {
-			@Override
-			public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
-				_tmpStore.put("counter"+(counter.count++), (Integer) request.getAttribute("__cleanup_recursion_counter"));
-			}
-		};
-		
-		cleanUp = new ActionContextCleanUp() {
-			@Override
-			protected Dispatcher createDispatcher() {
-				return _dispatcher;
-			}
-		};
-		
-		cleanUp2 = new ActionContextCleanUp() {
-			@Override
-			protected Dispatcher createDispatcher() {
-				return _dispatcher2;
-			}
-		};
-		
-		filterChain2 = new MockFilterChain() {
-			@Override
-			public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
-				_tmpStore.put("counter"+(counter.count++), (Integer) request.getAttribute("__cleanup_recursion_counter"));
-				cleanUp2.doFilter(request, response, filterChain);
-			}
-		};
-	}
-	
-	
-	public void testSingle() throws Exception {
-		assertFalse(_dispatcher.prepare);
-		assertFalse(_dispatcher.wrapRequest);
-		assertNull(request.getAttribute("__cleanup_recursion_counter"));
-		
-		cleanUp.init(filterConfig);
-		cleanUp.doFilter(request, response, filterChain);
-		cleanUp.destroy();
-		
-		assertEquals(_tmpStore.size(), 1);
-		assertEquals(_tmpStore.get("counter0"), new Integer(1));
-		
-		assertTrue(_dispatcher.prepare);
-		assertTrue(_dispatcher.wrapRequest);
-		assertEquals(request.getAttribute("__cleanup_recursion_counter"), new Integer("0"));
-	}
-	
-	public void testMultiple() throws Exception {
-		assertFalse(_dispatcher.prepare);
-		assertFalse(_dispatcher.wrapRequest);
-		assertFalse(_dispatcher2.prepare);
-		assertFalse(_dispatcher2.wrapRequest);
-		assertNull(request.getAttribute("__cleanup_recursion_counter"));
-		
-		cleanUp.init(filterConfig);
-		cleanUp2.init(filterConfig);
-		cleanUp.doFilter(request, response, filterChain2);
-		cleanUp2.destroy();
-		cleanUp.destroy();
-		
-		assertEquals(_tmpStore.size(), 2);
-		assertEquals(_tmpStore.get("counter0"), new Integer(1));
-		assertEquals(_tmpStore.get("counter1"), new Integer(2));
-		
-		assertFalse(_dispatcher2.prepare);
-		assertFalse(_dispatcher2.wrapRequest);
-		assertTrue(_dispatcher.prepare);
-		assertTrue(_dispatcher.wrapRequest);
-		assertEquals(request.getAttribute("__cleanup_recursion_counter"), new Integer("0"));
-	}
-	
-	
-	class InnerDispatcher extends Dispatcher {
-		public boolean prepare = false;
-		public boolean wrapRequest = false;
-		public boolean service = false;
-		
-		public InnerDispatcher(ServletContext servletContext) {
-			super(servletContext);
-		}
-		
-		@Override
-		public void prepare(HttpServletRequest request, HttpServletResponse response) {
-			prepare = true;
-		}
-		
-		@Override
-		public HttpServletRequest wrapRequest(HttpServletRequest request, ServletContext servletContext) throws IOException {
-			wrapRequest = true;
-			return request;
-		}
-		
-		@Override
-		public void serviceAction(HttpServletRequest request, HttpServletResponse response, ServletContext context, ActionMapping mapping) throws ServletException {
-			service = true;
-		}
-	}
-	
-	class Counter {
-		public int count=0;
-	}
+
+
+    protected MockFilterConfig filterConfig;
+    protected MockHttpServletRequest request;
+    protected MockHttpServletResponse response;
+    protected MockFilterChain filterChain;
+    protected MockFilterChain filterChain2;
+    protected MockServletContext servletContext;
+
+    protected Counter counter;
+    protected Map<String, Integer> _tmpStore;
+    protected InnerDispatcher _dispatcher;
+    protected InnerDispatcher _dispatcher2;
+    protected ActionContextCleanUp cleanUp;
+    protected ActionContextCleanUp cleanUp2;
+
+
+    @Override
+    protected void tearDown() throws Exception {
+        filterConfig = null;
+        request = null;
+        response = null;
+        filterChain = null;
+        filterChain2 = null;
+        servletContext = null;
+        counter = null;
+        _tmpStore = null;
+        _dispatcher = null;
+        _dispatcher2 = null;
+        cleanUp = null;
+        cleanUp2 = null;
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        Dispatcher.setInstance(null);
+
+        counter = new Counter();
+        _tmpStore = new LinkedHashMap<String, Integer>();
+
+        filterConfig = new MockFilterConfig();
+        request = new MockHttpServletRequest();
+        response = new MockHttpServletResponse();
+        servletContext = new MockServletContext();
+        _dispatcher = new InnerDispatcher(servletContext) {
+            @Override
+            public String toString() {
+                return "dispatcher";
+            }
+        };
+        _dispatcher2 = new InnerDispatcher(servletContext){
+            @Override
+            public String toString() {
+                return "dispatcher2";
+            }
+        };
+
+
+        filterChain = new MockFilterChain() {
+            @Override
+            public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
+                _tmpStore.put("counter"+(counter.count++), (Integer) request.getAttribute("__cleanup_recursion_counter"));
+            }
+        };
+
+        cleanUp = new ActionContextCleanUp() {
+            @Override
+            protected Dispatcher createDispatcher() {
+                return _dispatcher;
+            }
+        };
+
+        cleanUp2 = new ActionContextCleanUp() {
+            @Override
+            protected Dispatcher createDispatcher() {
+                return _dispatcher2;
+            }
+        };
+
+        filterChain2 = new MockFilterChain() {
+            @Override
+            public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
+                _tmpStore.put("counter"+(counter.count++), (Integer) request.getAttribute("__cleanup_recursion_counter"));
+                cleanUp2.doFilter(request, response, filterChain);
+            }
+        };
+    }
+
+
+    public void testSingle() throws Exception {
+        assertFalse(_dispatcher.prepare);
+        assertFalse(_dispatcher.wrapRequest);
+        assertNull(request.getAttribute("__cleanup_recursion_counter"));
+
+        cleanUp.init(filterConfig);
+        cleanUp.doFilter(request, response, filterChain);
+        cleanUp.destroy();
+
+        assertEquals(_tmpStore.size(), 1);
+        assertEquals(_tmpStore.get("counter0"), new Integer(1));
+
+        assertTrue(_dispatcher.prepare);
+        assertTrue(_dispatcher.wrapRequest);
+        assertEquals(request.getAttribute("__cleanup_recursion_counter"), new Integer("0"));
+    }
+
+    public void testMultiple() throws Exception {
+        assertFalse(_dispatcher.prepare);
+        assertFalse(_dispatcher.wrapRequest);
+        assertFalse(_dispatcher2.prepare);
+        assertFalse(_dispatcher2.wrapRequest);
+        assertNull(request.getAttribute("__cleanup_recursion_counter"));
+
+        cleanUp.init(filterConfig);
+        cleanUp2.init(filterConfig);
+        cleanUp.doFilter(request, response, filterChain2);
+        cleanUp2.destroy();
+        cleanUp.destroy();
+
+        assertEquals(_tmpStore.size(), 2);
+        assertEquals(_tmpStore.get("counter0"), new Integer(1));
+        assertEquals(_tmpStore.get("counter1"), new Integer(2));
+
+        assertFalse(_dispatcher2.prepare);
+        assertFalse(_dispatcher2.wrapRequest);
+        assertTrue(_dispatcher.prepare);
+        assertTrue(_dispatcher.wrapRequest);
+        assertEquals(request.getAttribute("__cleanup_recursion_counter"), new Integer("0"));
+    }
+
+
+    class InnerDispatcher extends Dispatcher {
+        public boolean prepare = false;
+        public boolean wrapRequest = false;
+        public boolean service = false;
+
+        public InnerDispatcher(ServletContext servletContext) {
+            super(servletContext);
+        }
+
+        @Override
+        public void prepare(HttpServletRequest request, HttpServletResponse response) {
+            prepare = true;
+        }
+
+        @Override
+        public HttpServletRequest wrapRequest(HttpServletRequest request, ServletContext servletContext) throws IOException {
+            wrapRequest = true;
+            return request;
+        }
+
+        @Override
+        public void serviceAction(HttpServletRequest request, HttpServletResponse response, ServletContext context, ActionMapping mapping) throws ServletException {
+            service = true;
+        }
+    }
+
+    class Counter {
+        public int count=0;
+    }
 }

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java Mon Nov  6 07:01:43 2006
@@ -1,19 +1,22 @@
 /*
  * $Id$
  *
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
  *
- * 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
  *
- *      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.
+ * 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 org.apache.struts2.dispatcher;
 
@@ -32,49 +35,49 @@
 
 /**
  * Test case for Dispatcher.
- * 
+ *
  */
 public class DispatcherTest extends StrutsTestCase {
 
-	public void testDefaultResurceBundlePropertyLoaded() throws Exception {
+    public void testDefaultResurceBundlePropertyLoaded() throws Exception {
         Locale.setDefault(Locale.US); // force to US locale as we also have _de and _da properties
-		
-		// some i18n messages from xwork-messages.properties
-		assertEquals(
-				LocalizedTextUtil.findDefaultText("xwork.error.action.execution", Locale.US), 
-				"Error during Action invocation");
-		
-		// some i18n messages from struts-messages.properties
-		assertEquals(
-				LocalizedTextUtil.findDefaultText("struts.messages.error.uploading", Locale.US, 
-						new Object[] { "some error messages" }), 
-				"Error uploading: some error messages");
-	}
-	
-	public void testPrepareSetEncodingProperly() throws Exception {
-		HttpServletRequest req = new MockHttpServletRequest();
-		HttpServletResponse res = new MockHttpServletResponse();
-		
-		Settings.set(StrutsConstants.STRUTS_I18N_ENCODING, "utf-8");
-		
-		
-		Dispatcher du = Dispatcher.getInstance();
-		du.prepare(req, res);
-		
-		assertEquals(req.getCharacterEncoding(), "utf-8");
-	}
-	
-	public void testPrepareSetEncodingPropertyWithMultipartRequest() throws Exception {
-		MockHttpServletRequest req = new MockHttpServletRequest();
-		MockHttpServletResponse res = new MockHttpServletResponse();
-		
-		req.setContentType("multipart/form-data");
-		Settings.set(StrutsConstants.STRUTS_I18N_ENCODING, "utf-8");
-		
-		
-		Dispatcher du = Dispatcher.getInstance();
-		du.prepare(req, res);
-		
-		assertEquals(req.getCharacterEncoding(), "utf-8");
-	}
+
+        // some i18n messages from xwork-messages.properties
+        assertEquals(
+                LocalizedTextUtil.findDefaultText("xwork.error.action.execution", Locale.US),
+                "Error during Action invocation");
+
+        // some i18n messages from struts-messages.properties
+        assertEquals(
+                LocalizedTextUtil.findDefaultText("struts.messages.error.uploading", Locale.US,
+                        new Object[] { "some error messages" }),
+                "Error uploading: some error messages");
+    }
+
+    public void testPrepareSetEncodingProperly() throws Exception {
+        HttpServletRequest req = new MockHttpServletRequest();
+        HttpServletResponse res = new MockHttpServletResponse();
+
+        Settings.set(StrutsConstants.STRUTS_I18N_ENCODING, "utf-8");
+
+
+        Dispatcher du = Dispatcher.getInstance();
+        du.prepare(req, res);
+
+        assertEquals(req.getCharacterEncoding(), "utf-8");
+    }
+
+    public void testPrepareSetEncodingPropertyWithMultipartRequest() throws Exception {
+        MockHttpServletRequest req = new MockHttpServletRequest();
+        MockHttpServletResponse res = new MockHttpServletResponse();
+
+        req.setContentType("multipart/form-data");
+        Settings.set(StrutsConstants.STRUTS_I18N_ENCODING, "utf-8");
+
+
+        Dispatcher du = Dispatcher.getInstance();
+        du.prepare(req, res);
+
+        assertEquals(req.getCharacterEncoding(), "utf-8");
+    }
 }

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterDispatcherTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterDispatcherTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterDispatcherTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterDispatcherTest.java Mon Nov  6 07:01:43 2006
@@ -1,19 +1,22 @@
 /*
  * $Id$
  *
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
  *
- * 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
  *
- *      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.
+ * 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 org.apache.struts2.dispatcher;
 
@@ -53,7 +56,7 @@
 
 
     public void testParsePackages() throws Exception {
-    	
+
         FilterDispatcher filterDispatcher = new FilterDispatcher();
         String[] result1 = filterDispatcher.parse("foo.bar.package1 foo.bar.package2 foo.bar.package3");
         String[] result2 = filterDispatcher.parse("foo.bar.package1\tfoo.bar.package2\tfoo.bar.package3");
@@ -130,155 +133,155 @@
         filterDispatcher.destroy();
         assertTrue(((InnerInitailizableDestroyableObjectFactory) ObjectFactory.getObjectFactory()).destroyable);
     }
-    
+
     public void testIfActionMapperIsNullDontServiceAction() throws Exception {
-    	try {
-    		MockServletContext servletContext = new MockServletContext();
-    		MockFilterConfig filterConfig = new MockFilterConfig(servletContext);
-    		MockHttpServletRequest req = new MockHttpServletRequest(servletContext);
-    		MockHttpServletResponse res = new MockHttpServletResponse();
-    		MockFilterChain chain = new MockFilterChain();
-    		final NoOpDispatcher _dispatcher = new NoOpDispatcher(servletContext);
-    		Dispatcher.setInstance(null);
-
-    		ConfigurationManager confManager = new ConfigurationManager();
-    		confManager.setConfiguration(new DefaultConfiguration());
-    		_dispatcher.setConfigurationManager(confManager);
-    		
-    		
-    		ObjectFactory.setObjectFactory(new InnerObjectFactory());
-    		
-    		Map settings = new HashMap();
-    		settings.put(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterDispatcherTest$NullActionMapper");
-    		Settings.setInstance(new InnerConfiguration(settings));
-    	
-    		FilterDispatcher filter = new FilterDispatcher() {
-    			protected Dispatcher createDispatcher() {
-    				return _dispatcher;
-    			}
-    		};
-    		filter.init(filterConfig);
-    		filter.doFilter(req, res, chain);
-    	
-    		assertFalse(_dispatcher.serviceRequest);
-    	}
-    	finally {
-    		Settings.reset();
-    	}
-    }
-    
-    public void testCharacterEncodingSetBeforeRequestWrappingAndActionService() throws Exception { 
-    	try {
-    		MockServletContext servletContext = new MockServletContext();
-    		MockFilterConfig filterConfig = new MockFilterConfig(servletContext);
-    		MockHttpServletRequest req = new MockHttpServletRequest(servletContext);
-    		MockHttpServletResponse res = new MockHttpServletResponse();
-    		MockFilterChain chain = new MockFilterChain();
-    		final InnerDispatcher _dispatcher = new InnerDispatcher(servletContext);
-    		Dispatcher.setInstance(null);
-
-    		ConfigurationManager confManager = new ConfigurationManager();
-    		confManager.setConfiguration(new DefaultConfiguration());
-    		_dispatcher.setConfigurationManager(confManager);
-    		
-    		
-    		ObjectFactory.setObjectFactory(new InnerObjectFactory());
-    		
-    		Map settings = new HashMap();
-    		settings.put(StrutsConstants.STRUTS_I18N_ENCODING, "UTF-16_DUMMY");
-    		settings.put(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterDispatcherTest$InnerActionMapper");
-    		Settings.setInstance(new InnerConfiguration(settings));
-    	
-    		FilterDispatcher filter = new FilterDispatcher() {
-    			protected Dispatcher createDispatcher() {
-    				return _dispatcher;
-    			}
-    		};
-    		filter.init(filterConfig);
-    		filter.doFilter(req, res, chain);
-    	
-    		assertTrue(_dispatcher.wrappedRequest);
-    		assertTrue(_dispatcher.serviceRequest);
-    	}
-    	finally {
-    		Settings.reset();
-    	}
+        try {
+            MockServletContext servletContext = new MockServletContext();
+            MockFilterConfig filterConfig = new MockFilterConfig(servletContext);
+            MockHttpServletRequest req = new MockHttpServletRequest(servletContext);
+            MockHttpServletResponse res = new MockHttpServletResponse();
+            MockFilterChain chain = new MockFilterChain();
+            final NoOpDispatcher _dispatcher = new NoOpDispatcher(servletContext);
+            Dispatcher.setInstance(null);
+
+            ConfigurationManager confManager = new ConfigurationManager();
+            confManager.setConfiguration(new DefaultConfiguration());
+            _dispatcher.setConfigurationManager(confManager);
+
+
+            ObjectFactory.setObjectFactory(new InnerObjectFactory());
+
+            Map settings = new HashMap();
+            settings.put(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterDispatcherTest$NullActionMapper");
+            Settings.setInstance(new InnerConfiguration(settings));
+
+            FilterDispatcher filter = new FilterDispatcher() {
+                protected Dispatcher createDispatcher() {
+                    return _dispatcher;
+                }
+            };
+            filter.init(filterConfig);
+            filter.doFilter(req, res, chain);
+
+            assertFalse(_dispatcher.serviceRequest);
+        }
+        finally {
+            Settings.reset();
+        }
+    }
+
+    public void testCharacterEncodingSetBeforeRequestWrappingAndActionService() throws Exception {
+        try {
+            MockServletContext servletContext = new MockServletContext();
+            MockFilterConfig filterConfig = new MockFilterConfig(servletContext);
+            MockHttpServletRequest req = new MockHttpServletRequest(servletContext);
+            MockHttpServletResponse res = new MockHttpServletResponse();
+            MockFilterChain chain = new MockFilterChain();
+            final InnerDispatcher _dispatcher = new InnerDispatcher(servletContext);
+            Dispatcher.setInstance(null);
+
+            ConfigurationManager confManager = new ConfigurationManager();
+            confManager.setConfiguration(new DefaultConfiguration());
+            _dispatcher.setConfigurationManager(confManager);
+
+
+            ObjectFactory.setObjectFactory(new InnerObjectFactory());
+
+            Map settings = new HashMap();
+            settings.put(StrutsConstants.STRUTS_I18N_ENCODING, "UTF-16_DUMMY");
+            settings.put(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterDispatcherTest$InnerActionMapper");
+            Settings.setInstance(new InnerConfiguration(settings));
+
+            FilterDispatcher filter = new FilterDispatcher() {
+                protected Dispatcher createDispatcher() {
+                    return _dispatcher;
+                }
+            };
+            filter.init(filterConfig);
+            filter.doFilter(req, res, chain);
+
+            assertTrue(_dispatcher.wrappedRequest);
+            assertTrue(_dispatcher.serviceRequest);
+        }
+        finally {
+            Settings.reset();
+        }
     }
 
 
     // === inner class ========
     public static class InnerObjectFactory extends ObjectFactory {
-    	
+
     }
-    
+
     public static class NoOpDispatcher extends Dispatcher {
-    	protected boolean wrappedRequest = false;
-    	protected boolean serviceRequest = false;
+        protected boolean wrappedRequest = false;
+        protected boolean serviceRequest = false;
 
-		public NoOpDispatcher(ServletContext servletContext) {
-			super(servletContext);
-		}
-
-		public HttpServletRequest wrapRequest(HttpServletRequest request, ServletContext servletContext) throws IOException {
-			wrappedRequest = true;
-			return request;
-		}
-		
-		public void serviceAction(HttpServletRequest request, HttpServletResponse response, ServletContext context, ActionMapping mapping) throws ServletException {
-			serviceRequest = true;
-		}
+        public NoOpDispatcher(ServletContext servletContext) {
+            super(servletContext);
+        }
+
+        public HttpServletRequest wrapRequest(HttpServletRequest request, ServletContext servletContext) throws IOException {
+            wrappedRequest = true;
+            return request;
+        }
+
+        public void serviceAction(HttpServletRequest request, HttpServletResponse response, ServletContext context, ActionMapping mapping) throws ServletException {
+            serviceRequest = true;
+        }
     }
-    
+
     public static class InnerDispatcher extends Dispatcher {
-    	
-    	protected boolean wrappedRequest = false;
-    	protected boolean serviceRequest = false;
-
-		public InnerDispatcher(ServletContext servletContext) {
-			super(servletContext);
-		}
-
-		public HttpServletRequest wrapRequest(HttpServletRequest request, ServletContext servletContext) throws IOException {
-			wrappedRequest = true;
-			// if we set the chracter encoding AFTER we do wrap request, we will get
-			// a failing test
-			assertNotNull(request.getCharacterEncoding());
-			assertEquals(request.getCharacterEncoding(), "UTF-16_DUMMY");
-			
-			return request;
-		}
-		
-		public void serviceAction(HttpServletRequest request, HttpServletResponse response, ServletContext context, ActionMapping mapping) throws ServletException {
-			serviceRequest = true;
-			// if we set the chracter encoding AFTER we do wrap request, we will get
-			// a failing test
-			assertNotNull(request.getCharacterEncoding());
-			assertEquals(request.getCharacterEncoding(), "UTF-16_DUMMY");
-		}
+
+        protected boolean wrappedRequest = false;
+        protected boolean serviceRequest = false;
+
+        public InnerDispatcher(ServletContext servletContext) {
+            super(servletContext);
+        }
+
+        public HttpServletRequest wrapRequest(HttpServletRequest request, ServletContext servletContext) throws IOException {
+            wrappedRequest = true;
+            // if we set the chracter encoding AFTER we do wrap request, we will get
+            // a failing test
+            assertNotNull(request.getCharacterEncoding());
+            assertEquals(request.getCharacterEncoding(), "UTF-16_DUMMY");
+
+            return request;
+        }
+
+        public void serviceAction(HttpServletRequest request, HttpServletResponse response, ServletContext context, ActionMapping mapping) throws ServletException {
+            serviceRequest = true;
+            // if we set the chracter encoding AFTER we do wrap request, we will get
+            // a failing test
+            assertNotNull(request.getCharacterEncoding());
+            assertEquals(request.getCharacterEncoding(), "UTF-16_DUMMY");
+        }
     }
-    
+
     public static class InnerActionMapper implements ActionMapper {
 
-		public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager config) {
-			return new ActionMapping();
-		}
-
-		public String getUriFromActionMapping(ActionMapping mapping) {
-			return null;
-		}
+        public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager config) {
+            return new ActionMapping();
+        }
+
+        public String getUriFromActionMapping(ActionMapping mapping) {
+            return null;
+        }
     }
-    
+
     public static class NullActionMapper implements ActionMapper {
-    	public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager config) {
-			return null;
-		}
-
-		public String getUriFromActionMapping(ActionMapping mapping) {
-			return null;
-		}
+        public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager config) {
+            return null;
+        }
+
+        public String getUriFromActionMapping(ActionMapping mapping) {
+            return null;
+        }
     }
-    
-    
+
+
     public static class InnerConfiguration extends Settings {
         Map<String,String> m;
 

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/FilterTest.java Mon Nov  6 07:01:43 2006
@@ -1,19 +1,22 @@
 /*
- * $Id: FilterDispatcherTest.java 449367 2006-09-24 06:49:04Z mrdon $
+ * $Id: $
  *
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
  *
- * 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
  *
- *      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.
+ * 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 org.apache.struts2.dispatcher;
 
@@ -43,302 +46,302 @@
 
 
 /**
- * 
+ *
  * @version $Date$ $Id$
  */
-public class FilterTest extends TestCase { 
-	
-	protected MockFilterConfig filterConfig;
-	protected MockHttpServletRequest request;
-	protected MockHttpServletResponse response;
-	protected MockFilterChain filterChain;
-	protected MockFilterChain filterChain2;
-	protected MockServletContext servletContext;
-	
-	protected InnerDispatcher _dispatcher1;
-	protected InnerDispatcher _dispatcher2;
-	protected ActionContextCleanUp cleanUp;
-	protected FilterDispatcher filterDispatcher;
-	
-	protected int cleanUpFilterCreateDispatcherCount = 0; // number of times clean up filter create a dispatcher
-	protected int filterDispatcherCreateDispatcherCount = 0; // number of times FilterDispatcher create a dispatcher
-	
-	
-	@Override
-	protected void tearDown() throws Exception {
-		filterConfig = null;
-		request = null;
-		response = null;
-		filterChain = null;
-		filterChain2 = null;
-		servletContext = null;
-		_dispatcher1 = null;
-		_dispatcher2 = null;
-		cleanUp = null;
-		filterDispatcher = null;
-	}
-	
-	@Override
-	protected void setUp() throws Exception {
-		Dispatcher.setInstance(null);
-		
-		filterConfig = new MockFilterConfig();
-		request = new MockHttpServletRequest();
-		response = new MockHttpServletResponse();
-		servletContext = new MockServletContext();
-		
-		_dispatcher1 = new InnerDispatcher(servletContext){
-			@Override
-			public String toString() {
-				return "dispatcher1";
-			}
-		};
-		_dispatcher2 = new InnerDispatcher(servletContext){
-			@Override
-			public String toString() {
-				return "dispatcher2";
-			}
-		};
-		filterChain = new MockFilterChain() {
-			@Override
-			public void doFilter(ServletRequest req, ServletResponse res) throws IOException, ServletException {
-				filterDispatcher.doFilter(req, res, filterChain2);
-			}
-		};
-		filterChain2 = new MockFilterChain() {
-			@Override
-			public void doFilter(ServletRequest req, ServletResponse res) throws IOException, ServletException {
-			}
-		};
-		
-		
-		cleanUp = new ActionContextCleanUp() {
-			@Override
-			protected Dispatcher createDispatcher() {
-				cleanUpFilterCreateDispatcherCount++;
-				return _dispatcher1;
-			}
-			
-			@Override
-			public String toString() {
-				return "cleanUp";
-			}
-		};
-		
-		filterDispatcher = new FilterDispatcher() {
-			@Override
-			protected Dispatcher createDispatcher() {
-				filterDispatcherCreateDispatcherCount++;
-				return _dispatcher2;
-			}
-			
-			@Override
-			public String toString() {
-				return "filterDispatcher";
-			}
-		};
-	}
-	
-	
-	public void testUsingFilterDispatcherOnly() throws Exception {
-		ObjectFactory oldObjecFactory = ObjectFactory.getObjectFactory();
-		try {
-			ObjectFactory.setObjectFactory(new InnerObjectFactory());
-			Settings.set(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterTest$InnerMapper");
-		
-			assertEquals(cleanUpFilterCreateDispatcherCount, 0);
-			assertEquals(filterDispatcherCreateDispatcherCount, 0);
-			assertFalse(_dispatcher1.prepare);
-			assertFalse(_dispatcher1.wrapRequest);
-			assertFalse(_dispatcher1.service);
-			assertFalse(_dispatcher2.prepare);
-			assertFalse(_dispatcher2.wrapRequest);
-			assertFalse(_dispatcher2.service);
-		
-			filterDispatcher.init(filterConfig);
-			filterDispatcher.doFilter(request, response, filterChain2);
-			filterDispatcher.destroy();
-		
-			// we are using FilterDispatcher only, so cleanUp filter's Dispatcher should not be created.
-			assertEquals(cleanUpFilterCreateDispatcherCount, 0);
-			assertEquals(filterDispatcherCreateDispatcherCount, 1);
-			assertFalse(_dispatcher1.prepare);
-			assertFalse(_dispatcher1.wrapRequest);
-			assertFalse(_dispatcher1.service);
-			assertTrue(_dispatcher2.prepare);
-			assertTrue(_dispatcher2.wrapRequest);
-			assertTrue(_dispatcher2.service);
-			assertTrue(Dispatcher.getInstance() == null);
-		}
-		finally {
-			ObjectFactory.setObjectFactory(oldObjecFactory);
-		}
-	}
-	
-	public void testUsingFilterDispatcherOnly_Multiple() throws Exception {
-		ObjectFactory oldObjecFactory = ObjectFactory.getObjectFactory();
-		try {
-			ObjectFactory.setObjectFactory(new InnerObjectFactory());
-			Settings.set(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterTest$InnerMapper");
-		
-			assertEquals(cleanUpFilterCreateDispatcherCount, 0);
-			assertEquals(filterDispatcherCreateDispatcherCount, 0);
-			assertFalse(_dispatcher1.prepare);
-			assertFalse(_dispatcher1.wrapRequest);
-			assertFalse(_dispatcher1.service);
-			assertFalse(_dispatcher2.prepare);
-			assertFalse(_dispatcher2.wrapRequest);
-			assertFalse(_dispatcher2.service);
-		
-			filterDispatcher.init(filterConfig);
-			filterDispatcher.doFilter(request, response, filterChain2);
-			filterDispatcher.doFilter(request, response, filterChain2);
-			filterDispatcher.destroy();
-		
-			assertEquals(cleanUpFilterCreateDispatcherCount, 0);
-			// We should create dispatcher once, although filter.doFilter(...) is called  many times.
-			assertEquals(filterDispatcherCreateDispatcherCount, 1);
-			assertFalse(_dispatcher1.prepare);
-			assertFalse(_dispatcher1.wrapRequest);
-			assertFalse(_dispatcher1.service);
-			assertTrue(_dispatcher2.prepare);
-			assertTrue(_dispatcher2.wrapRequest);
-			assertTrue(_dispatcher2.service);
-			assertTrue(Dispatcher.getInstance() == null);
-		}
-		finally {
-			ObjectFactory.setObjectFactory(oldObjecFactory);
-		}
-	}
-	
-	public void testUsingCleanUpAndFilterDispatcher() throws Exception {
-		ObjectFactory oldObjecFactory = ObjectFactory.getObjectFactory();
-		try {
-			ObjectFactory.setObjectFactory(new InnerObjectFactory());
-			Settings.set(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterTest$InnerMapper");
-		
-			assertEquals(cleanUpFilterCreateDispatcherCount, 0);
-			assertEquals(filterDispatcherCreateDispatcherCount, 0);
-			assertFalse(_dispatcher1.prepare);
-			assertFalse(_dispatcher1.wrapRequest);
-			assertFalse(_dispatcher1.service);
-			assertFalse(_dispatcher2.prepare);
-			assertFalse(_dispatcher2.wrapRequest);
-			assertFalse(_dispatcher2.service);
-		
-			cleanUp.init(filterConfig);
-			filterDispatcher.init(filterConfig);
-			cleanUp.doFilter(request, response, filterChain);
-			filterDispatcher.destroy();
-			cleanUp.destroy();
-		
-			assertEquals(cleanUpFilterCreateDispatcherCount, 1);
-			assertEquals(filterDispatcherCreateDispatcherCount, 1);
-			assertTrue(_dispatcher1.prepare);
-			assertTrue(_dispatcher1.wrapRequest);
-			assertTrue(_dispatcher1.service);
-			assertFalse(_dispatcher2.prepare);
-			assertFalse(_dispatcher2.wrapRequest);
-			assertFalse(_dispatcher2.service);
-			assertTrue(Dispatcher.getInstance() == null);
-		}
-		finally {
-			ObjectFactory.setObjectFactory(oldObjecFactory);
-		}
-	}
-	
-	
-	public void testUsingCleanUpAndFilterDispatcher_Multiple() throws Exception {
-		ObjectFactory oldObjecFactory = ObjectFactory.getObjectFactory();
-		try {
-			ObjectFactory.setObjectFactory(new InnerObjectFactory());
-			Settings.set(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterTest$InnerMapper");
-		
-			assertEquals(cleanUpFilterCreateDispatcherCount, 0);
-			assertEquals(filterDispatcherCreateDispatcherCount, 0);
-			assertFalse(_dispatcher1.prepare);
-			assertFalse(_dispatcher1.wrapRequest);
-			assertFalse(_dispatcher1.service);
-			assertFalse(_dispatcher2.prepare);
-			assertFalse(_dispatcher2.wrapRequest);
-			assertFalse(_dispatcher2.service);
-		
-			cleanUp.init(filterConfig);
-			filterDispatcher.init(filterConfig);
-			cleanUp.doFilter(request, response, filterChain);
-			cleanUp.doFilter(request, response, filterChain);
-			filterDispatcher.destroy();
-			cleanUp.destroy();
-		
-			assertEquals(cleanUpFilterCreateDispatcherCount, 1);
-			assertEquals(filterDispatcherCreateDispatcherCount, 1);
-			assertTrue(_dispatcher1.prepare);
-			assertTrue(_dispatcher1.wrapRequest);
-			assertTrue(_dispatcher1.service);
-			assertFalse(_dispatcher2.prepare);
-			assertFalse(_dispatcher2.wrapRequest);
-			assertFalse(_dispatcher2.service);
-			assertTrue(Dispatcher.getInstance() == null);
-		}
-		finally {
-			ObjectFactory.setObjectFactory(oldObjecFactory);
-		}
-	}
-	
-	
-	class InnerDispatcher extends Dispatcher {
-		public boolean prepare = false;
-		public boolean wrapRequest = false;
-		public boolean service = false;
-		
-		public InnerDispatcher(ServletContext servletContext) {
-			super(servletContext);
-		}
-		
-		@Override
-		public void prepare(HttpServletRequest request, HttpServletResponse response) {
-			prepare = true;
-		}
-		
-		@Override
-		public HttpServletRequest wrapRequest(HttpServletRequest request, ServletContext servletContext) throws IOException {
-			wrapRequest = true;
-			return request;
-		}
-		
-		@Override
-		public void serviceAction(HttpServletRequest request, HttpServletResponse response, ServletContext context, ActionMapping mapping) throws ServletException {
-			service = true;
-		}
-	}
-	
-	class NullInnerMapper implements ActionMapper {
-		public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager) {
-			return null;
-		}
-
-		public String getUriFromActionMapping(ActionMapping mapping) {
-			return null;
-		}
-	}
-	
-	public static class InnerMapper implements ActionMapper {
-		
-		public InnerMapper() {}
-		
-		public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager) {
-			return new ActionMapping();
-		}
-
-		public String getUriFromActionMapping(ActionMapping mapping) {
-			return "";
-		}
-	}
-	
-	class InnerObjectFactory extends ObjectFactory {
-		public InnerObjectFactory() {
-			super();
-		}
-	}
+public class FilterTest extends TestCase {
+
+    protected MockFilterConfig filterConfig;
+    protected MockHttpServletRequest request;
+    protected MockHttpServletResponse response;
+    protected MockFilterChain filterChain;
+    protected MockFilterChain filterChain2;
+    protected MockServletContext servletContext;
+
+    protected InnerDispatcher _dispatcher1;
+    protected InnerDispatcher _dispatcher2;
+    protected ActionContextCleanUp cleanUp;
+    protected FilterDispatcher filterDispatcher;
+
+    protected int cleanUpFilterCreateDispatcherCount = 0; // number of times clean up filter create a dispatcher
+    protected int filterDispatcherCreateDispatcherCount = 0; // number of times FilterDispatcher create a dispatcher
+
+
+    @Override
+    protected void tearDown() throws Exception {
+        filterConfig = null;
+        request = null;
+        response = null;
+        filterChain = null;
+        filterChain2 = null;
+        servletContext = null;
+        _dispatcher1 = null;
+        _dispatcher2 = null;
+        cleanUp = null;
+        filterDispatcher = null;
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        Dispatcher.setInstance(null);
+
+        filterConfig = new MockFilterConfig();
+        request = new MockHttpServletRequest();
+        response = new MockHttpServletResponse();
+        servletContext = new MockServletContext();
+
+        _dispatcher1 = new InnerDispatcher(servletContext){
+            @Override
+            public String toString() {
+                return "dispatcher1";
+            }
+        };
+        _dispatcher2 = new InnerDispatcher(servletContext){
+            @Override
+            public String toString() {
+                return "dispatcher2";
+            }
+        };
+        filterChain = new MockFilterChain() {
+            @Override
+            public void doFilter(ServletRequest req, ServletResponse res) throws IOException, ServletException {
+                filterDispatcher.doFilter(req, res, filterChain2);
+            }
+        };
+        filterChain2 = new MockFilterChain() {
+            @Override
+            public void doFilter(ServletRequest req, ServletResponse res) throws IOException, ServletException {
+            }
+        };
+
+
+        cleanUp = new ActionContextCleanUp() {
+            @Override
+            protected Dispatcher createDispatcher() {
+                cleanUpFilterCreateDispatcherCount++;
+                return _dispatcher1;
+            }
+
+            @Override
+            public String toString() {
+                return "cleanUp";
+            }
+        };
+
+        filterDispatcher = new FilterDispatcher() {
+            @Override
+            protected Dispatcher createDispatcher() {
+                filterDispatcherCreateDispatcherCount++;
+                return _dispatcher2;
+            }
+
+            @Override
+            public String toString() {
+                return "filterDispatcher";
+            }
+        };
+    }
+
+
+    public void testUsingFilterDispatcherOnly() throws Exception {
+        ObjectFactory oldObjecFactory = ObjectFactory.getObjectFactory();
+        try {
+            ObjectFactory.setObjectFactory(new InnerObjectFactory());
+            Settings.set(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterTest$InnerMapper");
+
+            assertEquals(cleanUpFilterCreateDispatcherCount, 0);
+            assertEquals(filterDispatcherCreateDispatcherCount, 0);
+            assertFalse(_dispatcher1.prepare);
+            assertFalse(_dispatcher1.wrapRequest);
+            assertFalse(_dispatcher1.service);
+            assertFalse(_dispatcher2.prepare);
+            assertFalse(_dispatcher2.wrapRequest);
+            assertFalse(_dispatcher2.service);
+
+            filterDispatcher.init(filterConfig);
+            filterDispatcher.doFilter(request, response, filterChain2);
+            filterDispatcher.destroy();
+
+            // we are using FilterDispatcher only, so cleanUp filter's Dispatcher should not be created.
+            assertEquals(cleanUpFilterCreateDispatcherCount, 0);
+            assertEquals(filterDispatcherCreateDispatcherCount, 1);
+            assertFalse(_dispatcher1.prepare);
+            assertFalse(_dispatcher1.wrapRequest);
+            assertFalse(_dispatcher1.service);
+            assertTrue(_dispatcher2.prepare);
+            assertTrue(_dispatcher2.wrapRequest);
+            assertTrue(_dispatcher2.service);
+            assertTrue(Dispatcher.getInstance() == null);
+        }
+        finally {
+            ObjectFactory.setObjectFactory(oldObjecFactory);
+        }
+    }
+
+    public void testUsingFilterDispatcherOnly_Multiple() throws Exception {
+        ObjectFactory oldObjecFactory = ObjectFactory.getObjectFactory();
+        try {
+            ObjectFactory.setObjectFactory(new InnerObjectFactory());
+            Settings.set(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterTest$InnerMapper");
+
+            assertEquals(cleanUpFilterCreateDispatcherCount, 0);
+            assertEquals(filterDispatcherCreateDispatcherCount, 0);
+            assertFalse(_dispatcher1.prepare);
+            assertFalse(_dispatcher1.wrapRequest);
+            assertFalse(_dispatcher1.service);
+            assertFalse(_dispatcher2.prepare);
+            assertFalse(_dispatcher2.wrapRequest);
+            assertFalse(_dispatcher2.service);
+
+            filterDispatcher.init(filterConfig);
+            filterDispatcher.doFilter(request, response, filterChain2);
+            filterDispatcher.doFilter(request, response, filterChain2);
+            filterDispatcher.destroy();
+
+            assertEquals(cleanUpFilterCreateDispatcherCount, 0);
+            // We should create dispatcher once, although filter.doFilter(...) is called  many times.
+            assertEquals(filterDispatcherCreateDispatcherCount, 1);
+            assertFalse(_dispatcher1.prepare);
+            assertFalse(_dispatcher1.wrapRequest);
+            assertFalse(_dispatcher1.service);
+            assertTrue(_dispatcher2.prepare);
+            assertTrue(_dispatcher2.wrapRequest);
+            assertTrue(_dispatcher2.service);
+            assertTrue(Dispatcher.getInstance() == null);
+        }
+        finally {
+            ObjectFactory.setObjectFactory(oldObjecFactory);
+        }
+    }
+
+    public void testUsingCleanUpAndFilterDispatcher() throws Exception {
+        ObjectFactory oldObjecFactory = ObjectFactory.getObjectFactory();
+        try {
+            ObjectFactory.setObjectFactory(new InnerObjectFactory());
+            Settings.set(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterTest$InnerMapper");
+
+            assertEquals(cleanUpFilterCreateDispatcherCount, 0);
+            assertEquals(filterDispatcherCreateDispatcherCount, 0);
+            assertFalse(_dispatcher1.prepare);
+            assertFalse(_dispatcher1.wrapRequest);
+            assertFalse(_dispatcher1.service);
+            assertFalse(_dispatcher2.prepare);
+            assertFalse(_dispatcher2.wrapRequest);
+            assertFalse(_dispatcher2.service);
+
+            cleanUp.init(filterConfig);
+            filterDispatcher.init(filterConfig);
+            cleanUp.doFilter(request, response, filterChain);
+            filterDispatcher.destroy();
+            cleanUp.destroy();
+
+            assertEquals(cleanUpFilterCreateDispatcherCount, 1);
+            assertEquals(filterDispatcherCreateDispatcherCount, 1);
+            assertTrue(_dispatcher1.prepare);
+            assertTrue(_dispatcher1.wrapRequest);
+            assertTrue(_dispatcher1.service);
+            assertFalse(_dispatcher2.prepare);
+            assertFalse(_dispatcher2.wrapRequest);
+            assertFalse(_dispatcher2.service);
+            assertTrue(Dispatcher.getInstance() == null);
+        }
+        finally {
+            ObjectFactory.setObjectFactory(oldObjecFactory);
+        }
+    }
+
+
+    public void testUsingCleanUpAndFilterDispatcher_Multiple() throws Exception {
+        ObjectFactory oldObjecFactory = ObjectFactory.getObjectFactory();
+        try {
+            ObjectFactory.setObjectFactory(new InnerObjectFactory());
+            Settings.set(StrutsConstants.STRUTS_MAPPER_CLASS, "org.apache.struts2.dispatcher.FilterTest$InnerMapper");
+
+            assertEquals(cleanUpFilterCreateDispatcherCount, 0);
+            assertEquals(filterDispatcherCreateDispatcherCount, 0);
+            assertFalse(_dispatcher1.prepare);
+            assertFalse(_dispatcher1.wrapRequest);
+            assertFalse(_dispatcher1.service);
+            assertFalse(_dispatcher2.prepare);
+            assertFalse(_dispatcher2.wrapRequest);
+            assertFalse(_dispatcher2.service);
+
+            cleanUp.init(filterConfig);
+            filterDispatcher.init(filterConfig);
+            cleanUp.doFilter(request, response, filterChain);
+            cleanUp.doFilter(request, response, filterChain);
+            filterDispatcher.destroy();
+            cleanUp.destroy();
+
+            assertEquals(cleanUpFilterCreateDispatcherCount, 1);
+            assertEquals(filterDispatcherCreateDispatcherCount, 1);
+            assertTrue(_dispatcher1.prepare);
+            assertTrue(_dispatcher1.wrapRequest);
+            assertTrue(_dispatcher1.service);
+            assertFalse(_dispatcher2.prepare);
+            assertFalse(_dispatcher2.wrapRequest);
+            assertFalse(_dispatcher2.service);
+            assertTrue(Dispatcher.getInstance() == null);
+        }
+        finally {
+            ObjectFactory.setObjectFactory(oldObjecFactory);
+        }
+    }
+
+
+    class InnerDispatcher extends Dispatcher {
+        public boolean prepare = false;
+        public boolean wrapRequest = false;
+        public boolean service = false;
+
+        public InnerDispatcher(ServletContext servletContext) {
+            super(servletContext);
+        }
+
+        @Override
+        public void prepare(HttpServletRequest request, HttpServletResponse response) {
+            prepare = true;
+        }
+
+        @Override
+        public HttpServletRequest wrapRequest(HttpServletRequest request, ServletContext servletContext) throws IOException {
+            wrapRequest = true;
+            return request;
+        }
+
+        @Override
+        public void serviceAction(HttpServletRequest request, HttpServletResponse response, ServletContext context, ActionMapping mapping) throws ServletException {
+            service = true;
+        }
+    }
+
+    class NullInnerMapper implements ActionMapper {
+        public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager) {
+            return null;
+        }
+
+        public String getUriFromActionMapping(ActionMapping mapping) {
+            return null;
+        }
+    }
+
+    public static class InnerMapper implements ActionMapper {
+
+        public InnerMapper() {}
+
+        public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager) {
+            return new ActionMapping();
+        }
+
+        public String getUriFromActionMapping(ActionMapping mapping) {
+            return "";
+        }
+    }
+
+    class InnerObjectFactory extends ObjectFactory {
+        public InnerObjectFactory() {
+            super();
+        }
+    }
 }
 

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/HttpHeaderResultTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/HttpHeaderResultTest.java?view=diff&rev=471756&r1=471755&r2=471756
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/HttpHeaderResultTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/HttpHeaderResultTest.java Mon Nov  6 07:01:43 2006
@@ -1,19 +1,22 @@
 /*
  * $Id$
  *
- * Copyright 2006 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
  *
- * 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
  *
- *      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.
+ * 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 org.apache.struts2.dispatcher;