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.panels.teststeps;
14  
15  import com.eviware.soapui.impl.EmptyPanelBuilder;
16  import com.eviware.soapui.impl.rest.panels.request.AbstractRestRequestDesktopPanel;
17  import com.eviware.soapui.impl.wsdl.teststeps.HttpTestRequestStep;
18  import com.eviware.soapui.impl.wsdl.teststeps.RestTestRequest;
19  import com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep;
20  import com.eviware.soapui.support.components.JPropertiesTable;
21  
22  import javax.swing.*;
23  
24  /***
25   * PanelBuilder for HttpTestRequest
26   *
27   * @author Ole.Matzura
28   */
29  
30  public class HttpTestRequestPanelBuilder extends EmptyPanelBuilder<HttpTestRequestStep>
31  {
32     public HttpTestRequestPanelBuilder()
33     {
34     }
35  
36     public AbstractRestRequestDesktopPanel buildDesktopPanel( HttpTestRequestStep testStep )
37     {
38        return testStep instanceof RestTestRequestStep ? new RestTestRequestDesktopPanel( (RestTestRequestStep) testStep ) :
39                new HttpTestRequestDesktopPanel( testStep );
40     }
41  
42     public boolean hasDesktopPanel()
43     {
44        return true;
45     }
46  
47     public JPanel buildOverviewPanel( HttpTestRequestStep testStep )
48     {
49        RestTestRequest request = testStep.getTestRequest();
50        JPropertiesTable<RestTestRequest> table = new JPropertiesTable<RestTestRequest>( "REST TestRequest Properties" );
51  
52        // basic properties
53        table.addProperty( "Name", "name", true );
54        table.addProperty( "Description", "description", true );
55  //   	table.addProperty( "Message Size", "contentLength", false );
56        table.addProperty( "Encoding", "encoding", new String[] { null, "UTF-8", "iso-8859-1" } );
57  
58        if( request.getOperation() != null )
59           table.addProperty( "Endpoint", "endpoint", request.getInterface().getEndpoints() );
60  
61        table.addProperty( "Path", "path", true );
62  
63        table.addProperty( "Bind Address", "bindAddress", true );
64  
65        if( request.getOperation() != null )
66        {
67           table.addProperty( "Service", "service" );
68           table.addProperty( "Resource", "resourcePath" );
69        }
70  
71        // security / authentication
72        table.addProperty( "Username", "username", true );
73        table.addProperty( "Password", "password", true );
74        table.addProperty( "Domain", "domain", true );
75  
76        // post-processing
77        table.addProperty( "Pretty Print", "prettyPrint", JPropertiesTable.BOOLEAN_OPTIONS );
78        table.addProperty( "Dump File", "dumpFile", true ).setDescription( "Dumps response message to specified file" );
79        table.addProperty( "Max Size", "maxSize", true ).setDescription( "The maximum number of bytes to receive" );
80        table.setPropertyObject( request );
81  
82        return table;
83     }
84  
85     public boolean hasOverviewPanel()
86     {
87        return true;
88     }
89  }