summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-10-10 19:48:42 +0300
committerTeemu Suo-Anttila <teemusa@vaadin.com>2016-01-05 14:06:36 +0200
commit7d6349737dba9b96c8abc184b7c2f8b9530cd008 (patch)
tree955d8f7390b3e5172ff8e021a5343020462870bc
parenta4269bca4b9d96257da8136413068093d53861b5 (diff)
downloadvaadin-framework-7d6349737dba9b96c8abc184b7c2f8b9530cd008.tar.gz
vaadin-framework-7d6349737dba9b96c8abc184b7c2f8b9530cd008.zip
Include correct type and parameter info in exception (#19064)
Change-Id: I26baf26dae6d1ad8b93529191cc69ffc0445aa40
-rw-r--r--server/src/com/vaadin/data/util/sqlcontainer/query/generator/StatementHelper.java4
-rw-r--r--server/tests/src/com/vaadin/data/util/sqlcontainer/generator/StatementHelperTest.java16
2 files changed, 15 insertions, 5 deletions
diff --git a/server/src/com/vaadin/data/util/sqlcontainer/query/generator/StatementHelper.java b/server/src/com/vaadin/data/util/sqlcontainer/query/generator/StatementHelper.java
index 379b319207..5a9fcb17c0 100644
--- a/server/src/com/vaadin/data/util/sqlcontainer/query/generator/StatementHelper.java
+++ b/server/src/com/vaadin/data/util/sqlcontainer/query/generator/StatementHelper.java
@@ -153,8 +153,8 @@ public class StatementHelper implements Serializable {
return;
}
- throw new SQLException("Data type not supported by SQLContainer: "
- + dataType.getClass().toString());
+ throw new SQLException("Data type for parameter " + i
+ + " not supported by SQLContainer: " + dataType.getName());
}
}
diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/generator/StatementHelperTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/generator/StatementHelperTest.java
index f1eb365c45..b89b7e747d 100644
--- a/server/tests/src/com/vaadin/data/util/sqlcontainer/generator/StatementHelperTest.java
+++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/generator/StatementHelperTest.java
@@ -19,6 +19,7 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import org.easymock.EasyMock;
+import org.junit.Assert;
import org.junit.Test;
import com.vaadin.data.util.sqlcontainer.query.generator.StatementHelper;
@@ -29,14 +30,23 @@ import com.vaadin.data.util.sqlcontainer.query.generator.StatementHelper;
*/
public class StatementHelperTest {
- @Test(expected = SQLException.class)
+ @Test
public void testSetValueNullParameter() throws SQLException {
StatementHelper helper = new StatementHelper();
- helper.addParameterValue(null, Object.class);
+ helper.addParameterValue(null, StatementHelper.class);
PreparedStatement statement = EasyMock
.createMock(PreparedStatement.class);
// should throw SQLException, not NPE
- helper.setParameterValuesToStatement(statement);
+ try {
+ helper.setParameterValuesToStatement(statement);
+ Assert.fail("Expected SQLExecption for unsupported type");
+ } catch (SQLException e) {
+ // Exception should contain info about which parameter and the type
+ // which was unsupported
+ Assert.assertTrue(e.getMessage().contains("parameter 0"));
+ Assert.assertTrue(e.getMessage().contains(
+ StatementHelper.class.getName()));
+ }
}
@Test