OPEN - issue BATCH-295: JobLauncher should have only one run method.
http://jira.springframework.org/browse/BATCH-295 Add a property editor for JobIdentifier so the JMX demo can work.
This commit is contained in:
@@ -24,9 +24,6 @@ import java.util.Properties;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.io.file.mapping.BeanWrapperFieldSetMapper;
|
||||
import org.springframework.batch.io.file.mapping.BindingException;
|
||||
import org.springframework.batch.support.IntArrayPropertyEditor;
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
import org.springframework.beans.NotWritablePropertyException;
|
||||
import org.springframework.beans.propertyeditors.CustomNumberEditor;
|
||||
@@ -252,17 +249,6 @@ public class BeanWrapperFieldSetMapperTests extends TestCase {
|
||||
assertEquals('C', result.getVarChar());
|
||||
}
|
||||
|
||||
public void testIntArray() throws Exception {
|
||||
BeanWithIntArray result = new BeanWithIntArray();
|
||||
BeanWrapperImpl wrapper = new BeanWrapperImpl(result);
|
||||
wrapper.registerCustomEditor(int[].class, new IntArrayPropertyEditor());
|
||||
PropertiesEditor editor = new PropertiesEditor();
|
||||
editor.setAsText("numbers=1,2,3, 4");
|
||||
Properties props = (Properties) editor.getValue();
|
||||
wrapper.setPropertyValues(props);
|
||||
assertEquals(4, result.numbers[3]);
|
||||
}
|
||||
|
||||
// BeanWrapperFieldSetMapper doesn't currently support nesting with
|
||||
// collections.
|
||||
public void testNestedList() {
|
||||
@@ -307,37 +293,6 @@ public class BeanWrapperFieldSetMapperTests extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testSetCustomEditorsWithInvalidTypeName() throws Exception {
|
||||
|
||||
BeanWrapperFieldSetMapper mapper = new BeanWrapperFieldSetMapper();
|
||||
try {
|
||||
mapper.setCustomEditors(Collections.singletonMap("FOO", new CustomNumberEditor(Long.class, true)));
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testSetCustomEditorsWithInvalidType() throws Exception {
|
||||
|
||||
BeanWrapperFieldSetMapper mapper = new BeanWrapperFieldSetMapper();
|
||||
try {
|
||||
mapper.setCustomEditors(Collections.singletonMap(new Object(), new CustomNumberEditor(Long.class, true)));
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testSetCustomEditorsWithInvalidEditor() throws Exception {
|
||||
|
||||
BeanWrapperFieldSetMapper mapper = new BeanWrapperFieldSetMapper();
|
||||
try {
|
||||
mapper.setCustomEditors(Collections.singletonMap(Long.class, "FOO"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testPaddedLongWithEditor() throws Exception {
|
||||
|
||||
BeanWrapperFieldSetMapper mapper = new BeanWrapperFieldSetMapper();
|
||||
@@ -367,14 +322,6 @@ public class BeanWrapperFieldSetMapperTests extends TestCase {
|
||||
assertEquals(78, bean.getVarInt());
|
||||
}
|
||||
|
||||
private static class BeanWithIntArray {
|
||||
private int[] numbers;
|
||||
|
||||
public void setNumbers(int[] numbers) {
|
||||
this.numbers = numbers;
|
||||
}
|
||||
}
|
||||
|
||||
private static class TestNestedList {
|
||||
|
||||
List nestedC;
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* 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.springframework.batch.io.support;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Properties;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.support.DefaultPropertyEditorRegistrar;
|
||||
import org.springframework.batch.support.IntArrayPropertyEditor;
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
import org.springframework.beans.propertyeditors.CustomNumberEditor;
|
||||
import org.springframework.beans.propertyeditors.PropertiesEditor;
|
||||
|
||||
public class DefaultPropertEditorRegistrarTests extends TestCase {
|
||||
|
||||
public void testIntArray() throws Exception {
|
||||
DefaultPropertyEditorRegistrar mapper = new DefaultPropertyEditorRegistrar();
|
||||
BeanWithIntArray result = new BeanWithIntArray();
|
||||
BeanWrapperImpl wrapper = new BeanWrapperImpl(result);
|
||||
mapper.setCustomEditors(Collections.singletonMap(int[].class, new IntArrayPropertyEditor()));
|
||||
mapper.registerCustomEditors(wrapper);
|
||||
PropertiesEditor editor = new PropertiesEditor();
|
||||
editor.setAsText("numbers=1,2,3, 4");
|
||||
Properties props = (Properties) editor.getValue();
|
||||
wrapper.setPropertyValues(props);
|
||||
assertEquals(4, result.numbers[3]);
|
||||
}
|
||||
|
||||
public void testSetCustomEditorsWithInvalidTypeName() throws Exception {
|
||||
|
||||
DefaultPropertyEditorRegistrar mapper = new DefaultPropertyEditorRegistrar();
|
||||
try {
|
||||
mapper.setCustomEditors(Collections.singletonMap("FOO", new CustomNumberEditor(Long.class, true)));
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testSetCustomEditorsWithInvalidType() throws Exception {
|
||||
|
||||
DefaultPropertyEditorRegistrar mapper = new DefaultPropertyEditorRegistrar();
|
||||
try {
|
||||
mapper.setCustomEditors(Collections.singletonMap(new Object(), new CustomNumberEditor(Long.class, true)));
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testSetCustomEditorsWithInvalidEditor() throws Exception {
|
||||
|
||||
DefaultPropertyEditorRegistrar mapper = new DefaultPropertyEditorRegistrar();
|
||||
try {
|
||||
mapper.setCustomEditors(Collections.singletonMap(Long.class, "FOO"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
private static class BeanWithIntArray {
|
||||
private int[] numbers;
|
||||
|
||||
public void setNumbers(int[] numbers) {
|
||||
this.numbers = numbers;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user