home | career | drupal | java | mac | mysql | perl | scala | uml | unix

Groovy example source code file (Groovy2350Bug.groovy)

This example Groovy source code file (Groovy2350Bug.groovy) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

defaultnoargctor, defaultnoargctor, defaultnoargctor2, defaultnoargctor2, groovy2350bug, groovytestcase, nodefaultctor, nodefaultctor, null, string, string

The Groovy Groovy2350Bug.groovy source code

package groovy.bugs

class Groovy2350Bug extends GroovyTestCase{

     void testNoArg () {
         shouldFail (org.codehaus.groovy.runtime.metaclass.MethodSelectionException) {
             def a = new DefaultNoArgCtor()
             println a

         assertEquals "NULL", new DefaultNoArgCtor2().value

     void testNoDefCtor () {
         def a = new NoDefaultCtor("first")
         assertEquals "toS: first", a.toString()

         def b = new NoDefaultCtor()
         assertEquals "toS: null", b.toString()

class NoDefaultCtor {
    def field

    NoDefaultCtor(param) { field= param }

    String toString() {
      return "toS: ${field}"

class DefaultNoArgCtor {
  DefaultNoArgCtor(String s) {}

  DefaultNoArgCtor(int s) {}

class DefaultNoArgCtor2 {
  String value

  DefaultNoArgCtor2(String s) {
      value = s ? s : "NULL"

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy Groovy2350Bug.groovy source code file:

new blog posts


Copyright 1998-2014 Alvin Alexander, alvinalexander.com
All Rights Reserved.