Skip to content
Browse files

GROOVY-5305: Update dependencies (hsqldb)

  • Loading branch information...
1 parent 4c5c29d commit 4d1c9ab57ef68b70c4943bcf24ba851fd5f4f2a9 @paulk-asert paulk-asert committed
View
2 build.gradle
@@ -72,7 +72,7 @@ dependencies {
testCompile "jmock:jmock:1.2.0"
testCompile "jmock:jmock-cglib:1.2.0"
testCompile "xmlunit:xmlunit:1.3"
- testCompile "hsqldb:hsqldb:1.8.0.10"
+ testCompile "org.hsqldb:hsqldb:2.2.8"
testCompile "ch.qos.logback:logback-classic:0.9.21"
testCompile "log4j:log4j:1.2.16"
testCompile "org.slf4j:jcl-over-slf4j:1.6.0"
View
4 pom.xml
@@ -765,9 +765,9 @@
<!-- used for SQL library -->
<dependency>
- <groupId>hsqldb</groupId>
+ <groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
- <version>1.8.0.10</version>
+ <version>2.2.8</version>
<scope>test</scope>
</dependency>
View
4 security/groovy.policy
@@ -252,8 +252,8 @@ grant codeBase "file:${user.dir}/src/test/groovy/sql/-" {
};
grant codeBase "file:${user.dir}/src/test/groovy/sql/SqlCompleteWithoutDataSourceTest.groovy" {
- //TODO: what should this be see other TODO about narrowing down main directories
- //permission java.io.FilePermission "${groovy.lib}${/}axion${/}jars${/}axion-1.0-M3-dev.jar", "read";
+ permission java.util.PropertyPermission "file.separator", "read";
+ permission java.util.PropertyPermission "line.separator", "read";
};
grant codeBase "file:${user.dir}/src/test/groovy/sql/SqlTest.groovy" {
View
20 src/main/groovy/sql/Sql.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2011 the original author or authors.
+ * Copyright 2003-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
* In simple cases, you can just provide
* the necessary details to set up a connection (e.g. for hsqldb):
* <pre>
- * def db = [url:'jdbc:hsqldb:mem:testDB', user:'sa', password:'', driver:'org.hsqldb.jdbcDriver']
+ * def db = [url:'jdbc:hsqldb:mem:testDB', user:'sa', password:'', driver:'org.hsqldb.jdbc.JDBCDriver']
* def sql = Sql.newInstance(db.url, db.user, db.password, db.driver)
* </pre>
* 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
* url:'jdbc:hsqldb:mem:testDB',
* user:'sa',
* password:'',
- * driver:'org.hsqldb.jdbcDriver',
+ * driver:'org.hsqldb.jdbc.JDBCDriver',
* cacheStatements: true,
* resultSetConcurrency: CONCUR_READ_ONLY
* )
@@ -1719,19 +1719,19 @@ public GroovyRowResult firstRow(String sql, Object[] params) throws SQLException
* <p/>
* Example usages:
* <pre>
- * sql.execute "drop table if exists PERSON"
+ * sql.execute "DROP TABLE IF EXISTS person"
*
* sql.execute """
- * create table PERSON (
- * id integer not null,
- * firstname varchar(100),
- * lastname varchar(100),
- * location_id integer
+ * CREATE TABLE person (
+ * id INTEGER NOT NULL,
+ * firstname VARCHAR(100),
+ * lastname VARCHAR(100),
+ * location_id INTEGER
* )
* """
*
* sql.execute """
- * insert into PERSON (id, firstname, lastname, location_id) values (4, 'Paul', 'King', 40)
+ * INSERT INTO person (id, firstname, lastname, location_id) VALUES (4, 'Paul', 'King', 40)
* """
* assert sql.updateCount == 1
* </pre>
View
18 src/test/groovy/sql/PersonTest.groovy
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 the original author or authors.
+ * Copyright 2003-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,9 @@ package groovy.sql
import javax.sql.DataSource
+import static groovy.sql.SqlTestConstants.DB_DATASOURCE
+import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
+
class PersonTest extends GroovyTestCase {
void testFoo() {
@@ -66,15 +69,14 @@ order by firstName DESC, age'''
assert dataSet.sql == expectedSql
assert dataSet.parameters == expectedParams
}
-
+
protected DataSource createDataSource() {
- def ds = new org.hsqldb.jdbc.jdbcDataSource()
- ds.database = "jdbc:hsqldb:mem:foo" + getMethodName()
- ds.user = 'sa'
- ds.password = ''
- return ds
+ return DB_DATASOURCE.newInstance(
+ database: DB_URL_PREFIX + getMethodName(),
+ user: 'sa',
+ password: '')
}
-
+
protected def createDataSet() {
def type = Person
assert type != null , "failed to load Person class"
View
20 src/test/groovy/sql/SqlBatchTest.groovy
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2011 the original author or authors.
+ * Copyright 2003-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,9 @@
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
/**
* Test Sql batch features
@@ -25,17 +27,15 @@ import java.sql.Connection
*/
class SqlBatchTest extends GroovyTestCase {
Sql sql
- def personFood
private others = ['Jean':'Gabin', 'Lino':'Ventura']
void setUp() {
- DataSource ds = new org.hsqldb.jdbc.jdbcDataSource()
- ds.database = "jdbc:hsqldb:mem:foo" + getMethodName()
- ds.user = 'sa'
- ds.password = ''
- Connection con = ds.connection
- sql = new Sql(con)
- sql.execute("CREATE TABLE person ( id INTEGER, firstname VARCHAR, lastname VARCHAR, PRIMARY KEY (id))")
+ DataSource ds = DB_DATASOURCE.newInstance(
+ database: DB_URL_PREFIX + getMethodName(),
+ user: 'sa',
+ password: '')
+ sql = new Sql(ds.connection)
+ sql.execute("CREATE TABLE person ( id INTEGER, firstname VARCHAR(10), lastname VARCHAR(10), PRIMARY KEY (id))")
// populate some data
def people = sql.dataSet("PERSON")
View
21 src/test/groovy/sql/SqlCacheTest.groovy
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2009 the original author or authors.
+ * Copyright 2003-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,9 @@ 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
+
/**
* Unit test of Sql cache feature
* @author Marc DeXeT
@@ -36,11 +39,11 @@ class SqlCacheTest extends GroovyTestCase {
int createStatementCallCounter
void setUp() {
- ds = new org.hsqldb.jdbc.jdbcDataSource()
- ds.database = "jdbc:hsqldb:mem:foo" + getMethodName()
- ds.user = 'sa'
- ds.password = ''
- con = ds.getConnection()
+ ds = DB_DATASOURCE.newInstance(
+ database: DB_URL_PREFIX + getMethodName(),
+ user: 'sa',
+ password: '')
+ con = ds.connection
def methodOverride = [
createStatement: {Object[] args ->
createStatementCallCounter++
@@ -55,9 +58,9 @@ class SqlCacheTest extends GroovyTestCase {
]
wrappedCon = ProxyGenerator.INSTANCE.instantiateDelegate(methodOverride, [Connection], con)
sql = new Sql(wrappedCon)
- sql.execute("create table PERSON ( id integer, firstname varchar, lastname varchar )")
- sql.execute("create table FOOD ( id integer, type varchar, name varchar)")
- sql.execute("create table PERSON_FOOD ( personid integer, foodid integer)")
+ sql.execute("create table PERSON ( id INTEGER, firstname VARCHAR(10), lastname VARCHAR(10) )")
+ sql.execute("create table FOOD ( id INTEGER, type VARCHAR(10), name VARCHAR(10))")
+ sql.execute("create table PERSON_FOOD ( personid INTEGER, foodid INTEGER)")
// now let's populate the datasets
def people = sql.dataSet("PERSON")
View
19 src/test/groovy/sql/SqlCallTest.groovy
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2009 the original author or authors.
+ * Copyright 2003-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,11 @@
*/
package groovy.sql
-import java.sql.Connection
import javax.sql.DataSource
+import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
+import static groovy.sql.SqlTestConstants.DB_DATASOURCE
+
/**
* Test Sql transaction features using a Sql built from a connection
*
@@ -28,12 +30,11 @@ class SqlCallTest extends GroovyTestCase {
Sql sql
protected Sql setUpSql() {
- DataSource ds = new org.hsqldb.jdbc.jdbcDataSource()
- ds.database = "jdbc:hsqldb:mem:foo" + getMethodName()
- ds.user = 'sa'
- ds.password = ''
- Connection con = ds.connection
- return new Sql(con)
+ DataSource ds = DB_DATASOURCE.newInstance(
+ database: DB_URL_PREFIX + getMethodName(),
+ user: 'sa',
+ password: '')
+ return new Sql(ds.connection)
}
protected tryDrop(String tableName) {
@@ -46,7 +47,7 @@ class SqlCallTest extends GroovyTestCase {
sql = setUpSql()
["PERSON"].each{ tryDrop(it) }
- sql.execute("CREATE TABLE person ( id INTEGER, firstname VARCHAR, lastname VARCHAR, PRIMARY KEY (id))")
+ sql.execute("CREATE TABLE person ( id INTEGER, firstname VARCHAR(10), lastname VARCHAR(10), PRIMARY KEY (id))")
// populate some data
def people = sql.dataSet("PERSON")
View
20 src/test/groovy/sql/SqlCompleteTest.groovy
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2011 the original author or authors.
+ * Copyright 2003-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
*/
package groovy.sql
+import static groovy.sql.SqlTestConstants.DB_DATASOURCE
+
class SqlCompleteTest extends TestHelper {
boolean personMetaClosureCalled = false
@@ -303,10 +305,10 @@ class SqlCompleteTest extends TestHelper {
features.each {
/** @todo HSQLDB doesn't yet support ResultSet updating
if (it.id == 1) {
- it.name = it.name + " Rocks!"
- println("Changing name to ${it.name}")
+ it.name = it.name + " Rocks!"
+ println("Changing name to ${it.name}")
}
- */
+ /* */
results.add(it.name)
}
def expected = ["GDO", "GPath", "GroovyMarkup"]
@@ -431,10 +433,10 @@ class SqlCompleteTest extends TestHelper {
void testNewInstanceMapMustContainNonNullUrl() {
shouldFail(IllegalArgumentException) {
- Sql.newInstance(driver: 'org.hsqldb.jdbcDriver', user: 'scott', password: 'tiger')
+ Sql.newInstance(driver: DB_DATASOURCE.name, user: 'scott', password: 'tiger')
}
shouldFail(IllegalArgumentException) {
- Sql.newInstance(url: null, driver: 'org.hsqldb.jdbcDriver', user: 'scott', password: 'tiger')
+ Sql.newInstance(url: null, driver: DB_DATASOURCE.name, user: 'scott', password: 'tiger')
}
}
@@ -454,16 +456,16 @@ class SqlCompleteTest extends TestHelper {
void testNewInstanceMapShouldRequireUserAndPasswordIfOneIsProvided() {
shouldFail(IllegalArgumentException) {
- Sql.newInstance(url: getURI(), driver: 'org.hsqldb.jdbcDriver', user: 'scott')
+ Sql.newInstance(url: getURI(), driver: DB_DATASOURCE.name, user: 'scott')
}
shouldFail(IllegalArgumentException) {
- Sql.newInstance(url: getURI(), driver: 'org.hsqldb.jdbcDriver', password: 'tiger')
+ Sql.newInstance(url: getURI(), driver: DB_DATASOURCE.name, password: 'tiger')
}
}
void testNewInstanceMapNotDestructiveGROOVY5216() {
String url = getURI()
- String driver = 'org.hsqldb.jdbcDriver'
+ String driver = DB_DATASOURCE.name
String user = 'sa'
String password = ''
View
21 src/test/groovy/sql/SqlCompleteWithoutDataSourceTest.groovy
@@ -1,7 +1,23 @@
+/*
+ * Copyright 2003-2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package groovy.sql
import java.sql.DriverManager
-import org.hsqldb.jdbcDriver
+
+import static groovy.sql.SqlTestConstants.DB_DATASOURCE
/**
* Tests the use of the Sql class using just a Connection
@@ -10,8 +26,7 @@ import org.hsqldb.jdbcDriver
class SqlCompleteWithoutDataSourceTest extends SqlCompleteTest {
protected def newSql(String uri) {
- def driver = Class.forName('org.hsqldb.jdbcDriver')
- println("Loading driver ${driver}")
+ Class.forName(DB_DATASOURCE.name)
return new Sql(DriverManager.getConnection(uri))
}
}
View
4 src/test/groovy/sql/SqlRowsTest.groovy
@@ -6,8 +6,8 @@ class SqlRowsTest extends TestHelper {
Sql sql = super.createSql()
["JOINTESTA", "JOINTESTB"].each{ tryDrop(it) }
- sql.execute("create table JOINTESTA ( id integer, bid integer, name varchar)")
- sql.execute("create table JOINTESTB ( id integer, name varchar)")
+ sql.execute("create table JOINTESTA ( id INTEGER, bid INTEGER, name VARCHAR(10))")
+ sql.execute("create table JOINTESTB ( id INTEGER, name VARCHAR(10))")
def jointesta = sql.dataSet("JOINTESTA")
jointesta.add( id:1, bid:3, name:'A 1' )
View
18 src/test/groovy/sql/SqlStatementTest.groovy
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2009 the original author or authors.
+ * Copyright 2003-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,9 @@ 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
+
/**
* Unit test of Sql statement feature
*
@@ -27,13 +30,12 @@ class SqlStatementTest extends GroovyTestCase {
Sql sql
void setUp() {
- DataSource ds = new org.hsqldb.jdbc.jdbcDataSource()
- ds.database = "jdbc:hsqldb:mem:foo" + getMethodName()
- ds.user = 'sa'
- ds.password = ''
- Connection con = ds.connection
- sql = new Sql(con)
- sql.execute("create table PERSON ( id integer, firstname varchar, lastname varchar )")
+ DataSource ds = DB_DATASOURCE.newInstance(
+ database: DB_URL_PREFIX + getMethodName(),
+ user: 'sa',
+ password: '')
+ sql = new Sql(ds.connection)
+ sql.execute("create table PERSON ( id INTEGER, firstname VARCHAR(10), lastname VARCHAR(10) )")
// now let's populate the datasets
def people = sql.dataSet("PERSON")
View
29 src/test/groovy/sql/SqlTest.groovy
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2010 the original author or authors.
+ * Copyright 2003-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,10 @@
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
/**
* This is more of a sample program than a unit test and is here as an easy
@@ -96,13 +100,12 @@ class SqlTest extends GroovyTestCase {
}
void testExecuteInsert() {
- def foo = 'food-drink'
- def bar = 'guiness'
+ def value = 'log entry'
if (sql.dataSource.connection.metaData.supportsGetGeneratedKeys()) {
- def keys = sql.executeInsert('insert into FOOD (type,name) values (?,?)', [foo, bar])
+ def keys = sql.executeInsert('insert into LOG (value) values (?)', [value])
assert 1 == keys.size()
} else {
- def count = sql.executeUpdate('insert into FOOD (type,name) values (?,?)', [foo, bar])
+ def count = sql.executeUpdate('insert into LOG (value) values (?)', [value])
assert 1 == count
}
}
@@ -131,7 +134,7 @@ class SqlTest extends GroovyTestCase {
if (res)
res.close()
}
- res = sub.rows('select * from PERSON') { metaData ->
+ sub.rows('select * from PERSON') { metaData ->
assert sub.connection && !sub.connection.isClosed()
data = (1..metaData.columnCount).collect {
metaData.getColumnName(it).toLowerCase()
@@ -141,14 +144,16 @@ class SqlTest extends GroovyTestCase {
}
private createSql() {
- def ds = new org.hsqldb.jdbc.jdbcDataSource()
- ds.database = "jdbc:hsqldb:mem:foo" + getMethodName()
- ds.user = 'sa'
- ds.password = ''
+ DataSource ds = DB_DATASOURCE.newInstance(
+ database: DB_URL_PREFIX + getMethodName(),
+ user: 'sa',
+ password: '')
+ sql = new Sql(ds.connection)
def sql = new Sql(ds)
- sql.execute("create table PERSON ( firstname varchar, lastname varchar )")
- sql.execute("create table FOOD ( type varchar, name varchar)")
+ sql.execute("create table PERSON ( firstname VARCHAR(10), lastname VARCHAR(10) )")
+ sql.execute("create table FOOD ( type VARCHAR(10), name VARCHAR(10))")
+ sql.execute("create table LOG ( value VARCHAR(20), id INTEGER IDENTITY)")
// now let's populate the datasets
def people = sql.dataSet("PERSON")
View
6 src/test/groovy/sql/SqlTestConstants.groovy
@@ -0,0 +1,6 @@
+package groovy.sql
+
+class SqlTestConstants {
+ public static final String DB_URL_PREFIX = 'jdbc:hsqldb:mem:testDB'
+ public static final Class DB_DATASOURCE = org.hsqldb.jdbc.JDBCDataSource
+}
View
16 src/test/groovy/sql/SqlTransactionConnectionTest.groovy
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2009 the original author or authors.
+ * Copyright 2003-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,9 @@ 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
+
/**
* Test Sql transaction features using a Sql built from a connection
*
@@ -26,12 +29,11 @@ import java.sql.Connection
class SqlTransactionConnectionTest extends SqlTransactionTestCase {
protected Sql setUpSql() {
- DataSource ds = new org.hsqldb.jdbc.jdbcDataSource()
- ds.database = "jdbc:hsqldb:mem:foo" + getMethodName()
- ds.user = 'sa'
- ds.password = ''
- Connection con = ds.connection
- return new Sql(con)
+ DataSource ds = DB_DATASOURCE.newInstance(
+ database: DB_URL_PREFIX + getMethodName(),
+ user: 'sa',
+ password: '')
+ return new Sql(ds.connection)
}
}
View
13 src/test/groovy/sql/SqlTransactionDataSourceTest.groovy
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2009 the original author or authors.
+ * Copyright 2003-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,9 @@ package groovy.sql
import javax.sql.DataSource
+import static groovy.sql.SqlTestConstants.DB_DATASOURCE
+import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
+
/**
* Test Sql transaction features using a Sql built from a DataSource
*
@@ -24,10 +27,10 @@ import javax.sql.DataSource
*/
class SqlTransactionDataSourceTest extends SqlTransactionTestCase {
protected Sql setUpSql() {
- DataSource ds = new org.hsqldb.jdbc.jdbcDataSource()
- ds.database = "jdbc:hsqldb:mem:foo" + getMethodName()
- ds.user = 'sa'
- ds.password = ''
+ DataSource ds = DB_DATASOURCE.newInstance(
+ database: DB_URL_PREFIX + getMethodName(),
+ user: 'sa',
+ password: '')
return new Sql(ds)
}
}
View
14 src/test/groovy/sql/SqlTransactionTestCase.groovy
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2009 the original author or authors.
+ * Copyright 2003-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,8 +43,8 @@ class SqlTransactionTestCase extends GroovyTestCase {
// drop them in this order due to FK constraint
["PERSON_FOOD", "PERSON"].each{ tryDrop(it) }
- sql.execute("CREATE TABLE person ( id INTEGER, firstname VARCHAR, lastname VARCHAR, PRIMARY KEY (id))")
- sql.execute("CREATE TABLE person_food ( personid INTEGER, food VARCHAR, FOREIGN KEY (personid) REFERENCES person(id))")
+ sql.execute("CREATE TABLE person ( id INTEGER, firstname VARCHAR(10), lastname VARCHAR(10), PRIMARY KEY (id))")
+ sql.execute("CREATE TABLE person_food ( personid INTEGER, food VARCHAR(10), FOREIGN KEY (personid) REFERENCES person(id))")
// populate some data
def people = sql.dataSet("PERSON")
@@ -94,7 +94,7 @@ class SqlTransactionTestCase extends GroovyTestCase {
fail("Should have thrown an exception before now")
} catch (SQLException se) {
assert numAdds == 1
- assert se.message.contains('Integrity constraint violation')
+ assert se.message.toLowerCase().contains('integrity constraint violation')
sql.rollback()
}
connection.autoCommit = true
@@ -116,7 +116,7 @@ class SqlTransactionTestCase extends GroovyTestCase {
fail("Should have thrown an exception before now")
} catch (SQLException se) {
assert numAdds == 1
- assert se.message.contains('Integrity constraint violation')
+ assert se.message.toLowerCase().contains('integrity constraint violation')
personFood.rollback()
}
connection.autoCommit = true
@@ -137,7 +137,7 @@ class SqlTransactionTestCase extends GroovyTestCase {
fail("Should have thrown an exception before now")
} catch (SQLException se) {
assert numAdds == 1
- assert se.message.contains('Integrity constraint violation')
+ assert se.message.toLowerCase().contains('integrity constraint violation')
}
assert sql.rows("SELECT * FROM PERSON_FOOD").size() == 3
}
@@ -155,7 +155,7 @@ class SqlTransactionTestCase extends GroovyTestCase {
fail("Should have thrown an exception before now")
} catch (SQLException se) {
assert numAdds == 1
- assert se.message.contains('Integrity constraint violation')
+ assert se.message.toLowerCase().contains('integrity constraint violation')
}
assert sql.rows("SELECT * FROM PERSON_FOOD").size() == 3
}
View
2 src/test/groovy/sql/SqlWithTypedResultsTest.groovy
@@ -9,7 +9,7 @@ class SqlWithTypedResultsTest extends TestHelper {
void testSqlQuery() {
def sql = createEmptySql()
- sql.execute("create table groovytest ( anint integer, astring varchar )");
+ sql.execute("create table groovytest ( anint INTEGER, astring VARCHAR(10) )");
def groovytest = sql.dataSet("groovytest")
groovytest.add(anint: 1, astring: "Groovy")
View
23 src/test/groovy/sql/TestHelper.groovy
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2010 the original author or authors.
+ * Copyright 2003-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,9 @@
*/
package groovy.sql
+import static groovy.sql.SqlTestConstants.DB_DATASOURCE
+import static groovy.sql.SqlTestConstants.DB_URL_PREFIX
+
class TestHelper extends GroovyTestCase {
TestHelper() {
def testdb = System.getProperty("groovy.testdb.props")
@@ -58,9 +61,9 @@ class TestHelper extends GroovyTestCase {
sql.execute "drop table FEATURE"
}
- 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))")
+ 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))")
// now let's populate the datasets
def people = sql.dataSet("PERSON")
@@ -91,7 +94,7 @@ class TestHelper extends GroovyTestCase {
protected getURI() {
if (props && props."groovy.testdb.url")
return props."groovy.testdb.url"
- def answer = "jdbc:hsqldb:mem:foo"
+ def answer = DB_URL_PREFIX
def name = getMethodName()
if (name == null) {
name = ""
@@ -110,12 +113,10 @@ class TestHelper extends GroovyTestCase {
if (!username && !password) return Sql.newInstance(url:url, driver:"$driver")
return Sql.newInstance(url, username, password, driver)
}
- // TODO once hsqldb 1.9.0 is out rename this
- // def ds = new org.hsqldb.jdbc.JDBCDataSource()
- def ds = new org.hsqldb.jdbc.jdbcDataSource()
- ds.database = uri
- ds.user = 'sa'
- ds.password = ''
+ def ds = DB_DATASOURCE.newInstance(
+ database: uri,
+ user: 'sa',
+ password: '')
return new Sql(ds)
}
}
View
8 src/test/groovy/util/ConfigSlurperTest.groovy
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2010 the original author or authors.
+ * Copyright 2003-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -83,7 +83,7 @@ test=foo + 1
def config = new ConfigSlurper("production").parse('''
dataSource {
pooling = false
- driverClassName = "org.hsqldb.jdbcDriver"
+ driverClassName = "org.hsqldb.jdbc.JDBCDriver"
username = "sa"
password = ""
}
@@ -97,7 +97,7 @@ environments {
test {
dataSource {
dbCreate = "update"
- url = "jdbc:hsqldb:mem:testDb"
+ url = "jdbc:hsqldb:mem:testDB"
}
}
production {
@@ -110,7 +110,7 @@ environments {
}''')
assertEquals false, config.dataSource.pooling
- assertEquals "org.hsqldb.jdbcDriver", config.dataSource.driverClassName
+ assertEquals "org.hsqldb.jdbc.JDBCDriver", config.dataSource.driverClassName
assertEquals "sa", config.dataSource.username
assertEquals "secret", config.dataSource.password
assertEquals "update", config.dataSource.dbCreate

0 comments on commit 4d1c9ab

Please sign in to comment.
Something went wrong with that request. Please try again.