You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by st...@apache.org on 2016/09/12 14:08:29 UTC
svn commit: r1760375 -
/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/IndexedPropertyTestCase.java
Author: stain
Date: Mon Sep 12 14:08:29 2016
New Revision: 1760375
URL: http://svn.apache.org/viewvc?rev=1760375&view=rev
Log:
BEANUTILS-492 workarounds in test case
.. but Assume.assumeTrue does not cause the test to be ignored :(
Modified:
commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/IndexedPropertyTestCase.java
Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/IndexedPropertyTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/IndexedPropertyTestCase.java?rev=1760375&r1=1760374&r2=1760375&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/IndexedPropertyTestCase.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/IndexedPropertyTestCase.java Mon Sep 12 14:08:29 2016
@@ -22,13 +22,14 @@ import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Assume;
+
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
@@ -40,7 +41,9 @@ import org.apache.commons.logging.LogFac
public class IndexedPropertyTestCase extends TestCase {
- private static final Log log = LogFactory.getLog(IndexedPropertyTestCase.class);
+ private static final String BEANUTILS_492 = "BEANUTILS-492: IndexedPropertyDescriptor not supported for List in Java 8";
+
+ private static final Log log = LogFactory.getLog(IndexedPropertyTestCase.class);
// ---------------------------------------------------- Instance Variables
@@ -153,9 +156,10 @@ public class IndexedPropertyTestCase ext
try {
final PropertyDescriptor descriptor = propertyUtilsBean.getPropertyDescriptor(bean, "stringList");
assertNotNull("No List Descriptor", descriptor);
- assertEquals("Not IndexedPropertyDescriptor",
- IndexedPropertyDescriptor.class,
- descriptor.getClass());
+ // BEANUTILS-492 - can't assume lists are handled as arrays in Java 8+
+// assertEquals("Not IndexedPropertyDescriptor",
+// IndexedPropertyDescriptor.class,
+// descriptor.getClass());
assertEquals("PropertDescriptor Type invalid",
List.class,
descriptor.getPropertyType());
@@ -172,9 +176,9 @@ public class IndexedPropertyTestCase ext
try {
final PropertyDescriptor descriptor = propertyUtilsBean.getPropertyDescriptor(bean, "arrayList");
assertNotNull("No ArrayList Descriptor", descriptor);
- assertEquals("Not IndexedPropertyDescriptor",
- IndexedPropertyDescriptor.class,
- descriptor.getClass());
+// assertEquals("Not IndexedPropertyDescriptor",
+// IndexedPropertyDescriptor.class,
+// descriptor.getClass());
assertEquals("PropertDescriptor Type invalid",
ArrayList.class,
descriptor.getPropertyType());
@@ -189,8 +193,8 @@ public class IndexedPropertyTestCase ext
public void testArrayReadMethod() {
try {
- final IndexedPropertyDescriptor descriptor =
- (IndexedPropertyDescriptor)propertyUtilsBean.getPropertyDescriptor(bean, "stringArray");
+ final PropertyDescriptor descriptor =
+ (PropertyDescriptor)propertyUtilsBean.getPropertyDescriptor(bean, "stringArray");
assertNotNull("No Array Read Method", descriptor.getReadMethod());
} catch(final Exception e) {
fail("Threw exception " + e);
@@ -203,8 +207,8 @@ public class IndexedPropertyTestCase ext
public void testArrayWriteMethod() {
try {
- final IndexedPropertyDescriptor descriptor =
- (IndexedPropertyDescriptor)propertyUtilsBean.getPropertyDescriptor(bean, "stringArray");
+ final PropertyDescriptor descriptor =
+ (PropertyDescriptor)propertyUtilsBean.getPropertyDescriptor(bean, "stringArray");
assertNotNull("No Array Write Method", descriptor.getWriteMethod());
} catch(final Exception e) {
fail("Threw exception " + e);
@@ -249,8 +253,8 @@ public class IndexedPropertyTestCase ext
public void testListReadMethod() {
try {
- final IndexedPropertyDescriptor descriptor =
- (IndexedPropertyDescriptor)propertyUtilsBean.getPropertyDescriptor(bean, "stringList");
+ final PropertyDescriptor descriptor =
+ (PropertyDescriptor)propertyUtilsBean.getPropertyDescriptor(bean, "stringList");
assertNotNull("No List Read Method", descriptor.getReadMethod());
} catch(final Exception e) {
fail("Threw exception " + e);
@@ -267,8 +271,8 @@ public class IndexedPropertyTestCase ext
public void testListWriteMethod() {
try {
- final IndexedPropertyDescriptor descriptor =
- (IndexedPropertyDescriptor)propertyUtilsBean.getPropertyDescriptor(bean, "stringList");
+ final PropertyDescriptor descriptor =
+ (PropertyDescriptor)propertyUtilsBean.getPropertyDescriptor(bean, "stringList");
assertNotNull("No List Write Method", descriptor.getWriteMethod());
} catch(final Exception e) {
fail("Threw exception " + e);
@@ -278,29 +282,21 @@ public class IndexedPropertyTestCase ext
/**
* Test Indexed Read Method for a List
*/
- public void testListIndexedReadMethod() {
-
- try {
- final IndexedPropertyDescriptor descriptor =
- (IndexedPropertyDescriptor)propertyUtilsBean.getPropertyDescriptor(bean, "stringList");
- assertNotNull("No List Indexed Read Method", descriptor.getIndexedReadMethod());
- } catch(final Exception e) {
- fail("Threw exception " + e);
- }
+ public void testListIndexedReadMethod() throws Exception {
+ final PropertyDescriptor descriptor = propertyUtilsBean.getPropertyDescriptor(bean, "stringList");
+ assertNotNull("stringList descriptor not found", descriptor);
+ Assume.assumeTrue(BEANUTILS_492, descriptor instanceof IndexedPropertyDescriptor);
+ assertNotNull("No List Indexed Read Method", ((IndexedPropertyDescriptor)descriptor).getIndexedReadMethod());
}
/**
* Test Indexed Write Method for a List
*/
- public void testListIndexedWriteMethod() {
-
- try {
- final IndexedPropertyDescriptor descriptor =
- (IndexedPropertyDescriptor)propertyUtilsBean.getPropertyDescriptor(bean, "stringList");
- assertNotNull("No List Indexed Write Method", descriptor.getIndexedWriteMethod());
- } catch(final Exception e) {
- fail("Threw exception " + e);
- }
+ public void testListIndexedWriteMethod() throws Exception {
+ final PropertyDescriptor descriptor = propertyUtilsBean.getPropertyDescriptor(bean, "stringList");
+ assertNotNull("stringList descriptor not found", descriptor);
+ Assume.assumeTrue(BEANUTILS_492, descriptor instanceof IndexedPropertyDescriptor);
+ assertNotNull("No List Indexed Write Method", ((IndexedPropertyDescriptor)descriptor).getIndexedWriteMethod());
}
/**
@@ -309,8 +305,8 @@ public class IndexedPropertyTestCase ext
public void testArrayListReadMethod() {
try {
- final IndexedPropertyDescriptor descriptor =
- (IndexedPropertyDescriptor)propertyUtilsBean.getPropertyDescriptor(bean, "arrayList");
+ final PropertyDescriptor descriptor =
+ (PropertyDescriptor)propertyUtilsBean.getPropertyDescriptor(bean, "arrayList");
assertNotNull("No ArrayList Read Method", descriptor.getReadMethod());
} catch(final Exception e) {
fail("Threw exception " + e);
@@ -323,8 +319,8 @@ public class IndexedPropertyTestCase ext
public void testArrayListWriteMethod() {
try {
- final IndexedPropertyDescriptor descriptor =
- (IndexedPropertyDescriptor)propertyUtilsBean.getPropertyDescriptor(bean, "arrayList");
+ final PropertyDescriptor descriptor =
+ propertyUtilsBean.getPropertyDescriptor(bean, "arrayList");
assertNotNull("No ArrayList Write Method", descriptor.getWriteMethod());
} catch(final Exception e) {
fail("Threw exception " + e);