Forum Discussion

atila_inovecky's avatar
atila_inovecky
New Contributor
9 years ago

Ambiguous method overloading for method java.lang.String#init

I use attached teardown script for raw request and response logging of REST transactions. It work correctly in case I run the the case. But it throws error message in case that I call particular Test Case from other Test Case by usage of "Run Test Case" step.

 

How should be correctly convert bytes[] to String in this case?

 

def myRequest = new java.lang.String( it.testRequest.response.getRawRequestData())

 

Error message:

Thu Oct 13 16:17:41 CEST 2016:ERROR:groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method java.lang.String#<init>.
Cannot resolve which method to invoke for [null] due to overlapping prototypes between:
	[class [B]
	[class [C]
	[class java.lang.String]
   groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method java.lang.String#<init>.
   Cannot resolve which method to invoke for [null] due to overlapping prototypes between:
   	[class [B]
   	[class [C]
   	[class java.lang.String]
   	at groovy.lang.MetaClassImpl.chooseMostSpecificParams(MetaClassImpl.java:2980)
   	at groovy.lang.MetaClassImpl.chooseMethodInternal(MetaClassImpl.java:2932)
   	at groovy.lang.MetaClassImpl.chooseMethod(MetaClassImpl.java:2875)
   	at groovy.lang.MetaClassImpl.createConstructorSite(MetaClassImpl.java:3129)
   	at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallConstructorSite(CallSiteArray.java:88)
   	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
   	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
   	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
   	at Script1$_run_closure1.doCall(Script1.groovy:30)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   	at java.lang.reflect.Method.invoke(Unknown Source)
   	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
   	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
   	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
   	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
   	at groovy.lang.Closure.call(Closure.java:411)
   	at groovy.lang.Closure.call(Closure.java:427)
   	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1325)
   	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1297)
   	at org.codehaus.groovy.runtime.dgm$148.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:108)
   	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
   	at Script1.run(Script1.groovy:10)
   	at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:92)
   	at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.runTearDownScript(WsdlTestCase.java:898)
   	at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTearDownScripts(AbstractTestCaseRunner.java:186)
   	at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalFinally(AbstractTestCaseRunner.java:171)
   	at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalFinally(AbstractTestCaseRunner.java:46)
   	at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:150)
   	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
   	at java.util.concurrent.FutureTask.run(Unknown Source)
   	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
   	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   	at java.lang.Thread.run(Unknown Source)

 

Teardown script:

 


import com.eviware.soapui.support.XmlHolder import com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext import java.text.SimpleDateFormat ; def currentStepInd = context.currentStepIndex log.info testRunner.testCase.getTestStepCount(); def soapuiRequests = testRunner.testCase.getTestStepsOfType(com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep) soapuiRequests.each{ Date startTime = new Date(); def mydate =new SimpleDateFormat("YYYYMMdd'T'HHmmss").format(new Date()) parentTest = it.getTestCase(); int stepIndex = parentTest.getIndexOfTestStep(it); def fileName = mydate + " " + String.format("%03d", stepIndex+1) + "."+ it.name def inputFileRequest = new File("C:\\soapui\\"+ fileName+" - REQUEST.txt") def inputFileResponse = new File("C:\\soapui\\"+ "" + fileName+ "- RESPONSE.html") //Writing soapUI response and request to the file inputFileResponse.write(it.testRequest.response.getResponseContent()) def myRequest = new java.lang.String( it.testRequest.response.getRawRequestData()) inputFileRequest.write(myRequest) // inputFileRequest.write(it.testRequest.response.getRequestContent(

 

 

No RepliesBe the first to reply