Add @Override annotations to test sources
Issue: SPR-10129
This commit is contained in:
@@ -360,18 +360,22 @@ public final class BeanUtilsTests {
|
||||
|
||||
private String value;
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKey(String aKey) {
|
||||
key = aKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String aValue) {
|
||||
value = aValue;
|
||||
}
|
||||
|
||||
@@ -507,6 +507,7 @@ public class BeanWrapperGenericsTests {
|
||||
|
||||
private Map<String, List<List<Integer>>> mapOfListOfListOfInteger;
|
||||
|
||||
@Override
|
||||
public Map<String, Integer> getMapOfInteger() {
|
||||
return mapOfInteger;
|
||||
}
|
||||
@@ -515,10 +516,12 @@ public class BeanWrapperGenericsTests {
|
||||
this.mapOfInteger = mapOfInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<Integer>> getMapOfListOfInteger() {
|
||||
return mapOfListOfInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMapOfListOfInteger(Map<String, List<Integer>> mapOfListOfInteger) {
|
||||
this.mapOfListOfInteger = mapOfListOfInteger;
|
||||
}
|
||||
@@ -591,6 +594,7 @@ public class BeanWrapperGenericsTests {
|
||||
|
||||
private double version;
|
||||
|
||||
@Override
|
||||
public Double getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
@@ -613,10 +617,12 @@ public class BeanWrapperGenericsTests {
|
||||
|
||||
private Long id;
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(Long aId) {
|
||||
this.id = aId;
|
||||
}
|
||||
|
||||
@@ -329,6 +329,7 @@ public final class BeanWrapperTests {
|
||||
TestBean tb = new TestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
bw.registerCustomEditor(String.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setValue(Object value) {
|
||||
super.setValue(value.toString());
|
||||
}
|
||||
@@ -500,6 +501,7 @@ public final class BeanWrapperTests {
|
||||
PropsTester pt = new PropsTester();
|
||||
BeanWrapper bw = new BeanWrapperImpl(pt);
|
||||
bw.registerCustomEditor(String.class, "stringArray", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) {
|
||||
setValue(text.substring(1));
|
||||
}
|
||||
@@ -559,6 +561,7 @@ public final class BeanWrapperTests {
|
||||
TestBean tb = new TestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
bw.registerCustomEditor(String.class, "name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setValue(Object value) {
|
||||
if (value instanceof String[]) {
|
||||
setValue(StringUtils.arrayToDelimitedString(((String[]) value), "-"));
|
||||
@@ -636,6 +639,7 @@ public final class BeanWrapperTests {
|
||||
PropsTester pt = new PropsTester();
|
||||
BeanWrapper bw = new BeanWrapperImpl(pt);
|
||||
bw.registerCustomEditor(int.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) {
|
||||
setValue(new Integer(Integer.parseInt(text) + 1));
|
||||
}
|
||||
@@ -1022,6 +1026,7 @@ public final class BeanWrapperTests {
|
||||
IndexedTestBean bean = new IndexedTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.registerCustomEditor(TestBean.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
if (!StringUtils.hasLength(text)) {
|
||||
throw new IllegalArgumentException();
|
||||
@@ -1055,6 +1060,7 @@ public final class BeanWrapperTests {
|
||||
IndexedTestBean bean = new IndexedTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.registerCustomEditor(TestBean.class, "map", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
if (!StringUtils.hasLength(text)) {
|
||||
throw new IllegalArgumentException();
|
||||
@@ -1078,6 +1084,7 @@ public final class BeanWrapperTests {
|
||||
IndexedTestBean bean = new IndexedTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.registerCustomEditor(TestBean.class, "map", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
if (!StringUtils.hasLength(text)) {
|
||||
throw new IllegalArgumentException();
|
||||
@@ -1191,6 +1198,7 @@ public final class BeanWrapperTests {
|
||||
PrimitiveArrayBean tb = new PrimitiveArrayBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
bw.registerCustomEditor(int.class, "array", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setValue(Object value) {
|
||||
if (value instanceof Integer) {
|
||||
super.setValue(new Integer(((Integer) value).intValue() + 1));
|
||||
@@ -1209,6 +1217,7 @@ public final class BeanWrapperTests {
|
||||
PrimitiveArrayBean tb = new PrimitiveArrayBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
bw.registerCustomEditor(int.class, "array[1]", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setValue(Object value) {
|
||||
if (value instanceof Integer) {
|
||||
super.setValue(new Integer(((Integer) value).intValue() + 1));
|
||||
@@ -1821,6 +1830,7 @@ public final class BeanWrapperTests {
|
||||
this.frozen = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
if (this.frozen) {
|
||||
throw new UnsupportedOperationException();
|
||||
@@ -1830,16 +1840,19 @@ public final class BeanWrapperTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
this.accessed = true;
|
||||
return super.entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
this.accessed = true;
|
||||
return super.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
this.accessed = true;
|
||||
return super.size();
|
||||
|
||||
@@ -115,6 +115,7 @@ public final class ConcurrentBeanWrapperTests {
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
|
||||
@@ -214,6 +214,7 @@ public class ExtendedBeanInfoTests {
|
||||
@Test
|
||||
public void cornerSpr9453() throws IntrospectionException {
|
||||
final class Bean implements Spr9453<Class<?>> {
|
||||
@Override
|
||||
public Class<?> getProp() {
|
||||
return null;
|
||||
}
|
||||
@@ -589,7 +590,9 @@ public class ExtendedBeanInfoTests {
|
||||
public Number setFoo(String foo) { return null; }
|
||||
}
|
||||
class C extends B {
|
||||
@Override
|
||||
public String getFoo() { return null; }
|
||||
@Override
|
||||
public Integer setFoo(String foo) { return null; }
|
||||
}
|
||||
|
||||
@@ -861,6 +864,7 @@ public class ExtendedBeanInfoTests {
|
||||
}
|
||||
|
||||
interface TextBookOperations extends BookOperations {
|
||||
@Override
|
||||
TextBook getBook();
|
||||
}
|
||||
|
||||
@@ -870,6 +874,7 @@ public class ExtendedBeanInfoTests {
|
||||
}
|
||||
|
||||
class LawLibrary extends Library implements TextBookOperations {
|
||||
@Override
|
||||
public LawBook getBook() { return null; }
|
||||
}
|
||||
|
||||
|
||||
@@ -182,10 +182,12 @@ class RequiredTestBean implements BeanNameAware, BeanFactoryAware {
|
||||
this.jobTitle = jobTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Required
|
||||
public void setBeanName(String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Required
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ public final class ConcurrentBeanFactoryTests {
|
||||
public void setUp() throws Exception {
|
||||
XmlBeanFactory factory = new XmlBeanFactory(CONTEXT);
|
||||
factory.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
|
||||
@Override
|
||||
public void registerCustomEditors(PropertyEditorRegistry registry) {
|
||||
registry.registerCustomEditor(Date.class, new CustomDateEditor((DateFormat) DATE_FORMAT.clone(), false));
|
||||
}
|
||||
@@ -125,6 +126,7 @@ public final class ConcurrentBeanFactoryTests {
|
||||
|
||||
private class TestRun extends Thread {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
|
||||
@@ -836,6 +836,7 @@ public class DefaultListableBeanFactoryTests {
|
||||
public void testCustomEditor() {
|
||||
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
|
||||
lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
|
||||
@Override
|
||||
public void registerCustomEditors(PropertyEditorRegistry registry) {
|
||||
NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
|
||||
registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
|
||||
@@ -853,6 +854,7 @@ public class DefaultListableBeanFactoryTests {
|
||||
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
|
||||
GenericConversionService conversionService = new DefaultConversionService();
|
||||
conversionService.addConverter(new Converter<String, Float>() {
|
||||
@Override
|
||||
public Float convert(String source) {
|
||||
try {
|
||||
NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
|
||||
@@ -875,6 +877,7 @@ public class DefaultListableBeanFactoryTests {
|
||||
public void testCustomEditorWithBeanReference() {
|
||||
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
|
||||
lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
|
||||
@Override
|
||||
public void registerCustomEditors(PropertyEditorRegistry registry) {
|
||||
NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
|
||||
registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
|
||||
@@ -1907,9 +1910,11 @@ public class DefaultListableBeanFactoryTests {
|
||||
RootBeanDefinition bd = new RootBeanDefinition(BeanWithDisposableBean.class);
|
||||
lbf.registerBeanDefinition("test", bd);
|
||||
lbf.addBeanPostProcessor(new BeanPostProcessor() {
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) {
|
||||
return new TestBean();
|
||||
}
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) {
|
||||
return bean;
|
||||
}
|
||||
@@ -1926,9 +1931,11 @@ public class DefaultListableBeanFactoryTests {
|
||||
RootBeanDefinition bd = new RootBeanDefinition(BeanWithCloseable.class);
|
||||
lbf.registerBeanDefinition("test", bd);
|
||||
lbf.addBeanPostProcessor(new BeanPostProcessor() {
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) {
|
||||
return new TestBean();
|
||||
}
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) {
|
||||
return bean;
|
||||
}
|
||||
@@ -1946,9 +1953,11 @@ public class DefaultListableBeanFactoryTests {
|
||||
bd.setDestroyMethodName("close");
|
||||
lbf.registerBeanDefinition("test", bd);
|
||||
lbf.addBeanPostProcessor(new BeanPostProcessor() {
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) {
|
||||
return new TestBean();
|
||||
}
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) {
|
||||
return bean;
|
||||
}
|
||||
@@ -2117,6 +2126,7 @@ public class DefaultListableBeanFactoryTests {
|
||||
lbf.registerBeanDefinition("test", bd);
|
||||
final String nameSetOnField = "nameSetOnField";
|
||||
lbf.addBeanPostProcessor(new InstantiationAwareBeanPostProcessorAdapter() {
|
||||
@Override
|
||||
public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
|
||||
TestBean tb = (TestBean) bean;
|
||||
try {
|
||||
@@ -2156,6 +2166,7 @@ public class DefaultListableBeanFactoryTests {
|
||||
|
||||
TestSecuredBean bean = (TestSecuredBean) Subject.doAsPrivileged(subject,
|
||||
new PrivilegedAction() {
|
||||
@Override
|
||||
public Object run() {
|
||||
return lbf.getBean("test");
|
||||
}
|
||||
@@ -2244,14 +2255,17 @@ public class DefaultListableBeanFactoryTests {
|
||||
public ConstructorDependencyFactoryBean(String dependency) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject() {
|
||||
return "test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
@@ -2262,6 +2276,7 @@ public class DefaultListableBeanFactoryTests {
|
||||
|
||||
private static boolean closed;
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
closed = true;
|
||||
}
|
||||
@@ -2272,6 +2287,7 @@ public class DefaultListableBeanFactoryTests {
|
||||
|
||||
private static boolean closed;
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
closed = true;
|
||||
}
|
||||
@@ -2316,14 +2332,17 @@ public class DefaultListableBeanFactoryTests {
|
||||
|
||||
public static class FactoryBeanThatShouldntBeCalled implements FactoryBean<Object> {
|
||||
|
||||
@Override
|
||||
public Object getObject() {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return false;
|
||||
}
|
||||
@@ -2334,15 +2353,18 @@ public class DefaultListableBeanFactoryTests {
|
||||
|
||||
public boolean initialized = false;
|
||||
|
||||
@Override
|
||||
public Object getObject() throws Exception {
|
||||
this.initialized = true;
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
@@ -2353,23 +2375,28 @@ public class DefaultListableBeanFactoryTests {
|
||||
|
||||
public boolean initialized = false;
|
||||
|
||||
@Override
|
||||
public Object getObject() throws Exception {
|
||||
this.initialized = true;
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrototype() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEagerInit() {
|
||||
return true;
|
||||
}
|
||||
@@ -2452,6 +2479,7 @@ public class DefaultListableBeanFactoryTests {
|
||||
this.numberFormat = numberFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convertIfNecessary(Object value, Class requiredType) {
|
||||
if (value instanceof String && Float.class.isAssignableFrom(requiredType)) {
|
||||
@@ -2470,11 +2498,13 @@ public class DefaultListableBeanFactoryTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convertIfNecessary(Object value, Class requiredType, MethodParameter methodParam) {
|
||||
return convertIfNecessary(value, requiredType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convertIfNecessary(Object value, Class requiredType, Field field) {
|
||||
return convertIfNecessary(value, requiredType);
|
||||
@@ -2490,6 +2520,7 @@ public class DefaultListableBeanFactoryTests {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@@ -77,14 +77,17 @@ public final class FactoryBeanTests {
|
||||
|
||||
public static class NullReturningFactoryBean implements FactoryBean<Object> {
|
||||
|
||||
@Override
|
||||
public Object getObject() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
@@ -103,6 +106,7 @@ public final class FactoryBeanTests {
|
||||
return beta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(beta, "'beta' property is required");
|
||||
}
|
||||
@@ -131,6 +135,7 @@ public final class FactoryBeanTests {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(gamma, "'gamma' property is required");
|
||||
}
|
||||
@@ -149,14 +154,17 @@ public final class FactoryBeanTests {
|
||||
this.beta = beta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject() {
|
||||
return this.beta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public final class SharedBeanRegistryTests {
|
||||
assertSame(tb, beanRegistry.getSingleton("tb"));
|
||||
|
||||
TestBean tb2 = (TestBean) beanRegistry.getSingleton("tb2", new ObjectFactory<Object>() {
|
||||
@Override
|
||||
public Object getObject() throws BeansException {
|
||||
return new TestBean();
|
||||
}
|
||||
|
||||
@@ -989,6 +989,7 @@ public final class AutowiredAnnotationBeanPostProcessorTests {
|
||||
public ExtendedResourceInjectionBean() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Autowired @Required
|
||||
public void setTestBean2(TestBean testBean2) {
|
||||
super.setTestBean2(testBean2);
|
||||
@@ -1068,6 +1069,7 @@ public final class AutowiredAnnotationBeanPostProcessorTests {
|
||||
|
||||
private ITestBean testBean4;
|
||||
|
||||
@Override
|
||||
@Autowired(required = false)
|
||||
public void setTestBean2(TestBean testBean2) {
|
||||
super.setTestBean2(testBean2);
|
||||
@@ -1114,6 +1116,7 @@ public final class AutowiredAnnotationBeanPostProcessorTests {
|
||||
|
||||
private ITestBean testBean4;
|
||||
|
||||
@Override
|
||||
@Autowired(required = false)
|
||||
public void setTestBean2(TestBean testBean2) {
|
||||
super.setTestBean2(testBean2);
|
||||
@@ -1185,6 +1188,7 @@ public final class AutowiredAnnotationBeanPostProcessorTests {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Autowired
|
||||
public void setTestBean2(TestBean testBean2) {
|
||||
super.setTestBean2(testBean2);
|
||||
@@ -1447,14 +1451,17 @@ public final class AutowiredAnnotationBeanPostProcessorTests {
|
||||
|
||||
public static class StringFactoryBean implements FactoryBean<String> {
|
||||
|
||||
@Override
|
||||
public String getObject() throws Exception {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<String> getObjectType() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public final class CustomAutowireConfigurerTests {
|
||||
|
||||
public static class CustomResolver implements AutowireCandidateResolver {
|
||||
|
||||
@Override
|
||||
public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) {
|
||||
if (!bdHolder.getBeanDefinition().isAutowireCandidate()) {
|
||||
return false;
|
||||
@@ -82,6 +83,7 @@ public final class CustomAutowireConfigurerTests {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSuggestedValue(DependencyDescriptor descriptor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -609,6 +609,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
||||
public ExtendedResourceInjectionBean() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Inject @Required
|
||||
public void setTestBean2(TestBean testBean2) {
|
||||
super.setTestBean2(testBean2);
|
||||
@@ -662,6 +663,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
||||
|
||||
private ITestBean testBean4;
|
||||
|
||||
@Override
|
||||
@Inject
|
||||
public void setTestBean2(TestBean testBean2) {
|
||||
super.setTestBean2(testBean2);
|
||||
@@ -708,6 +710,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
||||
|
||||
private ITestBean testBean4;
|
||||
|
||||
@Override
|
||||
@Inject
|
||||
public void setTestBean2(TestBean testBean2) {
|
||||
super.setTestBean2(testBean2);
|
||||
@@ -779,6 +782,7 @@ public class InjectAnnotationBeanPostProcessorTests {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Inject
|
||||
public void setTestBean2(TestBean testBean2) {
|
||||
super.setTestBean2(testBean2);
|
||||
@@ -1074,14 +1078,17 @@ public class InjectAnnotationBeanPostProcessorTests {
|
||||
|
||||
public static class StringFactoryBean implements FactoryBean<String> {
|
||||
|
||||
@Override
|
||||
public String getObject() throws Exception {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<String> getObjectType() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ public final class CustomEditorConfigurerTests {
|
||||
final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.GERMAN);
|
||||
cec.setPropertyEditorRegistrars(new PropertyEditorRegistrar[] {
|
||||
new PropertyEditorRegistrar() {
|
||||
@Override
|
||||
public void registerCustomEditors(PropertyEditorRegistry registry) {
|
||||
registry.registerCustomEditor(Date.class, new CustomDateEditor(df, true));
|
||||
}
|
||||
@@ -189,6 +190,7 @@ public final class CustomEditorConfigurerTests {
|
||||
|
||||
public static class MyTestEditor extends PropertyEditorSupport {
|
||||
|
||||
@Override
|
||||
public void setAsText(String text) {
|
||||
setValue(new String[] {"test"});
|
||||
}
|
||||
|
||||
@@ -812,6 +812,7 @@ public final class PropertyResourceConfigurerTests {
|
||||
|
||||
private static class ConvertingOverrideConfigurer extends PropertyOverrideConfigurer {
|
||||
|
||||
@Override
|
||||
protected String convertPropertyValue(String originalValue) {
|
||||
return "X" + originalValue;
|
||||
}
|
||||
@@ -826,10 +827,12 @@ public final class PropertyResourceConfigurerTests {
|
||||
|
||||
private Preferences userRoot = new MockPreferences();
|
||||
|
||||
@Override
|
||||
public Preferences systemRoot() {
|
||||
return systemRoot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Preferences userRoot() {
|
||||
return userRoot;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ public final class SimpleScopeTests {
|
||||
objects.add(new TestBean());
|
||||
objects.add(new TestBean());
|
||||
}
|
||||
@Override
|
||||
public Object get(String name, ObjectFactory<?> objectFactory) {
|
||||
if (index >= objects.size()) {
|
||||
index = 0;
|
||||
|
||||
@@ -30,21 +30,26 @@ final class TestTypes {}
|
||||
*/
|
||||
class NoOpScope implements Scope {
|
||||
|
||||
@Override
|
||||
public Object get(String name, ObjectFactory<?> objectFactory) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object remove(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerDestructionCallback(String name, Runnable callback) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveContextualObject(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConversationId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -71,10 +71,12 @@ public final class CustomProblemReporterTests {
|
||||
private List<Problem> warnings = new ArrayList<Problem>();
|
||||
|
||||
|
||||
@Override
|
||||
public void fatal(Problem problem) {
|
||||
throw new BeanDefinitionParsingException(problem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Problem problem) {
|
||||
System.out.println(problem);
|
||||
this.errors.add(problem);
|
||||
@@ -84,6 +86,7 @@ public final class CustomProblemReporterTests {
|
||||
return this.errors.toArray(new Problem[this.errors.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(Problem problem) {
|
||||
System.out.println(problem);
|
||||
this.warnings.add(problem);
|
||||
|
||||
@@ -391,6 +391,7 @@ public class BeanFactoryGenericsTests {
|
||||
public void testGenericMapWithCollectionValueConstructor() throws MalformedURLException {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
bf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
|
||||
@Override
|
||||
public void registerCustomEditors(PropertyEditorRegistry registry) {
|
||||
registry.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false));
|
||||
}
|
||||
@@ -547,6 +548,7 @@ public class BeanFactoryGenericsTests {
|
||||
public void testGenericMapWithCollectionValueFactoryMethod() throws MalformedURLException {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
bf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
|
||||
@Override
|
||||
public void registerCustomEditors(PropertyEditorRegistry registry) {
|
||||
registry.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false));
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public class PropertiesBeanDefinitionReaderTests extends TestCase {
|
||||
|
||||
private PropertiesBeanDefinitionReader reader;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
this.reader = new PropertiesBeanDefinitionReader(beanFactory);
|
||||
|
||||
@@ -61,14 +61,17 @@ public class Spr8954Tests {
|
||||
|
||||
static class FooFactoryBean implements FactoryBean<Foo>, AnInterface {
|
||||
|
||||
@Override
|
||||
public Foo getObject() throws Exception {
|
||||
return new Foo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return Foo.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -129,23 +129,28 @@ public class CallbacksSecurityTests {
|
||||
checkCurrentContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
checkCurrentContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
checkCurrentContext();
|
||||
destroyed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanName(String name) {
|
||||
checkCurrentContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
checkCurrentContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory)
|
||||
throws BeansException {
|
||||
checkCurrentContext();
|
||||
@@ -164,26 +169,31 @@ public class CallbacksSecurityTests {
|
||||
checkCurrentContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEagerInit() {
|
||||
checkCurrentContext();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrototype() {
|
||||
checkCurrentContext();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject() throws Exception {
|
||||
checkCurrentContext();
|
||||
return new Object();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getObjectType() {
|
||||
checkCurrentContext();
|
||||
return Object.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
checkCurrentContext();
|
||||
return false;
|
||||
@@ -219,6 +229,7 @@ public class CallbacksSecurityTests {
|
||||
|
||||
return AccessController.doPrivileged(new PrivilegedAction<String>() {
|
||||
|
||||
@Override
|
||||
public String run() {
|
||||
Subject subject = Subject.getSubject(acc);
|
||||
if (subject == null) {
|
||||
@@ -246,6 +257,7 @@ public class CallbacksSecurityTests {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
@@ -291,6 +303,7 @@ public class CallbacksSecurityTests {
|
||||
private final AccessControlContext acc = new AccessControlContext(
|
||||
new ProtectionDomain[] { empty });
|
||||
|
||||
@Override
|
||||
public AccessControlContext getAccessControlContext() {
|
||||
return acc;
|
||||
}
|
||||
@@ -320,6 +333,7 @@ public class CallbacksSecurityTests {
|
||||
try {
|
||||
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
|
||||
|
||||
@Override
|
||||
public Object run() throws Exception {
|
||||
method.invoke(bean);
|
||||
return null;
|
||||
@@ -334,6 +348,7 @@ public class CallbacksSecurityTests {
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<Object>() {
|
||||
|
||||
@Override
|
||||
public Object run() throws Exception {
|
||||
return cl.newInstance();
|
||||
}
|
||||
@@ -444,6 +459,7 @@ public class CallbacksSecurityTests {
|
||||
|
||||
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
|
||||
|
||||
@Override
|
||||
public Object run() throws Exception {
|
||||
beanFactory.getBean("working-factory-method");
|
||||
beanFactory.getBean("container-execution");
|
||||
@@ -478,6 +494,7 @@ public class CallbacksSecurityTests {
|
||||
|
||||
NonPrivilegedBean bean = Subject.doAsPrivileged(
|
||||
subject, new PrivilegedAction<NonPrivilegedBean>() {
|
||||
@Override
|
||||
public NonPrivilegedBean run() {
|
||||
return lbf.getBean("test", NonPrivilegedBean.class);
|
||||
}
|
||||
@@ -502,6 +519,7 @@ public class CallbacksSecurityTests {
|
||||
// request the beans from non-privileged code
|
||||
Subject.doAsPrivileged(subject, new PrivilegedAction<Object>() {
|
||||
|
||||
@Override
|
||||
public Object run() {
|
||||
// sanity check
|
||||
assertEquals("user1", getCurrentSubjectName());
|
||||
|
||||
@@ -24,15 +24,18 @@ import org.springframework.beans.factory.FactoryBean;
|
||||
*/
|
||||
public class CustomFactoryBean implements FactoryBean<Object> {
|
||||
|
||||
@Override
|
||||
public Object getObject() throws Exception {
|
||||
return System.getProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getObjectType() {
|
||||
System.setProperty("factory.object.type", "true");
|
||||
return Properties.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.beans.factory.DisposableBean;
|
||||
*/
|
||||
public class DestroyBean implements DisposableBean {
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
System.setProperty("security.destroy", "true");
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
*/
|
||||
public class InitBean implements InitializingBean {
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
System.getProperties();
|
||||
}
|
||||
|
||||
@@ -326,6 +326,7 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
|
||||
|
||||
public static class TestBeanEditor extends PropertyEditorSupport {
|
||||
|
||||
@Override
|
||||
public void setAsText(String text) {
|
||||
TestBean tb = new TestBean();
|
||||
StringTokenizer st = new StringTokenizer(text, "_");
|
||||
@@ -350,6 +351,7 @@ class MustBeInitialized implements InitializingBean {
|
||||
/**
|
||||
* @see InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
this.inited = true;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public class BeanNameGenerationTests extends TestCase {
|
||||
|
||||
private DefaultListableBeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
public void setUp() {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
|
||||
|
||||
@@ -45,6 +45,7 @@ public class CollectingReaderEventListener implements ReaderEventListener {
|
||||
private final List imports = new LinkedList();
|
||||
|
||||
|
||||
@Override
|
||||
public void defaultsRegistered(DefaultsDefinition defaultsDefinition) {
|
||||
this.defaults.add(defaultsDefinition);
|
||||
}
|
||||
@@ -53,6 +54,7 @@ public class CollectingReaderEventListener implements ReaderEventListener {
|
||||
return Collections.unmodifiableList(this.defaults);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentRegistered(ComponentDefinition componentDefinition) {
|
||||
this.componentDefinitions.put(componentDefinition.getName(), componentDefinition);
|
||||
}
|
||||
@@ -66,6 +68,7 @@ public class CollectingReaderEventListener implements ReaderEventListener {
|
||||
return (ComponentDefinition[]) collection.toArray(new ComponentDefinition[collection.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void aliasRegistered(AliasDefinition aliasDefinition) {
|
||||
List aliases = (List) this.aliasMap.get(aliasDefinition.getBeanName());
|
||||
if(aliases == null) {
|
||||
@@ -80,6 +83,7 @@ public class CollectingReaderEventListener implements ReaderEventListener {
|
||||
return aliases == null ? null : Collections.unmodifiableList(aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importProcessed(ImportDefinition importDefinition) {
|
||||
this.imports.add(importDefinition);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public class CollectionMergingTests extends TestCase {
|
||||
|
||||
private DefaultListableBeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
BeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
|
||||
|
||||
@@ -51,14 +51,17 @@ public class CountingFactory implements FactoryBean {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getObject() {
|
||||
return "myString";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getObjectType() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class DefaultLifecycleMethodsTests extends TestCase {
|
||||
|
||||
private XmlBeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
this.beanFactory = new XmlBeanFactory(new ClassPathResource("defaultLifecycleMethods.xml", getClass()));
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ public final class DelegatingEntityResolverTests {
|
||||
|
||||
|
||||
private static final class NoOpEntityResolver implements EntityResolver {
|
||||
@Override
|
||||
public InputSource resolveEntity(String publicId, String systemId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ public class DependenciesBean implements BeanFactoryAware {
|
||||
return spouse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public class EventPublicationTests extends TestCase {
|
||||
private final CollectingReaderEventListener eventListener = new CollectingReaderEventListener();
|
||||
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
|
||||
reader.setEventListener(this.eventListener);
|
||||
|
||||
@@ -27,6 +27,7 @@ public class GeneratedNameBean implements BeanNameAware {
|
||||
|
||||
private GeneratedNameBean child;
|
||||
|
||||
@Override
|
||||
public void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public class MetadataAttachmentTests extends TestCase {
|
||||
|
||||
private XmlBeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
this.beanFactory = new XmlBeanFactory(new ClassPathResource("withMeta.xml", getClass()));
|
||||
}
|
||||
|
||||
@@ -171,6 +171,7 @@ public class ProfileXmlBeanDefinitionTests {
|
||||
private static Matcher<BeanDefinitionRegistry> containsBeanDefinition(final String beanName) {
|
||||
return new TypeSafeMatcher<BeanDefinitionRegistry>() {
|
||||
|
||||
@Override
|
||||
public void describeTo(Description desc) {
|
||||
desc.appendText("a BeanDefinitionRegistry containing bean named ")
|
||||
.appendValue(beanName);
|
||||
|
||||
@@ -57,6 +57,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial
|
||||
return initMethodDeclared;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanName(String name) {
|
||||
this.beanName = name;
|
||||
}
|
||||
@@ -65,6 +66,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial
|
||||
return beanName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.owningFactory = beanFactory;
|
||||
}
|
||||
@@ -79,6 +81,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial
|
||||
this.postProcessedBeforeInit = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
if (this.owningFactory == null) {
|
||||
throw new RuntimeException("Factory didn't call setBeanFactory before afterPropertiesSet on lifecycle bean");
|
||||
@@ -130,6 +133,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (this.destroyed) {
|
||||
throw new IllegalStateException("Already destroyed");
|
||||
@@ -144,6 +148,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial
|
||||
|
||||
public static class PostProcessor implements BeanPostProcessor {
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException {
|
||||
if (bean instanceof ProtectedLifecycleBean) {
|
||||
((ProtectedLifecycleBean) bean).postProcessBeforeInit();
|
||||
@@ -151,6 +156,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String name) throws BeansException {
|
||||
if (bean instanceof ProtectedLifecycleBean) {
|
||||
((ProtectedLifecycleBean) bean).postProcessAfterInit();
|
||||
|
||||
@@ -46,6 +46,7 @@ public class UtilNamespaceHandlerTests extends TestCase {
|
||||
|
||||
private CollectingReaderEventListener listener = new CollectingReaderEventListener();
|
||||
|
||||
@Override
|
||||
public void setUp() {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
|
||||
|
||||
@@ -46,6 +46,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
|
||||
|
||||
private XmlBeanFactory factory;
|
||||
|
||||
@Override
|
||||
protected void setUp() {
|
||||
parent = new DefaultListableBeanFactory();
|
||||
Map m = new HashMap();
|
||||
@@ -59,6 +60,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
|
||||
|
||||
this.factory = new XmlBeanFactory(new ClassPathResource("test.xml", getClass()), parent);
|
||||
this.factory.addBeanPostProcessor(new BeanPostProcessor() {
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException {
|
||||
if (bean instanceof TestBean) {
|
||||
((TestBean) bean).setPostProcessed(true);
|
||||
@@ -68,6 +70,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String name) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
@@ -77,10 +80,12 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest
|
||||
//this.factory.preInstantiateSingletons();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BeanFactory getBeanFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testCount() {
|
||||
assertCount(24);
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ public class BeanInfoTests extends TestCase {
|
||||
|
||||
public static class ValueBeanBeanInfo extends SimpleBeanInfo {
|
||||
|
||||
@Override
|
||||
public PropertyDescriptor[] getPropertyDescriptors() {
|
||||
try {
|
||||
PropertyDescriptor pd = new PropertyDescriptor("value", ValueBean.class);
|
||||
@@ -96,6 +97,7 @@ public class BeanInfoTests extends TestCase {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
if (JdkVersion.getMajorJavaVersion() >= JdkVersion.JAVA_15) {
|
||||
Assert.isTrue(this.target instanceof ValueBean, "Target must be available on JDK 1.5+");
|
||||
|
||||
@@ -113,6 +113,7 @@ public class CustomEditorTests {
|
||||
TestBean tb = new TestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
bw.registerCustomEditor(String.class, "name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("prefix" + text);
|
||||
}
|
||||
@@ -130,6 +131,7 @@ public class CustomEditorTests {
|
||||
TestBean tb = new TestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
bw.registerCustomEditor(String.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("prefix" + text);
|
||||
}
|
||||
@@ -148,6 +150,7 @@ public class CustomEditorTests {
|
||||
tb.setSpouse(new TestBean());
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
bw.registerCustomEditor(String.class, "spouse.name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("prefix" + text);
|
||||
}
|
||||
@@ -166,6 +169,7 @@ public class CustomEditorTests {
|
||||
tb.setSpouse(new TestBean());
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
bw.registerCustomEditor(String.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("prefix" + text);
|
||||
}
|
||||
@@ -853,6 +857,7 @@ public class CustomEditorTests {
|
||||
IndexedTestBean bean = new IndexedTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.registerCustomEditor(String.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("prefix" + text);
|
||||
}
|
||||
@@ -905,16 +910,19 @@ public class CustomEditorTests {
|
||||
IndexedTestBean bean = new IndexedTestBean(false);
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.registerCustomEditor(String.class, "array.name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("array" + text);
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(String.class, "list.name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("list" + text);
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(String.class, "map.name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("map" + text);
|
||||
}
|
||||
@@ -969,31 +977,37 @@ public class CustomEditorTests {
|
||||
IndexedTestBean bean = new IndexedTestBean(false);
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.registerCustomEditor(String.class, "array[0].name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("array0" + text);
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(String.class, "array[1].name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("array1" + text);
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(String.class, "list[0].name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("list0" + text);
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(String.class, "list[1].name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("list1" + text);
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(String.class, "map[key1].name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("mapkey1" + text);
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(String.class, "map[key2].name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("mapkey2" + text);
|
||||
}
|
||||
@@ -1060,28 +1074,34 @@ public class CustomEditorTests {
|
||||
tb5.setNestedIndexedBean(new IndexedTestBean());
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.registerCustomEditor(String.class, "array.nestedIndexedBean.array.name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("array" + text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsText() {
|
||||
return ((String) getValue()).substring(5);
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(String.class, "list.nestedIndexedBean.list.name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("list" + text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsText() {
|
||||
return ((String) getValue()).substring(4);
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(String.class, "map.nestedIndexedBean.map.name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("map" + text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsText() {
|
||||
return ((String) getValue()).substring(4);
|
||||
}
|
||||
@@ -1138,16 +1158,19 @@ public class CustomEditorTests {
|
||||
tb5.setNestedIndexedBean(new IndexedTestBean());
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.registerCustomEditor(String.class, "array[0].nestedIndexedBean.array[0].name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("array" + text);
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(String.class, "list.nestedIndexedBean.list[1].name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("list" + text);
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(String.class, "map[key1].nestedIndexedBean.map.name", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("map" + text);
|
||||
}
|
||||
@@ -1174,28 +1197,34 @@ public class CustomEditorTests {
|
||||
IndexedTestBean bean = new IndexedTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.registerCustomEditor(TestBean.class, "array", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(new TestBean("array" + text, 99));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsText() {
|
||||
return ((TestBean) getValue()).getName();
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(TestBean.class, "list", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(new TestBean("list" + text, 99));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsText() {
|
||||
return ((TestBean) getValue()).getName();
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(TestBean.class, "map", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(new TestBean("map" + text, 99));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsText() {
|
||||
return ((TestBean) getValue()).getName();
|
||||
}
|
||||
@@ -1222,55 +1251,67 @@ public class CustomEditorTests {
|
||||
IndexedTestBean bean = new IndexedTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.registerCustomEditor(TestBean.class, "array[0]", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(new TestBean("array0" + text, 99));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsText() {
|
||||
return ((TestBean) getValue()).getName();
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(TestBean.class, "array[1]", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(new TestBean("array1" + text, 99));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsText() {
|
||||
return ((TestBean) getValue()).getName();
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(TestBean.class, "list[0]", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(new TestBean("list0" + text, 99));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsText() {
|
||||
return ((TestBean) getValue()).getName();
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(TestBean.class, "list[1]", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(new TestBean("list1" + text, 99));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsText() {
|
||||
return ((TestBean) getValue()).getName();
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(TestBean.class, "map[key1]", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(new TestBean("mapkey1" + text, 99));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsText() {
|
||||
return ((TestBean) getValue()).getName();
|
||||
}
|
||||
});
|
||||
bw.registerCustomEditor(TestBean.class, "map[key2]", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(new TestBean("mapkey2" + text, 99));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsText() {
|
||||
return ((TestBean) getValue()).getName();
|
||||
}
|
||||
@@ -1297,6 +1338,7 @@ public class CustomEditorTests {
|
||||
IndexedTestBean bean = new IndexedTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.registerCustomEditor(List.class, "list", new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
List<TestBean> result = new ArrayList<TestBean>();
|
||||
result.add(new TestBean("list" + text, 99));
|
||||
@@ -1347,6 +1389,7 @@ public class CustomEditorTests {
|
||||
IndexedTestBean tb = new IndexedTestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
bw.registerCustomEditor(TestBean.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(new TestBean(text, 99));
|
||||
}
|
||||
@@ -1362,6 +1405,7 @@ public class CustomEditorTests {
|
||||
TestBean tb = new TestBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(tb);
|
||||
bw.registerCustomEditor(String.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue("-" + text + "-");
|
||||
}
|
||||
@@ -1436,6 +1480,7 @@ public class CustomEditorTests {
|
||||
|
||||
private static class TestBeanEditor extends PropertyEditorSupport {
|
||||
|
||||
@Override
|
||||
public void setAsText(String text) {
|
||||
TestBean tb = new TestBean();
|
||||
StringTokenizer st = new StringTokenizer(text, "_");
|
||||
@@ -1448,6 +1493,7 @@ public class CustomEditorTests {
|
||||
|
||||
private static class OldValueAccessingTestBeanEditor extends PropertyEditorSupport {
|
||||
|
||||
@Override
|
||||
public void setAsText(String text) {
|
||||
TestBean tb = new TestBean();
|
||||
StringTokenizer st = new StringTokenizer(text, "_");
|
||||
|
||||
@@ -104,6 +104,7 @@ public class PropertyComparatorTests {
|
||||
|
||||
private String lastName;
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
return nickName.compareTo(((Dog)o).nickName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user