Skip to content

Commit 4d1c9ab

Browse files
committed
GROOVY-5305: Update dependencies (hsqldb)
1 parent 4c5c29d commit 4d1c9ab

20 files changed

+162
-120
lines changed

Diff for: build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ dependencies {
7272
testCompile "jmock:jmock:1.2.0"
7373
testCompile "jmock:jmock-cglib:1.2.0"
7474
testCompile "xmlunit:xmlunit:1.3"
75-
testCompile "hsqldb:hsqldb:1.8.0.10"
75+
testCompile "org.hsqldb:hsqldb:2.2.8"
7676
testCompile "ch.qos.logback:logback-classic:0.9.21"
7777
testCompile "log4j:log4j:1.2.16"
7878
testCompile "org.slf4j:jcl-over-slf4j:1.6.0"

Diff for: pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -765,9 +765,9 @@
765765

766766
<!-- used for SQL library -->
767767
<dependency>
768-
<groupId>hsqldb</groupId>
768+
<groupId>org.hsqldb</groupId>
769769
<artifactId>hsqldb</artifactId>
770-
<version>1.8.0.10</version>
770+
<version>2.2.8</version>
771771
<scope>test</scope>
772772
</dependency>
773773

Diff for: security/groovy.policy

+2-2
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ grant codeBase "file:${user.dir}/src/test/groovy/sql/-" {
252252
};
253253

254254
grant codeBase "file:${user.dir}/src/test/groovy/sql/SqlCompleteWithoutDataSourceTest.groovy" {
255-
//TODO: what should this be see other TODO about narrowing down main directories
256-
//permission java.io.FilePermission "${groovy.lib}${/}axion${/}jars${/}axion-1.0-M3-dev.jar", "read";
255+
permission java.util.PropertyPermission "file.separator", "read";
256+
permission java.util.PropertyPermission "line.separator", "read";
257257
};
258258

259259
grant codeBase "file:${user.dir}/src/test/groovy/sql/SqlTest.groovy" {

Diff for: src/main/groovy/sql/Sql.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2003-2011 the original author or authors.
2+
* Copyright 2003-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
5858
* In simple cases, you can just provide
5959
* the necessary details to set up a connection (e.g. for hsqldb):
6060
* <pre>
61-
* def db = [url:'jdbc:hsqldb:mem:testDB', user:'sa', password:'', driver:'org.hsqldb.jdbcDriver']
61+
* def db = [url:'jdbc:hsqldb:mem:testDB', user:'sa', password:'', driver:'org.hsqldb.jdbc.JDBCDriver']
6262
* def sql = Sql.newInstance(db.url, db.user, db.password, db.driver)
6363
* </pre>
6464
* or if you have an existing connection (perhaps from a connection pool) or a
@@ -350,7 +350,7 @@ public static Sql newInstance(String url, String driverClassName) throws SQLExce
350350
* url:'jdbc:hsqldb:mem:testDB',
351351
* user:'sa',
352352
* password:'',
353-
* driver:'org.hsqldb.jdbcDriver',
353+
* driver:'org.hsqldb.jdbc.JDBCDriver',
354354
* cacheStatements: true,
355355
* resultSetConcurrency: CONCUR_READ_ONLY
356356
* )
@@ -1719,19 +1719,19 @@ public GroovyRowResult firstRow(String sql, Object[] params) throws SQLException
17191719
* <p/>
17201720
* Example usages:
17211721
* <pre>
1722-
* sql.execute "drop table if exists PERSON"
1722+
* sql.execute "DROP TABLE IF EXISTS person"
17231723
*
17241724
* sql.execute """
1725-
* create table PERSON (
1726-
* id integer not null,
1727-
* firstname varchar(100),
1728-
* lastname varchar(100),
1729-
* location_id integer
1725+
* CREATE TABLE person (
1726+
* id INTEGER NOT NULL,
1727+
* firstname VARCHAR(100),
1728+
* lastname VARCHAR(100),
1729+
* location_id INTEGER
17301730
* )
17311731
* """
17321732
*
17331733
* sql.execute """
1734-
* insert into PERSON (id, firstname, lastname, location_id) values (4, 'Paul', 'King', 40)
1734+
* INSERT INTO person (id, firstname, lastname, location_id) VALUES (4, 'Paul', 'King', 40)
17351735
* """
17361736
* assert sql.updateCount == 1
17371737
* </pre>

Diff for: src/test/groovy/sql/PersonTest.groovy

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2003-2008 the original author or authors.
2+
* Copyright 2003-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,9 @@ package groovy.sql
1717

1818
import javax.sql.DataSource
1919

20+
import static groovy.sql.SqlTestConstants.DB_DATASOURCE
21+
import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
22+
2023
class PersonTest extends GroovyTestCase {
2124

2225
void testFoo() {
@@ -66,15 +69,14 @@ order by firstName DESC, age'''
6669
assert dataSet.sql == expectedSql
6770
assert dataSet.parameters == expectedParams
6871
}
69-
72+
7073
protected DataSource createDataSource() {
71-
def ds = new org.hsqldb.jdbc.jdbcDataSource()
72-
ds.database = "jdbc:hsqldb:mem:foo" + getMethodName()
73-
ds.user = 'sa'
74-
ds.password = ''
75-
return ds
74+
return DB_DATASOURCE.newInstance(
75+
database: DB_URL_PREFIX + getMethodName(),
76+
user: 'sa',
77+
password: '')
7678
}
77-
79+
7880
protected def createDataSet() {
7981
def type = Person
8082
assert type != null , "failed to load Person class"

Diff for: src/test/groovy/sql/SqlBatchTest.groovy

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2003-2011 the original author or authors.
2+
* Copyright 2003-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,9 @@
1616
package groovy.sql
1717

1818
import javax.sql.DataSource
19-
import java.sql.Connection
19+
20+
import static groovy.sql.SqlTestConstants.DB_DATASOURCE
21+
import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
2022

2123
/**
2224
* Test Sql batch features
@@ -25,17 +27,15 @@ import java.sql.Connection
2527
*/
2628
class SqlBatchTest extends GroovyTestCase {
2729
Sql sql
28-
def personFood
2930
private others = ['Jean':'Gabin', 'Lino':'Ventura']
3031

3132
void setUp() {
32-
DataSource ds = new org.hsqldb.jdbc.jdbcDataSource()
33-
ds.database = "jdbc:hsqldb:mem:foo" + getMethodName()
34-
ds.user = 'sa'
35-
ds.password = ''
36-
Connection con = ds.connection
37-
sql = new Sql(con)
38-
sql.execute("CREATE TABLE person ( id INTEGER, firstname VARCHAR, lastname VARCHAR, PRIMARY KEY (id))")
33+
DataSource ds = DB_DATASOURCE.newInstance(
34+
database: DB_URL_PREFIX + getMethodName(),
35+
user: 'sa',
36+
password: '')
37+
sql = new Sql(ds.connection)
38+
sql.execute("CREATE TABLE person ( id INTEGER, firstname VARCHAR(10), lastname VARCHAR(10), PRIMARY KEY (id))")
3939

4040
// populate some data
4141
def people = sql.dataSet("PERSON")

Diff for: src/test/groovy/sql/SqlCacheTest.groovy

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2003-2009 the original author or authors.
2+
* Copyright 2003-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,9 @@ import javax.sql.DataSource
2020
import java.sql.Connection
2121
import org.codehaus.groovy.runtime.InvokerHelper
2222

23+
import static groovy.sql.SqlTestConstants.DB_DATASOURCE
24+
import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
25+
2326
/**
2427
* Unit test of Sql cache feature
2528
* @author Marc DeXeT
@@ -36,11 +39,11 @@ class SqlCacheTest extends GroovyTestCase {
3639
int createStatementCallCounter
3740

3841
void setUp() {
39-
ds = new org.hsqldb.jdbc.jdbcDataSource()
40-
ds.database = "jdbc:hsqldb:mem:foo" + getMethodName()
41-
ds.user = 'sa'
42-
ds.password = ''
43-
con = ds.getConnection()
42+
ds = DB_DATASOURCE.newInstance(
43+
database: DB_URL_PREFIX + getMethodName(),
44+
user: 'sa',
45+
password: '')
46+
con = ds.connection
4447
def methodOverride = [
4548
createStatement: {Object[] args ->
4649
createStatementCallCounter++
@@ -55,9 +58,9 @@ class SqlCacheTest extends GroovyTestCase {
5558
]
5659
wrappedCon = ProxyGenerator.INSTANCE.instantiateDelegate(methodOverride, [Connection], con)
5760
sql = new Sql(wrappedCon)
58-
sql.execute("create table PERSON ( id integer, firstname varchar, lastname varchar )")
59-
sql.execute("create table FOOD ( id integer, type varchar, name varchar)")
60-
sql.execute("create table PERSON_FOOD ( personid integer, foodid integer)")
61+
sql.execute("create table PERSON ( id INTEGER, firstname VARCHAR(10), lastname VARCHAR(10) )")
62+
sql.execute("create table FOOD ( id INTEGER, type VARCHAR(10), name VARCHAR(10))")
63+
sql.execute("create table PERSON_FOOD ( personid INTEGER, foodid INTEGER)")
6164

6265
// now let's populate the datasets
6366
def people = sql.dataSet("PERSON")

Diff for: src/test/groovy/sql/SqlCallTest.groovy

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2003-2009 the original author or authors.
2+
* Copyright 2003-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,9 +15,11 @@
1515
*/
1616
package groovy.sql
1717

18-
import java.sql.Connection
1918
import javax.sql.DataSource
2019

20+
import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
21+
import static groovy.sql.SqlTestConstants.DB_DATASOURCE
22+
2123
/**
2224
* Test Sql transaction features using a Sql built from a connection
2325
*
@@ -28,12 +30,11 @@ class SqlCallTest extends GroovyTestCase {
2830
Sql sql
2931

3032
protected Sql setUpSql() {
31-
DataSource ds = new org.hsqldb.jdbc.jdbcDataSource()
32-
ds.database = "jdbc:hsqldb:mem:foo" + getMethodName()
33-
ds.user = 'sa'
34-
ds.password = ''
35-
Connection con = ds.connection
36-
return new Sql(con)
33+
DataSource ds = DB_DATASOURCE.newInstance(
34+
database: DB_URL_PREFIX + getMethodName(),
35+
user: 'sa',
36+
password: '')
37+
return new Sql(ds.connection)
3738
}
3839

3940
protected tryDrop(String tableName) {
@@ -46,7 +47,7 @@ class SqlCallTest extends GroovyTestCase {
4647
sql = setUpSql()
4748
["PERSON"].each{ tryDrop(it) }
4849

49-
sql.execute("CREATE TABLE person ( id INTEGER, firstname VARCHAR, lastname VARCHAR, PRIMARY KEY (id))")
50+
sql.execute("CREATE TABLE person ( id INTEGER, firstname VARCHAR(10), lastname VARCHAR(10), PRIMARY KEY (id))")
5051

5152
// populate some data
5253
def people = sql.dataSet("PERSON")

Diff for: src/test/groovy/sql/SqlCompleteTest.groovy

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2003-2011 the original author or authors.
2+
* Copyright 2003-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
1515
*/
1616
package groovy.sql
1717

18+
import static groovy.sql.SqlTestConstants.DB_DATASOURCE
19+
1820
class SqlCompleteTest extends TestHelper {
1921

2022
boolean personMetaClosureCalled = false
@@ -303,10 +305,10 @@ class SqlCompleteTest extends TestHelper {
303305
features.each {
304306
/** @todo HSQLDB doesn't yet support ResultSet updating
305307
if (it.id == 1) {
306-
it.name = it.name + " Rocks!"
307-
println("Changing name to ${it.name}")
308+
it.name = it.name + " Rocks!"
309+
println("Changing name to ${it.name}")
308310
}
309-
*/
311+
/* */
310312
results.add(it.name)
311313
}
312314
def expected = ["GDO", "GPath", "GroovyMarkup"]
@@ -431,10 +433,10 @@ class SqlCompleteTest extends TestHelper {
431433

432434
void testNewInstanceMapMustContainNonNullUrl() {
433435
shouldFail(IllegalArgumentException) {
434-
Sql.newInstance(driver: 'org.hsqldb.jdbcDriver', user: 'scott', password: 'tiger')
436+
Sql.newInstance(driver: DB_DATASOURCE.name, user: 'scott', password: 'tiger')
435437
}
436438
shouldFail(IllegalArgumentException) {
437-
Sql.newInstance(url: null, driver: 'org.hsqldb.jdbcDriver', user: 'scott', password: 'tiger')
439+
Sql.newInstance(url: null, driver: DB_DATASOURCE.name, user: 'scott', password: 'tiger')
438440
}
439441
}
440442

@@ -454,16 +456,16 @@ class SqlCompleteTest extends TestHelper {
454456

455457
void testNewInstanceMapShouldRequireUserAndPasswordIfOneIsProvided() {
456458
shouldFail(IllegalArgumentException) {
457-
Sql.newInstance(url: getURI(), driver: 'org.hsqldb.jdbcDriver', user: 'scott')
459+
Sql.newInstance(url: getURI(), driver: DB_DATASOURCE.name, user: 'scott')
458460
}
459461
shouldFail(IllegalArgumentException) {
460-
Sql.newInstance(url: getURI(), driver: 'org.hsqldb.jdbcDriver', password: 'tiger')
462+
Sql.newInstance(url: getURI(), driver: DB_DATASOURCE.name, password: 'tiger')
461463
}
462464
}
463465

464466
void testNewInstanceMapNotDestructiveGROOVY5216() {
465467
String url = getURI()
466-
String driver = 'org.hsqldb.jdbcDriver'
468+
String driver = DB_DATASOURCE.name
467469
String user = 'sa'
468470
String password = ''
469471

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
1+
/*
2+
* Copyright 2003-2012 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package groovy.sql
217

318
import java.sql.DriverManager
4-
import org.hsqldb.jdbcDriver
19+
20+
import static groovy.sql.SqlTestConstants.DB_DATASOURCE
521

622
/**
723
* Tests the use of the Sql class using just a Connection
@@ -10,8 +26,7 @@ import org.hsqldb.jdbcDriver
1026
class SqlCompleteWithoutDataSourceTest extends SqlCompleteTest {
1127

1228
protected def newSql(String uri) {
13-
def driver = Class.forName('org.hsqldb.jdbcDriver')
14-
println("Loading driver ${driver}")
29+
Class.forName(DB_DATASOURCE.name)
1530
return new Sql(DriverManager.getConnection(uri))
1631
}
1732
}

Diff for: src/test/groovy/sql/SqlRowsTest.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ class SqlRowsTest extends TestHelper {
66
Sql sql = super.createSql()
77

88
["JOINTESTA", "JOINTESTB"].each{ tryDrop(it) }
9-
sql.execute("create table JOINTESTA ( id integer, bid integer, name varchar)")
10-
sql.execute("create table JOINTESTB ( id integer, name varchar)")
9+
sql.execute("create table JOINTESTA ( id INTEGER, bid INTEGER, name VARCHAR(10))")
10+
sql.execute("create table JOINTESTB ( id INTEGER, name VARCHAR(10))")
1111

1212
def jointesta = sql.dataSet("JOINTESTA")
1313
jointesta.add( id:1, bid:3, name:'A 1' )

0 commit comments

Comments
 (0)