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.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( "Timeout", "timeout", true );
70  
71  		table.addProperty( "Bind Address", "bindAddress", true );
72  		table.addProperty( "Follow Redirects", "followRedirects", JPropertiesTable.BOOLEAN_OPTIONS );
73  
74  		StringList keystores = new StringList( request.getTestStep().getTestCase().getTestSuite().getProject()
75  				.getWssContainer().getCryptoNames() );
76  		keystores.add( "" );
77  		table.addProperty( "SSL Keystore", "sslKeystore", keystores.toStringArray() );
78  
79  		table.addProperty( "Strip whitespaces", "stripWhitespaces", JPropertiesTable.BOOLEAN_OPTIONS );
80  		table.addProperty( "Remove Empty Content", "removeEmptyContent", JPropertiesTable.BOOLEAN_OPTIONS );
81  		table.addProperty( "Entitize Properties", "entitizeProperties", JPropertiesTable.BOOLEAN_OPTIONS );
82  
83  		// post-processing
84  		table.addProperty( "Pretty Print", "prettyPrint", JPropertiesTable.BOOLEAN_OPTIONS );
85  		table.addProperty( "Dump File", "dumpFile", true ).setDescription( "Dumps response message to specified file" );
86  		table.addProperty( "Max Size", "maxSize", true ).setDescription( "The maximum number of bytes to receive" );
87  		table.setPropertyObject( request );
88  
89  		return table;
90  	}
91  
92  	public boolean hasOverviewPanel()
93  	{
94  		return true;
95  	}
96  }