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 15:35:53 UTC

svn commit: r1760389 - /commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira422TestCase.java

Author: stain
Date: Mon Sep 12 15:35:53 2016
New Revision: 1760389

URL: http://svn.apache.org/viewvc?rev=1760389&view=rev
Log:
BEANUTILS-492 Ignore test on Java 8 or more

.. to use Assume.assumeTrue() this test was converted to Java 8

Modified:
    commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira422TestCase.java

Modified: commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira422TestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira422TestCase.java?rev=1760389&r1=1760388&r2=1760389&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira422TestCase.java (original)
+++ commons/proper/beanutils/trunk/src/test/java/org/apache/commons/beanutils/bugs/Jira422TestCase.java Mon Sep 12 15:35:53 2016
@@ -16,28 +16,61 @@
  */
 package org.apache.commons.beanutils.bugs;
 
-import java.util.List;
+import static org.junit.Assert.assertEquals;
 
-import junit.framework.TestCase;
+import java.beans.BeanInfo;
+import java.beans.IndexedPropertyDescriptor;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.util.List;
 
 import org.apache.commons.beanutils.PropertyUtils;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
 
 /**
  * getPropertyType return null on second descendant class
+ * <p>
+ * This test only work in Java 7 or earlier (See BEANUTILS-492) - as 
+ * a weaker alternative, see {@link Jira422bTestCase}.
+ * 
  *
  * @version $Id$
  * @see <a href="https://issues.apache.org/jira/browse/BEANUTILS-422">https://issues.apache.org/jira/browse/BEANUTILS-422</a>
  */
-public class Jira422TestCase extends TestCase {
+public class Jira422TestCase {
 
-    public void testRootBean() throws Exception {
+	/**
+	 * Detects BEANUTILS-492 in Java 8 or later
+	 * 
+	 * @see <a href="https://issues.apache.org/jira/browse/BEANUTILS-492">BEANUTILS-492</a>
+	 */
+	@BeforeClass
+	public static void assumeSupportsIndexedLists() throws IntrospectionException {
+		BeanInfo beanInfo = Introspector.getBeanInfo(RootBean.class);
+		for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
+			if (pd.getName().equals("file")) {
+				Assume.assumeTrue("BEANUTILS-492: IndexedPropertyDescriptor no longer supported for java.util.List", 
+						pd instanceof IndexedPropertyDescriptor);
+			}					
+		}
+		Assert.fail("Could not find PropertyDescriptor for 'file'"); 
+	}
+	
+	@Test
+    public void testRootBean() throws Exception {    	
         final RootBean bean = new FirstChildBean();
         final Class<?> propertyType = PropertyUtils.getPropertyType(bean, "file[0]");
         assertEquals(String.class.getName(), propertyType.getName());
     }
 
-    public void testSecondChildBean() throws Exception {
-        final RootBean bean = new SecondChildBean();
+	@Test	
+    public void testSecondChildBean() throws Exception {    	
+    	final RootBean bean = new SecondChildBean();
         final Class<?> propertyType = PropertyUtils.getPropertyType(bean, "file[0]");
         assertEquals(String.class.getName(), propertyType.getName());
     }