dbwong commented on a change in pull request #567: PHOENIX-5134 Phoenix 
Connection Driver #normalize does not distinguis…
URL: https://github.com/apache/phoenix/pull/567#discussion_r314515268
 
 

 ##########
 File path: 
phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriverTest.java
 ##########
 @@ -146,7 +149,70 @@ public void testNegativeGetConnectionInfo() throws 
SQLException {
             }
         }
     }
-    
+
+    @Test
+    public void testDiffTenantID() throws Exception {
+        String tenantId1 = "1";
+        String tenantId2 = "2";
+        String[] urls = new String[] {
+                "jdbc:phoenix:localhost:2181" + JDBC_PROTOCOL_TERMINATOR
+                        + PhoenixRuntime.TENANT_ID_ATTRIB + "=" + tenantId1,
+                "jdbc:phoenix:localhost:2181;test=true" + 
JDBC_PROTOCOL_TERMINATOR
+                        + PhoenixRuntime.TENANT_ID_ATTRIB + "=" + tenantId2,
+        };
+        ConnectionInfo[] infos = new ConnectionInfo[]{
+                new ConnectionInfo("localhost", 2181, null, null, null, 
tenantId1),
+                new ConnectionInfo("localhost", 2181, null, null, null, 
tenantId2)
+        };
+
+        assertEquals(urls.length,infos.length);
+        for (int i = 0; i < urls.length; i++) {
+            try {
+                ConnectionInfo info = ConnectionInfo.create(urls[i]);
+                assertEquals(infos[i], info);
+            } catch (AssertionError e) {
+                throw new AssertionError("For \"" + urls[i] + "\": " + 
e.getMessage());
+            }
+        }
+    }
+
+    @Test
+    public void testGetTenantIDFunction() {
+        String[] invalidUrls = new String[] {
+                null,
+                "",
+                "jdbc:phoenix",
+                "jdbc:phoenix;test=true",
+                "jdbc:phoenix:localhost",
+                "localhost:123:/foo-bar",
+                "localhost:123:/foo-bar;TenantId",
+                "localhost:123:/foo-bar;TenantId="
+        };
+        for (int i = 0; i < invalidUrls.length; i++) {
+            try {
+                assertEquals( ConnectionInfo.getTenantID(invalidUrls[i]), 
null);
 
 Review comment:
   nit: expected is first

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to