kids
resume
links
jbum
jblog
recommendations
about
Bob's musings... (cc:world)        bob@jadn.com groovy.rss
Geb, Gradle, Groovy Console - Tuesday, 19 October 2010 Categories: all, groovy 

Quite pleased with my short time with Geb (a groovy browser automation solution.) All 76 permutations of form filling now automated!! (took about 2 hours.) Now integration testing is going to be a breeze.

I used this short gradle script:

apply plugin: 'groovy'
apply plugin: 'idea'
repositories {
    mavenRepo urls: ["http://repo1.maven.org/maven2"]
    mavenCentral()
}
dependencies {
     groovy group: 'org.codehaus.groovy', name: 'groovy', version: '1.7.5'
     compile "org.codehaus.geb:geb-core:latest.release",
        "org.seleniumhq.selenium:selenium-firefox-driver:latest.release"
     testCompile 'junit:junit:4.7'
}
task(console, dependsOn: 'classes', type: JavaExec) {
    main = 'groovy.ui.Console'
    classpath = sourceSets.main.runtimeClasspath
}
Which lets you bring up a groovy console to test out groovy/geb code. Like so
     $ gradle console
And then noodle with a script until it's ready to be knighted as a unit test....
import geb.*
import org.openqa.selenium.firefox.FirefoxDriver

Browser.drive( new FirefoxDriver(), "http://google.com" ){
    go()   
    assert title == "Google" 
    $("input", name: "q").value("wikipedia")
    $("input", value: "Google Search").click()
}
Extra sweet!!

If you need a Grails/Gradle/Griffon/Android/Java hacker, I'm seeking my next gig right now!!

Groovy web server using only the JDK in 8 lines please - Thursday, 08 July 2010 Categories: all, groovy 

// Groovy web server using only the JDK in 8 lines please
import com.sun.net.httpserver.*;
HttpServer server = HttpServer.create(new InetSocketAddress(2222),0)
server.createContext('/', { HttpExchange exchange ->
    exchange.sendResponseHeaders(200,0);
    exchange.responseBody.write('hello from groovy land.'.bytes)
    exchange.responseBody.close();
}  as HttpHandler)
server.start();

Groovy Console Tip - Wednesday, 28 October 2009 Categories: all, groovy 

I hack lots of small stuff together using the Groovy and Grails Consoles (using Groovy 1.5.x and Grails 1.0.3 - I know, I know... old versions...) A handy way to make your script so that it can be interrupted is to simply insert "Thread.sleep(0)" in any loop your doing. When you send it an interrupt the Sleep will throw a runtime and stop your script.

while(true){
    println 'getting wiki text'
    new URL('http://wiki').text
    Thread.sleep(0)
}

Giving the Grails Console some recall - Monday, 13 July 2009 Categories: all, groovy 

The Grails Console is a handy way to try and tinker with stuff. If you switch back to your editor/IDE and change a domain or controller class, the console restarts. This is good, but it drops all the tinkering that you were doing. That can mean a loosing quite a bit of work.

At a coworkers suggestion, I tried modifying the Grails Console to save the current text during a restart. This is what I did and it works. Edit $GRAILS_HOME/scripts/console.groovy and replace the existing monitorCallback with this one

       monitorCallback = {
            def text = console.inputArea.text
            println "Exiting console"
            console.exit()
            println "Console had ---\n$text\n---"
            createConsole()
            println " Restarting console"
            console.run()
            // wait for inputArea to be constructed
            Thread.sleep(500)
            console.inputArea.text = text
        }
Yea, the sleep is grotty, but without it the inputArea wasnt always constructed in time (race.) It dumps the current script to the console as a cut/paste backup if the console doesnt reload in a happy way.

Boston Grails Consultant needed - Monday, 15 June 2009 Categories: all, groovy 

A friend of mine says

We are a small company in Waltham, Massachusetts looking for a full-time Grails contractor for 3 months (Q3). Even a talented J2EE contractor could be of interest (with a passion for learning new technology), although a Grails developer would be our first priority.
Anyone looking in the Boston area?

Part time Groovy Gig in Boston Area - Thursday, 23 April 2009 Categories: all, groovy 

A buddy of mine, @cutshot, is looking for a part time (1-3 month) Groovy developer to help out with a project. Any groovy people in the Boston Area looking for some work?

IntelliJ and HumanTime - Friday, 06 February 2009 Categories: all, groovy 

Two interesting things I found today.

I use IntelliJ a lot when working on Grails and Groovy projects. Since IntelliJ doesn't have Eclipe's quick overview feature (Control-o), I do a lot of searhing when using IntelliJ. Alas the incremental search in IntelliJ, marks stuff yellow... and it doesnt clear it when you change your search. After a few searches your file is too yellow too look at. To clear all the highlighting, just hit escape twice. (thanks Ed for finding this one.)

I wanted to display how long it took to process something, but I wanted it to be readable by humans.

ie. Loading data took 1h 3m 33s
and NOT
Loading data took 28882 seconds
This little class makes that pretty easy, Date Formatting and Parsing for Humans in Java with HumanTime

Although I still wish I had a nice solution that would just do days.

println daysAgo( new Date(0) )
with output like
30 years, 2 months and 12 days ago

Make commuting (or treadmill time) fun with a groovy podcast downloader - Thursday, 13 November 2008 Categories: all, groovy 

Make commuting (or treadmill time) fun with a groovy podcast downloader

I've received quite a bit of feedback on my earlier release of my groovy podcast downloader script. I've folded in this feedback.

Take a spin at http://github.com/bherrmann7/podcast-get/tree/master/src/pget.groovy Enjoy!! Please send along feedback! bob@jadn.com

YES, THERE IS MORE!!!
To read my older drivel, CLICK HERE    Don't say I didnt warn you.
Made using jblog.sf.net