You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2011/12/02 17:33:45 UTC

svn commit: r1209569 [45/50] - in /struts/struts2/branches/STRUTS_3_X: apps/blank/src/main/java/example/ apps/blank/src/test/java/example/ apps/jboss-blank/src/main/java/example/ apps/jboss-blank/src/test/java/example/ apps/mailreader/src/main/java/mai...

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/AddressTypeConverter.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/AddressTypeConverter.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/AddressTypeConverter.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/AddressTypeConverter.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,29 @@
+package org.apache.struts2.xwork2.test.annotations;
+
+import org.apache.struts2.xwork2.conversion.impl.DefaultTypeConverter;
+
+import java.util.Map;
+
+public class AddressTypeConverter extends DefaultTypeConverter {
+	@Override public Object convertValue(Map<String, Object> context, Object value, Class toType) {
+		if(value instanceof String) {
+			return decodeAddress((String)value);
+		} else if(value instanceof String && value.getClass().isArray()) {
+			return decodeAddress(((String[])value)[0]);
+		} else {
+			Address address = (Address)value;
+			return address.getLine1() + ":" + address.getLine2() + ":" +
+			       address.getCity() + ":" + address.getCountry();
+		}
+	}
+
+	private Address decodeAddress(String encodedAddress) {
+		String[] parts = ((String)encodedAddress).split(":");
+		Address address = new Address();
+		address.setLine1(parts[0]);
+		address.setLine2(parts[1]);
+		address.setCity(parts[2]);
+		address.setCountry(parts[3]);
+		return address;
+	}
+}
\ No newline at end of file

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/Person.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/Person.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/Person.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/Person.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,22 @@
+package org.apache.struts2.xwork2.test.annotations;
+
+public class Person {
+	private String firstName;
+	private String lastName;
+	
+	public String getFirstName() {
+		return firstName;
+	}
+	
+	public void setFirstName(String firstName) {
+		this.firstName = firstName;
+	}
+	
+	public String getLastName() {
+		return lastName;
+	}
+	
+	public void setLastName(String lastName) {
+		this.lastName = lastName;
+	}
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/PersonAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/PersonAction.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/PersonAction.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/PersonAction.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,47 @@
+package org.apache.struts2.xwork2.test.annotations;
+
+import org.apache.struts2.xwork2.conversion.annotations.Conversion;
+import org.apache.struts2.xwork2.conversion.annotations.ConversionType;
+import org.apache.struts2.xwork2.conversion.annotations.TypeConversion;
+import org.apache.struts2.xwork2.util.Element;
+
+import java.util.List;
+
+@Conversion(
+	conversions={
+		@TypeConversion(type=ConversionType.APPLICATION,
+						key="org.apache.struts2.xwork2.test.annotations.Address",
+						converter="org.apache.struts2.xwork2.test.annotations.AddressTypeConverter"),
+		@TypeConversion(type= ConversionType.APPLICATION,
+						key="org.apache.struts2.xwork2.test.annotations.Person",
+						converter="org.apache.struts2.xwork2.test.annotations.PersonTypeConverter")})
+public class PersonAction {
+	List<Person> users;
+	private List<Address> address;
+	@Element(Address.class)
+	private List addressesNoGenericElementAnnotation;
+
+	public List<Person> getUsers() {
+		return users;
+	}
+
+	public void setUsers(List<Person> users) {
+		this.users = users;
+	}
+
+	public void setAddress(List<Address> address) {
+		this.address = address;
+	}
+
+	public List<Address> getAddress() {
+		return address;
+	}
+
+	public void setAddressesNoGenericElementAnnotation(List addressesNoGenericElementAnnotation) {
+		this.addressesNoGenericElementAnnotation = addressesNoGenericElementAnnotation;
+	}
+
+	public List getAddressesNoGenericElementAnnotation() {
+		return addressesNoGenericElementAnnotation;
+	}
+}
\ No newline at end of file

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/PersonActionTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/PersonActionTest.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/PersonActionTest.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/PersonActionTest.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,87 @@
+package org.apache.struts2.xwork2.test.annotations;
+
+import org.apache.struts2.xwork2.ActionContext;
+import org.apache.struts2.xwork2.XWorkTestCase;
+import org.apache.struts2.xwork2.conversion.impl.XWorkConverter;
+import org.apache.struts2.xwork2.util.ValueStack;
+import org.apache.struts2.xwork2.util.reflection.ReflectionContextState;
+
+import java.util.Map;
+
+
+public class PersonActionTest extends XWorkTestCase {
+    
+	public void testAddPerson() {
+        ValueStack stack = ActionContext.getContext().getValueStack();
+
+        Map<String, Object> stackContext = stack.getContext();
+        stackContext.put(ReflectionContextState.CREATE_NULL_OBJECTS, Boolean.TRUE);
+        stackContext.put(ReflectionContextState.DENY_METHOD_EXECUTION, Boolean.TRUE);
+        stackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
+
+        PersonAction action = new PersonAction();
+        stack.push(action);
+
+        stack.setValue("users", "jonathan:gerrish");
+        assertNotNull(action.getUsers());
+        assertEquals(1, action.getUsers().size());
+        
+        for(Object person : action.getUsers()) {
+        	System.out.println("Person: " + person);
+        }
+        
+        assertEquals(Person.class, action.getUsers().get(0).getClass());
+        assertEquals("jonathan", action.getUsers().get(0).getFirstName());
+        assertEquals("gerrish", action.getUsers().get(0).getLastName());
+	}
+	
+	public void testAddAddress() {
+        ValueStack stack = ActionContext.getContext().getValueStack();
+		Map<String, Object> stackContext = stack.getContext();
+		stackContext.put(ReflectionContextState.CREATE_NULL_OBJECTS, Boolean.TRUE);
+		stackContext.put(ReflectionContextState.DENY_METHOD_EXECUTION, Boolean.TRUE);
+		stackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
+
+		PersonAction action = new PersonAction();
+		stack.push(action);
+
+		stack.setValue("address", "2 Chandos Court:61 Haverstock Hill:London:England");
+		assertNotNull(action.getAddress());
+		assertEquals(1, action.getAddress().size());
+
+		for(Object address : action.getAddress()) {
+			System.out.println("Address: " + address);
+		}
+
+		assertEquals(Address.class, action.getAddress().get(0).getClass());
+		assertEquals("2 Chandos Court", action.getAddress().get(0).getLine1());
+		assertEquals("61 Haverstock Hill", action.getAddress().get(0).getLine2());
+		assertEquals("London", action.getAddress().get(0).getCity());
+		assertEquals("England", action.getAddress().get(0).getCountry());
+	}
+	
+	public void testAddAddressesNoGenericElementAnnotation() {
+        ValueStack stack = ActionContext.getContext().getValueStack();
+		Map<String, Object> stackContext = stack.getContext();
+		stackContext.put(ReflectionContextState.CREATE_NULL_OBJECTS, Boolean.TRUE);
+		stackContext.put(ReflectionContextState.DENY_METHOD_EXECUTION, Boolean.TRUE);
+		stackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
+
+		PersonAction action = new PersonAction();
+		stack.push(action);
+
+		stack.setValue("addressesNoGenericElementAnnotation", "2 Chandos Court:61 Haverstock Hill:London:England");
+		assertNotNull(action.getAddressesNoGenericElementAnnotation());
+		assertEquals(1, action.getAddressesNoGenericElementAnnotation().size());
+
+		for(Object address : action.getAddressesNoGenericElementAnnotation()) {
+			System.out.println("Address: " + address);
+		}
+
+		assertEquals(Address.class, action.getAddressesNoGenericElementAnnotation().get(0).getClass());
+		assertEquals("2 Chandos Court", ((Address)action.getAddressesNoGenericElementAnnotation().get(0)).getLine1());
+		assertEquals("61 Haverstock Hill", ((Address)action.getAddressesNoGenericElementAnnotation().get(0)).getLine2());
+		assertEquals("London", ((Address)action.getAddressesNoGenericElementAnnotation().get(0)).getCity());
+		assertEquals("England", ((Address)action.getAddressesNoGenericElementAnnotation().get(0)).getCountry());
+	}
+}
\ No newline at end of file

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/PersonTypeConverter.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/PersonTypeConverter.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/PersonTypeConverter.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/PersonTypeConverter.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,27 @@
+package org.apache.struts2.xwork2.test.annotations;
+
+import org.apache.struts2.xwork2.conversion.impl.DefaultTypeConverter;
+
+import java.util.Map;
+
+public class PersonTypeConverter extends DefaultTypeConverter {
+	@Override
+    public Object convertValue(Map<String, Object> context, Object value, Class toType) {
+		if(value instanceof String) {
+			return decodePerson((String)value);
+		} else if(value instanceof String && value.getClass().isArray()) {
+			return decodePerson(((String[])value)[0]);
+		} else {
+			Person person = (Person)value;
+			return person.getFirstName() + ":" + person.getLastName();
+		}
+	}
+
+	private Person decodePerson(String encodedPerson) {
+		String[] parts = ((String)encodedPerson).split(":");
+		Person person = new Person();
+		person.setFirstName(parts[0]);
+		person.setLastName(parts[1]);
+		return person;
+	}
+}
\ No newline at end of file

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/ValidateAnnotatedMethodOnlyAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/ValidateAnnotatedMethodOnlyAction.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/ValidateAnnotatedMethodOnlyAction.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/annotations/ValidateAnnotatedMethodOnlyAction.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,55 @@
+package org.apache.struts2.xwork2.test.annotations;
+
+import org.apache.struts2.xwork2.ActionSupport;
+import org.apache.struts2.xwork2.validator.annotations.ExpressionValidator;
+import org.apache.struts2.xwork2.validator.annotations.Validation;
+
+/**
+ * <code>ValidateAnnotatedMethodOnlyAction</code>
+ *
+ * @author <a href="mailto:hermanns@aixcept.de">Rainer Hermanns</a>
+ * @version $Id: ValidateAnnotatedMethodOnlyAction.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+@Validation
+public class ValidateAnnotatedMethodOnlyAction extends ActionSupport {
+
+    String param1;
+    String param2;
+
+
+    public String getParam1() {
+        return param1;
+    }
+
+    public void setParam1(String param1) {
+        this.param1 = param1;
+    }
+
+    public String getParam2() {
+        return param2;
+    }
+
+    public void setParam2(String param2) {
+        this.param2 = param2;
+    }
+
+    @ExpressionValidator(expression = "(param1 != null) || (param2 != null)",
+            message = "Need param1 or param2.")
+    public String annotatedMethod() {
+        try {
+            // do search
+        } catch (Exception e) {
+            return INPUT;
+        }
+        return SUCCESS;
+    }
+
+    public String notAnnotatedMethod() {
+        try {
+            // do different search
+        } catch (Exception e) {
+            return INPUT;
+        }
+        return SUCCESS;
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/subtest/NullModelDrivenAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/subtest/NullModelDrivenAction.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/subtest/NullModelDrivenAction.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/test/subtest/NullModelDrivenAction.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,19 @@
+package org.apache.struts2.xwork2.test.subtest;
+
+import org.apache.struts2.xwork2.ModelDrivenAction;
+
+/**
+ * Extends ModelDrivenAction to return a null model.
+ *
+ * @author Mark Woon
+ */
+public class NullModelDrivenAction extends ModelDrivenAction {
+
+    /**
+     * @return the model to be pushed onto the ValueStack instead of the Action itself
+     */
+    @Override
+    public Object getModel() {
+        return null;
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/AnnotatedCat.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/AnnotatedCat.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/AnnotatedCat.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/AnnotatedCat.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2.util;
+
+import org.apache.struts2.xwork2.conversion.annotations.Conversion;
+import org.apache.struts2.xwork2.conversion.annotations.TypeConversion;
+
+import java.util.List;
+
+
+/**
+ * @author <a href="mailto:plightbo@cisco.com">Pat Lightbody</a>
+ * @author $Author: lukaszlenart $
+ * @author Rainer Hermanns
+ * @version $Revision: 1209415 $
+ */
+@Conversion()
+public class AnnotatedCat {
+
+    public static final String SCIENTIFIC_NAME = "Feline";
+
+
+    Foo foo;
+    List kittens;
+    String name;
+
+
+    public void setFoo(Foo foo) {
+        this.foo = foo;
+    }
+
+    public Foo getFoo() {
+        return foo;
+    }
+
+    public void setKittens(List kittens) {
+        this.kittens = kittens;
+    }
+
+    @TypeConversion(
+            key = "kittens", converter = "org.apache.struts2.xwork2.util.Cat"
+    )
+    public List getKittens() {
+        return kittens;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/AnnotationUtilsTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/AnnotationUtilsTest.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/AnnotationUtilsTest.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/AnnotationUtilsTest.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,101 @@
+package org.apache.struts2.xwork2.util;
+
+import junit.framework.TestCase;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+
+/**
+ * @author Dan Oxlade, dan d0t oxlade at gmail d0t c0m
+ */
+public class AnnotationUtilsTest extends TestCase {
+
+
+    public void testIsAnnotatedByWithoutAnnotationArgsReturnsFalse() throws Exception {
+
+        assertFalse(AnnotationUtils.isAnnotatedBy(DummyClass.class));
+        assertFalse(AnnotationUtils.isAnnotatedBy(DummyClass.class.getMethod("methodWithAnnotation")));
+
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testIsAnnotatedByWithSingleAnnotationArgMatchingReturnsTrue() throws Exception {
+
+        assertTrue(AnnotationUtils.isAnnotatedBy(DummyClass.class.getMethod("methodWithAnnotation"), MyAnnotation.class));
+
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testIsAnnotatedByWithMultiAnnotationArgMatchingReturnsTrue() throws Exception {
+
+        assertFalse(AnnotationUtils.isAnnotatedBy(DummyClass.class.getMethod("methodWithAnnotation"), Deprecated.class));
+        assertTrue(AnnotationUtils.isAnnotatedBy(DummyClass.class.getMethod("methodWithAnnotation"), MyAnnotation.class, Deprecated.class));
+        assertTrue(AnnotationUtils.isAnnotatedBy(DummyClass.class.getMethod("methodWithAnnotation"), Deprecated.class, MyAnnotation.class));
+
+    }
+
+    public void testGetAnnotedMethodsWithoutAnnotationArgs() throws Exception {
+
+        Collection<? extends AnnotatedElement> ans = AnnotationUtils.getAnnotatedMethods(DummyClass.class);
+
+        assertTrue(ans.size() == 1);
+
+        assertEquals(ans.iterator().next(), DummyClass.class.getMethod("methodWithAnnotation"));
+
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testGetAnnotatedMethodsWithAnnotationArgs() throws Exception {
+
+        Collection<? extends AnnotatedElement> ans = AnnotationUtils.getAnnotatedMethods(DummyClass.class, Deprecated.class);
+        assertTrue(ans.isEmpty());
+
+        ans = AnnotationUtils.getAnnotatedMethods(DummyClass.class, Deprecated.class, MyAnnotation.class);
+        assertEquals(1, ans.size());
+
+        ans = AnnotationUtils.getAnnotatedMethods(DummyClass.class, MyAnnotation.class);
+        assertEquals(1, ans.size());
+
+        ans = AnnotationUtils.getAnnotatedMethods(DummyClass.class, MyAnnotation.class, MyAnnotation2.class);
+        assertEquals(1, ans.size());
+
+        ans = AnnotationUtils.getAnnotatedMethods(DummyClassExt.class, MyAnnotation.class, MyAnnotation2.class);
+        assertEquals(2, ans.size());
+
+    }
+
+    /**
+     * *****************************************************************
+     * <p/>
+     * TEST CLASSES
+     */
+    private static class DummyClass {
+
+        public DummyClass() {
+        }
+
+        @MyAnnotation
+        public void methodWithAnnotation() {
+        }
+
+    }
+
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface MyAnnotation {
+    }
+
+    private static final class DummyClassExt extends DummyClass {
+
+        @MyAnnotation2
+        public void anotherAnnotatedMethod() {
+        }
+
+    }
+
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface MyAnnotation2 {
+    }
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Bar.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Bar.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Bar.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Bar.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2002-2003,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2.util;
+
+import org.apache.struts2.xwork2.ActionSupport;
+
+
+/**
+ * @author <a href="mailto:plightbo@cisco.com">Pat Lightbody</a>
+ * @author $Author: lukaszlenart $
+ * @version $Revision: 1209415 $
+ */
+public class Bar extends ActionSupport {
+
+    Long id;
+    String title;
+    int somethingElse;
+
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getId() {
+        return this.id;
+    }
+
+    public void setSomethingElse(int somethingElse) {
+        this.somethingElse = somethingElse;
+    }
+
+    public int getSomethingElse() {
+        return somethingElse;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    @Override
+    public String toString() {
+        return getTitle() + ":" + getSomethingElse();
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/BarJunior.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/BarJunior.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/BarJunior.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/BarJunior.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,4 @@
+package org.apache.struts2.xwork2.util;
+
+public class BarJunior extends Bar {
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Cat.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Cat.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Cat.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Cat.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2002-2003,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2.util;
+
+import java.util.List;
+
+
+/**
+ * @author <a href="mailto:plightbo@cisco.com">Pat Lightbody</a>
+ * @author $Author: lukaszlenart $
+ * @version $Revision: 1209415 $
+ */
+public class Cat {
+
+    public static final String SCIENTIFIC_NAME = "Feline";
+
+    Foo foo;
+    List kittens;
+    String name;
+
+
+    public void setFoo(Foo foo) {
+        this.foo = foo;
+    }
+
+    public Foo getFoo() {
+        return foo;
+    }
+
+    public void setKittens(List kittens) {
+        this.kittens = kittens;
+    }
+
+    public List getKittens() {
+        return kittens;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/ClassLoaderUtilTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/ClassLoaderUtilTest.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/ClassLoaderUtilTest.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/ClassLoaderUtilTest.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2002-2003,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2.util;
+
+import junit.framework.TestCase;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Arrays;
+import java.util.Enumeration;
+
+public class ClassLoaderUtilTest extends TestCase {
+
+    public void testGetResources() throws IOException {
+        Iterator<URL> i = ClassLoaderUtil.getResources("xwork-sample.xml", ClassLoaderUtilTest.class, false);
+        assertNotNull(i);
+        
+        assertTrue(i.hasNext());
+        URL url = i.next();
+        assertTrue(url.toString().endsWith("xwork-sample.xml"));
+        assertTrue(!i.hasNext());
+    }
+    
+    public void testGetResources_Multiple() throws IOException {
+        Iterator<URL> i = ClassLoaderUtil.getResources("xwork-1.0.dtd", ClassLoaderUtilTest.class, false);
+        assertNotNull(i);
+        
+        assertTrue(i.hasNext());
+        URL url = i.next();
+        assertTrue(url.toString().endsWith("xwork-1.0.dtd"));
+        url = i.next();
+        assertTrue(url.toString().endsWith("xwork-1.0.dtd"));
+        assertTrue(!i.hasNext());
+    }
+
+    public void testGetResources_Aggregate() throws IOException {
+        Iterator<URL> i = ClassLoaderUtil.getResources("xwork-1.0.dtd", ClassLoaderUtilTest.class, true);
+        assertNotNull(i);
+
+        assertTrue(i.hasNext());
+        URL url = i.next();
+        assertTrue(url.toString().endsWith("xwork-1.0.dtd"));
+        url = i.next();
+        assertTrue(url.toString().endsWith("xwork-1.0.dtd"));
+        assertTrue(!i.hasNext());
+    }
+
+    public void testGetResources_None() throws IOException {
+        Iterator<URL> i = ClassLoaderUtil.getResources("asdfasdf.html", ClassLoaderUtilTest.class, false);
+        assertNotNull(i);
+        
+        assertTrue(!i.hasNext());
+    }
+
+    public void testGetResource() {
+        URL url = ClassLoaderUtil.getResource("xwork-sample.xml", ClassLoaderUtilTest.class);
+        assertNotNull(url);
+        
+        assertTrue(url.toString().endsWith("xwork-sample.xml"));
+    }
+    
+    public void testGetResource_None() {
+        URL url = ClassLoaderUtil.getResource("asf.xml", ClassLoaderUtilTest.class);
+        assertNull(url);
+    }
+
+    public void testAggregateIterator() {
+       ClassLoaderUtil.AggregateIterator<String> aggr = new ClassLoaderUtil.AggregateIterator<String>();
+
+       Enumeration en1 = new Enumeration() {
+           private Iterator itt = Arrays.asList("str1", "str1", "str3", "str1").iterator();
+           public boolean hasMoreElements() {
+               return itt.hasNext();
+           }
+
+           public Object nextElement() {
+               return itt.next();
+           }
+       };
+
+       Enumeration en2 = new Enumeration() {
+           private Iterator itt = Arrays.asList("str4", "str5").iterator();
+           public boolean hasMoreElements() {
+               return itt.hasNext();
+           }
+
+           public Object nextElement() {
+               return itt.next();
+           }
+       };
+
+
+       aggr.addEnumeration(en1);
+       aggr.addEnumeration(en2);
+
+       assertTrue(aggr.hasNext());
+       assertEquals("str1", aggr.next());
+
+       assertTrue(aggr.hasNext());
+       assertEquals("str3", aggr.next());
+
+       assertTrue(aggr.hasNext());
+       assertEquals("str4", aggr.next());
+
+       assertTrue(aggr.hasNext());
+       assertEquals("str5", aggr.next());
+
+       assertFalse(aggr.hasNext());
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/ClassPathFinderTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/ClassPathFinderTest.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/ClassPathFinderTest.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/ClassPathFinderTest.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,54 @@
+/*
+ * $Id: ClassPathFinderTest.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ *
+ * Copyright 2003-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2.util;
+
+import org.apache.struts2.xwork2.XWorkTestCase;
+
+import java.util.Vector;
+
+public class ClassPathFinderTest extends XWorkTestCase {
+	
+	public void testFinder() {
+		ClassPathFinder finder = new ClassPathFinder();
+		finder.setPattern("**/xwork-test-wildcard-*.xml");
+		Vector<String> found = finder.findMatches();
+		assertEquals(found.contains("org/apache/struts2/xwork2/config/providers/xwork-test-wildcard-1.xml"), true );
+		assertEquals(found.contains("org/apache/struts2/xwork2/config/providers/xwork-test-wildcard-2.xml"), true );
+		assertEquals(found.contains("org/apache/struts2/xwork2/config/providers/xwork-test-wildcard-include.xml"), true );
+		assertEquals(found.contains("org/apache/struts2/xwork2/config/providers/xwork-test-results.xml"), false);
+		
+		ClassPathFinder finder2 = new ClassPathFinder();
+		finder2.setPattern("org/**/xwork2/config/providers/xwork-test-wildcard-1.xml");
+		Vector<String> found2 = finder2.findMatches();
+		assertEquals(found2.contains("org/apache/struts2/xwork2/config/providers/xwork-test-wildcard-1.xml"), true);
+		assertEquals(found2.contains("org/apache/struts2/xwork2/config/providers/xwork-test-wildcard-2.xml"), false);
+		
+		ClassPathFinder finder3 = new ClassPathFinder();
+		finder3.setPattern("org/apache/struts2/xwork2/config/providers/xwork-test-wildcard-1.xml");
+		Vector<String> found3 = finder3.findMatches();
+		assertEquals(found3.contains("org/apache/struts2/xwork2/config/providers/xwork-test-wildcard-1.xml"), true);
+		assertEquals(found3.contains("org/apache/struts2/xwork2/config/providers/xwork-test-wildcard-2.xml"), false);
+		
+		ClassPathFinder finder4 = new ClassPathFinder();
+		finder4.setPattern("no/matches/*");
+		Vector<String> found4 = finder4.findMatches();
+		assertEquals(found4.isEmpty(), true);
+		
+	}
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Dog.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Dog.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Dog.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Dog.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2002-2003,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2.util;
+
+import java.io.Serializable;
+
+
+/**
+ * @author <a href="mailto:plightbo@cisco.com">Pat Lightbody</a>
+ * @author $Author: lukaszlenart $
+ * @version $Revision: 1209415 $
+ */
+public class Dog implements Serializable {
+
+    public static final String SCIENTIFIC_NAME = "Canine";
+
+
+    Cat hates;
+    String name;
+    int[] childAges;
+    boolean male;
+    int age;
+    static String deity;
+
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public int getAge() {
+        return age;
+    }
+
+    public void setChildAges(int[] childAges) {
+        this.childAges = childAges;
+    }
+
+    public int[] getChildAges() {
+        return childAges;
+    }
+
+    public void setException(String blah) throws Exception {
+        throw new Exception("This is expected");
+    }
+
+    public String getException() throws Exception {
+        throw new Exception("This is expected");
+    }
+
+    public void setHates(Cat hates) {
+        this.hates = hates;
+    }
+
+    public Cat getHates() {
+        return hates;
+    }
+
+    public void setMale(boolean male) {
+        this.male = male;
+    }
+
+    public boolean isMale() {
+        return male;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+    
+    public static String getDeity() {
+        return deity;
+    }
+
+    public static void setDeity(String deity) {
+        Dog.deity = deity;
+    }
+
+    public int computeDogYears() {
+        return age * 7;
+    }
+
+    public int multiplyAge(int by) {
+        return age * by;
+    }
+
+    /**
+     * @return null
+     */
+    public Integer nullMethod() {
+        return null;
+    }
+
+    /**
+     * a method which is safe to call with a null argument
+     *
+     * @param arg the Boolean to return
+     * @return arg, if it is not null, or Boolean.TRUE if arg is null
+     */
+    public Boolean nullSafeMethod(Boolean arg) {
+        return (arg == null) ? Boolean.TRUE : arg;
+    }
+
+    public void getBite() {
+        throw new RuntimeException("wuf wuf");
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/DomHelperTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/DomHelperTest.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/DomHelperTest.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/DomHelperTest.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2002-2003,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2.util;
+
+import org.apache.struts2.xwork2.util.location.Location;
+import junit.framework.TestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+import java.io.StringReader;
+
+/**
+ * Test cases for {@link DomHelper}.
+ */
+public class DomHelperTest extends TestCase {
+
+    private String xml = "<!DOCTYPE foo [\n" +
+                         "<!ELEMENT foo (bar)>\n" +
+                         "<!ELEMENT bar (#PCDATA)>\n" +
+                         "]>\n" +
+                         "<foo>\n" +
+                         " <bar/>\n" +
+                         "</foo>\n";
+    
+    public void testParse() throws Exception {
+        InputSource in = new InputSource(new StringReader(xml));
+        in.setSystemId("foo://bar");
+        
+        Document doc = DomHelper.parse(in);
+        assertNotNull(doc);
+        assertTrue("Wrong root node",
+            "foo".equals(doc.getDocumentElement().getNodeName()));
+        
+        NodeList nl = doc.getElementsByTagName("bar");
+        assertTrue(nl.getLength() == 1);
+        
+        
+        
+    }
+    
+    public void testGetLocationObject() throws Exception {
+        InputSource in = new InputSource(new StringReader(xml));
+        in.setSystemId("foo://bar");
+        
+        Document doc = DomHelper.parse(in);
+        
+        NodeList nl = doc.getElementsByTagName("bar");
+        
+        Location loc = DomHelper.getLocationObject((Element)nl.item(0));
+        
+        assertNotNull(loc);
+        assertTrue("Should be line 6, was "+loc.getLineNumber(), 
+            6==loc.getLineNumber());
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/FileManagerTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/FileManagerTest.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/FileManagerTest.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/FileManagerTest.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,36 @@
+package org.apache.struts2.xwork2.util;
+
+import org.apache.struts2.xwork2.XWorkTestCase;
+
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * FileManager Tester.
+ *
+ * @author <Lukasz>
+ * @since <pre>02/18/2009</pre>
+ * @version 1.0
+ */
+public class FileManagerTest extends XWorkTestCase {
+
+    public void testGetFileInJar() throws Exception {
+        testLoadFile("xwork-jar.xml");
+        testLoadFile("xwork - jar.xml");
+        testLoadFile("xwork-zip.xml");
+        testLoadFile("xwork - zip.xml");
+        testLoadFile("xwork-jar2.xml");
+        testLoadFile("xwork - jar2.xml");
+        testLoadFile("xwork-zip2.xml");
+        testLoadFile("xwork - zip2.xml");
+    }
+
+    private void testLoadFile(String fileName) {
+        FileManager.setReloadingConfigs(true);
+        URL url = ClassLoaderUtil.getResource(fileName, FileManagerTest.class);
+        InputStream file = FileManager.loadFile(url, true);
+        assertNotNull(file);
+        assertFalse(!FileManager.fileNeedsReloading(fileName));
+    }
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Foo.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Foo.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Foo.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Foo.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,218 @@
+/*
+ * Copyright 2002-2003,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2.util;
+
+import java.util.*;
+
+
+/**
+ * @author <a href="mailto:plightbo@cisco.com">Pat Lightbody</a>
+ * @author $Author: lukaszlenart $
+ * @version $Revision: 1209415 $
+ */
+public class Foo {
+
+    Bar bar;
+    Date birthday;
+    Date event;
+    Date meeting;
+    Foo child;
+    List cats;
+    List moreCats;
+    List strings;
+    Collection barCollection;
+    Map catMap;
+    Map anotherCatMap;
+    String title;
+    long[] points;
+    Foo[] relatives;
+    boolean useful;
+    int number;
+    long aLong;
+    Calendar calendar;
+    BarJunior barJunior;
+
+    public BarJunior getBarJunior() {
+        return barJunior;
+    }
+
+    public void setBarJunior(BarJunior barJunior) {
+        this.barJunior = barJunior;
+    }
+
+    public void setALong(long aLong) {
+        this.aLong = aLong;
+    }
+
+    public long getALong() {
+        return aLong;
+    }
+
+    public void setBar(Bar bar) {
+        this.bar = bar;
+    }
+
+    public Bar getBar() {
+        return bar;
+    }
+
+    public void setBirthday(Date birthday) {
+        this.birthday = birthday;
+    }
+
+    public Date getBirthday() {
+        return birthday;
+    }
+
+    public void setCatMap(Map catMap) {
+        this.catMap = catMap;
+    }
+
+    public Map getCatMap() {
+        return catMap;
+    }
+
+    public void setCats(List cats) {
+        this.cats = cats;
+    }
+
+    public List getCats() {
+        return cats;
+    }
+
+    public void setChild(Foo child) {
+        this.child = child;
+    }
+
+    public Foo getChild() {
+        return child;
+    }
+
+    public void setNumber(int number) {
+        this.number = number;
+    }
+
+    public int getNumber() {
+        return number;
+    }
+
+    /**
+     * @return Returns the anotherCatMap.
+     */
+    public Map getAnotherCatMap() {
+        return anotherCatMap;
+    }
+
+    /**
+     * @param anotherCatMap The anotherCatMap to set.
+     */
+    public void setAnotherCatMap(Map anotherCatMap) {
+        this.anotherCatMap = anotherCatMap;
+    }
+
+    /**
+     * @return Returns the moreCats.
+     */
+    public List getMoreCats() {
+        return moreCats;
+    }
+
+    /**
+     * @param moreCats The moreCats to set.
+     */
+    public void setMoreCats(List moreCats) {
+        this.moreCats = moreCats;
+    }
+
+    /**
+     * @return Returns the catSet.
+     */
+    public Collection getBarCollection() {
+        return barCollection;
+    }
+
+    /**
+     * @param barCollection The barCollection to set.
+     */
+    public void setBarCollection(Collection barCollection) {
+        this.barCollection = barCollection;
+    }
+
+    public void setPoints(long[] points) {
+        this.points = points;
+    }
+
+    public long[] getPoints() {
+        return points;
+    }
+
+    public void setRelatives(Foo[] relatives) {
+        this.relatives = relatives;
+    }
+
+    public Foo[] getRelatives() {
+        return relatives;
+    }
+
+    public void setStrings(List strings) {
+        this.strings = strings;
+    }
+
+    public List getStrings() {
+        return strings;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setUseful(boolean useful) {
+        this.useful = useful;
+    }
+
+    public boolean isUseful() {
+        return useful;
+    }
+    
+    
+    public Date getEvent() {
+    	return event;
+    }
+    
+    public void setEvent(Date event) {
+    	this.event = event;
+    }
+    
+    public Date getMeeting() {
+    	return meeting;
+    }
+    
+    public void setMeeting(Date meeting) {
+    	this.meeting = meeting;
+    }
+
+    public Calendar getCalendar() {
+        return calendar;
+    }
+
+    public void setCalendar(Calendar calendar) {
+        this.calendar = calendar;
+    }     
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/FurColor.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/FurColor.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/FurColor.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/FurColor.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2002-2003,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2.util;
+
+public enum FurColor {
+    BROWN, BLACK, GREEN
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/GetPropertiesTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/GetPropertiesTest.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/GetPropertiesTest.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/GetPropertiesTest.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,40 @@
+/*
+ * Created on Jan 23, 2006
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.struts2.xwork2.util;
+
+import org.apache.struts2.xwork2.ActionContext;
+import org.apache.struts2.xwork2.XWorkTestCase;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * @author Gabe
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class GetPropertiesTest extends XWorkTestCase {
+
+    public void testGetCollectionProperties()  {
+        doGetCollectionPropertiesTest(new ArrayList());
+        doGetCollectionPropertiesTest(new HashSet());
+        
+    }
+    
+    public void doGetCollectionPropertiesTest(Collection c) {
+        ValueStack vs = ActionContext.getContext().getValueStack();
+        Foo foo = new Foo();
+        foo.setBarCollection(c);
+        vs.push(foo);
+        assertEquals(Boolean.TRUE, vs.findValue("barCollection.isEmpty"));
+        assertEquals(Boolean.TRUE, vs.findValue("barCollection.empty"));
+        assertEquals(new Integer(0), vs.findValue("barCollection.size"));
+        assertTrue(vs.findValue("barCollection.iterator") instanceof java.util.Iterator);
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Indexed.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Indexed.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Indexed.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Indexed.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,41 @@
+package org.apache.struts2.xwork2.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author mimo
+ *
+ */
+public class Indexed {
+
+    public Object[] values = new Object[3];
+    public Map<String, Object> map = new HashMap<String, Object>();
+
+    public void setSimple(int i, Object v) {
+        values[i] = v;
+    }
+
+    public Object getSimple(int i) {
+        return values[i];
+    }
+
+
+
+    public void setIntegerMap(String key, Integer value) {
+        map.put(key, value);
+    }
+
+    public Integer getIntegerMap(String key) {
+        return (Integer) map.get(key);
+    }
+
+    public void setStringMap(String key, String value) {
+        map.put(key, value);
+    }
+
+    public String getStringMap(String key) {
+        return (String) map.get(key);
+    }
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/ListHolder.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/ListHolder.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/ListHolder.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/ListHolder.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,37 @@
+package org.apache.struts2.xwork2.util;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * User: patrick Date: Dec 20, 2005 Time: 11:15:29 AM
+ */
+public class ListHolder {
+    List<Long> longs;
+    List<String> strings;
+    List<Date> dates;
+
+    public List<Long> getLongs() {
+        return longs;
+    }
+
+    public void setLongs(List<Long> longs) {
+        this.longs = longs;
+    }
+
+    public List<String> getStrings() {
+        return strings;
+    }
+
+    public void setStrings(List<String> strings) {
+        this.strings = strings;
+    }
+
+    public List<Date> getDates() {
+        return dates;
+    }
+
+    public void setDates(List<Date> dates) {
+        this.dates = dates;
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/LocalizedTextUtilTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/LocalizedTextUtilTest.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/LocalizedTextUtilTest.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/LocalizedTextUtilTest.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,268 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2.util;
+
+import com.mockobjects.dynamic.Mock;
+import org.apache.struts2.xwork2.ActionContext;
+import org.apache.struts2.xwork2.ActionSupport;
+import org.apache.struts2.xwork2.XWorkMessages;
+import org.apache.struts2.xwork2.config.providers.XmlConfigurationProvider;
+import org.apache.struts2.xwork2.test.ModelDrivenAction2;
+import org.apache.struts2.xwork2.test.TestBean2;
+import org.apache.struts2.xwork2.Action;
+import org.apache.struts2.xwork2.ActionInvocation;
+import org.apache.struts2.xwork2.ActionProxy;
+import org.apache.struts2.xwork2.ModelDriven;
+import org.apache.struts2.xwork2.XWorkTestCase;
+import org.apache.struts2.xwork2.SimpleAction;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+
+/**
+ * Unit test for {@link LocalizedTextUtil}.
+ *
+ * @author jcarreira
+ * @author tm_jee
+ * 
+ * @version $Date: 2011-12-02 12:24:48 +0100 (Fri, 02 Dec 2011) $ $Id: LocalizedTextUtilTest.java 1209415 2011-12-02 11:24:48Z lukaszlenart $
+ */
+public class LocalizedTextUtilTest extends XWorkTestCase {
+
+	public void testNpeWhenClassIsPrimitive() throws Exception {
+		ValueStack stack = ActionContext.getContext().getValueStack();
+		stack.push(new MyObject());
+		String result = LocalizedTextUtil.findText(MyObject.class, "someObj.someI18nKey", Locale.ENGLISH, "default message", null, stack);
+		System.out.println(result);
+	}
+	
+	public static class MyObject extends ActionSupport {
+		public boolean getSomeObj() {
+			return true;
+		}
+	}
+	
+	public void testActionGetTextWithNullObject() throws Exception {
+		MyAction action = new MyAction();
+		
+		Mock mockActionInvocation = new Mock(ActionInvocation.class);
+        mockActionInvocation.expectAndReturn("getAction", action);
+        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
+		ActionContext.getContext().getValueStack().push(action);
+		
+		String message = action.getText("barObj.title");
+		assertEquals("Title:", message);
+	}
+	
+	
+	public static class MyAction extends ActionSupport {
+		private Bar testBean2;
+		
+		public Bar getBarObj() {
+			return testBean2;
+		}
+		public void setBarObj(Bar testBean2) {
+			this.testBean2 = testBean2;
+		}
+	}
+	
+    public void testActionGetText() throws Exception {
+        ModelDrivenAction2 action = new ModelDrivenAction2();
+        TestBean2 bean = (TestBean2) action.getModel();
+        Bar bar = new Bar();
+        bean.setBarObj(bar);
+
+        Mock mockActionInvocation = new Mock(ActionInvocation.class);
+        mockActionInvocation.expectAndReturn("getAction", action);
+        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
+        ActionContext.getContext().getValueStack().push(action);
+        ActionContext.getContext().getValueStack().push(action.getModel());
+
+        String message = action.getText("barObj.title");
+        assertEquals("Title:", message);
+    }
+
+    public void testNullKeys() {
+        LocalizedTextUtil.findText(this.getClass(), null, Locale.getDefault());
+    }
+
+    public void testActionGetTextXXX() throws Exception {
+        LocalizedTextUtil.addDefaultResourceBundle("org/apache/struts2/xwork2/util/FindMe");
+
+        SimpleAction action = new SimpleAction();
+
+        Mock mockActionInvocation = new Mock(ActionInvocation.class);
+        mockActionInvocation.expectAndReturn("getAction", action);
+        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
+        ActionContext.getContext().getValueStack().push(action);
+
+        String message = action.getText("bean.name");
+        String foundBean2 = action.getText("bean2.name");
+
+        assertEquals("Okay! You found Me!", foundBean2);
+        assertEquals("Haha you cant FindMe!", message);
+    }
+
+    public void testAddDefaultResourceBundle() {
+        String text = LocalizedTextUtil.findDefaultText("foo.range", Locale.getDefault());
+        assertNull("Found message when it should not be available.", null);
+
+        LocalizedTextUtil.addDefaultResourceBundle("org/apache/struts2/xwork2/SimpleAction");
+
+        String message = LocalizedTextUtil.findDefaultText("foo.range", Locale.US);
+        assertEquals("Foo Range Message", message);
+    }
+
+    public void testAddDefaultResourceBundle2() throws Exception {
+        LocalizedTextUtil.addDefaultResourceBundle("org/apache/struts2/xwork2/SimpleAction");
+
+        ActionProxy proxy = actionProxyFactory.createActionProxy("/", "packagelessAction", new HashMap<String, Object>(), false, true);
+        proxy.execute();
+    }
+
+    public void testDefaultMessage() throws Exception {
+        String message = LocalizedTextUtil.findDefaultText(XWorkMessages.ACTION_EXECUTION_ERROR, Locale.getDefault());
+        assertEquals("Error during Action invocation", message);
+    }
+
+    public void testDefaultMessageOverride() throws Exception {
+        String message = LocalizedTextUtil.findDefaultText(XWorkMessages.ACTION_EXECUTION_ERROR, Locale.getDefault());
+        assertEquals("Error during Action invocation", message);
+
+        LocalizedTextUtil.addDefaultResourceBundle("org/apache/struts2/xwork2/test");
+
+        message = LocalizedTextUtil.findDefaultText(XWorkMessages.ACTION_EXECUTION_ERROR, Locale.getDefault());
+        assertEquals("Testing resource bundle override", message);
+    }
+
+    public void testFindTextInChildProperty() throws Exception {
+        ModelDriven action = new ModelDrivenAction2();
+        TestBean2 bean = (TestBean2) action.getModel();
+        Bar bar = new Bar();
+        bean.setBarObj(bar);
+
+        Mock mockActionInvocation = new Mock(ActionInvocation.class);
+        mockActionInvocation.expectAndReturn("hashCode", 0);
+        mockActionInvocation.expectAndReturn("getAction", action);
+        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
+        ActionContext.getContext().getValueStack().push(action);
+        ActionContext.getContext().getValueStack().push(action.getModel());
+
+        String message = LocalizedTextUtil.findText(ModelDrivenAction2.class, "invalid.fieldvalue.barObj.title", Locale.getDefault());
+        assertEquals("Title is invalid!", message);
+    }
+
+    public void testFindTextInInterface() throws Exception {
+        Action action = new ModelDrivenAction2();
+        Mock mockActionInvocation = new Mock(ActionInvocation.class);
+        mockActionInvocation.expectAndReturn("getAction", action);
+        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
+
+        String message = LocalizedTextUtil.findText(ModelDrivenAction2.class, "test.foo", Locale.getDefault());
+        assertEquals("Foo!", message);
+    }
+
+    public void testFindTextInPackage() throws Exception {
+        ModelDriven action = new ModelDrivenAction2();
+
+        Mock mockActionInvocation = new Mock(ActionInvocation.class);
+        mockActionInvocation.expectAndReturn("getAction", action);
+        ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
+
+        String message = LocalizedTextUtil.findText(ModelDrivenAction2.class, "package.properties", Locale.getDefault());
+        assertEquals("It works!", message);
+    }
+
+    public void testParameterizedDefaultMessage() throws Exception {
+        String message = LocalizedTextUtil.findDefaultText(XWorkMessages.MISSING_ACTION_EXCEPTION, Locale.getDefault(), new String[]{"AddUser"});
+        assertEquals("There is no Action mapped for action name AddUser.", message);
+    }
+
+    public void testParameterizedDefaultMessageWithPackage() throws Exception {
+        String message = LocalizedTextUtil.findDefaultText(XWorkMessages.MISSING_PACKAGE_ACTION_EXCEPTION, Locale.getDefault(), new String[]{"blah", "AddUser"});
+        assertEquals("There is no Action mapped for namespace blah and action name AddUser.", message);
+    }
+
+    public void testLocalizedDateFormatIsUsed() {
+        LocalizedTextUtil.addDefaultResourceBundle("org/apache/struts2/xwork2/util/LocalizedTextUtilTest");
+        Object[] params = new Object[]{new Date()};
+        String usDate = LocalizedTextUtil.findDefaultText("test.format.date", Locale.US, params);
+        String germanDate = LocalizedTextUtil.findDefaultText("test.format.date", Locale.GERMANY, params);
+        assertFalse(usDate.equals(germanDate));
+    }
+
+    public void testXW377() {
+        LocalizedTextUtil.addDefaultResourceBundle("org/apache/struts2/xwork2/util/LocalizedTextUtilTest");
+
+        String text = LocalizedTextUtil.findText(Bar.class, "xw377", ActionContext.getContext().getLocale(), "xw377", null, ActionContext.getContext().getValueStack());
+        assertEquals("xw377", text); // should not log
+
+        String text2 = LocalizedTextUtil.findText(LocalizedTextUtilTest.class, "notinbundle", ActionContext.getContext().getLocale(), "hello", null, ActionContext.getContext().getValueStack());
+        assertEquals("hello", text2); // should log WARN
+
+        String text3 = LocalizedTextUtil.findText(LocalizedTextUtilTest.class, "notinbundle.key", ActionContext.getContext().getLocale(), "notinbundle.key", null, ActionContext.getContext().getValueStack());
+        assertEquals("notinbundle.key", text3); // should log WARN
+
+        String text4 = LocalizedTextUtil.findText(LocalizedTextUtilTest.class, "xw377", ActionContext.getContext().getLocale(), "hello", null, ActionContext.getContext().getValueStack());
+        assertEquals("xw377", text4); // should not log
+
+        String text5 = LocalizedTextUtil.findText(LocalizedTextUtilTest.class, "username", ActionContext.getContext().getLocale(), null, null, ActionContext.getContext().getValueStack());
+        assertEquals("Santa", text5); // should not log
+    }
+
+    public void testXW404() {
+        // This tests will try to load bundles from the 3 locales but we only have files for France and Germany.
+        // Before this fix loading the bundle for Germany failed since Italy have previously failed and thus the misses cache
+        // contained a false entry
+
+        // Set default Locale to Locale.US
+        Locale defaultLocale = Locale.getDefault();
+        Locale.setDefault(Locale.US);
+
+        ResourceBundle rbFrance = LocalizedTextUtil.findResourceBundle("org/apache/struts2/xwork2/util/XW404", Locale.FRANCE);
+        ResourceBundle rbItaly = LocalizedTextUtil.findResourceBundle("org/apache/struts2/xwork2/util/XW404", Locale.ITALY);
+        ResourceBundle rbGermany = LocalizedTextUtil.findResourceBundle("org/apache/struts2/xwork2/util/XW404", Locale.GERMANY);
+
+        // Reset to previous default Locale 
+        Locale.setDefault(defaultLocale);
+
+        assertNotNull(rbFrance);
+        assertEquals("Bonjour", rbFrance.getString("hello"));
+
+        assertNull(rbItaly);
+
+        assertNotNull(rbGermany);
+        assertEquals("Hallo", rbGermany.getString("hello"));
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        loadConfigurationProviders(new XmlConfigurationProvider("xwork-sample.xml"));
+
+        ActionContext.getContext().setLocale(Locale.US);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        LocalizedTextUtil.clearDefaultResourceBundles();
+    }
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/MyBean.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/MyBean.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/MyBean.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/MyBean.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2.util;
+
+import java.io.Serializable;
+
+/**
+ * <code>MyBean</code>
+ *
+ * @author Rainer Hermanns
+ */
+public class MyBean implements Serializable {
+
+    private Long id;
+    private String name;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+
+    @Override
+    public String toString() {
+        return "MyBean{" +
+                "id=" + id +
+                ", name='" + name + '\'' +
+                '}';
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/MyBeanAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/MyBeanAction.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/MyBeanAction.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/MyBeanAction.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2.util;
+
+import org.apache.struts2.xwork2.Action;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <code>MyBeanAction</code>
+ *
+ * @author Rainer Hermanns
+ */
+public class MyBeanAction implements Action {
+
+    private List beanList = new ArrayList();
+    private Map beanMap = new HashMap();
+
+    public List getBeanList() {
+        return beanList;
+    }
+
+    public void setBeanList(List beanList) {
+        this.beanList = beanList;
+    }
+
+    public Map getBeanMap() {
+        return beanMap;
+    }
+
+    public void setBeanMap(Map beanMap) {
+        this.beanMap = beanMap;
+    }
+
+    public String execute() throws Exception {
+        return SUCCESS;
+    }
+
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/MyBeanActionTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/MyBeanActionTest.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/MyBeanActionTest.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/MyBeanActionTest.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2.util;
+
+import org.apache.struts2.xwork2.ActionContext;
+import org.apache.struts2.xwork2.ActionProxy;
+import org.apache.struts2.xwork2.XWorkTestCase;
+import org.apache.struts2.xwork2.config.providers.XmlConfigurationProvider;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * <code>MyBeanActionTest</code>
+ *
+ * @author Rainer Hermanns
+ */
+public class MyBeanActionTest extends XWorkTestCase {
+
+    public void testIndexedList() {
+        HashMap<String, Object> params = new HashMap<String, Object>();
+        params.put("beanList(1234567890).name", "This is the bla bean");
+        params.put("beanList(1234567891).name", "This is the 2nd bla bean");
+
+        HashMap<String, Object> extraContext = new HashMap<String, Object>();
+        extraContext.put(ActionContext.PARAMETERS, params);
+
+        try {
+            ActionProxy proxy = actionProxyFactory.createActionProxy("", "MyBean", extraContext);
+            proxy.execute();
+            assertEquals(2, Integer.parseInt(proxy.getInvocation().getStack().findValue("beanList.size").toString()));
+            assertEquals(MyBean.class.getName(), proxy.getInvocation().getStack().findValue("beanList.get(0)").getClass().getName());
+            assertEquals(MyBean.class.getName(), proxy.getInvocation().getStack().findValue("beanList.get(1)").getClass().getName());
+
+            assertEquals("This is the bla bean", proxy.getInvocation().getStack().findValue("beanList.get(0).name"));
+            assertEquals(new Long(1234567890), Long.valueOf(proxy.getInvocation().getStack().findValue("beanList.get(0).id").toString()));
+            assertEquals("This is the 2nd bla bean", proxy.getInvocation().getStack().findValue("beanList.get(1).name"));
+            assertEquals(new Long(1234567891), Long.valueOf(proxy.getInvocation().getStack().findValue("beanList.get(1).id").toString()));
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail();
+        }
+    }
+
+    public void testIndexedMap() {
+        HashMap<String, Object> params = new HashMap<String, Object>();
+        params.put("beanMap[1234567890].id", "1234567890");
+        params.put("beanMap[1234567891].id", "1234567891");
+
+        params.put("beanMap[1234567890].name", "This is the bla bean");
+        params.put("beanMap[1234567891].name", "This is the 2nd bla bean");
+
+        HashMap<String, Object> extraContext = new HashMap<String, Object>();
+        extraContext.put(ActionContext.PARAMETERS, params);
+
+        try {
+            ActionProxy proxy = actionProxyFactory.createActionProxy("", "MyBean", extraContext);
+            proxy.execute();
+            MyBeanAction action = (MyBeanAction) proxy.getInvocation().getAction();
+
+            assertEquals(2, Integer.parseInt(proxy.getInvocation().getStack().findValue("beanMap.size").toString()));
+
+            Map map = (Map) proxy.getInvocation().getStack().findValue("beanMap");
+            assertEquals(true, action.getBeanMap().containsKey(new Long(1234567890)));
+            assertEquals(true, action.getBeanMap().containsKey(new Long(1234567891)));
+
+
+            assertEquals(MyBean.class.getName(), proxy.getInvocation().getStack().findValue("beanMap.get(1234567890L)").getClass().getName());
+            assertEquals(MyBean.class.getName(), proxy.getInvocation().getStack().findValue("beanMap.get(1234567891L)").getClass().getName());
+
+            assertEquals("This is the bla bean", proxy.getInvocation().getStack().findValue("beanMap.get(1234567890L).name"));
+            assertEquals("This is the 2nd bla bean", proxy.getInvocation().getStack().findValue("beanMap.get(1234567891L).name"));
+
+            assertEquals("1234567890", proxy.getInvocation().getStack().findValue("beanMap.get(1234567890L).id").toString());
+            assertEquals("1234567891", proxy.getInvocation().getStack().findValue("beanMap.get(1234567891L).id").toString());
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail();
+        }
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // ensure we're using the default configuration, not simple config
+        loadConfigurationProviders(new XmlConfigurationProvider("xwork-sample.xml"));
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/NamedVariablePatternMatcherTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/NamedVariablePatternMatcherTest.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/NamedVariablePatternMatcherTest.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/NamedVariablePatternMatcherTest.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2002-2006,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2.util;
+
+import org.apache.struts2.xwork2.util.NamedVariablePatternMatcher.CompiledPattern;
+import junit.framework.TestCase;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+public class NamedVariablePatternMatcherTest extends TestCase {
+
+    public void testCompile() {
+        NamedVariablePatternMatcher matcher = new NamedVariablePatternMatcher();
+
+        assertNull(matcher.compilePattern(null));
+        assertNull(matcher.compilePattern(""));
+
+        CompiledPattern pattern = matcher.compilePattern("foo");
+        assertEquals("foo", pattern.getPattern().pattern());
+
+        pattern = matcher.compilePattern("foo{jim}");
+        assertEquals("foo([^/]+)", pattern.getPattern().pattern());
+        assertEquals("jim", pattern.getVariableNames().get(0));
+
+        pattern = matcher.compilePattern("foo{jim}/{bob}");
+        assertEquals("foo([^/]+)/([^/]+)", pattern.getPattern().pattern());
+        assertEquals("jim", pattern.getVariableNames().get(0));
+        assertEquals("bob", pattern.getVariableNames().get(1));
+        assertTrue(pattern.getPattern().matcher("foostar/jie").matches());
+        assertFalse(pattern.getPattern().matcher("foo/star/jie").matches());
+    }
+
+    public void testMatch() {
+        NamedVariablePatternMatcher matcher = new NamedVariablePatternMatcher();
+
+        Map<String,String> vars = new HashMap<String,String>();
+        CompiledPattern pattern = new CompiledPattern(Pattern.compile("foo([^/]+)"), Arrays.asList("bar"));
+
+        assertTrue(matcher.match(vars, "foobaz", pattern));
+        assertEquals("baz", vars.get("bar"));
+    }
+
+    public void testIsLiteral() {
+        NamedVariablePatternMatcher matcher = new NamedVariablePatternMatcher();
+
+        assertTrue(matcher.isLiteral("bob"));
+        assertFalse(matcher.isLiteral("bob{jim}"));
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Owner.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Owner.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Owner.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/Owner.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2002-2003,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2.util;
+
+
+/**
+ * DOCUMENT ME!
+ *
+ * @author $author$
+ * @version $Revision: 1209415 $
+ */
+public class Owner {
+
+    private Dog dog;
+
+
+    public void setDog(Dog dog) {
+        this.dog = dog;
+    }
+
+    public Dog getDog() {
+        return dog;
+    }
+}

Added: struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/ResolverUtilTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/ResolverUtilTest.java?rev=1209569&view=auto
==============================================================================
--- struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/ResolverUtilTest.java (added)
+++ struts/struts2/branches/STRUTS_3_X/xwork-core/src/test/java/org/apache/struts2/xwork2/util/ResolverUtilTest.java Fri Dec  2 16:33:03 2011
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2002-2003,2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts2.xwork2.util;
+
+import org.apache.struts2.xwork2.ObjectFactory;
+import org.apache.struts2.xwork2.spring.SpringObjectFactory;
+import junit.framework.TestCase;
+
+import java.net.URL;
+import java.util.Set;
+
+public class ResolverUtilTest extends TestCase {
+
+    public void testSimpleFind() throws Exception {
+        ResolverUtil<ObjectFactory> resolver = new ResolverUtil<ObjectFactory>();
+        resolver.findImplementations(ObjectFactory.class, "org");
+        Set<Class<? extends ObjectFactory>> impls = resolver.getClasses();
+        
+        assertTrue(impls.contains(ObjectFactory.class));
+        assertTrue(impls.contains(SpringObjectFactory.class));
+    }
+    
+    public void testMissingSomeFind() throws Exception {
+        ResolverUtil<ObjectFactory> resolver = new ResolverUtil<ObjectFactory>();
+        resolver.findImplementations(ObjectFactory.class, "org.apache.struts2.xwork2.spring");
+        Set<Class<? extends ObjectFactory>> impls = resolver.getClasses();
+        
+        assertFalse(impls.contains(ObjectFactory.class));
+        assertTrue(impls.contains(SpringObjectFactory.class));
+    }
+    
+    public void testFindNamedResource() throws Exception {
+        ResolverUtil resolver = new ResolverUtil();
+        resolver.findNamedResource("xwork-default.xml", "");
+        Set<URL> impls = resolver.getResources();
+        
+        assertTrue(impls.size() > 0);
+    }
+    
+    public void testFindNamedResourceInDir() throws Exception {
+        ResolverUtil resolver = new ResolverUtil();
+        resolver.findNamedResource("SimpleAction.properties", "org/apache/struts2");
+        Set<URL> impls = resolver.getResources();
+        
+        assertTrue(impls.size() > 0);
+    }
+
+}