This is an automated email from the ASF dual-hosted git repository.

thecarlhall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbutils.git

commit d72b5b9566241df1a217bd7a958e6d09d4415e0c
Author: rewerma <[email protected]>
AuthorDate: Fri Jul 12 03:53:56 2019 +0800

    unit test for annotation mapping
---
 .../apache/commons/dbutils/BeanProcessorTest.java  | 58 ++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java 
b/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java
index a1f6cea..52161b8 100644
--- a/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java
+++ b/src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.dbutils;
 
+import org.apache.commons.dbutils.annotations.Column;
+
 import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
 import java.sql.ResultSetMetaData;
@@ -128,4 +130,60 @@ public class BeanProcessorTest extends BaseTestCase {
             assertTrue(columns[i] != BeanProcessor.PROPERTY_NOT_FOUND);
         }
     }
+
+    public static class MapColumnToAnnotationFieldBean {
+        private String one;
+
+        private String two;
+
+        private String three;
+
+        private String four;
+
+        public String getOne() {
+            return one;
+        }
+
+        public void setOne(final String one) {
+            this.one = one;
+        }
+
+        public String getTwo() {
+            return two;
+        }
+
+        public void setTwo(final String two) {
+            this.two = two;
+        }
+
+        @Column(name = "three_")
+        public String getThree() {
+            return three;
+        }
+
+        public void setThree(final String three) {
+            this.three = three;
+        }
+
+        public String getFour() {
+            return four;
+        }
+
+        public void setFour(final String four) {
+            this.four = four;
+        }
+    }
+
+    public void testMapColumnToAnnotationField() throws Exception {
+        final String[] columnNames = { "test", "test", "three_" };
+        final String[] columnLabels = { "one", "two", null };
+        final ResultSetMetaData rsmd = 
ProxyFactory.instance().createResultSetMetaData(
+                new MockResultSetMetaData(columnNames, columnLabels));
+        final PropertyDescriptor[] props = 
Introspector.getBeanInfo(MapColumnToAnnotationFieldBean.class).getPropertyDescriptors();
+
+        final int[] columns = beanProc.mapColumnsToProperties(rsmd, props);
+        for (int i = 1; i < columns.length; i++) {
+            assertTrue(columns[i] != BeanProcessor.PROPERTY_NOT_FOUND);
+        }
+    }
 }

Reply via email to