RestRequestStepResult testStepResult = new RestRequestStepResult( this );
try
{
submit = testRequest.submit( runContext, false );
HttpResponse response = ( HttpResponse )submit.getResponse();
if( submit.getStatus() != Submit.Status.CANCELED )
{
if( submit.getStatus() == Submit.Status.ERROR )
{
testStepResult.setStatus( TestStepStatus.FAILED );
testStepResult.addMessage( submit.getError().toString() );
testRequest.setResponse( null, runContext );
}
else if( response == null )
{
testStepResult.setStatus( TestStepStatus.FAILED );
testStepResult.addMessage( "Request is missing response" );
testRequest.setResponse( null, runContext );
}
else
{
runContext.setProperty( AssertedXPathsContainer.ASSERTEDXPATHSCONTAINER_PROPERTY, testStepResult );
testRequest.setResponse( response, runContext );
testStepResult.setTimeTaken( response.getTimeTaken() );
testStepResult.setSize( response.getContentLength() );
testStepResult.setResponse( response );
switch( testRequest.getAssertionStatus() )
{
case FAILED :
testStepResult.setStatus( TestStepStatus.FAILED );
break;
case VALID :
testStepResult.setStatus( TestStepStatus.OK );
break;
case UNKNOWN :
testStepResult.setStatus( TestStepStatus.UNKNOWN );
break;
}
}
}
else
{
testStepResult.setStatus( TestStepStatus.CANCELED );
testStepResult.addMessage( "Request was canceled" );
}
if( response != null )
{
testStepResult.setRequestContent( response.getRequestContent() );
testStepResult.addProperty( "URL", response.getURL() == null ? "<missing>" : response.getURL().toString() );
testStepResult.addProperty( "Method", String.valueOf( response.getMethod() ) );
testStepResult.addProperty( "StatusCode", String.valueOf( response.getStatusCode() ) );
testStepResult.addProperty( "HTTP Version", response.getHttpVersion() );
}
else
{
testStepResult.addMessage( "Missing Response" );
testStepResult.setRequestContent( testRequest.getRequestContent() );