Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

GROOVY-5305: Update dependencies (hsqldb - revert versions but minor …

…refactoring to make changing easier)
  • Loading branch information...
commit 456e6a6ef2f27f6a78b5a3c4b5e1287333efb622 1 parent c6176ca
@paulk-asert paulk-asert authored
View
3  build.gradle
@@ -74,7 +74,8 @@ dependencies {
testCompile "jmock:jmock:1.2.0"
testCompile "jmock:jmock-cglib:1.2.0"
testCompile "xmlunit:xmlunit:1.3"
- testCompile group:"org.hsqldb", name:"hsqldb", version:"2.2.8", classifier:"jdk5"
+ testCompile "hsqldb:hsqldb:1.8.0.10"
+// testCompile group:"org.hsqldb", name:"hsqldb", version:"2.2.8", classifier:"jdk5"
// testCompile "com.h2database:h2:1.3.164"
testCompile "ch.qos.logback:logback-classic:0.9.21"
testCompile "log4j:log4j:1.2.16"
View
8 pom.xml
@@ -775,12 +775,20 @@
<!-- used for testing SQL library -->
<dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.10</version>
+ <scope>test</scope>
+ </dependency>
+<!--
+ <dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.2.8</version>
<classifier>jdk5</classifier>
<scope>test</scope>
</dependency>
+-->
<!--
<dependency>
<groupId>com.h2database</groupId>
View
11 src/main/groovy/sql/Sql.java
@@ -388,14 +388,19 @@ public static Sql newInstance(Map<String, Object> args) throws SQLException, Cla
Object url = sqlArgs.remove("url");
Connection connection;
- if (props != null) connection = DriverManager.getConnection(url.toString(), new Properties(props));
- else if (sqlArgs.containsKey("user")) {
+ if (props != null) {
+ System.err.println("url = " + url);
+ System.err.println("props = " + props);
+ connection = DriverManager.getConnection(url.toString(), new Properties(props));
+ } else if (sqlArgs.containsKey("user")) {
Object user = sqlArgs.remove("user");
Object password = sqlArgs.remove("password");
connection = DriverManager.getConnection(url.toString(),
(user == null ? null : user.toString()),
(password == null ? null : password.toString()));
- } else connection = DriverManager.getConnection(url.toString());
+ } else {
+ connection = DriverManager.getConnection(url.toString());
+ }
Sql result = (Sql) InvokerHelper.invokeConstructorOf(Sql.class, sqlArgs);
result.setConnection(connection);
View
9 src/test/groovy/sql/PersonTest.groovy
@@ -17,8 +17,7 @@ package groovy.sql
import javax.sql.DataSource
-import static groovy.sql.SqlTestConstants.DB_DATASOURCE
-import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
+import static groovy.sql.SqlTestConstants.*
class PersonTest extends GroovyTestCase {
@@ -72,9 +71,9 @@ order by firstName DESC, age'''
protected DataSource createDataSource() {
return DB_DATASOURCE.newInstance(
- database: DB_URL_PREFIX + getMethodName(),
- user: 'sa',
- password: '')
+ (DB_DS_KEY): DB_URL_PREFIX + getMethodName(),
+ user: DB_USER,
+ password: DB_PASSWORD)
}
protected def createDataSet() {
View
9 src/test/groovy/sql/SqlBatchTest.groovy
@@ -17,8 +17,7 @@ package groovy.sql
import javax.sql.DataSource
-import static groovy.sql.SqlTestConstants.DB_DATASOURCE
-import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
+import static groovy.sql.SqlTestConstants.*
/**
* Test Sql batch features
@@ -31,9 +30,9 @@ class SqlBatchTest extends GroovyTestCase {
void setUp() {
DataSource ds = DB_DATASOURCE.newInstance(
- database: DB_URL_PREFIX + getMethodName(),
- user: 'sa',
- password: '')
+ (DB_DS_KEY): DB_URL_PREFIX + getMethodName(),
+ user: DB_USER,
+ password: DB_PASSWORD)
sql = new Sql(ds.connection)
sql.execute("CREATE TABLE person ( id INTEGER, firstname VARCHAR(10), lastname VARCHAR(10), PRIMARY KEY (id))")
View
9 src/test/groovy/sql/SqlCacheTest.groovy
@@ -20,8 +20,7 @@ import javax.sql.DataSource
import java.sql.Connection
import org.codehaus.groovy.runtime.InvokerHelper
-import static groovy.sql.SqlTestConstants.DB_DATASOURCE
-import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
+import static groovy.sql.SqlTestConstants.*
/**
* Unit test of Sql cache feature
@@ -40,9 +39,9 @@ class SqlCacheTest extends GroovyTestCase {
void setUp() {
ds = DB_DATASOURCE.newInstance(
- database: DB_URL_PREFIX + getMethodName(),
- user: 'sa',
- password: '')
+ (DB_DS_KEY): DB_URL_PREFIX + getMethodName(),
+ user: DB_USER,
+ password: DB_PASSWORD)
con = ds.connection
def methodOverride = [
createStatement: {Object[] args ->
View
9 src/test/groovy/sql/SqlCallTest.groovy
@@ -17,8 +17,7 @@ package groovy.sql
import javax.sql.DataSource
-import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
-import static groovy.sql.SqlTestConstants.DB_DATASOURCE
+import static groovy.sql.SqlTestConstants.*
/**
* Test Sql transaction features using a Sql built from a connection
@@ -31,9 +30,9 @@ class SqlCallTest extends GroovyTestCase {
protected Sql setUpSql() {
DataSource ds = DB_DATASOURCE.newInstance(
- database: DB_URL_PREFIX + getMethodName(),
- user: 'sa',
- password: '')
+ (DB_DS_KEY): DB_URL_PREFIX + getMethodName(),
+ user: DB_USER,
+ password: DB_PASSWORD)
return new Sql(ds.connection)
}
View
24 src/test/groovy/sql/SqlCompleteTest.groovy
@@ -15,7 +15,7 @@
*/
package groovy.sql
-import static groovy.sql.SqlTestConstants.DB_DRIVER
+import static groovy.sql.SqlTestConstants.*
class SqlCompleteTest extends TestHelper {
@@ -446,7 +446,7 @@ class SqlCompleteTest extends TestHelper {
}
void testNewInstanceMapShouldNotHavePropertiesAndAccountInfo() {
- def args = [url: getURI(), user: 'sa', password: '']
+ def args = [url: getURI(), user: DB_USER, password: DB_PASSWORD]
args.properties = [:] as Properties
shouldFail(IllegalArgumentException) {
Sql.newInstance(args)
@@ -465,30 +465,22 @@ class SqlCompleteTest extends TestHelper {
void testNewInstanceMapNotDestructiveGROOVY5216() {
String url = getURI()
String driver = DB_DRIVER.name
- String user = 'sa'
- String password = ''
+ String user = DB_USER
+ String password = DB_PASSWORD
// First pass with user/password and no properties
def args = [url: url, driver: driver, user: user, password: password]
def sql = Sql.newInstance(args)
- assert 4 == args.size()
- assert url == args.url
- assert driver == args.driver
- assert user == args.user
- assert password == args.password
+ assert args == [url: url, driver: driver, user: user, password: password]
// Second pass with properties
+ String url2 = getURI()
def props = new Properties()
props.user = user
props.password = password
- def args2 = [url: url, driver: driver, properties: props]
+ def args2 = [url: url2, driver: driver, properties: props]
def sql2 = Sql.newInstance(args2)
- assert 3 == args2.size()
- assert url == args.url
- assert driver == args.driver
- assert 2 == props.size()
- assert user == props.user
- assert password == props.password
+ assert args2 == [url: url2, driver: driver, properties: [user: user, password: password]]
}
}
View
2  src/test/groovy/sql/SqlCompleteWithoutDataSourceTest.groovy
@@ -24,7 +24,7 @@ import static groovy.sql.SqlTestConstants.DB_DRIVER
* rather than a DataSource
*/
class SqlCompleteWithoutDataSourceTest extends SqlCompleteTest {
- protected def newSql(String uri) {
+ protected Sql newSql(String uri) {
Class.forName(DB_DRIVER.name)
return new Sql(DriverManager.getConnection(uri, [user:'sa', password:''] as Properties))
}
View
12 src/test/groovy/sql/SqlRowsTest.groovy
@@ -5,7 +5,7 @@ class SqlRowsTest extends TestHelper {
protected Sql createSql() {
Sql sql = super.createSql()
- ["JOINTESTA", "JOINTESTB"].each{ tryDrop(it) }
+ ["JOINTESTA", "JOINTESTB"].each{ tryDrop(sql, it) }
sql.execute("create table JOINTESTA ( id INTEGER, bid INTEGER, name VARCHAR(10))")
sql.execute("create table JOINTESTB ( id INTEGER, name VARCHAR(10))")
@@ -23,7 +23,6 @@ class SqlRowsTest extends TestHelper {
void testFirstRowWithPropertyName() {
def sql = createSql()
-
def results = sql.firstRow("select firstname, lastname from PERSON where id=1").firstname
def expected = "James"
assert results == expected
@@ -31,7 +30,6 @@ class SqlRowsTest extends TestHelper {
void testFirstRowWithPropertyNameAndParams() {
def sql = createSql()
-
def results = sql.firstRow("select firstname, lastname from PERSON where id=?", [1]).lastname
def expected = "Strachan"
assert results == expected
@@ -39,7 +37,6 @@ class SqlRowsTest extends TestHelper {
void testFirstRowWithPropertyNumber() {
def sql = createSql()
-
def results = sql.firstRow("select firstname, lastname from PERSON where id=1")[0]
def expected = "James"
assert results == expected
@@ -47,7 +44,6 @@ class SqlRowsTest extends TestHelper {
void testFirstRowWithPropertyNumberAndParams() {
def sql = createSql()
-
def results = sql.firstRow("select firstname, lastname from PERSON where id=?", [1])[0]
def expected = "James"
assert results == expected
@@ -55,7 +51,6 @@ class SqlRowsTest extends TestHelper {
void testAllRowsWithPropertyNumber() {
def sql = createSql()
-
def results = sql.rows("select firstname, lastname from PERSON where id=1 or id=2 order by id")
assert results[0][0] == "James"
assert results[0][1] == "Strachan"
@@ -65,7 +60,6 @@ class SqlRowsTest extends TestHelper {
void testAllRowsWithPropertyNumberAndParams() {
def sql = createSql()
-
def results = sql.rows("select firstname, lastname from PERSON where id=? or id=? order by id", [1,2])
assert results[0][0] == "James"
assert results[0][1] == "Strachan"
@@ -75,7 +69,6 @@ class SqlRowsTest extends TestHelper {
void testAllRowsWithPropertyName() {
def sql = createSql()
-
def results = sql.rows("select firstname, lastname from PERSON where id=1 or id=2 order by id")
assert results[0].firstname == "James"
assert results[0].lastname == "Strachan"
@@ -85,7 +78,6 @@ class SqlRowsTest extends TestHelper {
void testAsRenaming() {
def sql = createSql()
-
def results = sql.rows("select firstname, lastname, firstname || ' ' || lastname as fullname from PERSON where id=1")
assert results[0].firstname == "James"
assert results[0].lastname == "Strachan"
@@ -102,7 +94,6 @@ class SqlRowsTest extends TestHelper {
void testAllRowsWithPropertyNameAndParams() {
def sql = createSql()
-
def results = sql.rows("select firstname, lastname from PERSON where id=? or id=? order by id", [1,2])
assert results[0].firstname == "James"
assert results[0].lastname == "Strachan"
@@ -112,7 +103,6 @@ class SqlRowsTest extends TestHelper {
void testJoinsWithSameName_Groovy3320() {
def sql = createSql()
-
// First check it's ok
sql.rows( "select a.id, a.name, b.id, b.name from jointesta as a join jointestb as b on ( a.bid = b.id )" ).eachWithIndex { row, idx ->
assert row.size() == 2
View
10 src/test/groovy/sql/SqlStatementTest.groovy
@@ -16,10 +16,8 @@
package groovy.sql
import javax.sql.DataSource
-import java.sql.Connection
-import static groovy.sql.SqlTestConstants.DB_DATASOURCE
-import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
+import static groovy.sql.SqlTestConstants.*
/**
* Unit test of Sql statement feature
@@ -31,9 +29,9 @@ class SqlStatementTest extends GroovyTestCase {
void setUp() {
DataSource ds = DB_DATASOURCE.newInstance(
- database: DB_URL_PREFIX + getMethodName(),
- user: 'sa',
- password: '')
+ (DB_DS_KEY): DB_URL_PREFIX + getMethodName(),
+ user: DB_USER,
+ password: DB_PASSWORD)
sql = new Sql(ds.connection)
sql.execute("create table PERSON ( id INTEGER, firstname VARCHAR(10), lastname VARCHAR(10) )")
View
9 src/test/groovy/sql/SqlTest.groovy
@@ -18,8 +18,7 @@ package groovy.sql
import java.sql.Connection
import javax.sql.DataSource
-import static groovy.sql.SqlTestConstants.DB_DATASOURCE
-import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
+import static groovy.sql.SqlTestConstants.*
/**
* This is more of a sample program than a unit test and is here as an easy
@@ -145,9 +144,9 @@ class SqlTest extends GroovyTestCase {
private createSql() {
DataSource ds = DB_DATASOURCE.newInstance(
- database: DB_URL_PREFIX + getMethodName(),
- user: 'sa',
- password: '')
+ (DB_DS_KEY): DB_URL_PREFIX + getMethodName(),
+ user: DB_USER,
+ password: DB_PASSWORD)
sql = new Sql(ds.connection)
def sql = new Sql(ds)
View
34 src/test/groovy/sql/SqlTestConstants.groovy
@@ -1,7 +1,37 @@
package groovy.sql
+// trick to handle pesky lower case class names
+import org.hsqldb.jdbcDriver as Driver
+import org.hsqldb.jdbc.jdbcDataSource as DataSource
+
class SqlTestConstants {
+ //// legacy HSQLDB: "hsqldb:hsqldb:1.8.0.10"
public static final String DB_URL_PREFIX = 'jdbc:hsqldb:mem:testDB'
- public static final Class DB_DATASOURCE = org.hsqldb.jdbc.JDBCDataSource
- public static final Class DB_DRIVER = org.hsqldb.jdbc.JDBCDriver
+ public static final String DB_URL_SUFFIX = ''
+ public static final Class DB_DATASOURCE = DataSource
+ public static final Class DB_DRIVER = Driver
+ public static final String DB_USER = 'sa'
+ public static final String DB_PASSWORD = ''
+ public static final String DB_DS_KEY = 'database'
+
+ //// new HSQLDB: group:"org.hsqldb", name:"hsqldb", version:"2.2.8", classifier:"jdk5"
+ //// currently causing JVM crash under JDK15 on Bamboo CI server
+// public static final String DB_URL_PREFIX = 'jdbc:hsqldb:mem:testDB'
+// public static final String DB_URL_SUFFIX = ''
+// public static final Class DB_DATASOURCE = org.hsqldb.jdbc.JDBCDataSource
+// public static final Class DB_DRIVER = org.hsqldb.jdbc.JDBCDriver
+// public static final String DB_USER = 'sa'
+// public static final String DB_PASSWORD = ''
+// public static final String DB_DS_KEY = 'database'
+
+ //// H2 database: "com.h2database:h2:1.3.164" currently not working for:
+ //// SqlCallTest#testBuiltinStoredProcedureQuery (stored proc not supported or diff syntax)
+ //// SqlCacheTest#* (proxy issues during setup)
+// public static final String DB_URL_PREFIX = 'jdbc:h2:mem:testDB'
+// public static final String DB_URL_SUFFIX = ';DB_CLOSE_DELAY=-1'
+// public static final Class DB_DATASOURCE = org.h2.jdbcx.JdbcDataSource
+// public static final Class DB_DRIVER = org.h2.Driver
+// public static final String DB_USER = 'sa'
+// public static final String DB_PASSWORD = ''
+// public static final String DB_DS_KEY = 'URL'
}
View
10 src/test/groovy/sql/SqlTransactionConnectionTest.groovy
@@ -16,10 +16,8 @@
package groovy.sql
import javax.sql.DataSource
-import java.sql.Connection
-import static groovy.sql.SqlTestConstants.DB_DATASOURCE
-import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
+import static groovy.sql.SqlTestConstants.*
/**
* Test Sql transaction features using a Sql built from a connection
@@ -30,9 +28,9 @@ class SqlTransactionConnectionTest extends SqlTransactionTestCase {
protected Sql setUpSql() {
DataSource ds = DB_DATASOURCE.newInstance(
- database: DB_URL_PREFIX + getMethodName(),
- user: 'sa',
- password: '')
+ (DB_DS_KEY): DB_URL_PREFIX + getMethodName(),
+ user: DB_USER,
+ password: DB_PASSWORD)
return new Sql(ds.connection)
}
View
9 src/test/groovy/sql/SqlTransactionDataSourceTest.groovy
@@ -17,8 +17,7 @@ package groovy.sql
import javax.sql.DataSource
-import static groovy.sql.SqlTestConstants.DB_DATASOURCE
-import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
+import static groovy.sql.SqlTestConstants.*
/**
* Test Sql transaction features using a Sql built from a DataSource
@@ -28,9 +27,9 @@ import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
class SqlTransactionDataSourceTest extends SqlTransactionTestCase {
protected Sql setUpSql() {
DataSource ds = DB_DATASOURCE.newInstance(
- database: DB_URL_PREFIX + getMethodName(),
- user: 'sa',
- password: '')
+ (DB_DS_KEY): DB_URL_PREFIX + getMethodName(),
+ user: DB_USER,
+ password: DB_PASSWORD)
return new Sql(ds)
}
}
View
42 src/test/groovy/sql/TestHelper.groovy
@@ -15,8 +15,7 @@
*/
package groovy.sql
-import static groovy.sql.SqlTestConstants.DB_DATASOURCE
-import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
+import static groovy.sql.SqlTestConstants.*
class TestHelper extends GroovyTestCase {
TestHelper() {
@@ -41,26 +40,9 @@ class TestHelper extends GroovyTestCase {
return newSql(getURI())
}
- protected createSql() {
- def sql = newSql(getURI())
-
- ["PERSON", "FOOD", "FEATURE"].each { tryDrop(it) }
-
- def ignoreErrors = { Closure c ->
- try {
- c()
- } catch (java.sql.SQLException se) {}
- }
- ignoreErrors {
- sql.execute "drop table PERSON"
- }
- ignoreErrors {
- sql.execute "drop table FOOD"
- }
- ignoreErrors {
- sql.execute "drop table FEATURE"
- }
-
+ protected Sql createSql() {
+ Sql sql = newSql(getURI())
+ ["PERSON", "FOOD", "FEATURE"].each { tryDrop(sql, it) }
sql.execute("create table PERSON ( firstname VARCHAR(100), lastname VARCHAR(100), id INTEGER, location_id INTEGER, location_name VARCHAR(100) )")
sql.execute("create table FOOD ( type VARCHAR(100), name VARCHAR(100))")
sql.execute("create table FEATURE ( id INTEGER, name VARCHAR(100))")
@@ -85,10 +67,10 @@ class TestHelper extends GroovyTestCase {
return sql
}
- protected tryDrop(String tableName) {
+ protected tryDrop(Sql sql, String tableName) {
try {
- sql.execute("drop table $tableName")
- } catch (Exception e) {}
+ sql.execute("drop table $tableName".toString())
+ } catch (java.sql.SQLException se) {}
}
protected getURI() {
@@ -100,10 +82,10 @@ class TestHelper extends GroovyTestCase {
name = ""
}
name += counter++
- return answer + name
+ return answer + name + DB_URL_SUFFIX
}
- protected newSql(String uri) {
+ protected Sql newSql(String uri) {
if (props) {
def url = props."groovy.testdb.url"
def driver = props."groovy.testdb.driver"
@@ -114,9 +96,9 @@ class TestHelper extends GroovyTestCase {
return Sql.newInstance(url, username, password, driver)
}
def ds = DB_DATASOURCE.newInstance(
- database: uri,
- user: 'sa',
- password: '')
+ (DB_DS_KEY): uri,
+ user: DB_USER,
+ password: DB_PASSWORD)
return new Sql(ds)
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.