Repository: phoenix Updated Branches: refs/heads/3.0 41d7afcb8 -> a411c7b23
http://git-wip-us.apache.org/repos/asf/phoenix/blob/a411c7b2/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereCompilerTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereCompilerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereCompilerTest.java index 5122963..b3b8ac0 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereCompilerTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereCompilerTest.java @@ -65,6 +65,7 @@ import org.apache.phoenix.schema.SaltingUtil; import org.apache.phoenix.util.ByteUtil; import org.apache.phoenix.util.DateUtil; import org.apache.phoenix.util.NumberUtil; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.StringUtil; import org.junit.Ignore; @@ -79,7 +80,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { public void testSingleEqualFilter() throws SQLException { String tenantId = "000000000000001"; String query = "select * from atable where organization_id='" + tenantId + "' and a_integer=0"; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -94,7 +95,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { @Test public void testSingleFixedFullPkSalted() throws SQLException { - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); pconn.createStatement().execute("CREATE TABLE t (k bigint not null primary key, v varchar) SALT_BUCKETS=20"); String query = "select * from t where k=" + 1; PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); @@ -115,7 +116,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { @Test public void testSingleVariableFullPkSalted() throws SQLException { - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); pconn.createStatement().execute("CREATE TABLE t (k varchar primary key, v varchar) SALT_BUCKETS=20"); String query = "select * from t where k='a'"; PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); @@ -136,7 +137,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { @Test public void testMultiFixedFullPkSalted() throws SQLException { - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); pconn.createStatement().execute("CREATE TABLE t (k bigint not null primary key, v varchar) SALT_BUCKETS=20"); String query = "select * from t where k in (1,3)"; PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); @@ -185,7 +186,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { public void testMultiColumnEqualFilter() throws SQLException { String tenantId = "000000000000001"; String query = "select * from atable where organization_id='" + tenantId + "' and a_string=b_string"; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -202,7 +203,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { public void testCollapseFunctionToNull() throws SQLException { String tenantId = "000000000000001"; String query = "select * from atable where organization_id='" + tenantId + "' and substr(entity_id,null) = 'foo'"; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -219,7 +220,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { String query = "select * from atable where organization_id=? and a_integer=0 and a_string='foo'"; List<Object> binds = Arrays.<Object>asList(tenantId); - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); bindParams(pstmt, binds); QueryPlan plan = pstmt.optimizeQuery(); @@ -243,7 +244,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { public void testRHSLiteral() throws SQLException { String tenantId = "000000000000001"; String query = "select * from atable where organization_id='" + tenantId + "' and 0 >= a_integer"; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -262,7 +263,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { String tenantId = "000000000000001"; String dateStr = "2012-01-01 12:00:00"; String query = "select * from atable where organization_id='" + tenantId + "' and a_date >= to_date('" + dateStr + "')"; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -282,7 +283,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { private void helpTestToNumberFilter(String toNumberClause, BigDecimal expectedDecimal) throws Exception { String tenantId = "000000000000001"; String query = "select * from atable where organization_id='" + tenantId + "' and x_decimal >= " + toNumberClause; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -339,7 +340,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { String keyPrefix = "foo"; String query = "select * from atable where substr(entity_id,1,3)=?"; List<Object> binds = Arrays.<Object>asList(keyPrefix); - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); bindParams(pstmt, binds); QueryPlan plan = pstmt.optimizeQuery(); @@ -365,7 +366,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { String keyPrefix = "fo"; String query = "select * from atable where entity_id=?"; List<Object> binds = Arrays.<Object>asList(keyPrefix); - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); bindParams(pstmt, binds); QueryPlan plan = pstmt.optimizeQuery(); @@ -381,7 +382,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { String keyPrefix = "fo"; String query = "select * from atable where organization_id=? AND entity_id=?"; List<Object> binds = Arrays.<Object>asList(tenantId,keyPrefix); - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); bindParams(pstmt, binds); QueryPlan plan = pstmt.optimizeQuery(); @@ -396,7 +397,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { String keyPrefix = "foobar"; String query = "select * from atable where substr(entity_id,1,3)=?"; List<Object> binds = Arrays.<Object>asList(keyPrefix); - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); bindParams(pstmt, binds); QueryPlan plan = pstmt.optimizeQuery(); @@ -411,7 +412,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { String aString = (String)PDataType.VARCHAR.toObject(tooBigValue); String query = "select * from atable where a_string=?"; List<Object> binds = Arrays.<Object>asList(aString); - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); bindParams(pstmt, binds); QueryPlan plan = pstmt.optimizeQuery(); @@ -426,7 +427,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { int aInt = 2; String query = "select * from atable where organization_id=? and (substr(entity_id,1,3)=? or a_integer=?)"; List<Object> binds = Arrays.<Object>asList(tenantId, keyPrefix, aInt); - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); bindParams(pstmt, binds); QueryPlan plan = pstmt.optimizeQuery(); @@ -455,7 +456,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { public void testTypeMismatch() throws SQLException { String tenantId = "000000000000001"; String query = "select * from atable where organization_id='" + tenantId + "' and a_integer > 'foo'"; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); try { @@ -470,7 +471,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { public void testAndFalseFilter() throws SQLException { String tenantId = "000000000000001"; String query = "select * from atable where organization_id='" + tenantId + "' and a_integer=0 and 2=3"; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); assertDegenerate(plan.getContext()); @@ -480,7 +481,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { public void testFalseFilter() throws SQLException { String tenantId = "000000000000001"; String query = "select * from atable where organization_id='" + tenantId + "' and 2=3"; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); assertDegenerate(plan.getContext()); @@ -490,7 +491,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { public void testTrueFilter() throws SQLException { String tenantId = "000000000000001"; String query = "select * from atable where organization_id='" + tenantId + "' and 2<=2"; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -505,7 +506,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { public void testAndTrueFilter() throws SQLException { String tenantId = "000000000000001"; String query = "select * from atable where organization_id='" + tenantId + "' and a_integer=0 and 2<3"; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -527,7 +528,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { public void testOrFalseFilter() throws SQLException { String tenantId = "000000000000001"; String query = "select * from atable where organization_id='" + tenantId + "' and (a_integer=0 or 3!=3)"; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -548,7 +549,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { public void testOrTrueFilter() throws SQLException { String tenantId = "000000000000001"; String query = "select * from atable where organization_id='" + tenantId + "' and (a_integer=0 or 3>2)"; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -564,7 +565,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { public void testInFilter() throws SQLException { String tenantId = "000000000000001"; String query = "select * from atable where organization_id='" + tenantId + "' and a_string IN ('a','b')"; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -589,7 +590,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { String tenantId3 = "000000000000003"; String query = String.format("select * from %s where organization_id IN ('%s','%s','%s')", ATABLE_NAME, tenantId1, tenantId3, tenantId2); - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -616,7 +617,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { String tenantId3 = "000000000000003"; String query = String.format("select * from %s where organization_id='%s' OR organization_id='%s' OR organization_id='%s'", ATABLE_NAME, tenantId1, tenantId3, tenantId2); - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -644,7 +645,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { String entityId2 = "00000000000000Y"; String query = String.format("select * from %s where organization_id='%s' AND entity_id IN ('%s','%s')", ATABLE_NAME, tenantId, entityId1, entityId2); - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -674,7 +675,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { String entityId2 = "00000000000000Y"; String query = String.format("select * from %s where organization_id IN ('%s','%s','%s') AND entity_id>='%s' AND entity_id<='%s'", ATABLE_NAME, tenantId1, tenantId3, tenantId2, entityId1, entityId2); - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -703,7 +704,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { String entityId = "00000000000000X"; String query = String.format("select * from %s where organization_id IN ('%s','%s','%s') AND entity_id='%s'", ATABLE_NAME, tenantId1, tenantId3, tenantId2, entityId); - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -726,7 +727,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { String entityId = "00000000000000X"; String query = String.format("select * from %s where organization_id IN ('%s','%s','%s') AND entity_id='%s'", ATABLE_NAME, tenantId1, tenantId3, tenantId2, entityId); - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -756,7 +757,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { String entityId2 = "00000000000000Y"; String query = String.format("select * from %s where organization_id IN ('%s','%s') AND entity_id IN ('%s', '%s')", ATABLE_NAME, tenantId1, tenantId2, entityId1, entityId2); - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -780,7 +781,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { String tenantId2 = "02"; String query = String.format("select * from %s where organization_id > '%s' AND organization_id < '%s'", ATABLE_NAME, tenantId1, tenantId2); - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -801,7 +802,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { String entityId2 = "00000000000000Y"; String query = String.format("select * from %s where organization_id IN ('%s','%s','%s') AND entity_id IN ('%s', '%s')", ATABLE_NAME, tenantId1, tenantId3, tenantId2, entityId1, entityId2); - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -816,7 +817,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { public void testBetweenFilter() throws SQLException { String tenantId = "000000000000001"; String query = "select * from atable where organization_id='" + tenantId + "' and a_integer between 0 and 10"; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -838,7 +839,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { public void testNotBetweenFilter() throws SQLException { String tenantId = "000000000000001"; String query = "select * from atable where organization_id='" + tenantId + "' and a_integer not between 0 and 10"; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -866,7 +867,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { createTestTable(url, "create view tenant_filter_test (tenant_col integer) AS SELECT * FROM BASE_TABLE_FOR_TENANT_FILTER_TEST WHERE type_id= '" + tenantTypeId + "'"); String query = "select * from tenant_filter_test where a_integer=0 and a_string='foo'"; - PhoenixConnection pconn = DriverManager.getConnection(url, TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); @@ -898,7 +899,7 @@ public class WhereCompilerTest extends BaseConnectionlessQueryTest { createTestTable(getUrl(tenantId), "create view tenant_filter_test (tenant_col integer) AS SELECT * FROM BASE_TABLE_FOR_TENANT_FILTER_TEST"); String query = "select * from tenant_filter_test where a_integer=0 and a_string='foo'"; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(tenantId), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(tenantId), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/a411c7b2/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java index 4ee428c..321eb6e 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java @@ -57,6 +57,7 @@ import org.apache.phoenix.schema.PDataType; import org.apache.phoenix.util.ByteUtil; import org.apache.phoenix.util.DateUtil; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.TestUtil; import org.junit.Test; @@ -77,7 +78,7 @@ public class WhereOptimizerTest extends BaseConnectionlessQueryTest { } private static StatementContext compileStatement(String query, List<Object> binds, Integer limit) throws SQLException { - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), new Properties(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query); TestUtil.bindParams(pstmt, binds); QueryPlan plan = pstmt.compileQuery(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/a411c7b2/phoenix-core/src/test/java/org/apache/phoenix/iterate/AggregateResultScannerTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/iterate/AggregateResultScannerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/iterate/AggregateResultScannerTest.java index 2edd588..478e914 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/iterate/AggregateResultScannerTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/iterate/AggregateResultScannerTest.java @@ -54,6 +54,7 @@ import org.apache.phoenix.schema.SortOrder; import org.apache.phoenix.schema.tuple.SingleKeyValueTuple; import org.apache.phoenix.schema.tuple.Tuple; import org.apache.phoenix.util.AssertResults; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; @@ -88,7 +89,7 @@ public class AggregateResultScannerTest extends BaseConnectionlessQueryTest { new SingleKeyValueTuple(new KeyValue(B, SINGLE_COLUMN_FAMILY, SINGLE_COLUMN, PDataType.LONG.toBytes(2L))), }; - PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class); + PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixStatement statement = new PhoenixStatement(pconn); StatementContext context = new StatementContext(statement, null, new Scan(), new SequenceManager(statement)); AggregationManager aggregationManager = context.getAggregationManager(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/a411c7b2/phoenix-core/src/test/java/org/apache/phoenix/query/BaseConnectionlessQueryTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseConnectionlessQueryTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseConnectionlessQueryTest.java index 6fa9c7f..c78567a 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseConnectionlessQueryTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseConnectionlessQueryTest.java @@ -29,6 +29,7 @@ import static org.apache.phoenix.util.TestUtil.MULTI_CF_NAME; import static org.apache.phoenix.util.TestUtil.PHOENIX_CONNECTIONLESS_JDBC_URL; import static org.apache.phoenix.util.TestUtil.PTSDB_NAME; import static org.apache.phoenix.util.TestUtil.TABLE_WITH_ARRAY; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertTrue; import java.sql.DriverManager; @@ -44,6 +45,7 @@ import org.apache.phoenix.schema.PTable; import org.apache.phoenix.schema.PTableKey; import org.apache.phoenix.schema.TableRef; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.TestUtil; import org.junit.BeforeClass; @@ -80,7 +82,7 @@ public class BaseConnectionlessQueryTest extends BaseTest { if (PhoenixEmbeddedDriver.isTestUrl(url)) { driver = initDriver(ReadOnlyProps.EMPTY_PROPS); assertTrue(DriverManager.getDriver(url) == driver); - driver.connect(url, TestUtil.TEST_PROPERTIES); + driver.connect(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/a411c7b2/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java index 5469b91..0336d02 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java @@ -81,6 +81,7 @@ import static org.apache.phoenix.util.TestUtil.ROW9; import static org.apache.phoenix.util.TestUtil.STABLE_NAME; import static org.apache.phoenix.util.TestUtil.TABLE_WITH_ARRAY; import static org.apache.phoenix.util.TestUtil.TABLE_WITH_SALTING; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertNotNull; import java.math.BigDecimal; @@ -124,9 +125,9 @@ import org.apache.phoenix.schema.TableAlreadyExistsException; import org.apache.phoenix.schema.TableNotFoundException; import org.apache.phoenix.util.ConfigUtil; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; -import org.apache.phoenix.util.TestUtil; import org.junit.Assert; import com.google.common.collect.ImmutableMap; @@ -543,7 +544,7 @@ public abstract class BaseTest { PhoenixTestDriver driver = new PhoenixTestDriver(props); DriverManager.registerDriver(driver); Assert.assertTrue(DriverManager.getDriver(url) == driver); - Connection conn = driver.connect(url, TestUtil.TEST_PROPERTIES); + Connection conn = driver.connect(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.close(); return driver; } http://git-wip-us.apache.org/repos/asf/phoenix/blob/a411c7b2/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java b/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java index 59bb08e..c501379 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java @@ -185,7 +185,23 @@ public class TestUtil { public static final String JOIN_ITEM_TABLE_DISPLAY_NAME = JOIN_SCHEMA + "." + JOIN_ITEM_TABLE; public static final String JOIN_SUPPLIER_TABLE_DISPLAY_NAME = JOIN_SCHEMA + "." + JOIN_SUPPLIER_TABLE; - public static final Properties TEST_PROPERTIES = new Properties(); + /** + * Read-only properties used by all tests + */ + public static final Properties TEST_PROPERTIES = new Properties() { + @Override + public String put(Object key, Object value) { + throw new UnsupportedOperationException(); + } + @Override + public void clear() { + throw new UnsupportedOperationException(); + } + @Override + public Object remove(Object key) { + throw new UnsupportedOperationException(); + } + }; public static byte[][] getSplits(String tenantId) { return new byte[][] { http://git-wip-us.apache.org/repos/asf/phoenix/blob/a411c7b2/phoenix-flume/src/it/java/org/apache/phoenix/flume/RegexEventSerializerIT.java ---------------------------------------------------------------------- diff --git a/phoenix-flume/src/it/java/org/apache/phoenix/flume/RegexEventSerializerIT.java b/phoenix-flume/src/it/java/org/apache/phoenix/flume/RegexEventSerializerIT.java index 7f4a6af..f86f039 100644 --- a/phoenix-flume/src/it/java/org/apache/phoenix/flume/RegexEventSerializerIT.java +++ b/phoenix-flume/src/it/java/org/apache/phoenix/flume/RegexEventSerializerIT.java @@ -44,6 +44,7 @@ import org.apache.phoenix.end2end.BaseHBaseManagedTimeIT; import org.apache.phoenix.end2end.HBaseManagedTimeTest; import org.apache.phoenix.flume.serializer.EventSerializers; import org.apache.phoenix.flume.sink.PhoenixSink; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -258,7 +259,7 @@ public class RegexEventSerializerIT extends BaseHBaseManagedTimeIT { sink.process(); final String query = " SELECT * FROM \n " + fullTableName; - Properties props = new Properties(TEST_PROPERTIES); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); final ResultSet rs ; final Connection conn = DriverManager.getConnection(getUrl(), props); try{ @@ -332,7 +333,7 @@ public class RegexEventSerializerIT extends BaseHBaseManagedTimeIT { sink.process(); final String query = " SELECT * FROM \n " + fullTableName; - Properties props = new Properties(TEST_PROPERTIES); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); final ResultSet rs ; final Connection conn = DriverManager.getConnection(getUrl(), props); try{ @@ -392,7 +393,7 @@ public class RegexEventSerializerIT extends BaseHBaseManagedTimeIT { private int countRows(final String fullTableName) throws SQLException { Preconditions.checkNotNull(fullTableName); - Properties props = new Properties(TEST_PROPERTIES); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); final Connection conn = DriverManager.getConnection(getUrl(), props); ResultSet rs = null ; try{ http://git-wip-us.apache.org/repos/asf/phoenix/blob/a411c7b2/phoenix-pig/src/it/java/org/apache/phoenix/pig/PhoenixPigConfigurationIT.java ---------------------------------------------------------------------- diff --git a/phoenix-pig/src/it/java/org/apache/phoenix/pig/PhoenixPigConfigurationIT.java b/phoenix-pig/src/it/java/org/apache/phoenix/pig/PhoenixPigConfigurationIT.java index fc0267f..d35e039 100644 --- a/phoenix-pig/src/it/java/org/apache/phoenix/pig/PhoenixPigConfigurationIT.java +++ b/phoenix-pig/src/it/java/org/apache/phoenix/pig/PhoenixPigConfigurationIT.java @@ -31,6 +31,7 @@ import java.util.Properties; import org.apache.hadoop.conf.Configuration; import org.apache.phoenix.end2end.BaseHBaseManagedTimeIT; import org.apache.phoenix.end2end.HBaseManagedTimeTest; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; import org.junit.Test; @@ -42,7 +43,7 @@ public class PhoenixPigConfigurationIT extends BaseHBaseManagedTimeIT { @Test public void testUpsertStatement() throws Exception { - Properties props = new Properties(TEST_PROPERTIES); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(false); final String tableName = "TEST_TABLE"; @@ -62,7 +63,7 @@ public class PhoenixPigConfigurationIT extends BaseHBaseManagedTimeIT { @Test public void testSelectStatement() throws Exception { - Properties props = new Properties(TEST_PROPERTIES); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(false); final String tableName = "TEST_TABLE"; @@ -82,7 +83,7 @@ public class PhoenixPigConfigurationIT extends BaseHBaseManagedTimeIT { @Test public void testSelectStatementForSpecificColumns() throws Exception { - Properties props = new Properties(TEST_PROPERTIES); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(false); final String tableName = "TEST_TABLE";