[jbosstools-commits] JBoss Tools SVN: r21946 - in trunk/ws/plugins/org.jboss.tools.ws.ui: src/org/jboss/tools/ws/ui/messages and 2 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Thu May 6 22:07:58 EDT 2010
Author: bfitzpat
Date: 2010-05-06 22:07:57 -0400 (Thu, 06 May 2010)
New Revision: 21946
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/AddMonitorDialog.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/WSTestUtils.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/DelimitedStringList.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView.java
Log:
OPEN - issue JBIDE-6253: Need a web service tester (JAX-WS and JAX-RS) in the tooling
https://jira.jboss.org/jira/browse/JBIDE-6253
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF 2010-05-06 18:19:08 UTC (rev 21945)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF 2010-05-07 02:07:57 UTC (rev 21946)
@@ -22,7 +22,9 @@
com.ibm.icu,
org.apache.axis,
javax.xml.soap,
- javax.xml.rpc
+ javax.xml.rpc,
+ org.eclipse.wst.internet.monitor.core,
+ org.eclipse.wst.internet.monitor.ui
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.ws.ui,
org.jboss.tools.ws.ui.messages,
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2010-05-06 18:19:08 UTC (rev 21945)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2010-05-07 02:07:57 UTC (rev 21946)
@@ -68,13 +68,15 @@
JBossWS_DelimitedStringList_EditValue_Dialog_Message=Specify the updated value below.
JAXRSWSTestView_Action_URL_Label=Action URL:
+JAXRSWSTestView_Configure_Monitor_Button=Configure Monitor
JAXRSWSTestView_HTTP_Method_Label=HTTP Method:
JAXRSWSTestView_Invoke_Label=Invoke
+JAXRSWSTestView_Open_Monitor_Button=Open Monitor
JAXRSWSTestView_Request_Body_Label=Request Body
JAXRSWSTestView_Request_Header_Label=Request Header
JAXRSWSTestView_Request_Parameters_Label=Request Parameters
-JAXRSWSTestView_Results_Body_Label=Results Body
-JAXRSWSTestView_Results_Header_Label=Results Header
+JAXRSWSTestView_Results_Body_Label=Response Body
+JAXRSWSTestView_Results_Header_Label=Response Header
JAXRSWSTestView_Service_URL_Label=Service URL:
JAXRSWSTestView_Set_Sample_Data_Label=Set Sample Data
JAXRSWSTestView_Web_Service_Type_Label=Web Service Type:
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java 2010-05-06 18:19:08 UTC (rev 21945)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java 2010-05-07 02:07:57 UTC (rev 21946)
@@ -91,8 +91,10 @@
public static String JBossWS_DelimitedStringList_EditValue_Dialog_Title;
public static String JBossWS_DelimitedStringList_EditValue_Dialog_Message;
public static String JAXRSWSTestView_Action_URL_Label;
+ public static String JAXRSWSTestView_Configure_Monitor_Button;
public static String JAXRSWSTestView_HTTP_Method_Label;
public static String JAXRSWSTestView_Invoke_Label;
+ public static String JAXRSWSTestView_Open_Monitor_Button;
public static String JAXRSWSTestView_Request_Body_Label;
public static String JAXRSWSTestView_Request_Header_Label;
public static String JAXRSWSTestView_Request_Parameters_Label;
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/WSTestUtils.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/WSTestUtils.java 2010-05-06 18:19:08 UTC (rev 21945)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/WSTestUtils.java 2010-05-07 02:07:57 UTC (rev 21946)
@@ -35,6 +35,7 @@
*/
public class WSTestUtils {
+ private static Map<?, ?> requestHeaders = null;
private static Map<?, ?> resultHeaders = null;
private static String EMPTY_STRING = ""; //$NON-NLS-1$
@@ -42,6 +43,10 @@
return WSTestUtils.resultHeaders;
}
+ public static Map<?, ?> getRequestHeaders() {
+ return WSTestUtils.requestHeaders;
+ }
+
/*
* Start building the web query. Append parameters to URL
*/
@@ -92,6 +97,10 @@
// build the complete URL
URL url = null;
if (query != null) {
+ // add the ? if there are parameters
+ if (!address.endsWith("?") && methodType.equalsIgnoreCase("GET") ) { //$NON-NLS-1$//$NON-NLS-2$
+ address = address + "?"; //$NON-NLS-1$
+ }
// add parms to the url if we have some
url = new URL(address + query);
} else {
@@ -116,7 +125,7 @@
// set whether this is a GET or POST
httpurlc.setRequestMethod(methodType);
- // if we are sending/receiving XML, make sure the connection knows
+ // if we have headers to add
if (headers != null && !headers.isEmpty()) {
Iterator<?> iter = headers.entrySet().iterator();
while (iter.hasNext()) {
@@ -126,12 +135,15 @@
}
}
+ requestHeaders = httpurlc.getRequestProperties();
+
// CONNECT!
httpurlc.connect();
// If we are doing a POST and we have some request body to pass along, do it
if (requestBody != null && ( methodType.equalsIgnoreCase("POST") //$NON-NLS-1$
|| methodType.equalsIgnoreCase("PUT"))) { //$NON-NLS-1$
+ requestBody = stripNLsFromXML(requestBody);
OutputStreamWriter out = new OutputStreamWriter(httpurlc.getOutputStream());
out.write(requestBody);
out.close();
@@ -149,7 +161,7 @@
br.close();
response = sb.toString();
- WSTestUtils.resultHeaders = httpurlc.getHeaderFields();
+ resultHeaders = httpurlc.getHeaderFields();
// disconnect explicitly (may not be necessary)
httpurlc.disconnect();
@@ -171,7 +183,7 @@
String soapIn = body;
/* Use AXIS to call the WS */
- String document = soapIn;
+ String document = stripNLsFromXML(soapIn);
Service service = new Service();
Call call= (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
@@ -180,7 +192,31 @@
call.setProperty(Call.SOAPACTION_USE_PROPERTY,Boolean.TRUE);
call.setProperty(Call.SOAPACTION_URI_PROPERTY,action);
}
- SOAPEnvelope envelope = call.invoke( new Message(document) );
- return envelope.getBody().toString().replaceAll("><",">\n<");//$NON-NLS-1$ //$NON-NLS-2$
+ Message message = new Message(document);
+ SOAPEnvelope envelope = call.invoke( message );
+ System.out.println(envelope.getHeaders().toString());
+
+ String cleanedUp = stripNLsFromXML(envelope.getBody().toString());
+ return cleanedUp;
}
+
+ public static String addNLsToXML( String incoming ) {
+ String outgoing = null;
+ if (incoming != null) {
+ outgoing = incoming.replaceAll("><",">\n<");//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return outgoing;
+ }
+
+ public static String stripNLsFromXML ( String incoming ) {
+ String outgoing = null;
+ if (incoming != null) {
+ outgoing = incoming.replaceAll(">\n<","><");//$NON-NLS-1$ //$NON-NLS-2$
+ if (outgoing.contains("\n"))//$NON-NLS-1$
+ outgoing.replaceAll("\n"," ");//$NON-NLS-1$ //$NON-NLS-2$
+ if (outgoing.contains("\r"))//$NON-NLS-1$
+ outgoing.replaceAll("\r"," ");//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return outgoing;
+ }
}
Added: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/AddMonitorDialog.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/AddMonitorDialog.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/AddMonitorDialog.java 2010-05-07 02:07:57 UTC (rev 21946)
@@ -0,0 +1,18 @@
+package org.jboss.tools.ws.ui.views;
+
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.internet.monitor.core.internal.provisional.IMonitorWorkingCopy;
+import org.eclipse.wst.internet.monitor.ui.internal.MonitorDialog;
+
+ at SuppressWarnings("restriction")
+public class AddMonitorDialog extends MonitorDialog {
+
+ public AddMonitorDialog(Shell parentShell) {
+ super(parentShell);
+ }
+
+ public IMonitorWorkingCopy getMonitor() {
+ return this.monitor;
+ }
+
+}
Property changes on: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/AddMonitorDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/DelimitedStringList.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/DelimitedStringList.java 2010-05-06 18:19:08 UTC (rev 21945)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/DelimitedStringList.java 2010-05-07 02:07:57 UTC (rev 21946)
@@ -51,12 +51,11 @@
private Button mEditButton;
private List mPropsList;
private Text mAddText;
- private Text mHiddenText;
private boolean isReadOnly = false;
// current delimiter
private String mDelimiter = DELIMITER;
-
+
// Warning
private String mWarning = null;
@@ -212,35 +211,13 @@
public void widgetSelected(SelectionEvent e) {
DelimitedStringList.this.mPropsList.removeAll();
- DelimitedStringList.this.mHiddenText.setText(DelimitedStringList.this.getSelection().trim());
updatePropertyButtons();
}
});
}
- {
- this.mHiddenText = new Text(this, SWT.BORDER);
- final GridData gridData = new GridData();
- gridData.horizontalSpan = 2;
- this.mHiddenText.setLayoutData(gridData);
- this.mHiddenText.setVisible(false);
- }
updatePropertyButtons();
}
- /**
- * Add a listener to receive notifications when the property list is
- * modified.
- *
- * @param listener
- */
- public void addModifyListener(ModifyListener listener) {
- this.mHiddenText.addModifyListener(listener);
- }
-
- public void removeModifyListener(ModifyListener listener) {
- this.mHiddenText.removeModifyListener(listener);
- }
-
public void dispose() {
super.dispose();
}
@@ -258,8 +235,6 @@
if (!isReadOnly){
this.mClearAllButton.setEnabled(true);
}
- String selected = getSelection();
- this.mHiddenText.setText(selected.trim());
this.mAddText.setSelection(0, this.mAddText.getText().length());
this.mAddText.setFocus();
}
@@ -293,9 +268,6 @@
if (this.mPropsList.getSelectionCount() == 1) {
int index = this.mPropsList.getSelectionIndex();
this.mPropsList.remove(index);
- String selected = getSelection();
- this.mHiddenText.setText(selected.trim());
-
try {
if (this.mPropsList.getItem(index) != null) {
this.mPropsList.select(index);
@@ -339,8 +311,6 @@
}
}
- String selected = getSelection();
- this.mHiddenText.setText(selected.trim());
this.mPropsList.setSelection(destination);
}
}
@@ -380,8 +350,6 @@
counter++;
}
- String selected = getSelection();
- this.mHiddenText.setText(selected.trim());
this.mPropsList.setSelection(destination);
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView.java 2010-05-06 18:19:08 UTC (rev 21945)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView.java 2010-05-07 02:07:57 UTC (rev 21946)
@@ -10,16 +10,25 @@
******************************************************************************/
package org.jboss.tools.ws.ui.views;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
@@ -28,12 +37,18 @@
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
+import org.eclipse.wst.internet.monitor.core.internal.provisional.IMonitor;
+import org.eclipse.wst.internet.monitor.core.internal.provisional.MonitorCore;
import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
import org.jboss.tools.ws.ui.utils.WSTestUtils;
+ at SuppressWarnings("restriction")
public class JAXRSWSTestView extends ViewPart {
+ private static final String TCPIP_VIEW_ID = "org.eclipse.wst.internet.monitor.view";//$NON-NLS-1$
private static final String DELETE = "DELETE";//$NON-NLS-1$
private static final String PUT = "PUT";//$NON-NLS-1$
private static final String POST = "POST";//$NON-NLS-1$
@@ -67,6 +82,8 @@
private TabItem parmsTab;
private DelimitedStringList parmsList;
+ private Button openTCPIPMonitorButton;
+ private Button addTCPIPMonitorButton;
/**
* The constructor.
@@ -81,13 +98,19 @@
public void createPartControl(Composite parent) {
Composite innerComposite = new Composite (parent, SWT.NONE);
- innerComposite.setLayout(new GridLayout(2, false));
+ innerComposite.setLayout(new FillLayout());
- Label typeLabel = new Label(innerComposite, SWT.NONE);
+ SashForm sashForm = new SashForm(innerComposite, SWT.BORDER);
+ sashForm.setOrientation(SWT.HORIZONTAL);
+
+ Composite topHalf = new Composite (sashForm, SWT.NONE);
+ topHalf.setLayout(new GridLayout(2, false));
+
+ Label typeLabel = new Label(topHalf, SWT.NONE);
typeLabel.setText(JBossWSUIMessages.JAXRSWSTestView_Web_Service_Type_Label);
typeLabel.setLayoutData(new GridData());
- wsTypeCombo = new Combo(innerComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
+ wsTypeCombo = new Combo(topHalf, SWT.DROP_DOWN | SWT.READ_ONLY);
wsTypeCombo.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
wsTypeCombo.add(JAX_WS);
wsTypeCombo.add(JAX_RS);
@@ -97,39 +120,65 @@
}
public void widgetSelected(SelectionEvent e) {
setControlsForWSType(wsTypeCombo.getText());
+ setControlsForMethodType(methodCombo.getText());
+ setControlsForSelectedURL();
}
});
- Label methodLabel = new Label(innerComposite, SWT.NONE);
+ Label methodLabel = new Label(topHalf, SWT.NONE);
methodLabel.setText(JBossWSUIMessages.JAXRSWSTestView_HTTP_Method_Label);
methodLabel.setLayoutData(new GridData());
- methodCombo = new Combo(innerComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
+ methodCombo = new Combo(topHalf, SWT.DROP_DOWN | SWT.READ_ONLY);
methodCombo.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
methodCombo.add(GET);
methodCombo.add(POST);
methodCombo.add(PUT);
methodCombo.add(DELETE);
methodCombo.setText(GET);
+ methodCombo.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ public void widgetSelected(SelectionEvent e) {
+ setControlsForMethodType(methodCombo.getText());
+ }
+ });
- Label urlLabel = new Label(innerComposite, SWT.NONE);
+ Label urlLabel = new Label(topHalf, SWT.NONE);
urlLabel.setText(JBossWSUIMessages.JAXRSWSTestView_Service_URL_Label);
urlLabel.setLayoutData(new GridData());
-// urlText = new Text(innerComposite, SWT.BORDER);
-// urlText.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
-
- urlCombo = new Combo(innerComposite, SWT.BORDER | SWT.DROP_DOWN);
+ urlCombo = new Combo(topHalf, SWT.BORDER | SWT.DROP_DOWN);
urlCombo.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
+ urlCombo.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ public void widgetSelected(SelectionEvent e) {
+ setControlsForSelectedURL();
+ }
+ });
+ urlCombo.addKeyListener(new KeyListener() {
+ public void keyPressed(KeyEvent e) {
+ }
- Label actionLabel = new Label(innerComposite, SWT.NONE);
+ public void keyReleased(KeyEvent e) {
+ setControlsForSelectedURL();
+ if (e.keyCode == SWT.CR) {
+ handleTest();
+ }
+ }
+ });
+
+ Label actionLabel = new Label(topHalf, SWT.NONE);
actionLabel.setText(JBossWSUIMessages.JAXRSWSTestView_Action_URL_Label);
actionLabel.setLayoutData(new GridData());
- actionText = new Text(innerComposite, SWT.BORDER);
+ actionText = new Text(topHalf, SWT.BORDER);
actionText.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
- tabGroup = new TabFolder(innerComposite, SWT.BORDER);
+ tabGroup = new TabFolder(topHalf, SWT.BORDER);
bodyTab = new TabItem(tabGroup, SWT.NONE, 0);
bodyTab.setText(JBossWSUIMessages.JAXRSWSTestView_Request_Body_Label);
@@ -150,7 +199,7 @@
bodyTab.setControl(bodyText);
headerTab.setText(JBossWSUIMessages.JAXRSWSTestView_Request_Header_Label);
- GridData hgGridData = new GridData(SWT.FILL, SWT.NONE, true, false);
+ GridData hgGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
hgGridData.horizontalSpan = 2;
tabGroup.setLayoutData(hgGridData);
@@ -160,23 +209,14 @@
dlsListGD.horizontalSpan = 2;
dlsList.setLayoutData(dlsListGD);
-// Button sampleButton = new Button(innerComposite, SWT.PUSH);
-// sampleButton.setText(JBossWSUIMessages.JAXRSWSTestView_Set_Sample_Data_Label);
-// sampleButton.setLayoutData(new GridData());
-//
-// sampleButton.addSelectionListener(new SelectionListener() {
-// public void widgetSelected(SelectionEvent e) {
-// setupSample();
-// }
-// public void widgetDefaultSelected(SelectionEvent e) {
-// widgetSelected(e);
-// }
-// });
+ Composite buttonBar = new Composite ( topHalf, SWT.NONE);
+ GridData buttonBarGD = new GridData(SWT.FILL, SWT.NONE, true, false);
+ buttonBarGD.horizontalSpan = 2;
+ buttonBar.setLayoutData(buttonBarGD);
+ buttonBar.setLayout(new RowLayout());
- GridData buttonGD = new GridData(SWT.BEGINNING, SWT.NONE, false, false);
- testButton = new Button (innerComposite, SWT.PUSH);
+ testButton = new Button (buttonBar, SWT.PUSH);
testButton.setText(JBossWSUIMessages.JAXRSWSTestView_Invoke_Label);
- testButton.setLayoutData(buttonGD);
testButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
@@ -187,7 +227,47 @@
}
});
- resultTabGroup = new TabFolder(innerComposite, SWT.BORDER);
+ addTCPIPMonitorButton = new Button(buttonBar, SWT.PUSH);
+ addTCPIPMonitorButton.setText(JBossWSUIMessages.JAXRSWSTestView_Configure_Monitor_Button);
+
+ addTCPIPMonitorButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ configureMonitor();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+
+ openTCPIPMonitorButton = new Button(buttonBar, SWT.PUSH);
+ openTCPIPMonitorButton.setText(JBossWSUIMessages.JAXRSWSTestView_Open_Monitor_Button);
+
+ openTCPIPMonitorButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ openMonitor();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+
+ Button sampleButton = new Button(buttonBar, SWT.PUSH);
+ sampleButton.setText(JBossWSUIMessages.JAXRSWSTestView_Set_Sample_Data_Label);
+ sampleButton.setVisible(false);
+
+ sampleButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ setupSample();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+
+ Composite bottomHalf = new Composite (sashForm, SWT.NONE);
+ bottomHalf.setLayout(new GridLayout(2, false));
+
+ resultTabGroup = new TabFolder(bottomHalf, SWT.BORDER);
GridData rtGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
rtGridData.horizontalSpan = 2;
resultTabGroup.setLayoutData(rtGridData);
@@ -208,8 +288,120 @@
wsTypeCombo.setText(JAX_WS);
setControlsForWSType(wsTypeCombo.getText());
+ setControlsForMethodType(methodCombo.getText());
+ setControlsForSelectedURL();
}
+ private void setControlsForSelectedURL() {
+ if (urlCombo.getText().trim().length() > 0) {
+ testButton.setEnabled(true);
+ addTCPIPMonitorButton.setEnabled(true);
+ } else {
+ testButton.setEnabled(false);
+ addTCPIPMonitorButton.setEnabled(false);
+ }
+ }
+
+ /*
+ * Open the TCP/IP Monitor View
+ */
+ private void openMonitor() {
+ try {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().
+ getActivePage().showView(TCPIP_VIEW_ID);
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private IMonitor findMonitor(String urlToCheck) {
+ IMonitor monitor = null;
+
+ IMonitor[] monitors = MonitorCore.getMonitors();
+ if (monitors != null && monitors.length > 0) {
+ for (int i= 0; i < monitors.length; i++) {
+ if (urlToCheck.contains(monitors[i].getRemoteHost())) {
+ monitor = monitors[i];
+ break;
+ }
+ }
+ }
+ return monitor;
+ }
+
+ /*
+ * Configure a TCP/IP Monitor entry so we can monitor it
+ */
+ private void configureMonitor() {
+ if (urlCombo.getText().trim().length() > 0) {
+ String oldUrl = urlCombo.getText();
+ IMonitor monitor = findMonitor(oldUrl);
+ if (monitor == null) {
+
+ URL tempURL = null;
+ try {
+ tempURL = new URL(oldUrl);
+ } catch (MalformedURLException e) {
+ // ignore
+ }
+ AddMonitorDialog dialog = new AddMonitorDialog(getSite().getShell());
+ if (tempURL != null) {
+ dialog.getMonitor().setRemoteHost(tempURL.getHost());
+ if (tempURL.getPort() > 0)
+ dialog.getMonitor().setRemotePort(tempURL.getPort());
+ }
+ if (dialog.open() == Window.CANCEL)
+ return;
+ monitor = dialog.getMonitor();
+ }
+
+ if (monitor != null) {
+ monitor = findMonitor(oldUrl);
+ if (monitor != null) {
+ if (!monitor.isRunning()) {
+ try {
+ monitor.start();
+ } catch (CoreException e) {
+ // if we hit an error, put it in the results text
+ resultsText.setText(e.toString());
+ e.printStackTrace();
+ }
+ }
+
+ int port = monitor.getLocalPort();
+ int remotePort = monitor.getRemotePort();
+ String host = monitor.getRemoteHost();
+ String newUrl = null;
+ if (oldUrl.contains(host + ":" + remotePort)) { //$NON-NLS-1$
+ newUrl = oldUrl.replace(host + ":" + remotePort, "localhost:" + port); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ newUrl = oldUrl.replace(host, "localhost:" + port); //$NON-NLS-1$
+ }
+ urlCombo.setText(newUrl);
+ }
+ }
+ }
+ }
+
+ /*
+ * Enable/disable controls based on the WS technology type
+ * and the method.
+ *
+ * @param methodType
+ */
+ private void setControlsForMethodType ( String methodType ) {
+ if (wsTypeCombo.getText().equalsIgnoreCase(JAX_RS) &&
+ methodType.equalsIgnoreCase(GET)) {
+ bodyText.setEnabled(false);
+ } else {
+ bodyText.setEnabled(true);
+ }
+ }
+
+ /*
+ * Enable/disable controls based on the WS technology type
+ * @param wsType
+ */
private void setControlsForWSType ( String wsType ) {
if (wsType.equalsIgnoreCase(JAX_WS)) {
actionText.setEnabled(true);
@@ -219,6 +411,19 @@
dlsList.setEnabled(false);
parmsTab.getControl().setEnabled(false);
headerTab.getControl().setEnabled(false);
+ methodCombo.setText(POST);
+
+ String emptySOAP = "<?xml version=\"1.0\" standalone=\"yes\" ?>" + //$NON-NLS-1$
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" " + //$NON-NLS-1$
+ "xmlns:ns=\"INSERT_URL_HERE\">" + //$NON-NLS-1$
+ "<soap:Body>" + //$NON-NLS-1$
+ "</soap:Body>" + //$NON-NLS-1$
+ "</soap:Envelope>"; //$NON-NLS-1$
+ emptySOAP = WSTestUtils.addNLsToXML(emptySOAP);
+
+ if (bodyText.getText().trim().length() == 0) {
+ bodyText.setText(emptySOAP);
+ }
}
else if (wsType.equalsIgnoreCase(JAX_RS)) {
actionText.setEnabled(false);
@@ -228,12 +433,14 @@
dlsList.setEnabled(true);
parmsTab.getControl().setEnabled(true);
headerTab.getControl().setEnabled(true);
+ methodCombo.setText(GET);
}
}
/*
* Sets up the controls to call a public sample RESTful WS that does
- * a postal code lookup.
+ * a postal code lookup or a JAX-WS service that does a
+ * Shakespeare lookup.
*/
private void setupSample() {
// go to http://www.geonames.org/export/web-services.html for example
@@ -256,6 +463,7 @@
"</ns:GetSpeech>"+ //$NON-NLS-1$
"</soap:Body>" + //$NON-NLS-1$
"</soap:Envelope>"; //$NON-NLS-1$
+ soapIn = WSTestUtils.addNLsToXML(soapIn);
urlCombo.setText("http://www.xmlme.com/WSShakespeare.asmx"); //$NON-NLS-1$
actionText.setText("http://xmlme.com/WebServices/GetSpeech"); //$NON-NLS-1$
@@ -264,8 +472,14 @@
dlsList.setSelection(EMPTY_STRING);
tabGroup.setSelection(bodyTab);
}
+ setControlsForWSType(wsTypeCombo.getText());
+ setControlsForMethodType(methodCombo.getText());
+ setControlsForSelectedURL();
}
+ /*
+ * Actually perform the test based on which type of activity it is
+ */
private void handleTest() {
if (urlCombo.getItemCount() > 0) {
java.util.List<String> aList = Arrays.asList(urlCombo.getItems());
@@ -290,7 +504,8 @@
private void handleWSTest() {
try {
String result = WSTestUtils.invokeWS(urlCombo.getText(), actionText.getText(), bodyText.getText());
- resultsText.setText(result);
+ String cleanedUp = WSTestUtils.addNLsToXML(result);
+ resultsText.setText(cleanedUp);
resultHeadersList.removeAll();
if (WSTestUtils.getResultHeaders() != null) {
@@ -322,8 +537,10 @@
// Is this a GET or POST activity?
String method = methodCombo.getText();
- // What's the Request body text?
- String body = bodyText.getText();
+ // If it's a GET, what's the Request body text?
+ String body = EMPTY_STRING;
+ if (method.equalsIgnoreCase(GET))
+ body = bodyText.getText();
// if no actual text in the request body, set to null
if (body.trim().length() == 0) body = null;
@@ -368,7 +585,8 @@
WSTestUtils.callRestfulWebService(address, parameters, headers, method, body);
// put the results in the result text field
- resultsText.setText(result);
+ String cleanedUp = WSTestUtils.addNLsToXML(result);
+ resultsText.setText(cleanedUp);
resultHeadersList.removeAll();
Iterator<?> iter = WSTestUtils.getResultHeaders().entrySet().iterator();
@@ -381,7 +599,7 @@
text = text + entry.toString();
resultHeadersList.add(text);
}
-
+
} catch (Exception e) {
// if we hit an error, put it in the results text
More information about the jbosstools-commits
mailing list