View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 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.action.swing.ActionList;
20  import com.eviware.soapui.support.xml.XmlUtils;
21  
22  /***
23   * TestStep Result for a WsdlMessageExchange
24   * 
25   * @author ole.matzura
26   */
27  
28  public class WsdlSingleMessageExchangeTestStepResult extends WsdlTestStepResult
29  {
30  	private WsdlMessageExchange messageExchange;
31  	private boolean addedAction;
32  
33  	// private StringToStringMap properties;
34  
35  	public WsdlSingleMessageExchangeTestStepResult( WsdlTestStep step )
36  	{
37  		super( step );
38  	}
39  
40  	public void setMessageExchange( WsdlMessageExchange messageExchange )
41  	{
42  		this.messageExchange = messageExchange;
43  	}
44  
45  	@Override
46  	public ActionList getActions()
47  	{
48  		if( !addedAction )
49  		{
50  			addAction( new ShowMessageExchangeAction( messageExchange, "StepResult" ), true );
51  			addedAction = true;
52  		}
53  
54  		return super.getActions();
55  	}
56  
57  	// public String getRequestContent()
58  	// {
59  	// if( isDiscarded() )
60  	// return "<discarded>";
61  	//		
62  	// return messageExchange == null ? null :
63  	// messageExchange.getRequestContent();
64  	// }
65  	//
66  	// public void addProperty( String name, String value )
67  	// {
68  	// if( isDiscarded() )
69  	// return;
70  	//		
71  	// if( properties == null )
72  	// properties = new StringToStringMap();
73  	//		
74  	// properties.put( name, value );
75  	// }
76  
77  	public void discard()
78  	{
79  		super.discard();
80  
81  		messageExchange = null;
82  		// properties = null;
83  	}
84  
85  	public void writeTo( PrintWriter writer )
86  	{
87  		super.writeTo( writer );
88  
89  		if( isDiscarded() )
90  			return;
91  
92  		// writer.println( "---------------- Properties ------------------------"
93  		// );
94  		// if( properties == null )
95  		// {
96  		// writer.println( "Missing Properties" );
97  		// }
98  		// else
99  		// {
100 		// for( String name : properties.keySet() )
101 		// writer.println( name + ": " + properties.get( name ) );
102 		// }
103 
104 		writer.println( "---------------- Message Exchange ------------------" );
105 		if( messageExchange == null )
106 		{
107 			writer.println( "Missing MessageExchange" );
108 		}
109 		else
110 		{
111 			writer.println( "--- Request" );
112 			if( messageExchange.getRequestHeaders() != null )
113 				writer.println( "Request Headers: " + messageExchange.getRequestHeaders().toString() );
114 
115 			writer.println( XmlUtils.prettyPrintXml( messageExchange.getRequestContent() ) );
116 
117 			writer.println( "--- Response" );
118 			if( messageExchange.getResponseHeaders() != null )
119 				writer.println( "Response Headers: " + messageExchange.getResponseHeaders().toString() );
120 
121 			writer.println( XmlUtils.prettyPrintXml( messageExchange.getResponseContent() ) );
122 		}
123 	}
124 
125 	// public StringToStringMap getProperties()
126 	// {
127 	// return properties;
128 	// }
129 }