Skip to content

Commit

Permalink
Merge pull request #55 from rusher/master
Browse files Browse the repository at this point in the history
[misc] test correction since travis upgrade
  • Loading branch information
rusher committed Dec 5, 2015
2 parents 749bca5 + b597835 commit eddcf19
Show file tree
Hide file tree
Showing 23 changed files with 30 additions and 189 deletions.
12 changes: 0 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -324,18 +324,6 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
Expand Down
25 changes: 10 additions & 15 deletions src/test/java/org/mariadb/jdbc/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
import org.mariadb.jdbc.internal.protocol.Protocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Method;
import java.net.InetAddress;
Expand All @@ -25,7 +23,6 @@
*/
@Ignore
public class BaseTest {
protected static final Logger log = LoggerFactory.getLogger(BaseTest.class);
protected static final String mDefUrl = "jdbc:mysql://localhost:3306/testj?user=root";
protected static String connU;
protected static String connUri;
Expand All @@ -44,13 +41,13 @@ public class BaseTest {
public TestRule watcher = new TestWatcher() {
protected void succeeded(Description description) {
if (testSingleHost) {
log.debug("finished test success : " + description.getClassName() + "." + description.getMethodName());
System.out.println("finished test success : " + description.getClassName() + "." + description.getMethodName());
}
}

protected void failed(Throwable throwable, Description description) {
if (testSingleHost) {
log.debug("finished test failed : " + description.getClassName() + "." + description.getMethodName());
System.out.println("finished test failed : " + description.getClassName() + "." + description.getMethodName());
}
}
};
Expand All @@ -71,9 +68,6 @@ public static void beforeClassBaseTest() throws SQLException {
username = urlParser.getUsername();
password = urlParser.getPassword();

log.trace("Properties parsed from JDBC URL - hostname: " + hostname + ", port: " + port + ", database: "
+ database + ", username: " + username + ", password: " + password);

setUri();

sharedConnection = DriverManager.getConnection(connUri);
Expand Down Expand Up @@ -126,7 +120,7 @@ public static void afterClassBaseTest() throws SQLException {

// common function for logging information
static void logInfo(String message) {
log.info(message);
System.out.println(message);
}

/**
Expand Down Expand Up @@ -282,11 +276,12 @@ boolean checkMaxAllowedPacket(String testName) throws SQLException {
int innodbLogFileSize = rs.getInt(1);

if (maxAllowedPacket < 16 * 1024 * 1024) {
log.info("test '" + testName + "' skipped due to server variable max_allowed_packet < 16M");

System.out.println("test '" + testName + "' skipped due to server variable max_allowed_packet < 16M");
return false;
}
if (innodbLogFileSize < 16 * 1024 * 1024) {
log.info("test '" + testName + "' skipped due to server variable innodb_log_file_size < 16M");
System.out.println("test '" + testName + "' skipped due to server variable innodb_log_file_size < 16M");
return false;
}
return true;
Expand All @@ -304,11 +299,11 @@ boolean checkMaxAllowedPacketMore40m(String testName) throws SQLException {


if (maxAllowedPacket < 40 * 1024 * 1024) {
log.info("test '" + testName + "' skipped due to server variable max_allowed_packet < 40M");
System.out.println("test '" + testName + "' skipped due to server variable max_allowed_packet < 40M");
return false;
}
if (innodbLogFileSize < 160 * 1024 * 1024) {
log.info("test '" + testName + "' skipped due to server variable innodb_log_file_size < 160M");
System.out.println("test '" + testName + "' skipped due to server variable innodb_log_file_size < 160M");
return false;
}

Expand All @@ -335,7 +330,7 @@ boolean hasSuperPrivilege(String testName) throws SQLException {
rs.close();

if (!superPrivilege) {
log.info("test '" + testName + "' skipped because user '" + username + "' doesn't have SUPER privileges");
System.out.println("test '" + testName + "' skipped because user '" + username + "' doesn't have SUPER privileges");
}

return superPrivilege;
Expand All @@ -355,7 +350,7 @@ boolean isLocalConnection(String testName) {
}

if (isLocal == false) {
log.info("test '" + testName + "' skipped because connection is not local");
System.out.println("test '" + testName + "' skipped because connection is not local");
}

return isLocal;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/mariadb/jdbc/BigQueryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void testError() throws SQLException {

rs = connection.createStatement().executeQuery(request);
rs.next();
log.trace(String.valueOf(rs.getString(1).length()));
System.out.println(String.valueOf(rs.getString(1).length()));
} finally {
connection.close();
}
Expand Down
7 changes: 3 additions & 4 deletions src/test/java/org/mariadb/jdbc/CallableStatementTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,13 @@ public void getProcedures() throws SQLException {
ResultSetMetaData md = rs.getMetaData();

for (int i = 1; i <= md.getColumnCount(); i++) {
log.trace(md.getColumnLabel(i));
md.getColumnLabel(i);
}
while (rs.next()) {

while (rs.next()) {
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
log.trace(rs.getObject(i) + " ");
rs.getObject(i);
}

}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/mariadb/jdbc/ConnectionPoolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void run() {
stmt.execute("insert into t3 values('hello" + Thread.currentThread().getId() + "-" + i + "')");
conn.close();
} catch (SQLException e) {
log.debug(e.getSQLState());
//eat exception
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions src/test/java/org/mariadb/jdbc/ConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void abortTest() throws SQLException {
try {
securityManager.checkPermission(sqlPermission);
} catch (SecurityException se) {
log.info("test 'abortTest' skipped due to missing policy");
System.out.println("test 'abortTest' skipped due to missing policy");
return;
}
}
Expand Down Expand Up @@ -132,7 +132,7 @@ public void networkTimeoutTest() throws SQLException {
try {
securityManager.checkPermission(sqlPermission);
} catch (SecurityException se) {
log.warn("test 'setNetworkTimeout' skipped due to missing policy");
System.out.println("test 'setNetworkTimeout' skipped due to missing policy");
return;
}
}
Expand Down Expand Up @@ -191,7 +191,6 @@ public void checkMaxAllowedPacket() throws Throwable, SQLException, UnsupportedE
ResultSet rs = statement.executeQuery("show variables like 'max_allowed_packet'");
rs.next();
int maxAllowedPacket = rs.getInt(2);
log.trace("max_allowed_packet DB" + maxAllowedPacket);

//Create a SQL stream bigger than maxAllowedPacket
StringBuilder sb = new StringBuilder();
Expand All @@ -207,7 +206,7 @@ public void checkMaxAllowedPacket() throws Throwable, SQLException, UnsupportedE
statement.executeUpdate("INSERT INTO dummy VALUES " + sb.toString());
fail("The previous statement should throw an SQLException");
} catch (OutOfMemoryError e) {
log.warn("skip test 'maxAllowedPackedExceptionIsPrettyTest' - not enough memory");
System.out.println("skip test 'maxAllowedPackedExceptionIsPrettyTest' - not enough memory");
Assume.assumeNoException(e);
} catch (SQLException e) {
assertTrue(e.getMessage().contains("max_allowed_packet"));
Expand All @@ -227,10 +226,9 @@ public void checkMaxAllowedPacket() throws Throwable, SQLException, UnsupportedE
preparedStatement.executeBatch();
fail("The previous statement should throw an SQLException");
} catch (OutOfMemoryError e) {
log.warn("skip second test 'maxAllowedPackedExceptionIsPrettyTest' - not enough memory");
System.out.println("skip second test 'maxAllowedPackedExceptionIsPrettyTest' - not enough memory");
Assume.assumeNoException(e);
} catch (SQLException e) {
log.trace("normal SQlExeption " + e.getMessage());
assertTrue(e.getMessage().contains("max_allowed_packet"));
} catch (Exception e) {
fail("The previous statement should throw an SQLException not a general Exception");
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/mariadb/jdbc/DataSourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void setPortTest() throws SQLException {
ds.getConnection(username, password);
Assert.fail();
} catch (SQLException e) {
log.trace("port error : " + e.getMessage());
//normal error
}
}

Expand Down
1 change: 0 additions & 1 deletion src/test/java/org/mariadb/jdbc/DateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ public void serverTimezone() throws Exception {
java.sql.Timestamp ts = rs.getTimestamp(1);
long differenceToServer = ts.getTime() - now.getTime();
long diff = Math.abs(differenceToServer - totalOffset);
log.trace("diff : " + diff);
/* query take less than a second but taking in account server and client time second diff ... */
assertTrue(diff < 5000);

Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/mariadb/jdbc/DriverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1095,11 +1095,11 @@ public void namedpipe() throws Exception {
if (rs.getBoolean(1)) {
namedPipeName = rs.getString(2);
} else {
log.info("test 'namedpipe' skipped");
System.out.println("test 'namedpipe' skipped");
}
} catch (SQLException e) {
//named pipe not found,
log.info("test 'namedpipe' skipped");
System.out.println("test 'namedpipe' skipped");
}

//skip test if no namedPipeName was obtained because then we do not use a socket connection
Expand Down Expand Up @@ -1148,7 +1148,7 @@ public void localSocket() throws Exception {
if (!rs.next()) {
return;
}
log.info("os:" + rs.getString(1) + " path:" + rs.getString(2));
System.out.println("os:" + rs.getString(1) + " path:" + rs.getString(2));
String os = rs.getString(1);
if (os.toLowerCase().startsWith("win")) {
return;
Expand Down
Loading

0 comments on commit eddcf19

Please sign in to comment.