• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Questions abt Groovy environment

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dierk !!

Congratulations on the book.

Can you please share some info abt some of questions related to Groovy

1) Can we pass Groovy map, list and other collections objects from let say groovy interactive shell to some java api as input ?
2) Any IDE or any tools which can help in giving all the compile time error ?
I am not sure GMaven checks all the compile time error. Example of what I mean to say - if we have this line in Groovy Class 'Classs.forName(com.xyz.dept.project.something)' it should shout for spelling mistake in Classs ? How to take care of those ? Otherwise those showup as runtime error. GMaven compiles it fine, no compile time errors.
3) Can we make instance of Groovy class in java directly ? instead of using GroovyClassLoader and GroovyObject ? Also, does GroovyObject provide method invoking with args[] ?
4) Is Gunit in Eclipse smooth ?

Thanks,
Ajay

[ October 21, 2008: Message edited by: Ajay Jeswani ]
[ October 21, 2008: Message edited by: Ajay Jeswani ]
 
author
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ajay Jeswani:

Congratulations on the book.

Thanks a lot

1) Can we pass Groovy map, list and other collections objects from let say groovy interactive shell to some java api as input ?

Sure! That is what Groovy is all about!
2) Any IDE or any tools which can help in giving all the compile time error ?

Most complete IDE support is currently in IntelliJ IDEA followed by Netbeans and Eclipse.

I am not sure GMaven checks all the compile time error. Example of what I mean to say - if we have this line in Groovy Class 'Classs.forName(com.xyz.dept.project.something)' it should shout for spelling mistake in Classs ? How to take care of those ? Otherwise those showup as runtime error. GMaven compiles it fine, no compile time errors.

Well, from a Groovy perspective, your code is perfectly fine and there is no reason to throw an error at compile time. From the compiler perspective, 'Classs' may be just any reference (not necessarily a Class as you are entitled to capitalize any reference if you whish). The Groovy compiler cannot tell whether this reference will be available at runtime.
If you are in a _Class_ (as opposed to a _Script_) then IDE will give you an indication that the 'Classs' reference is not known at compile time (e.g. underline in IntelliJ).

3) Can we make instance of Groovy class in java directly ? instead of using GroovyClassLoader and GroovyObject ? Also, does GroovyObject provide method invoking with args[] ?

In case your Groovy Class is precompiled (which happens automatically inside the IDEs), then all you have to do in your Groovy code is "new MyGroovyClass()". In other words, there is no difference between Classes written in Groovy and Classes written in Java.

4) Is Gunit in Eclipse smooth ?

I don't have the slightest idea what GUnit is ;-)



keep groovin'
Dierk
 
Ajay Jeswani
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much Dierk.

By GUnit, I was refering to Groovy unit test for groovy like Junit for Java. I have faced issues running GUnit in eclipse many times it says 'Test Class Not Found'. Just wanted to know whats the best way to test Groovy Script and Class.
[ October 21, 2008: Message edited by: Ajay Jeswani ]
 
Dierk König
author
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JUnit is included in Groovy.

Lets say you have a file MyTest.groovy with content



Then you can simply run that test from the commandline:

or alternatively compile that class with groovyc or your IDE support and call the test exactly the same way as if it was written in Java (in IntelliJ IDEA, I simply right-click and select "Run Test" to start the internal JUnit support).

cheers
Dierk
 
reply
    Bookmark Topic Watch Topic
  • New Topic