Modified: struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/TestAction.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/TestAction.java?rev=834712&r1=834711&r2=834712&view=diff ============================================================================== --- struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/TestAction.java (original) +++ struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/TestAction.java Tue Nov 10 23:39:56 2009 @@ -1,3 +1,23 @@ +/* + * $Id$ + * + * 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 + * + * 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.uelplugin; import com.opensymphony.xwork2.ActionSupport;
Modified: struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/TestObject.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/TestObject.java?rev=834712&r1=834711&r2=834712&view=diff ============================================================================== --- struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/TestObject.java (original) +++ struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/TestObject.java Tue Nov 10 23:39:56 2009 @@ -1,3 +1,23 @@ +/* + * $Id$ + * + * 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 + * + * 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.uelplugin; import java.util.Date; @@ -25,6 +45,33 @@ private ChildTestAction childTestAction; private boolean invoked; + private String privateField = "private"; + protected String protectedField = "protected"; + + private void setSomePrivateField(String privateField) { + this.value = privateField; + } + + private String getSomePrivateField() { + return value; + } + + protected String getSomeProtectedField() { + return value; + } + + protected void setSomeProtectedField(String protectedField) { + this.value = protectedField; + } + + public String getPropWithoutSetter() { + return value; + } + + public void setPropWithoutGetter(String value) { + this.value = value; + } + public boolean wasInvoked() { return invoked; } Modified: struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/UELMethodInvocationTest.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/UELMethodInvocationTest.java?rev=834712&r1=834711&r2=834712&view=diff ============================================================================== --- struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/UELMethodInvocationTest.java (original) +++ struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/UELMethodInvocationTest.java Tue Nov 10 23:39:56 2009 @@ -1,3 +1,23 @@ +/* + * $Id$ + * + * 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 + * + * 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.uelplugin; import java.lang.reflect.InvocationTargetException; Modified: struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/UELStackReadValueTest.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/UELStackReadValueTest.java?rev=834712&r1=834711&r2=834712&view=diff ============================================================================== --- struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/UELStackReadValueTest.java (original) +++ struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/UELStackReadValueTest.java Tue Nov 10 23:39:56 2009 @@ -1,3 +1,23 @@ +/* + * $Id$ + * + * 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 + * + * 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.uelplugin; import java.lang.reflect.InvocationTargetException; @@ -5,6 +25,49 @@ public class UELStackReadValueTest extends AbstractUELTest { + public void testPrivateMethod() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + TestObject obj = new TestObject(); + root.push(obj); + + obj.setValue("private"); + assertNull(stack.findValue("somePrivateField")); + assertNull(stack.findValue("top.somePrivateField()")); + } + + public void testProtectedMethod() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + TestObject obj = new TestObject(); + root.push(obj); + + obj.setValue("protected"); + assertNull(stack.findValue("someProtectedField")); + assertNull(stack.findValue("top.someProtectedField()")); + } + + public void testPrivateField() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + TestObject obj = new TestObject(); + root.push(obj); + + obj.setValue("private"); + assertNull(stack.findValue("privateField")); + } + + public void testProtectedField() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + TestObject obj = new TestObject(); + root.push(obj); + + obj.setValue("protected"); + assertNull(stack.findValue("protectedField")); + } + + + public void testGetterWithoutSetter() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + TestObject obj = new TestObject(); + obj.setValue("getter"); + root.push(obj); + + assertEquals("getter", stack.findValue("propWithoutSetter")); + } + public void testTop() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { TestObject obj = new TestObject(); obj.setValue("0"); Modified: struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/UELStackSetValueTest.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/UELStackSetValueTest.java?rev=834712&r1=834711&r2=834712&view=diff ============================================================================== --- struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/UELStackSetValueTest.java (original) +++ struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/UELStackSetValueTest.java Tue Nov 10 23:39:56 2009 @@ -1,3 +1,23 @@ +/* + * $Id$ + * + * 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 + * + * 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.uelplugin; import com.opensymphony.xwork2.util.reflection.ReflectionContextState; @@ -7,6 +27,49 @@ public class UELStackSetValueTest extends AbstractUELTest { + + public void testPrivateMethod() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + TestObject obj = new TestObject(); + root.push(obj); + + stack.setValue("somePrivateField", "owned"); + assertNull(obj.getValue()); + } + + public void testProtectedMethod() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + TestObject obj = new TestObject(); + root.push(obj); + + stack.setValue("someProtectedField", "owned"); + assertNull(obj.getValue()); + } + + public void testPrivateField() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + TestObject obj = new TestObject(); + root.push(obj); + + stack.setValue("privateField", "owned"); + assertNull(obj.getValue()); + } + + public void testProtectedField() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + TestObject obj = new TestObject(); + root.push(obj); + + stack.setValue("protectedField", "owned"); + assertNull(obj.getValue()); + } + + + public void testSetterWithoutGetter() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + TestObject obj = new TestObject(); + root.push(obj); + + assertNull(obj.getValue()); + stack.setValue("propWithoutGetter", "go"); + assertEquals("go", obj.getValue()); + } + public void testSuperNested() { TestObject obj = new TestObject(); root.push(obj); Modified: struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/UELValueStackOtherTests.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/UELValueStackOtherTests.java?rev=834712&r1=834711&r2=834712&view=diff ============================================================================== --- struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/UELValueStackOtherTests.java (original) +++ struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/UELValueStackOtherTests.java Tue Nov 10 23:39:56 2009 @@ -1,3 +1,23 @@ +/* + * $Id$ + * + * 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 + * + * 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.uelplugin; import com.opensymphony.xwork2.ActionContext; Modified: struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/VulnerabilityTest.java URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/VulnerabilityTest.java?rev=834712&r1=834711&r2=834712&view=diff ============================================================================== --- struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/VulnerabilityTest.java (original) +++ struts/sandbox/trunk/struts2-uel-plugin/src/test/java/org/apache/struts2/uelplugin/VulnerabilityTest.java Tue Nov 10 23:39:56 2009 @@ -1,3 +1,23 @@ +/* + * $Id$ + * + * 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 + * + * 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.uelplugin; import com.opensymphony.xwork2.ActionContext;