Repository: commons-dbutils Updated Branches: refs/heads/master 865eca4b0 -> bcc01f8e5
Signed-off-by: Carl Hall <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/bcc01f8e Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/bcc01f8e Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/bcc01f8e Branch: refs/heads/master Commit: bcc01f8e58916fe60842d448cf87222439e6c74e Parents: eee69c7 Author: Michael Hausegger <[email protected]> Authored: Mon Jun 26 19:17:39 2017 +0200 Committer: Carl Hall <[email protected]> Committed: Sat Jul 8 16:28:50 2017 -0700 ---------------------------------------------------------------------- .../dbutils/GenerousBeanProcessorTest.java | 55 +++++++++++++++++--- 1 file changed, 48 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/bcc01f8e/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java b/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java index 4e90cdc..20aed1b 100644 --- a/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java +++ b/src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java @@ -16,16 +16,18 @@ */ package org.apache.commons.dbutils; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.when; -import java.beans.PropertyDescriptor; -import java.sql.ResultSetMetaData; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import java.beans.PropertyDescriptor; +import java.sql.ResultSetMetaData; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.when; + public class GenerousBeanProcessorTest { @@ -62,7 +64,26 @@ public class GenerousBeanProcessorTest { assertEquals(0, ret[2]); assertEquals(1, ret[3]); } - + + @SuppressWarnings("boxing") // test code + @Test + public void testMapColumnsToPropertiesMixedCase() throws Exception { + when(metaData.getColumnCount()).thenReturn(3); + + when(metaData.getColumnLabel(1)).thenReturn("tHree"); + when(metaData.getColumnLabel(2)).thenReturn("One"); + when(metaData.getColumnLabel(3)).thenReturn("tWO"); + + int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors); + + assertNotNull(ret); + assertEquals(4, ret.length); + assertEquals(-1, ret[0]); + assertEquals(2, ret[1]); + assertEquals(0, ret[2]); + assertEquals(1, ret[3]); + } + @SuppressWarnings("boxing") // test code @Test public void testMapColumnsToPropertiesWithUnderscores() throws Exception { @@ -81,7 +102,27 @@ public class GenerousBeanProcessorTest { assertEquals(0, ret[2]); assertEquals(1, ret[3]); } - + + @SuppressWarnings("boxing") // test code + @Test + public void testMapColumnsToPropertiesColumnLabelIsNull() throws Exception { + when(metaData.getColumnCount()).thenReturn(1); + when(metaData.getColumnName(1)).thenReturn("juhu"); + + when(metaData.getColumnLabel(1)).thenReturn(null); + when(metaData.getColumnLabel(2)).thenReturn("One"); + when(metaData.getColumnLabel(3)).thenReturn("tWO"); + + int[] ret = processor.mapColumnsToProperties(metaData, propDescriptors); + + assertNotNull(ret); + assertEquals(2, ret.length); + assertEquals(-1, ret[0]); + assertEquals(-1, ret[1]); + assertEquals(-1, ret[1]); + assertEquals(-1, ret[1]); + } + static class TestBean { private String one; private int two;
