Skip to content

Commit

Permalink
Merge pull request #4 from burtbeckwith/master
Browse files Browse the repository at this point in the history
cleanup
  • Loading branch information
fabiooshiro committed Feb 21, 2013
2 parents 5cbe639 + dd5ab6f commit 327bded
Show file tree
Hide file tree
Showing 51 changed files with 159 additions and 3,330 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Expand Up @@ -5,5 +5,5 @@ target
*.log
*.zip
.DS_Store
web-app/plugins
web-app/WEB-INF/lib
web-app
plugin.xml
87 changes: 16 additions & 71 deletions PlasticCriteriaGrailsPlugin.groovy
@@ -1,74 +1,19 @@
class PlasticCriteriaGrailsPlugin {
// the plugin version
def version = "0.6"
// the version or versions of Grails the plugin is designed for
def grailsVersion = "1.3 > *"
// the other plugins this plugin depends on
def dependsOn = [:]
// resources that are excluded from plugin packaging
def pluginExcludes = [
'grails-app/views/error.gsp',
'grails-app/domain/plastic/criteria/Artist.groovy',
'grails-app/domain/plastic/criteria/Portrait.groovy',
def version = "0.6"
def grailsVersion = "1.3 > *"
def pluginExcludes = [
'grails-app/domain/**',
'src/groovy/plastic/criteria/CriteriaDocTests.groovy'
]

// TODO Fill in these fields
def title = "Plastic Criteria Plugin" // Headline display name of the plugin
def author = "Fabio Issamu Oshiro"
def authorEmail = ""
def description = '''\
Mock Grails Criteria for Unit Tests
'''

// URL to the plugin's documentation
def documentation = "http://grails.org/plugin/plastic-criteria"

// Extra (optional) plugin metadata

// License: one of 'APACHE', 'GPL2', 'GPL3'
// def license = "APACHE"

// Details of company behind the plugin (if there is one)
def organization = [ name: "Investtools", url: "http://www.investtools.com.br/" ]

// Any additional developers beyond the author specified above.
// def developers = [ [ name: "Joe Bloggs", email: "joe@bloggs.net" ]]

// Location of the plugin's issue tracker.
// def issueManagement = [ system: "JIRA", url: "http://jira.grails.org/browse/GPMYPLUGIN" ]

// Online location of the plugin's browseable source code.
def scm = [ url: "https://github.com/fabiooshiro/plastic-criteria" ]

def doWithWebDescriptor = { xml ->
// TODO Implement additions to web.xml (optional), this event occurs before
}

def doWithSpring = {
// TODO Implement runtime spring config (optional)
}

def doWithDynamicMethods = { ctx ->
// TODO Implement registering dynamic methods to classes (optional)
}

def doWithApplicationContext = { applicationContext ->
// TODO Implement post initialization spring config (optional)
}

def onChange = { event ->
// TODO Implement code that is executed when any artefact that this plugin is
// watching is modified and reloaded. The event contains: event.source,
// event.application, event.manager, event.ctx, and event.plugin.
}

def onConfigChange = { event ->
// TODO Implement code that is executed when the project configuration changes.
// The event is the same as for 'onChange'.
}

def onShutdown = { event ->
// TODO Implement code that is executed when the application shuts down (optional)
}
]

def title = "Plastic Criteria Plugin"
def author = "Fabio Issamu Oshiro"
def authorEmail = ""
def description = 'Mock Grails Criteria for Unit Tests'
def documentation = "http://grails.org/plugin/plastic-criteria"

// def license = "WTFPL"
def organization = [ name: "Investtools", url: "http://www.investtools.com.br/" ]
def issueManagement = [ system: "GitHub", url: "https://github.com/fabiooshiro/plastic-criteria/issues" ]
def scm = [ url: "https://github.com/fabiooshiro/plastic-criteria" ]
}
19 changes: 9 additions & 10 deletions README.md
Expand Up @@ -21,9 +21,9 @@ Grails 2.0.x edit your <your-project>/grails-app/conf/BuildConfig.groovy
// (...)
plugins {
// (...) another plugins
// add this line
test ":plastic-criteria:0.4"
test ":plastic-criteria:0.6"
}
// (...)
```
Expand All @@ -36,27 +36,27 @@ package plastic.test
import grails.test.mixin.*
// import mockCriteria() static method
import static plastic.criteria.PlasticCriteria.*
import static plastic.criteria.PlasticCriteria.*
@TestFor(Product)
class ProductTests {
void testSomething() {
new Product(name: 'Foo', value: 10).save()
new Product(name: 'Foo', value: 20).save()
new Product(name: 'Bar', value: 200).save()
new Product(name: 'Bar', value: 100).save()
// replace default criteria mock
mockCriteria([Product])
mockCriteria([Product])
def results = Product.withCriteria{
projections{
groupProperty('name') // now you have groupProperty
sum('value')
}
}
assert [['Foo', 30 ], ['Bar', 300]] == results
}
}
Expand All @@ -67,7 +67,7 @@ just
```
import static plastic.criteria.PlasticCriteria.*;
```
and
and
```
mockCriteria([Product])
```
Expand All @@ -76,4 +76,3 @@ mockCriteria([Product])
<a href="https://twitter.com/fabiooshiro">Sr. Oshiro</a>,
<a href="http://www.facebook.com/MaxMustang23">Max Mustang</a>,
<a href="https://twitter.com/dtuler">Danilo Tuler</a>

6 changes: 0 additions & 6 deletions application.properties
@@ -1,7 +1 @@
#Grails Metadata file
#Mon Jan 21 11:35:17 BRST 2013
app.grails.version=2.1.3
app.name=plastic-criteria
plugins.hibernate=2.1.3
plugins.rest-client-builder=1.0.2
plugins.svn=1.0.1
53 changes: 21 additions & 32 deletions grails-app/conf/BuildConfig.groovy
@@ -1,39 +1,28 @@
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = 'target'
grails.project.target.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"

grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
repositories {
grailsCentral()
// uncomment the below to enable remote dependency resolution
// from public Maven repositories
mavenCentral()
mavenLocal()
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.

// runtime 'mysql:mysql-connector-java:5.1.5'
// build ":release:2.0.0"
inherits 'global'
log 'warn'

repositories {
grailsCentral()
mavenLocal()
mavenCentral()
}

dependencies {
compile 'javassist:javassist:3.12.1.GA'
}
}

plugins {
build ':release:2.2.0', ':rest-client-builder:1.0.3', {
export = false
}

plugins {
build(":tomcat:$grailsVersion",
":release:2.0.0") {
export = false
}
}
runtime ":hibernate:$grailsVersion", {
export = false
}
}
}
28 changes: 4 additions & 24 deletions grails-app/conf/Config.groovy
@@ -1,26 +1,6 @@
// configuration for plugin testing - will not be included in the plugin zip

log4j = {
// Example of changing the log pattern for the default console
// appender:
//
//appenders {
// console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
//}

error 'org.codehaus.groovy.grails.web.servlet', // controllers
'org.codehaus.groovy.grails.web.pages', // GSP
'org.codehaus.groovy.grails.web.sitemesh', // layouts
'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
'org.codehaus.groovy.grails.web.mapping', // URL mapping
'org.codehaus.groovy.grails.commons', // core / classloading
'org.codehaus.groovy.grails.plugins', // plugins
'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
'org.springframework',
'org.hibernate',
'net.sf.ehcache.hibernate'

warn 'org.mortbay.log'
error 'org.codehaus.groovy.grails',
'org.springframework',
'org.hibernate',
'net.sf.ehcache.hibernate'
}
grails.views.default.codec="none" // none, html, base64
grails.views.gsp.encoding="UTF-8"
49 changes: 10 additions & 39 deletions grails-app/conf/DataSource.groovy
@@ -1,43 +1,14 @@
dataSource {
pooled = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
pooled = true
driverClassName = 'org.h2.Driver'
username = 'sa'
password = ''
dbCreate = 'update'
url = 'jdbc:h2:mem:testDb'
}

hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:mem:devDb;MVCC=TRUE"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb;MVCC=TRUE"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:prodDb;MVCC=TRUE"
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
}
cache.use_second_level_cache = false
cache.use_query_cache = false
cache.provider_class = 'org.hibernate.cache.EhCacheProvider'
}
13 changes: 0 additions & 13 deletions grails-app/conf/UrlMappings.groovy

This file was deleted.

9 changes: 4 additions & 5 deletions grails-app/domain/plastic/criteria/Artist.groovy
@@ -1,13 +1,12 @@
package plastic.criteria;
package plastic.criteria

public class Artist {
class Artist {

String name

String toString(){
name
}

static hasMany = [portraits: Portrait]

}
17 changes: 8 additions & 9 deletions grails-app/domain/plastic/criteria/Portrait.groovy
@@ -1,25 +1,24 @@
package plastic.criteria;
package plastic.criteria

public class Portrait {
class Portrait {

static belongsTo = [artist: Artist]

String name

BigDecimal value

BigDecimal lastSoldPrice

String color

String toString(){
"${name} (id: ${id})"
}

static constraints = {
color nullable: true
value nullable: true
lastSoldPrice nullable: true
}

}
Empty file.
11 changes: 0 additions & 11 deletions grails-app/views/error.gsp

This file was deleted.

0 comments on commit 327bded

Please sign in to comment.