Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
Many times you construct a header with multiple values then pass it to requestProperties map. It would be more groovy if it accepted a GString instead of having to cast it to a String
# Less Groovy - url.getText(requestProperties:[Authentication:"Basic $auth".toString()]) == 'Groovy a:b' # More Groovy - url.getText(requestProperties:[Authentication:"Basic $auth"]) == 'Groovy a:b'
Exception -
:test org.codehaus.groovy.runtime.URLGetTextTest > testGetTextFromURLWithParameters FAILED java.lang.ClassCastException: org.codehaus.groovy.runtime.GStringImpl cannot be cast to java.lang.String at org.codehaus.groovy.runtime.ResourceGroovyMethods.configuredInputStream(ResourceGroovyMethods.java:2026) at org.codehaus.groovy.runtime.ResourceGroovyMethods.newReader(ResourceGroovyMethods.java:2132) at org.codehaus.groovy.runtime.ResourceGroovyMethods.getText(ResourceGroovyMethods.java:665) at org.codehaus.groovy.runtime.ResourceGroovyMethods.getText(ResourceGroovyMethods.java:633) at org.codehaus.groovy.runtime.dgm$965.invoke(Unknown Source) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:122) at org.codehaus.groovy.runtime.URLGetTextTest.testGetTextFromURLWithParameters(URLGetTextTest.groovy:57) 1 test completed, 1 failed :test FAILED
Test -
diff --git a/src/test/org/codehaus/groovy/runtime/URLGetTextTest.groovy b/src/test/org/codehaus/groovy/runtime/URLGetTextTest.groovy index 8a037e5..29a5f59 100644 --- a/src/test/org/codehaus/groovy/runtime/URLGetTextTest.groovy +++ b/src/test/org/codehaus/groovy/runtime/URLGetTextTest.groovy @@ -53,6 +53,9 @@ class URLGetTextTest extends GroovyTestCase { assert url.getText(requestProperties:[a:'b']) == 'Groovy a:b' + def b = "b" + assert url.getText(requestProperties:[a:"$b"]) == 'Groovy a:b' + assert url.getText(useCaches:true, requestProperties:[a:'b']) == 'Groovy cached a:b' assert url.getText() == url.getText()