(Slightly) Groovier Groovy


package net.unicon;
import javax.servlet.http.HttpServletRequest;

class ThingTest2 extends GroovyTestCase { 

  void testTestMe() {
    //We don't have to declare our types if we don't want to.
    def name = "x";
    def value = "42";
    def request = [ getAttribute : { n -> ( n == name ? value : null) } ] as HttpServletRequest;
    def thing = new Thing2();  
    //I have a feeling there's an easier way than "Integer.parseInt"
    assertEquals(0, thing.testMe(request, "phonyname"));
  }
}
Typing in Groovy is optional.
Next