|
Groovy example source code file (NewExpressionTest.groovy)
The Groovy NewExpressionTest.groovy source codepackage groovy import org.codehaus.groovy.runtime.DummyBean class NewExpressionTest extends GroovyTestCase { void testNewInstance() { def cheese = new String( "hey you hosers" ) assert cheese != null println(cheese) } void testNewBeanNoArgs() { def bean = new DummyBean() assert bean.name == "James" assert bean.i == 123 } void testNewBean1Args() { def bean = new DummyBean("Bob") assert bean.name == "Bob" assert bean.i == 123 } void testNewBean2Args() { def bean = new DummyBean("Bob", 1707) assert bean.name == "Bob" assert bean.i == 1707 } void testNewInstanceWithFullyQualifiedName() { def bean = new org.codehaus.groovy.runtime.DummyBean("Bob", 1707) assert bean.name == "Bob" assert bean.i == 1707 } void testNewInstanceWithFullyQualifiedNameNotImported() { def bean = new java.io.File("Foo") println "Created $bean" assert bean != null } void testNewOnMultipleLines() { def bean = new File ("Foo") assert bean != null } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy NewExpressionTest.groovy source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.