1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.panels.testcase.actions;
14
15 import java.awt.event.ActionEvent;
16 import java.util.HashSet;
17 import java.util.Set;
18
19 import javax.swing.AbstractAction;
20 import javax.swing.Action;
21 import javax.swing.JOptionPane;
22
23 import com.eviware.soapui.SoapUI;
24 import com.eviware.soapui.impl.wsdl.WsdlTestCase;
25 import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep;
26 import com.eviware.soapui.model.testsuite.TestStep;
27
28 /***
29 * Action for setting the endpoint for all requests in a testcase
30 *
31 * @author Ole.Matzura
32 */
33
34 public class SetEndpointAction extends AbstractAction
35 {
36 private final WsdlTestCase testCase;
37
38 public SetEndpointAction( WsdlTestCase testCase )
39 {
40 this.testCase = testCase;
41 putValue( Action.SMALL_ICON, SoapUI.createImageIcon( "/set_endpoint.gif"));
42 putValue( Action.SHORT_DESCRIPTION, "Sets the endpoint for all requests in this testcase" );
43 }
44
45 public void actionPerformed(ActionEvent e)
46 {
47 Set<String> endpointSet = new HashSet<String>();
48
49 for( int c = 0; c < testCase.getTestStepCount(); c++ )
50 {
51 TestStep step = testCase.getTestStepAt( c );
52 if( step instanceof WsdlTestRequestStep )
53 {
54 WsdlTestRequestStep requestStep = (WsdlTestRequestStep) step;
55 String [] endpoints = requestStep.getTestRequest().getOperation().getInterface().getEndpoints();
56 for( int i = 0; i < endpoints.length; i++ )
57 {
58 endpointSet.add( endpoints[i] );
59 }
60 }
61 }
62
63 String selected = (String) JOptionPane.showInputDialog( SoapUI.getInstance().getFrame(),
64 "Select endpoint to set for all requests", "Set endpoint",
65 JOptionPane.QUESTION_MESSAGE, null, endpointSet.toArray(), null );
66
67 if( selected == null ) return;
68
69 for( int c = 0; c < testCase.getTestStepCount(); c++ )
70 {
71 TestStep step = testCase.getTestStepAt( c );
72 if( step instanceof WsdlTestRequestStep )
73 {
74 WsdlTestRequestStep requestStep = (WsdlTestRequestStep) step;
75 requestStep.getTestRequest().setEndpoint( selected );
76 }
77 }
78 }
79 }