Community
Participate
Working Groups
I am using the Eclipse Version 3.6.0 and TPTP Version. 4.7.0 I am using TPTP Test from Recoding. its completelly recorded. I need correlate the some value, that why i am using getBody() method. But its always seems null . Please tell me solution or alternative solution. ASAP
to help you, i would need some information, as what class do you use (and from what plugin if possible). the getBody() method name exists in several different classes (for example, org.eclipse.ui.forms.widgets.ScrolledForm.getBody() or org.eclipse.hyades.test.http.runner.getBody()) a code snipplet would be greatly appreciated many thanks in advance, Jerome
Hi Jerome Thanks for response. I had got at null value "org.eclipse.hyades.test.http.runner.getBody()" int nUser = HttpTestUtil.getCurrentUser(this); HttpResponse response = m_httpExecutor[nUser].execute(request); System.out.println("response.getBody ::"+response .getBody()); Here "response.getBody()" value is null displayed
getBody comes from "HttpElement" so it is inherited by all elements. by default, it is not initialized to initialize it, you have 2 choice : . call directly "setBody("body to be stored")" . use "requestHelper.setAttribute(RequestHelper.ATT_BODY /* 4 */,"body to be stored")" (inside org.eclipse.hyades.test.tools.core.http.util package) a sample of code that use this can be found inside : org.eclipse.hyades.test.tools.ui.http.internal.codegen.GenTestSuite.generateHttp : protected StringBuffer generateHttp(ITestCase testCase) { RequestHelper requestHelper = new RequestHelper(); requestHelper.setTestCase(testCase); HttpRequest request = requestHelper.createHttpRequest(); if(request == null) return null; StringBuffer sb = new StringBuffer(); sb.append(helper.getImportedName("org.eclipse.hyades.test.http.runner.HttpRequest")).append(" request = new ").append(helper.getImportedName("org.eclipse.hyades.test.http.runner.HttpRequest")).append("();"); String value = null; value = request.getMethod(); if(value != null) sb.append(NL).append("request.setMethod(\"").append(adjustString(value)).append("\");"); // aberns: we oly want to add this call if 'getThinkTime' and 'setThinkTime' methods // exist in ther HTTPRequest, to ensure compatiblity with older tests. The same applies to HTTPExecutor. if( think_time > 0 ) { long thinkTime = request.getThinkTime(); if( thinkTime == -1 ) thinkTime = think_time; if( thinkTime > 0 ) sb.append("\n").append("request.setThinkTime( calcThinkTime( ").append( thinkTime ).append(",").append(variance).append(" ));"); } value = request.getVersion(); if(value != null) sb.append(NL).append("request.setVersion(\"").append(adjustString(value)).append("\");"); value = request.getHost(); if(value != null) sb.append(NL).append("request.setHost(\"").append(adjustString(value)).append("\");"); if(request.getPort() > 0) sb.append(NL).append("request.setPort(").append(request.getPort()).append(");"); value = request.getAbsolutePath(); if(value != null) sb.append(NL).append("request.setAbsolutePath(\"").append(adjustString(value)).append("\");"); value = request.getBody(); if(value != null) sb.append(NL).append("request.setBody(\"").append(adjustString(value)).append("\");"); if (request.getPageNumber() >= 0) sb.append(NL).append("request.setPageNumber(").append(request.getPageNumber()).append(");"); (etc...., full source code available under cvs) other possible solution (i can't debug your example, so i have no clue what field is filled and what isn't) : HttpResponse is created from HttpRequest but does not copy its body field. but you can perhaps find it with this : response.getRequest().getBody() hope it helps you, Jerome
closing, works as designed