Skip to content

Instantly share code, notes, and snippets.

View ddelponte's full-sized avatar

Dean Del Ponte ddelponte

  • Milwaukee, WI, USA
View GitHub Profile
@ddelponte
ddelponte / remoteTomcatRestart.groovy
Last active February 4, 2016 11:39
Restart remote tomcat instance
/**
* This script restarts a remote tomcat instance
* Usage: groovy restartRemoteTomcat.groovy or groovy restartRemoteTomcat.groovy remoteServer remoteUser pathToTomcatBinDirectory
* Example: groovy restartRemoteTomcat myServer username "/home/username/apache-tomcat-7.0.39/bin/"
*/
@Grapes([
@Grab('org.apache.ant:ant:1.8.3'),
@Grab(group = 'ant', module = 'ant-jsch', version = '1.6.5'),
@Grab(group = 'com.jcraft', module = 'jsch', version = '0.1.48'),
@ddelponte
ddelponte / grailsMimeUtility.groovy
Created July 31, 2013 12:49
How to get mimeType from file extension in Grails. Be sure to inject grailsMimeUtility into your controller or service before calling it.
def mimeType = grailsMimeUtility.getMimeTypeForExtension(extension)
println mimeType.name
@ddelponte
ddelponte / ServiceMock.groovy
Created August 9, 2013 19:48
How to mockout a service depended on by a controller. For more info, please see: http://refaktor.blogspot.com/2012/08/how-to-use-mocks-in-controller-tests.html
TwitterReaderService twitterReaderServiceMock = Mock(TwitterReaderService)
def setup() {
controller.twitterReaderService = twitterReaderServiceMock
}
@ddelponte
ddelponte / runAsyncMock.groovy
Created September 12, 2013 12:29
runAsync mocking
service.metaClass.runAsync = { it() }
// The first line basically says ‘take the code within the runAsync closure, and just execute it’.
// http://fbflex.wordpress.com/2011/10/26/grails-quick-tip-testing-spock-interactions-wrapped-by-the-executor-plugin/
@ddelponte
ddelponte / configurations
Last active August 29, 2015 13:58
Grails IntelliJ Settings
run-app -debug -reloading
-XX:MaxPermSize=512m -Xmx4096m
// To run in grails 2.4
grails -debug test-app
@ddelponte
ddelponte / BuildConfig.groovy
Last active August 29, 2015 13:59
Inline Plugin configuration
// Inline Testing
grails.plugin.location."platform-ui" = "../grails-platform-ui"
@ddelponte
ddelponte / Config.groovy
Last active August 29, 2015 13:59
Config.groovy for platform-ui and grails 2.3.x
plugin.platformCore.events.catchFlushExceptions = true
@ddelponte
ddelponte / BuildConfig.groovy
Created May 21, 2014 14:27
Write everything to target directory so it's easy to cleanup
//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"
@ddelponte
ddelponte / CriteriaProjections.groovy
Last active August 29, 2015 14:01
Have criteria projections return a map
import org.hibernate.criterion.CriteriaSpecification
BlogEntry.withCriteria {
maxResults 5
resultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP)
projections {
count('id', 'total')
groupProperty('author', 'author')
}
}
@ddelponte
ddelponte / SomeIntegrationSpec.groovy
Created May 28, 2014 14:29
Integration tests pass individually but fail when run as a suite
// Convert
myCoolemailService.myEmailService = Mock(MyEmailService)
// to
myCoolemailService.myEmailService = Mock([useObjenesis: false], MyEmailService)