Skip to content

Commit 0abceec

Browse files
committed
[misc] testing correction when testSingleHost is false
(cherry picked from commit 7db9cbb)
1 parent 542cac0 commit 0abceec

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/test/java/org/mariadb/jdbc/BaseTest.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,12 @@ public static void createFunction(String name, String body) throws SQLException
376376
* @throws SQLException if any error occur
377377
*/
378378
public boolean anonymousUser() throws SQLException {
379-
Statement stmt = sharedConnection.createStatement();
380-
ResultSet rs = stmt.executeQuery("SELECT * FROM mysql.user u where u.Host='localhost' and u.User=''");
381-
return rs.next();
379+
if (testSingleHost) {
380+
Statement stmt = sharedConnection.createStatement();
381+
ResultSet rs = stmt.executeQuery("SELECT * FROM mysql.user u where u.Host='localhost' and u.User=''");
382+
return rs.next();
383+
}
384+
return false;
382385
}
383386

384387
/**
@@ -388,8 +391,11 @@ public boolean anonymousUser() throws SQLException {
388391
* @throws SQLException exception
389392
*/
390393
static boolean isMariadbServer() throws SQLException {
391-
DatabaseMetaData md = sharedConnection.getMetaData();
392-
return md.getDatabaseProductVersion().contains("MariaDB");
394+
if (testSingleHost) {
395+
DatabaseMetaData md = sharedConnection.getMetaData();
396+
return md.getDatabaseProductVersion().contains("MariaDB");
397+
}
398+
return false;
393399
}
394400

395401
/**

src/test/java/org/mariadb/jdbc/failover/AllowMasterDownTest.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
package org.mariadb.jdbc.failover;
5454

5555
import org.junit.Assert;
56+
import org.junit.Assume;
5657
import org.junit.Before;
5758
import org.junit.Test;
5859
import org.mariadb.jdbc.BaseTest;
@@ -72,11 +73,14 @@ public class AllowMasterDownTest extends BaseTest {
7273
*/
7374
@Before
7475
public void init() {
75-
masterDownUrl = "jdbc:mariadb:replication//" + hostname + ":9999"
76-
+ "," + hostname + ((port == 0) ? "" : ":" + port)
77-
+ "/" + database + "?user=" + username
78-
+ ((password != null) ? "&password=" + password : "")
79-
+ "&retriesAllDown=10&allowMasterDownConnection";
76+
Assume.assumeTrue(testSingleHost);
77+
if (testSingleHost) {
78+
masterDownUrl = "jdbc:mariadb:replication//" + hostname + ":9999"
79+
+ "," + hostname + ((port == 0) ? "" : ":" + port)
80+
+ "/" + database + "?user=" + username
81+
+ ((password != null) ? "&password=" + password : "")
82+
+ "&retriesAllDown=10&allowMasterDownConnection";
83+
}
8084
}
8185

8286
@Test

0 commit comments

Comments
 (0)