From 793bd554e7e815607a1f325ef998efa8d4a4bef7 Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Wed, 27 Feb 2019 22:13:20 +0000 Subject: [PATCH] Minor fix for tests failing with URL without parameters. --- .../java/testsuite/x/devapi/SessionTest.java | 91 ++++++++++--------- .../testsuite/x/devapi/TableSelectTest.java | 3 +- 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/test/java/testsuite/x/devapi/SessionTest.java b/src/test/java/testsuite/x/devapi/SessionTest.java index a9f419554..58e6b19ea 100644 --- a/src/test/java/testsuite/x/devapi/SessionTest.java +++ b/src/test/java/testsuite/x/devapi/SessionTest.java @@ -1159,17 +1159,20 @@ public void testSessionAttributes() throws Exception { userAttributes.clear(); userAttributes.put("key1", "value1"); - testSessionAttributes_checkSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=value1"), userAttributes); - testSessionAttributes_checkSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=value1]"), userAttributes); - testSessionAttributes_checkClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=value1"), userAttributes); - testSessionAttributes_checkClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=value1]"), userAttributes); + String baseUrlLocal = this.baseUrl + (this.baseUrl.contains("?") ? "&" : "?"); + + testSessionAttributes_checkSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=value1", true), userAttributes); + testSessionAttributes_checkSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=value1]", true), userAttributes); + testSessionAttributes_checkClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=value1", true), userAttributes); + testSessionAttributes_checkClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=value1]", true), userAttributes); userAttributes.put("key2", "value2"); - testSessionAttributes_checkSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=value1,key2=value2"), userAttributes); - testSessionAttributes_checkSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=value1,key2=value2]"), userAttributes); - testSessionAttributes_checkClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=value1,key2=value2"), userAttributes); - testSessionAttributes_checkClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=value1,key2=value2]"), userAttributes); + testSessionAttributes_checkSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=value1,key2=value2", true), userAttributes); + testSessionAttributes_checkSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=value1,key2=value2]", true), + userAttributes); + testSessionAttributes_checkClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=value1,key2=value2", true), userAttributes); + testSessionAttributes_checkClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=value1,key2=value2]", true), userAttributes); // TSFR4/TSFR5/TSFR6 Create a Session without xdevapi.connection-attributes in the connection string, verify that all predefined attributes // exist and contain the correct values. Verify that only connection attributes starting with "_" were set for current session. @@ -1184,41 +1187,41 @@ public void testSessionAttributes() throws Exception { // xdevapi.connection-attributes=_key1=value1 // xdevapi.connection-attributes=key1=value1,_key2=value2 assertThrows(WrongArgumentException.class, "Key names in \"xdevapi.connection-attributes\" cannot start with \"_\".", () -> { - this.fact.getSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[_key1=value1]")); + this.fact.getSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[_key1=value1]", true)); return null; }); assertThrows(WrongArgumentException.class, "Key names in \"xdevapi.connection-attributes\" cannot start with \"_\".", () -> { - Client cli1 = cf.getClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[_key1=value1]"), new Properties()); + Client cli1 = cf.getClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[_key1=value1]", true), new Properties()); cli1.getSession(); return null; }); assertThrows(WrongArgumentException.class, "Key names in \"xdevapi.connection-attributes\" cannot start with \"_\".", () -> { - this.fact.getSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=value1,_key2=value2]")); + this.fact.getSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=value1,_key2=value2]", true)); return null; }); assertThrows(WrongArgumentException.class, "Key names in \"xdevapi.connection-attributes\" cannot start with \"_\".", () -> { - Client cli1 = cf.getClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=value1,_key2=value2]"), new Properties()); + Client cli1 = cf.getClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=value1,_key2=value2]", true), new Properties()); cli1.getSession(); return null; }); assertThrows(WrongArgumentException.class, "Key names in \"xdevapi.connection-attributes\" cannot start with \"_\".", () -> { - this.fact.getSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "_key1=value1")); + this.fact.getSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "_key1=value1", true)); return null; }); assertThrows(WrongArgumentException.class, "Key names in \"xdevapi.connection-attributes\" cannot start with \"_\".", () -> { - Client cli1 = cf.getClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "_key1=value1"), new Properties()); + Client cli1 = cf.getClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "_key1=value1", true), new Properties()); cli1.getSession(); return null; }); assertThrows(WrongArgumentException.class, "Key names in \"xdevapi.connection-attributes\" cannot start with \"_\".", () -> { - this.fact.getSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=value1,_key2=value2")); + this.fact.getSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=value1,_key2=value2", true)); return null; }); assertThrows(WrongArgumentException.class, "Key names in \"xdevapi.connection-attributes\" cannot start with \"_\".", () -> { - Client cli1 = cf.getClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=value1,_key2=value2"), new Properties()); + Client cli1 = cf.getClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=value1,_key2=value2", true), new Properties()); cli1.getSession(); return null; }); @@ -1236,34 +1239,34 @@ public void testSessionAttributes() throws Exception { userAttributes.clear(); userAttributes.put("key1", ""); - testSessionAttributes_checkSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1]"), userAttributes); - testSessionAttributes_checkSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=]"), userAttributes); - testSessionAttributes_checkSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1"), userAttributes); - testSessionAttributes_checkSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1="), userAttributes); - testSessionAttributes_checkClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1]"), userAttributes); - testSessionAttributes_checkClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=]"), userAttributes); - testSessionAttributes_checkClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1"), userAttributes); - testSessionAttributes_checkClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1="), userAttributes); + testSessionAttributes_checkSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1]", true), userAttributes); + testSessionAttributes_checkSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=]", true), userAttributes); + testSessionAttributes_checkSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1", true), userAttributes); + testSessionAttributes_checkSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=", true), userAttributes); + testSessionAttributes_checkClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1]", true), userAttributes); + testSessionAttributes_checkClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=]", true), userAttributes); + testSessionAttributes_checkClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1", true), userAttributes); + testSessionAttributes_checkClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=", true), userAttributes); userAttributes.put("key2", "value2"); - testSessionAttributes_checkSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1,key2=value2]"), userAttributes); - testSessionAttributes_checkSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=,key2=value2]"), userAttributes); - testSessionAttributes_checkSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1,key2=value2"), userAttributes); - testSessionAttributes_checkSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=,key2=value2"), userAttributes); - testSessionAttributes_checkClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1,key2=value2]"), userAttributes); - testSessionAttributes_checkClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=,key2=value2]"), userAttributes); - testSessionAttributes_checkClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1,key2=value2"), userAttributes); - testSessionAttributes_checkClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=,key2=value2"), userAttributes); + testSessionAttributes_checkSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1,key2=value2]", true), userAttributes); + testSessionAttributes_checkSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=,key2=value2]", true), userAttributes); + testSessionAttributes_checkSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1,key2=value2", true), userAttributes); + testSessionAttributes_checkSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=,key2=value2", true), userAttributes); + testSessionAttributes_checkClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1,key2=value2]", true), userAttributes); + testSessionAttributes_checkClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[key1=,key2=value2]", true), userAttributes); + testSessionAttributes_checkClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1,key2=value2", true), userAttributes); + testSessionAttributes_checkClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=,key2=value2", true), userAttributes); // TSFR10 Create a Session with xdevapi.connection-attributes=false in the connection string, verify // that no connection attribute was set for current session. - Session s10 = this.fact.getSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "false")); + Session s10 = this.fact.getSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "false", true)); SqlResult res = s10.sql("SELECT * FROM performance_schema.session_connect_attrs WHERE processlist_id = CONNECTION_ID()").execute(); assertFalse("Expected no connection attributes.", res.hasNext()); s10.close(); - Client c10 = cf.getClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "false"), new Properties()); + Client c10 = cf.getClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "false", true), new Properties()); s10 = c10.getSession(); res = s10.sql("SELECT * FROM performance_schema.session_connect_attrs WHERE processlist_id = CONNECTION_ID()").execute(); assertFalse("Expected no connection attributes.", res.hasNext()); @@ -1278,23 +1281,23 @@ public void testSessionAttributes() throws Exception { // xdevapi.connection-attributes=[] userAttributes.clear(); - testSessionAttributes_checkSession(this.baseUrl + "&" + PropertyKey.xdevapiConnectionAttributes.getKeyName(), userAttributes); - testSessionAttributes_checkSession(this.baseUrl + "&" + PropertyKey.xdevapiConnectionAttributes.getKeyName() + "=", userAttributes); - testSessionAttributes_checkSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "true"), userAttributes); - testSessionAttributes_checkSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[]"), userAttributes); - testSessionAttributes_checkClient(this.baseUrl + "&" + PropertyKey.xdevapiConnectionAttributes.getKeyName(), userAttributes); - testSessionAttributes_checkClient(this.baseUrl + "&" + PropertyKey.xdevapiConnectionAttributes.getKeyName() + "=", userAttributes); - testSessionAttributes_checkClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "true"), userAttributes); - testSessionAttributes_checkClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "[]"), userAttributes); + testSessionAttributes_checkSession(baseUrlLocal + PropertyKey.xdevapiConnectionAttributes.getKeyName(), userAttributes); + testSessionAttributes_checkSession(baseUrlLocal + PropertyKey.xdevapiConnectionAttributes.getKeyName() + "=", userAttributes); + testSessionAttributes_checkSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "true", true), userAttributes); + testSessionAttributes_checkSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[]", true), userAttributes); + testSessionAttributes_checkClient(baseUrlLocal + PropertyKey.xdevapiConnectionAttributes.getKeyName(), userAttributes); + testSessionAttributes_checkClient(baseUrlLocal + PropertyKey.xdevapiConnectionAttributes.getKeyName() + "=", userAttributes); + testSessionAttributes_checkClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "true", true), userAttributes); + testSessionAttributes_checkClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "[]", true), userAttributes); // TSFR13 Create a Session with xdevapi.connection-attributes=[key1=value1,key1=value2] in the connection string, verify that // a WrongArgumentException exception is thrown with the message Duplicate key "key1" used in "xdevapi.connection-attributes". assertThrows(WrongArgumentException.class, "Duplicate key \"key1\" used in \"xdevapi.connection-attributes\".", () -> { - this.fact.getSession(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=value1,key1=value2")); + this.fact.getSession(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=value1,key1=value2", true)); return null; }); assertThrows(WrongArgumentException.class, "Duplicate key \"key1\" used in \"xdevapi.connection-attributes\".", () -> { - Client cli1 = cf.getClient(this.baseUrl + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=value1,key1=value2"), new Properties()); + Client cli1 = cf.getClient(baseUrlLocal + makeParam(PropertyKey.xdevapiConnectionAttributes, "key1=value1,key1=value2", true), new Properties()); cli1.getSession(); return null; }); diff --git a/src/test/java/testsuite/x/devapi/TableSelectTest.java b/src/test/java/testsuite/x/devapi/TableSelectTest.java index a88295b34..f6811ba3b 100644 --- a/src/test/java/testsuite/x/devapi/TableSelectTest.java +++ b/src/test/java/testsuite/x/devapi/TableSelectTest.java @@ -212,7 +212,8 @@ public void testBug22931433() { table.insert("c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "cb1", "cb2") .values(0xcc, 0xcccc, 0xcccccc, 0xccccccccL, 0xccccccccccL, 0xccccccccccccL, 0xccccccccccccccL, 0xccccccccccccccccL, 0x00, -2).execute(); - Session s1 = this.fact.getSession(this.baseUrl + makeParam(PropertyKey.jdbcCompliantTruncation, "false")); + String testUrl = this.baseUrl + (this.baseUrl.contains("?") ? "&" : "?") + makeParam(PropertyKey.jdbcCompliantTruncation, "false", true); + Session s1 = this.fact.getSession(testUrl); table = s1.getDefaultSchema().getTable("testBug22931433"); RowResult rows = table.select("c1, c2, c3, c4, c5, c6, c7, c8, cb1, cb2").execute();