norricorp | 29 Jan 14:26 2015
Picon
Picon

[groovy-user] Eclipse junit groovy script

Hi, 
I have used groovy unit tests in eclipse and when run as a class they work.
But I was interested in running tests as a script (just out of interest).
I found this - http://groovy.codehaus.org/Unit+Testing - and setup a junit
configuration within eclipse (the example is in intellij). I set project to
my eclipse project, test class to groovy.util.AllTestSuite and left VM
arguments as default.
When I run the the configuration (named AllTestSuite) I get the following
Failed to invoke suite(): java.lang.NoClassDefFoundError:
org.apache.tools.ant.BuildLogger

Having searched this forum and googled, I notice the entries are form
several years ago. So obviously I am doing something pretty dumb.
Does anyone have any ideas?
Regadrs,
John

--
View this message in context: http://groovy.329449.n5.nabble.com/Eclipse-junit-groovy-script-tp5722324.html
Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

MarcHadfield | 28 Jan 00:04 2015

[groovy-user] Stackable Traits at runtime don't honor definition order


Hello all - 

when defined at runtime, stackable traits don't seem to honor the order in
withTraits(), whereas when defined statically they do.  Is this a groovy
bug, or am I doing something wrong?

Sample code with output follows.

Thanks!

Code:
trait D {
	void methodA() { print "D"; super.methodA() }
}
trait C {
	void methodA() { print "C"; super.methodA() }
}
trait B {
	void methodA() { print "B"; super.methodA() }
}
trait A {
	void methodA() { print "A" }
}

class M implements A, D, C, B { }
class Q {}

class MyDelegationTest {

(Continue reading)

Russel Winder | 27 Jan 19:05 2015
Picon

[groovy-user] Sanity check, pending IntelliJ IDEA error report

I have:

   <at> TailRecursive
  private static BigInteger iterate(final BigInteger i, final BigInteger a, final BigInteger b) {
    i < 1 ? a : iterate(i - 1, b, a + b)
  }

Which is clearly a trivial, and yet surprisingly interesting, bit of
Groovy code. Contextual note: the class in which this method resides is
marked  <at> CompileStatic.

Now the code works and the tests pass, which is good. However IntelliJ
IDEA insists on red-lining the iterate call claiming the values are
Integer, BigDecimal, Integer so there is no callable available. This is
IntelliJ IDEA being wrong isn't it…

--

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder <at> ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@...
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
Guillaume Laforge | 27 Jan 17:00 2015
Picon

[groovy-user] [ANN] Groovy Weekly #55

Hi all,

Here's the 55th Groovy Weekly edition:

Another busy week!

--
Guillaume Laforge
Groovy Project Manager
Pivotal, Inc.

Russel Winder | 27 Jan 11:24 2015
Picon

[groovy-user] Groovy and Apache Spark

Apache Spark publicizes it has Java, Scala and Python APIs, which begs
the questio of Kotlin, Ceylon and Groovy use. Is anyone already using it
from Groovy code. Is an API wrapper needed to make the Apache Spark Java
API more Groovy?

--

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder <at> ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@...
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
Jeremy Daggett | 26 Jan 20:53 2015
Picon

[groovy-user] JsonSlurper Deserialization Config?

Hi there!

I am working with JSON data that consistently uses snakey case in key names, however I want to convert these keys upon deserialization into a POGO like this:

    "some_key" : "value" -> "someKey" : "value"

I could provide an accessor like "getSomeKey()" to just return the value, but is there a way to slurp them in to lower camel case directly via JsonSlurper? Is there something like <at> JSONProperty that I could use [1]?

The GPath expressions using "object.some_key" is also awkward to use with the underscore names.

I can't find any documentation on how this might be achieved. Would I have to essentially convert all of the keys in the Map? 

Any pointers would be appreciated, thanks!

/jd

DECLOEDT Loic EVADERIS | 26 Jan 15:14 2015
Picon

[groovy-user] Question about protection of field

Hi all,

I was doing some basics tests on the beans feature of groovy and found a behavior I cannot understand. So, I would like your help on this.

I define a Person class with public properties: name, age, sex and a private field children. My problem is that The field ‘children’ can be set from another class and I did not find any way to do so.

You will find groovy files in attachment. I am using Groovy 2.3.7 for my development.

 

Regards,

Loïc.

 

--

Loïc Decloedt

CAD & Software Manager

eVaderis

 

Minatec Entreprise BHT

7, Parvis Louis Néel

38054 Grenoble Cedex 9

France

Attachment (Person.groovy): application/octet-stream, 791 bytes
Attachment (ProtectedPropTest.groovy): application/octet-stream, 857 bytes

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
DECLOEDT Loic EVADERIS | 26 Jan 14:41 2015
Picon

[groovy-user] Issue with documented way to run a script with a user base class

Hi,

I am working with the following tools:

-          JDK 1.7

-          Groovy 2.3.7

-          Eclipse Luna

I tested the method to run an external script by overriding its base class as documented in your doc page:

http://groovy.codehaus.org/Embedding+Groovy

However, when I apply this method, I have the following error:

java.lang.NoSuchMethodError: data.ScriptBaseTest$AbsScriptBaseTestScript: method <init>()V not found

                at Script1.<init>(Script1.groovy)

                at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

                at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

                at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

                at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

                at java.lang.Class.newInstance(Class.java:379)

                at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:420)

                at groovy.lang.GroovyShell.parse(GroovyShell.java:686)

                at groovy.lang.GroovyShell.evaluate(GroovyShell.java:568)

                at groovy.lang.GroovyShell.evaluate(GroovyShell.java:608)

                at groovy.lang.GroovyShell.evaluate(GroovyShell.java:579)

                at groovy.lang.GroovyShell$evaluate$0.call(Unknown Source)

                at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)

                at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)

                at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)

                at data.ScriptBaseTest.invalidTest(ScriptBaseTest.groovy:37)

 

Can you explain with this error is happening. Can I correct it in any way ?

 

In addition, I tried the method explained the method explained here, which works:

http://stackoverflow.com/questions/27027581/execute-groovy-script-in-java-with-specific-root-object

Is this method is better, can the documentation be updated?

 

Thanks,

Loïc.

 

--

Loïc Decloedt

CAD & Software Manager

eVaderis

 

Minatec Entreprise BHT

7, Parvis Louis Néel

38054 Grenoble Cedex 9

France

 

 

 

--

Loïc Decloedt

CAD & Software Manager

eVaderis

 

Minatec Entreprise BHT

7, Parvis Louis Néel

38054 Grenoble Cedex 9

France

Office : 04 38 7 81109

Mobile : 06 85 55 33 95

 

OC | 26 Jan 04:15 2015
Picon

[groovy-user] Can't install a dynamic property with capitalized name?!?

Subject says it all -- is this the desired behaviour? To me it feels VERY wrong...

===
51 /tmp> <q.groovy
class w {
  def CompiledOK='compiled OK'
  static main(av) {
    ExpandoMetaClass.enableGlobally()
    def mc=this.getMetaClass()
    def o=this.newInstance()
    ['okay','CompiledOK','Oops'].each {
      String getter="get${it.capitalize()}"
      if (!mc.respondsTo(this,getter,null))
        mc."get${it.capitalize()}"={ -> "instance getter '$it' OK" }
      println "$it -> "+o."$it"
    }
  }
}
52 /tmp> groovy q 
okay -> instance getter 'okay' OK
CompiledOK -> compiled OK
Caught: groovy.lang.MissingPropertyException: No such property: Oops for class: w
Possible solutions: oops
groovy.lang.MissingPropertyException: No such property: Oops for class: w
Possible solutions: oops
	at w$_main_closure1.doCall(q.groovy:11)
	at w.main(q.groovy:7)
53 /tmp> 
===
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Russel Winder | 25 Jan 16:36 2015
Picon

[groovy-user] Groovy and DevoxxUK 2015

There is far too much Java content at DevoxxUK, it really should be 
more Groovy. Get your proposals in… http://www.devoxx.co.uk/
--

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@...
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@...
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Sean Gilligan | 25 Jan 09:26 2015

[groovy-user] Issues with Groovy 2.4 traits -- compiler and IntellIJ

I'm seeing what I believe are two bugs in IntelliJ's Groovy support and
1 bug in the compiler itself:

1.  <at> SelfType is not recognized yet, so if I use  <at> CompileStatic and
 <at> SelfType IntelliJ complains the methods from the required "super" class
are not available.

2. I'm using optional method parameters in some of the trait methods and
getting this pop-up error: ""Default Initializers are not allowed in
abstract methods"

3. When I same trait with command-line Gradle I get a "Bug!" message
from the compiler, so I opened this JIRA issue:
http://jira.codehaus.org/browse/GROOVY-7275

This is the source file that is demonstrating all three problems:
https://github.com/msgilligan/bitcoin-spock/blob/msgilligan-cliapi-traits/src/main/groovy/com/msgilligan/bitcoin/rpc/BitcoinCLIAPI.groovy

Should I open bugs for #1 and #2 against IntelliJ? Are default/optional
method arguments allowed in traits?

Are there any suggested workarounds for any of these issues?

Thanks,

Sean

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Gmane