mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
add tests if conversion can get annotation from supers
This commit is contained in:
@@ -18,6 +18,9 @@
|
||||
*/
|
||||
package com.opensymphony.xwork2;
|
||||
|
||||
import com.opensymphony.xwork2.conversion.annotations.TypeConversion;
|
||||
import com.opensymphony.xwork2.conversion.impl.FooBarConverter;
|
||||
import com.opensymphony.xwork2.util.Bar;
|
||||
import com.opensymphony.xwork2.validator.annotations.IntRangeFieldValidator;
|
||||
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
|
||||
import com.opensymphony.xwork2.validator.annotations.Validations;
|
||||
@@ -37,6 +40,7 @@ public class AnnotatedTestBean {
|
||||
private Date birth;
|
||||
private String name;
|
||||
private int count;
|
||||
private Bar bar;
|
||||
|
||||
//~ Constructors ///////////////////////////////////////////////////////////
|
||||
|
||||
@@ -76,4 +80,13 @@ public class AnnotatedTestBean {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Bar getSupperBarObj() {
|
||||
return bar;
|
||||
}
|
||||
|
||||
@TypeConversion(converterClass = FooBarConverter.class)
|
||||
public void setSupperBarObj(Bar b) {
|
||||
bar = b;
|
||||
}
|
||||
}
|
||||
|
||||
+9
-1
@@ -177,7 +177,7 @@ public class AnnotationXWorkConverterTest extends XWorkTestCase {
|
||||
assertEquals("Invalid field value for field \"foo\".", message);
|
||||
}
|
||||
|
||||
public void testFindConversionMappingForInterface() {
|
||||
public void testFindConversionMappingForInterfaceAndSuperclass() {
|
||||
ModelDrivenAnnotationAction2 action = new ModelDrivenAnnotationAction2();
|
||||
ValueStack stack = ActionContext.getContext().getValueStack();
|
||||
stack.push(action);
|
||||
@@ -193,6 +193,14 @@ public class AnnotationXWorkConverterTest extends XWorkTestCase {
|
||||
|
||||
Bar b = (Bar) o;
|
||||
assertEquals(value, b.getTitle() + ":" + b.getSomethingElse());
|
||||
|
||||
String value2 = "qwer:456";
|
||||
Object o2 = converter.convertValue(ognlStackContext, action.getModel(), null, "supperBarObj", value2, Bar.class);
|
||||
assertNotNull(o2);
|
||||
assertTrue("class is: " + o.getClass(), o2 instanceof Bar);
|
||||
|
||||
Bar b2 = (Bar) o2;
|
||||
assertEquals(value2, b2.getTitle() + ":" + b2.getSomethingElse());
|
||||
}
|
||||
|
||||
public void testLocalizedDateConversion() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user