From ee9f5a6e09c87c7450fddd61cb8e3ddc03b61689 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Sat, 10 Oct 2015 19:48:42 +0300 Subject: Include correct type and parameter info in exception (#19064) Change-Id: Ic08bfa69bc0c4cb42ecbb1d53ab712e75075ee10 --- .../util/sqlcontainer/generator/StatementHelperTest.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'server/tests') 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 -- cgit v1.2.3