Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 319118 - getBody() method seems null
Summary: getBody() method seems null
Status: CLOSED WORKSFORME
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: TPTP (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P2 blocker (vote)
Target Milestone: ---   Edit
Assignee: Bozier jerome CLA
QA Contact: Kathy Chan CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-07 08:37 EDT by Murthy Killada CLA
Modified: 2016-05-05 10:32 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Murthy Killada CLA 2010-07-07 08:37:41 EDT
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
Comment 1 Bozier jerome CLA 2010-07-19 06:07:49 EDT
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
Comment 2 Murthy Killada CLA 2010-07-20 05:57:52 EDT
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
Comment 3 Bozier jerome CLA 2010-07-28 05:16:33 EDT
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
Comment 4 Bozier jerome CLA 2010-08-09 09:45:47 EDT
closing, works as designed