提交 f9f6a372 authored 作者: Niklas Mehner's avatar Niklas Mehner

Checkstyle / add copyright header / add missing test

上级 5bdfd153
...@@ -128,7 +128,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -128,7 +128,7 @@ public class JdbcConnection extends TraceObject implements Connection {
this.url = ci.getURL(); this.url = ci.getURL();
closeOld(); closeOld();
watcher = CloseWatcher.register(this, session, keepOpenStackTrace); watcher = CloseWatcher.register(this, session, keepOpenStackTrace);
this.clientInfo = new HashMap<String, String> (); this.clientInfo = new HashMap<String, String>();
} catch (Exception e) { } catch (Exception e) {
throw logAndConvert(e); throw logAndConvert(e);
} }
...@@ -152,7 +152,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -152,7 +152,7 @@ public class JdbcConnection extends TraceObject implements Connection {
this.getReadOnly = clone.getReadOnly; this.getReadOnly = clone.getReadOnly;
this.rollback = clone.rollback; this.rollback = clone.rollback;
this.watcher = null; this.watcher = null;
this.clientInfo = new HashMap<String, String> (clone.clientInfo); this.clientInfo = new HashMap<String, String>(clone.clientInfo);
} }
/** /**
......
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.jdbc; package org.h2.test.jdbc;
import org.h2.test.TestBase; import org.h2.test.TestBase;
......
...@@ -10,7 +10,6 @@ import java.sql.DatabaseMetaData; ...@@ -10,7 +10,6 @@ import java.sql.DatabaseMetaData;
import java.sql.Driver; import java.sql.Driver;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.ResultSetMetaData; import java.sql.ResultSetMetaData;
import java.sql.SQLClientInfoException;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.sql.Types; import java.sql.Types;
......
...@@ -7,12 +7,10 @@ package org.h2.test.jdbc; ...@@ -7,12 +7,10 @@ package org.h2.test.jdbc;
import java.sql.Connection; import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLClientInfoException;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Savepoint; import java.sql.Savepoint;
import java.sql.Statement; import java.sql.Statement;
import java.util.HashMap; import java.util.HashMap;
import java.util.Properties;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.engine.SysProperties; import org.h2.engine.SysProperties;
......
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.unit;
import org.h2.engine.Mode;
import org.h2.test.TestBase;
/**
* Unit test for the Mode class.
*/
public class TestMode extends TestBase {
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
TestBase.createCaller().init().test();
}
@Override
public void test() throws Exception {
testDb2ClientInfo();
testDerbyClientInfo();
testHsqlDbClientInfo();
testMsSqlServerClientInfo();
testMySqlClientInfo();
testOracleClientInfo();
testPostgresqlClientInfo();
}
private void testDb2ClientInfo() {
Mode db2Mode = Mode.getInstance("DB2");
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher("ApplicationName").matches());
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher("ClientAccountingInformation").matches());
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher("ClientUser").matches());
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher("ClientCorrelationToken").matches());
assertFalse(db2Mode.supportedClientInfoPropertiesRegEx.matcher("AnyOtherValue").matches());
}
private void testDerbyClientInfo() {
Mode derbyMode = Mode.getInstance("Derby");
assertNull(derbyMode.supportedClientInfoPropertiesRegEx);
}
private void testHsqlDbClientInfo() {
Mode hsqlMode = Mode.getInstance("HSQLDB");
assertNull(hsqlMode.supportedClientInfoPropertiesRegEx);
}
private void testMsSqlServerClientInfo() {
Mode msSqlMode = Mode.getInstance("MSSQLServer");
assertNull(msSqlMode.supportedClientInfoPropertiesRegEx);
}
private void testMySqlClientInfo() {
Mode mySqlMode = Mode.getInstance("MySQL");
assertTrue(mySqlMode.supportedClientInfoPropertiesRegEx.matcher("AnyString").matches());
}
private void testOracleClientInfo() {
Mode oracleMode = Mode.getInstance("Oracle");
assertTrue(oracleMode.supportedClientInfoPropertiesRegEx.matcher("anythingContaining.aDot").matches());
assertFalse(oracleMode.supportedClientInfoPropertiesRegEx.matcher("anythingContainingNoDot").matches());
}
private void testPostgresqlClientInfo() {
Mode postgresqlMode = Mode.getInstance("PostgreSQL");
assertTrue(postgresqlMode.supportedClientInfoPropertiesRegEx.matcher("ApplicationName").matches());
assertFalse(postgresqlMode.supportedClientInfoPropertiesRegEx.matcher("AnyOtherValue").matches());
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论