Repository: phoenix Updated Branches: refs/heads/calcite 7c662fd35 -> d3b227a18
Add PreparedStatement tests Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/d3b227a1 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/d3b227a1 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/d3b227a1 Branch: refs/heads/calcite Commit: d3b227a18e3df797e8866aa771719f28aa7b17db Parents: 7c662fd Author: maryannxue <[email protected]> Authored: Thu May 5 12:00:24 2016 -0400 Committer: maryannxue <[email protected]> Committed: Thu May 5 12:00:24 2016 -0400 ---------------------------------------------------------------------- .../apache/phoenix/calcite/BaseCalciteIT.java | 4 ++++ .../apache/phoenix/calcite/CalciteDMLIT.java | 24 ++++++++++++++++++++ 2 files changed, 28 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/d3b227a1/phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIT.java b/phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIT.java index dc21809..9ec77c5 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/calcite/BaseCalciteIT.java @@ -185,6 +185,10 @@ public class BaseCalciteIT extends BaseClientManagedTimeIT { statement.close(); return this; } + + public PreparedStatement prepareStatement() throws SQLException { + return start.getConnection().prepareStatement(sql); + } public void close() { start.close(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/d3b227a1/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteDMLIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteDMLIT.java b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteDMLIT.java index 4354fd5..01cadf1 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteDMLIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteDMLIT.java @@ -1,10 +1,16 @@ package org.apache.phoenix.calcite; import static org.apache.phoenix.util.TestUtil.ATABLE_NAME; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import java.sql.PreparedStatement; +import java.sql.ResultSet; import java.util.Properties; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; public class CalciteDMLIT extends BaseCalciteIT { @@ -28,6 +34,14 @@ public class CalciteDMLIT extends BaseCalciteIT { start(false, 1L).sql("select organization_id, entity_id from aTable") .resultIs(0, new Object[][] {{"1 ", "1 "}}) .close(); + final Sql sql = start(PROPS).sql("select * from atable where organization_id = ?"); + PreparedStatement stmt = sql.prepareStatement(); + stmt.setString(1, "1"); + ResultSet rs = stmt.executeQuery(); + assertTrue(rs.next()); + assertEquals("1 ", rs.getString(2)); + assertFalse(rs.next()); + sql.close(); } @Test @@ -56,4 +70,14 @@ public class CalciteDMLIT extends BaseCalciteIT { {3, 30, "00300", null, "03000"}}) .close(); } + + @Ignore + @Test public void testUpsertWithPreparedStatement() throws Exception { + final Sql sql = start(PROPS).sql("upsert into atable(organization_id, entity_id) values(?, ?)"); + PreparedStatement stmt = sql.prepareStatement(); + stmt.setString(1, "x"); + stmt.setString(2, "x"); + stmt.execute(); + sql.close(); + } }
