Permalink
Browse files

cleanup

  • Loading branch information...
1 parent 312ae6b commit 4422d4e08fce3c054c011eb90358e19e1054f88e Burt Beckwith committed Dec 4, 2012
View
21 .classpath
@@ -1,14 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src/java"/>
- <classpathentry kind="src" path="src/groovy"/>
- <classpathentry kind="src" path="grails-app/conf"/>
- <classpathentry kind="src" path="grails-app/controllers"/>
- <classpathentry kind="src" path="grails-app/domain"/>
- <classpathentry kind="src" path="grails-app/services"/>
- <classpathentry kind="src" path="grails-app/taglib"/>
- <classpathentry kind="src" path="test/integration"/>
- <classpathentry kind="src" path="test/unit"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="com.springsource.sts.grails.core.CLASSPATH_CONTAINER"/>
- <classpathentry kind="output" path="web-app/WEB-INF/classes"/>
-</classpath>
+ <classpathentry kind="src" path="src/groovy"/>
+ <classpathentry kind="src" path="grails-app/conf"/>
+ <classpathentry kind="src" path="test/unit"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.grails.ide.eclipse.core.CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/eclipseclasses"/>
+</classpath>
View
5 .gitignore
@@ -1,2 +1,7 @@
build/
.gradle/
+plugin.xml
+target
+web-app
+*.zip
+*.log
View
2 .project
@@ -12,7 +12,7 @@
</buildCommand>
</buildSpec>
<natures>
- <nature>com.springsource.sts.grails.core.nature</nature>
+ <nature>org.grails.ide.eclipse.core.nature</nature>
<nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
View
14 RestClientBuilderGrailsPlugin.groovy
@@ -1,18 +1,8 @@
class RestClientBuilderGrailsPlugin {
- // the plugin version
- def version = "1.0.3"
- // the version or versions of Grails the plugin is designed for
- def grailsVersion = "2.0 > *"
- // the other plugins this plugin depends on
- def dependsOn = [:]
- // resources that are excluded from plugin packaging
- def pluginExcludes = [
- "grails-app/views/error.gsp"
- ]
+ def version = "1.0.3"
+ def grailsVersion = "2.0 > *"
def title = 'REST Client Builder Plugin'
- def author = 'Graeme Rocher'
- def authorEmail = 'grocher@vmware.com'
def description = 'Grails REST Client Builder Plugin'
def documentation = 'http://grails.org/plugin/rest-client-builder'
View
3 application.properties
@@ -1,4 +1 @@
-#Grails Metadata file
-#Tue Dec 04 11:19:28 CET 2012
app.grails.version=2.1.1
-app.name=rest-client-builder
View
50 grails-app/conf/BuildConfig.groovy
@@ -1,41 +1,19 @@
-grails.project.class.dir = "target/classes"
-grails.project.test.class.dir = "target/test-classes"
-grails.project.test.reports.dir = "target/test-reports"
-grails.project.target.level = 1.6
-grails.project.plugins.dir="target/plugins"
-//grails.project.war.file = "target/${appName}-${appVersion}.war"
+grails.project.work.dir = 'target'
+grails.project.source.level = 1.6
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'
- }
+ inherits 'global'
+ log 'warn'
- plugins {
- build(":tomcat:$grailsVersion") {
- export = false
- }
- test ":spock:0.6-rc-1", {
- excludes 'xml-apis'
- export = false
- }
- }
+ repositories {
+ grailsCentral()
+ }
+
+ plugins {
+ test ":spock:0.6", {
+ excludes 'xml-apis'
+ export = false
+ }
+ }
}
View
26 grails-app/conf/Config.groovy
@@ -1,24 +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'
}
View
49 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'
}
View
46 src/groovy/grails/plugins/rest/client/RestBuilder.groovy
@@ -1,17 +1,25 @@
package grails.plugins.rest.client
-import org.springframework.core.io.*
-import org.springframework.web.client.RestTemplate
-import org.springframework.http.*
-import org.springframework.util.*
import static org.springframework.http.MediaType.*
+import grails.converters.JSON
+import grails.converters.XML
+import grails.web.JSONBuilder
+import groovy.util.slurpersupport.GPathResult
-import grails.converters.*
-import grails.web.*
-import org.springframework.http.client.*
import org.codehaus.groovy.grails.plugins.codecs.Base64Codec
-import groovy.util.slurpersupport.*
-import org.codehaus.groovy.grails.web.json.*
+import org.codehaus.groovy.grails.web.json.JSONElement
+import org.springframework.core.io.FileSystemResource
+import org.springframework.core.io.InputStreamResource
+import org.springframework.core.io.UrlResource
+import org.springframework.http.HttpEntity
+import org.springframework.http.HttpHeaders
+import org.springframework.http.HttpMethod
+import org.springframework.http.MediaType
+import org.springframework.http.ResponseEntity
+import org.springframework.http.client.SimpleClientHttpRequestFactory
+import org.springframework.util.LinkedMultiValueMap
+import org.springframework.util.MultiValueMap
+import org.springframework.web.client.RestTemplate
class RestBuilder {
@@ -40,7 +48,6 @@ class RestBuilder {
}
}
-
restTemplate = new RestTemplate()
restTemplate.setRequestFactory(new SimpleClientHttpRequestFactory(settings))
}
@@ -92,7 +99,7 @@ class RestBuilder {
}
try {
def responseEntity = restTemplate.exchange(url, method,requestCustomizer.createEntity(),
- String, requestCustomizer.getVariables())
+ String, requestCustomizer.getVariables())
handleResponse(responseEntity)
}
catch(org.springframework.web.client.HttpStatusCodeException e) {
@@ -103,6 +110,7 @@ class RestBuilder {
return new RestResponse(responseEntity: responseEntity)
}
}
+
class ErrorResponse {
@Delegate org.springframework.web.client.HttpStatusCodeException error
@Lazy String text = {
@@ -129,6 +137,7 @@ class ErrorResponse {
error.statusCode?.value() ?: 200
}
}
+
class RestResponse {
@Delegate ResponseEntity responseEntity
@Lazy JSONElement json = {
@@ -157,13 +166,13 @@ class RestResponse {
int getStatus() {
responseEntity?.statusCode?.value() ?: 200
}
-
}
+
class RequestCustomizer {
HttpHeaders headers = new HttpHeaders()
def body
MultiValueMap<String, Object> mvm = new LinkedMultiValueMap<String, Object>()
- Map<String, Object> variables = [:]
+ Map<String, Object> variables = [:]
// configures basic author
RequestCustomizer auth(String username, String password) {
@@ -233,11 +242,11 @@ class RequestCustomizer {
this.body = xml.toString()
return this
}
- RequestCustomizer urlVariables(Map<String, Object> variables) {
- if (variables!=null)
- this.variables = variables
- return this
- }
+ RequestCustomizer urlVariables(Map<String, Object> variables) {
+ if (variables!=null)
+ this.variables = variables
+ return this
+ }
RequestCustomizer body(content) {
if(content instanceof JSON) {
@@ -249,7 +258,6 @@ class RequestCustomizer {
else {
this.body = content
}
-
return this
}
View
27 test/unit/grails/plugins/rest/client/RestBuilderSpec.groovy
@@ -1,18 +1,16 @@
package grails.plugins.rest.client
-import org.codehaus.groovy.grails.web.json.*
-import groovy.util.slurpersupport.*
+import grails.converters.JSON
+import grails.test.mixin.TestMixin
+import grails.test.mixin.web.ControllerUnitTestMixin
+import grails.web.JSONBuilder
+import groovy.util.slurpersupport.GPathResult
-import grails.test.mixin.*
-import grails.test.mixin.web.*
-import spock.lang.*
+import org.codehaus.groovy.grails.web.json.JSONArray
+import org.codehaus.groovy.grails.web.json.JSONObject
-import grails.converters.*
-import grails.web.*
-import org.springframework.http.client.*
-import org.codehaus.groovy.grails.plugins.codecs.Base64Codec
-import groovy.util.slurpersupport.*
-import org.codehaus.groovy.grails.web.json.*
+import spock.lang.Issue
+import spock.lang.Specification
@TestMixin(ControllerUnitTestMixin)
class RestBuilderSpec extends Specification {
@@ -97,7 +95,6 @@ class RestBuilderSpec extends Specification {
resp.json instanceof JSONArray
}
-
def "Test basic authentication with PUT request"() {
given:"A rest client instance"
def rest = new RestBuilder()
@@ -136,7 +133,7 @@ class RestBuilderSpec extends Specification {
resp.text == "Group 'test-group' has been removed successfully."
}
- def "Test basic authentication with PUT request and JSON body"() {
+ def "Test basic authentication with PUT request and JSON body"() {
given:"A rest client instance"
def rest = new RestBuilder()
@@ -176,8 +173,7 @@ class RestBuilderSpec extends Specification {
resp.text == "Group 'test-group' has been removed successfully."
}
-
- def "Test basic authentication with PUT request and JSON as map"() {
+ def "Test basic authentication with PUT request and JSON as map"() {
given:"A rest client instance"
def rest = new RestBuilder()
@@ -264,4 +260,3 @@ class RestBuilderSpec extends Specification {
resp.json.name == 'acegi'
}
}
-

0 comments on commit 4422d4e

Please sign in to comment.