⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 persontest.groovy

📁 大名鼎鼎的java动态脚本语言。已经通过了sun的认证
💻 GROOVY
字号:
package groovy.sqlimport javax.sql.DataSourceimport org.axiondb.jdbc.AxionDataSourceclass PersonTest extends GroovyTestCase {    def type        void testFoo() {        def persons = createDataSet()		        def blogs = persons.findAll { it.lastName == "Bloggs" }		        assertSql(blogs, "select * from person where lastName = ?", ['Bloggs'])    }    void testWhereWithAndClause() {        def persons = createDataSet()		        def blogs = persons.findAll { it.lastName == "Bloggs" }                def bigBlogs = blogs.findAll { it.size > 100 }		        assertSql(bigBlogs, "select * from person where lastName = ? and size > ?", ['Bloggs', 100])    }    void testWhereClosureWithAnd() {        def persons = createDataSet()		        def blogs = persons.findAll { it.size < 10 && it.lastName == "Bloggs" }		        assertSql(blogs, "select * from person where size < ? and lastName = ?", [10, 'Bloggs'])    }     protected def compareFn(value) {        value > 1 && value < 10    }        protected def assertSql(dataSet, expectedSql, expectedParams) {        def sql = dataSet.sql        def params = dataSet.parameters        assert sql == expectedSql        assert params == expectedParams    }        protected DataSource createDataSource() {        return new AxionDataSource("jdbc:axiondb:foo" + getMethodName())    }        protected def createDataSet() {        def type = Person        assert type != null , "failed to load Person class"        def dataSource = createDataSource()        def sql = new Sql(dataSource)        return sql.dataSet(type)    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -