View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2009 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.panels.teststeps;
14  
15  import javax.swing.JPanel;
16  
17  import com.eviware.soapui.impl.EmptyPanelBuilder;
18  import com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestInterface;
19  import com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep;
20  import com.eviware.soapui.support.components.JPropertiesTable;
21  import com.eviware.soapui.support.types.StringList;
22  
23  /***
24   * PanelBuilder for RestTestRequest
25   * 
26   * @author Ole.Matzura
27   */
28  
29  public class RestTestRequestPanelBuilder extends EmptyPanelBuilder<RestTestRequestStep>
30  {
31  	public RestTestRequestPanelBuilder()
32  	{
33  	}
34  
35  	public RestTestRequestDesktopPanel buildDesktopPanel( RestTestRequestStep testStep )
36  	{
37  		return new RestTestRequestDesktopPanel( testStep );
38  	}
39  
40  	public boolean hasDesktopPanel()
41  	{
42  		return true;
43  	}
44  
45  	public JPanel buildOverviewPanel( RestTestRequestStep testStep )
46  	{
47  		RestTestRequestInterface request = testStep.getTestRequest();
48  		JPropertiesTable<RestTestRequestInterface> table = new JPropertiesTable<RestTestRequestInterface>(
49  				"REST TestRequest Properties" );
50  
51  		// basic properties
52  		table.addProperty( "Name", "name", true );
53  		table.addProperty( "Description", "description", true );
54  		// table.addProperty( "Message Size", "contentLength", false );
55  		table.addProperty( "Encoding", "encoding", new String[] { null, "UTF-8", "iso-8859-1" } );
56  
57  		if( request.getOperation() == null )
58  		{
59  			table.addProperty( "Path", "path", true );
60  		}
61  		else
62  		{
63  			table.addProperty( "Endpoint", "endpoint", request.getInterface().getEndpoints() );
64  			table.addProperty( "Service", "serviceName" );
65  			table.addProperty( "Resource", "path" );
66  			table.addProperty( "Method", "restMethodName" );
67  		}
68  
69  		table.addProperty( "Bind Address", "bindAddress", true );
70  		table.addProperty( "Follow Redirects", "followRedirects", JPropertiesTable.BOOLEAN_OPTIONS );
71  
72  		StringList keystores = new StringList( request.getTestStep().getTestCase().getTestSuite().getProject()
73  				.getWssContainer().getCryptoNames() );
74  		keystores.add( "" );
75  		table.addProperty( "SSL Keystore", "sslKeystore", keystores.toStringArray() );
76  
77  		table.addProperty( "Strip whitespaces", "stripWhitespaces", JPropertiesTable.BOOLEAN_OPTIONS );
78  		table.addProperty( "Remove Empty Content", "removeEmptyContent", JPropertiesTable.BOOLEAN_OPTIONS );
79  		table.addProperty( "Entitize Properties", "entitizeProperties", JPropertiesTable.BOOLEAN_OPTIONS );
80  
81  		// post-processing
82  		table.addProperty( "Pretty Print", "prettyPrint", JPropertiesTable.BOOLEAN_OPTIONS );
83  		table.addProperty( "Dump File", "dumpFile", true ).setDescription( "Dumps response message to specified file" );
84  		table.addProperty( "Max Size", "maxSize", true ).setDescription( "The maximum number of bytes to receive" );
85  		table.setPropertyObject( request );
86  
87  		return table;
88  	}
89  
90  	public boolean hasOverviewPanel()
91  	{
92  		return true;
93  	}
94  }