View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2008 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12  
13  package com.eviware.soapui.impl.wsdl.teststeps;
14  
15  import java.io.PrintWriter;
16  
17  import com.eviware.soapui.impl.wsdl.submit.WsdlMessageExchange;
18  import com.eviware.soapui.impl.wsdl.teststeps.actions.ShowMessageExchangeAction;
19  import com.eviware.soapui.support.xml.XmlUtils;
20  
21  /***
22   * TestStep Result for a WsdlMessageExchange
23   * 
24   * @author ole.matzura
25   */
26  
27  public class WsdlSingleMessageExchangeTestStepResult extends WsdlTestStepResult
28  {
29  	private WsdlMessageExchange messageExchange;
30  //	private StringToStringMap properties;
31  	
32  	public WsdlSingleMessageExchangeTestStepResult(WsdlTestStep step )
33  	{
34  		super( step );
35  	}
36  	
37  	public void setMessageExchange( WsdlMessageExchange messageExchange )
38  	{
39  		this.messageExchange = messageExchange;
40  		addAction( new ShowMessageExchangeAction( messageExchange, "StepResult" ), true );
41  	}
42  
43  //	public String getRequestContent()
44  //	{
45  //		if( isDiscarded() )
46  //			return "<discarded>";
47  //		
48  //		return messageExchange == null ? null : messageExchange.getRequestContent();
49  //	}
50  //
51  //	public void addProperty( String name, String value )
52  //	{
53  //		if( isDiscarded() )
54  //			return;
55  //		
56  //		if( properties == null )
57  //			properties = new StringToStringMap();
58  //		
59  //		properties.put( name, value );
60  //	}
61  	
62  	public void discard()
63  	{
64  		super.discard();
65  		
66  		messageExchange = null;
67  //		properties = null;
68  	}
69  
70  	public void writeTo(PrintWriter writer)
71  	{
72  		super.writeTo( writer );
73  		
74  		if( isDiscarded() )
75  			return;
76  		
77  //		writer.println( "---------------- Properties ------------------------" );
78  //		if( properties == null  )
79  //		{
80  //			writer.println( "Missing Properties" );
81  //		}
82  //		else
83  //		{
84  //			for( String name : properties.keySet() )
85  //				writer.println( name + ": " + properties.get( name ) );
86  //		}
87  
88  		writer.println( "---------------- Message Exchange ------------------" );
89  		if( messageExchange == null )
90  		{
91  			writer.println( "Missing MessageExchange" );
92  		}
93  		else
94  		{
95  			writer.println( "--- Request" );
96  			if( messageExchange.getRequestHeaders() != null )
97  				writer.println( "Request Headers: " + messageExchange.getRequestHeaders().toString() );
98  			
99  			writer.println( XmlUtils.prettyPrintXml( messageExchange.getRequestContent() ) );
100 
101 			writer.println( "--- Response" );
102 			if( messageExchange.getResponseHeaders() != null )
103 				writer.println( "Response Headers: " + messageExchange.getResponseHeaders().toString() );
104 			
105 			writer.println( XmlUtils.prettyPrintXml( messageExchange.getResponseContent() ) );
106 		}
107 	}
108 
109 //	public StringToStringMap getProperties()
110 //	{
111 //		return properties;
112 //	}
113 }