diff options
author | Paul Duffin <paulduffin@google.com> | 2016-07-15 11:02:21 +0100 |
---|---|---|
committer | Paul Duffin <paulduffin@google.com> | 2016-07-20 15:29:55 +0100 |
commit | f60f4ca1e64958be1baa4988ac48f97903d14eaf (patch) | |
tree | e8daaf060708886a7f8765c8062fa98b74da3938 /src | |
parent | e91f13f29b06462b03b1f757f206ab4d44e374b2 (diff) | |
download | platform_external_junit-params-f60f4ca1e64958be1baa4988ac48f97903d14eaf.tar.gz platform_external_junit-params-f60f4ca1e64958be1baa4988ac48f97903d14eaf.tar.bz2 platform_external_junit-params-f60f4ca1e64958be1baa4988ac48f97903d14eaf.zip |
Workaround Android's lack of java.beans.PropertyEditor/Manager
The classes are used to allow developers to customize
JUnitParams' handling of conversion from literal String values
to the type of parameters required by the parameterized test
methods.
This simply removes the code that uses the classes. That means
developers who require custom data types will have to accept
String parameters in their parameterized test methods and do the
conversions manually.
Bug: 30244565
Change-Id: I0dd479591d6fb60f0a08025c51ab3c9494c1bda2
Test: Once it compiles the tests will be run.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/junitparams/internal/InvokeParameterisedMethod.java | 7 | ||||
-rw-r--r-- | src/test/java/junitparams/ParametersConvertedWithPropertyEditorTest.java | 44 |
2 files changed, 0 insertions, 51 deletions
diff --git a/src/main/java/junitparams/internal/InvokeParameterisedMethod.java b/src/main/java/junitparams/internal/InvokeParameterisedMethod.java index 34024d5..7d313c2 100644 --- a/src/main/java/junitparams/internal/InvokeParameterisedMethod.java +++ b/src/main/java/junitparams/internal/InvokeParameterisedMethod.java @@ -1,7 +1,5 @@ package junitparams.internal; -import java.beans.PropertyEditor; -import java.beans.PropertyEditorManager; import java.lang.annotation.Annotation; import java.lang.reflect.Array; import java.math.BigDecimal; @@ -208,11 +206,6 @@ public class InvokeParameterisedMethod extends Statement { return Byte.parseByte((String) object); if (clazz.isAssignableFrom(BigDecimal.class)) return new BigDecimal((String) object); - PropertyEditor editor = PropertyEditorManager.findEditor(clazz); - if (editor != null) { - editor.setAsText((String) object); - return editor.getValue(); - } throw new IllegalArgumentException("Parameter type (" + clazz.getName() + ") cannot be handled!" + " Only primitive types, BigDecimals and Strings can be used."); } diff --git a/src/test/java/junitparams/ParametersConvertedWithPropertyEditorTest.java b/src/test/java/junitparams/ParametersConvertedWithPropertyEditorTest.java deleted file mode 100644 index 9d71418..0000000 --- a/src/test/java/junitparams/ParametersConvertedWithPropertyEditorTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package junitparams; - -import java.beans.PropertyEditorManager; -import java.beans.PropertyEditorSupport; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.assertj.core.api.Assertions.*; - -@RunWith(JUnitParamsRunner.class) -public class ParametersConvertedWithPropertyEditorTest { - - @BeforeClass - public static void registerEditors() { - PropertyEditorManager.registerEditor(StringWrapper.class, StringWrapperPropertyEditor.class); - } - - @Test - @Parameters({"wrapped , wrapped"}) - public void convertsToCustomType(StringWrapper wrapper, String text) { - assertThat(wrapper.getText()).isEqualTo(text); - } - - public static class StringWrapperPropertyEditor extends PropertyEditorSupport { - @Override - public void setAsText(String text) throws IllegalArgumentException { - setValue(new StringWrapper(text)); - } - } - - private static class StringWrapper { - private String text; - - StringWrapper(String text) { - this.text = text; - } - - String getText() { - return text; - } - } -} |