mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
WW-4210 Updates tests to use the class definition instead of string
This commit is contained in:
@@ -21,6 +21,7 @@ import com.opensymphony.xwork2.conversion.annotations.ConversionRule;
|
||||
import com.opensymphony.xwork2.conversion.annotations.ConversionType;
|
||||
import com.opensymphony.xwork2.conversion.annotations.TypeConversion;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -49,7 +50,7 @@ public class ConversionTestAction implements Action {
|
||||
return convertInt;
|
||||
}
|
||||
|
||||
@TypeConversion(type = ConversionType.APPLICATION, converter = "com.opensymphony.xwork2.util.XWorkBasicConverter")
|
||||
@TypeConversion(type = ConversionType.APPLICATION)
|
||||
public void setConvertInt( String convertInt ) {
|
||||
this.convertInt = convertInt;
|
||||
}
|
||||
@@ -67,7 +68,7 @@ public class ConversionTestAction implements Action {
|
||||
return users;
|
||||
}
|
||||
|
||||
@TypeConversion(rule = ConversionRule.COLLECTION, converter = "java.lang.String")
|
||||
@TypeConversion(rule = ConversionRule.COLLECTION, converterClass = String.class)
|
||||
public void setUsers( List users ) {
|
||||
this.users = users;
|
||||
}
|
||||
@@ -76,7 +77,7 @@ public class ConversionTestAction implements Action {
|
||||
return keyValues;
|
||||
}
|
||||
|
||||
@TypeConversion(rule = ConversionRule.MAP, converter = "java.math.BigInteger")
|
||||
@TypeConversion(rule = ConversionRule.MAP, converterClass = BigInteger.class)
|
||||
public void setKeyValues( HashMap keyValues ) {
|
||||
this.keyValues = keyValues;
|
||||
}
|
||||
@@ -90,7 +91,7 @@ public class ConversionTestAction implements Action {
|
||||
* Application level exceptions should be handled by returning
|
||||
* an error value, such as Action.ERROR.
|
||||
*/
|
||||
@TypeConversion(type = ConversionType.APPLICATION, key = "java.util.Date", converter = "com.opensymphony.xwork2.util.XWorkBasicConverter")
|
||||
@TypeConversion(type = ConversionType.APPLICATION, key = "java.util.Date")
|
||||
public String execute() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.opensymphony.xwork2.test;
|
||||
|
||||
import com.opensymphony.xwork2.conversion.annotations.Conversion;
|
||||
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.RequiredFieldValidator;
|
||||
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
|
||||
@@ -29,15 +30,12 @@ import com.opensymphony.xwork2.validator.annotations.Validation;
|
||||
* @author Mark Woon
|
||||
* @author Rainer Hermanns
|
||||
*/
|
||||
@Validation()
|
||||
@Conversion()
|
||||
public interface AnnotationDataAware {
|
||||
|
||||
void setBarObj(Bar b);
|
||||
|
||||
@TypeConversion(
|
||||
converter = "com.opensymphony.xwork2.conversion.impl.FooBarConverter"
|
||||
)
|
||||
@TypeConversion(converterClass = FooBarConverter.class)
|
||||
Bar getBarObj();
|
||||
|
||||
@RequiredFieldValidator(message = "You must enter a value for data.")
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.opensymphony.xwork2.test;
|
||||
import com.opensymphony.xwork2.AnnotatedTestBean;
|
||||
import com.opensymphony.xwork2.conversion.annotations.Conversion;
|
||||
import com.opensymphony.xwork2.conversion.annotations.TypeConversion;
|
||||
import com.opensymphony.xwork2.conversion.impl.FooBarConverter;
|
||||
import com.opensymphony.xwork2.util.Bar;
|
||||
import com.opensymphony.xwork2.util.Cat;
|
||||
|
||||
@@ -56,9 +57,7 @@ public class AnnotationTestBean2 extends AnnotatedTestBean implements Annotation
|
||||
return cat;
|
||||
}
|
||||
|
||||
@TypeConversion(
|
||||
key = "cat", converter = "com.opensymphony.xwork2.conversion.impl.FooBarConverter"
|
||||
)
|
||||
@TypeConversion(key = "cat", converterClass = FooBarConverter.class)
|
||||
public void setCat(Cat cat) {
|
||||
this.cat = cat;
|
||||
}
|
||||
|
||||
@@ -82,12 +82,12 @@ public class AnnotationUser implements AnnotationUserMarker {
|
||||
}
|
||||
|
||||
@KeyProperty( value = "name")
|
||||
@TypeConversion( converter = "java.lang.String", rule = ConversionRule.COLLECTION)
|
||||
@TypeConversion(converterClass = String.class, rule = ConversionRule.COLLECTION)
|
||||
public List getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
@TypeConversion( converter = "java.lang.String", rule = ConversionRule.MAP)
|
||||
@TypeConversion(converterClass = String.class, rule = ConversionRule.MAP)
|
||||
public void setMap(Map m) {
|
||||
map = m;
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ import java.util.List;
|
||||
conversions={
|
||||
@TypeConversion(type=ConversionType.APPLICATION,
|
||||
key="com.opensymphony.xwork2.test.annotations.Address",
|
||||
converter="com.opensymphony.xwork2.test.annotations.AddressTypeConverter"),
|
||||
converterClass=AddressTypeConverter.class),
|
||||
@TypeConversion(type=ConversionType.APPLICATION,
|
||||
key="com.opensymphony.xwork2.test.annotations.Person",
|
||||
converter="com.opensymphony.xwork2.test.annotations.PersonTypeConverter")})
|
||||
converterClass=PersonTypeConverter.class)})
|
||||
public class PersonAction {
|
||||
List<Person> users;
|
||||
private List<Address> address;
|
||||
|
||||
@@ -50,9 +50,7 @@ public class AnnotatedCat {
|
||||
this.kittens = kittens;
|
||||
}
|
||||
|
||||
@TypeConversion(
|
||||
key = "kittens", converter = "com.opensymphony.xwork2.util.Cat"
|
||||
)
|
||||
@TypeConversion(key = "kittens", converterClass = Cat.class)
|
||||
public List getKittens() {
|
||||
return kittens;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user