public void actionPerformed(ActionEvent e) { boolean createOptional = request .getSettings() .getBoolean(WsdlSettings.XML_GENERATION_ALWAYS_INCLUDE_OPTIONAL_ELEMENTS); if (!createOptional) { Boolean create = UISupport.confirmOrCancel("Create optional elements in schema?", "Create Request"); if (create == null) return; createOptional = create.booleanValue(); } WsdlOperation wsdlOperation = (WsdlOperation) request.getOperation(); String req = wsdlOperation.createRequest(createOptional); if (req == null) { UISupport.showErrorMessage("Request creation failed"); return; } if (request.getRequestContent() != null && request.getRequestContent().trim().length() > 0) { if (UISupport.confirm("Keep existing values", "Recreate Request")) { req = SoapUtils.transferSoapHeaders( request.getRequestContent(), req, wsdlOperation.getInterface().getSoapVersion()); req = XmlUtils.transferValues(request.getRequestContent(), req); } } request.setRequestContent(req); }
public void perform(WsdlProject project, Object param) { if (project.isRemote()) { String path = UISupport.prompt("Reload remote project URL", getName(), project.getPath()); if (path != null) { try { project.reload(path); } catch (SoapUIException ex) { UISupport.showErrorMessage(ex); } } } else { File file = UISupport.getFileDialogs() .open( this, "Reload Project", ".xml", "SoapUI Project Files (*.xml)", project.getPath()); if (file != null) { try { project.reload(file.getAbsolutePath()); } catch (SoapUIException ex) { UISupport.showErrorMessage(ex); } } } }
@Override public void perform(WsdlTestSuite testSuite, Object param) { if (IntegrationUtils.forceSaveProject(testSuite.getProject())) { if (!StartLoadUI.testCajoConnection()) { if (UISupport.confirm( StartLoadUI.LOADUI_LAUNCH_QUESTION, StartLoadUI.LOADUI_LAUNCH_TITLE)) { StartLoadUI.launchLoadUI(); } return; } XFormDialog dialog = ADialogBuilder.buildDialog(TestSuiteForm.class); dialog.setOptions(TestSuiteForm.LOADUIPROJECT, IntegrationUtils.getAvailableProjects()); if (!StringUtils.isNullOrEmpty(IntegrationUtils.getOpenedProjectName())) { dialog.setValue(TestSuiteForm.LOADUIPROJECT, IntegrationUtils.getOpenedProjectName()); } else { dialog.setValue(TestSuiteForm.LOADUIPROJECT, IntegrationUtils.CREATE_NEW_OPTION); } List<String> testSuiteLoadTests = new ArrayList<String>(); for (TestCase testCase : testSuite.getTestCaseList()) { for (LoadTest loadTest : testCase.getLoadTestList()) { testSuiteLoadTests.add(testCase.getName() + " - " + loadTest.getName()); } } String[] names = new String[testSuiteLoadTests.size()]; for (int c = 0; c < names.length; c++) { names[c] = testSuiteLoadTests.get(c); } dialog.setOptions(TestSuiteForm.LOADTESTS, names); if (dialog.show()) { if (dialog.getReturnValue() == XFormDialog.OK_OPTION) { String loadUIProject = dialog.getValue(TestSuiteForm.LOADUIPROJECT); String openedProjectName = IntegrationUtils.getOpenedProjectName(); if (!StringUtils.isNullOrEmpty(openedProjectName) && !loadUIProject.equals(openedProjectName) && IntegrationUtils.checkOpenedLoadUIProjectForClose()) { return; } String[] soapuiLoadTests = StringUtils.toStringArray( ((XFormMultiSelectList) dialog.getFormField(TestSuiteForm.LOADTESTS)) .getSelectedOptions()); if (soapuiLoadTests.length == 0) { UISupport.showErrorMessage("No LoadTests selected."); return; } try { IntegrationUtils.exportMultipleLoadTestToLoadUI( testSuite, soapuiLoadTests, loadUIProject); } catch (IOException e) { UISupport.showInfoMessage("Error while opening selected loadUI project"); return; } } } } }
public void actionPerformed(ActionEvent e) { String[] oldData = getData(); if (e.getSource() == addButton) { String value = UISupport.prompt("Specify value to add", "Add..", defaultValue); if (value != null) { listModel.addElement(value); firePropertyChange("options", oldData, getData()); } } else { int selectedIndex = list.getSelectedIndex(); if (e.getSource() == removeButton && selectedIndex != -1) { Object elm = listModel.getElementAt(selectedIndex); if (UISupport.confirm("Remove [" + elm.toString() + "] from list", "Remove")) { listModel.remove(selectedIndex); firePropertyChange("options", oldData, getData()); } } else if (e.getSource() == editButton && selectedIndex != -1) { String elm = (String) listModel.getElementAt(selectedIndex); String value = UISupport.prompt("Specify value", "Edit..", elm); if (value != null) { listModel.setElementAt(value, selectedIndex); firePropertyChange("options", oldData, getData()); } } } }
/** Test of attachPathToProject method, of class AssertionEnabler. */ @Test public void testAttachPathToProject() throws Exception { System.out.println("attachPathToProject"); File file = new File("src/test/resources/testFiles/"); WsdlTestSuite suite1 = project.addNewTestSuite("suite3"); UISupport.setToolHost(new SwingToolHost()); XFormFactory.Factory.instance = new SwingFormFactory(); Map<QName, WsdlInterface> bindingMap = (new WsdlBindingMapFactory()).createBindingMap(project, file); GetCommunicationParser getComParser = new GetCommunicationParser(); GCResult result = getComParser.parseGetCommunications(suite1, file, "listen_uri", "mock_uri", bindingMap); AssertionEnabler assertionInstance = new AssertionEnabler(result); UISupport.setToolHost(new SwingToolHost()); XFormFactory.Factory.instance = new SwingFormFactory(); assertionInstance.buildDialog(); // TODO review the generated test code and remove the default call to fail. }
public JCollapsibleTablePanel(JTable table, String title) { super(new JPanel(), title); setTable(table); setMinusIcon(UISupport.createImageIcon("/minus.gif")); setPlusIcon(UISupport.createImageIcon("/plus.gif")); this.title = title; }
public void perform(final WsdlProject project, Object param) { try { UISupport.select(project.getWorkspace().openProject(project)); } catch (SoapUIException e) { UISupport.showErrorMessage(e); } }
protected void generate(StringToStringMap values, ToolHost toolHost, WsdlProject project) throws Exception { String wstoolsDir = SoapUI.getSettings().getString(ToolsSettings.JBOSSWS_WSTOOLS_LOCATION, null); if (Tools.isEmpty(wstoolsDir)) { UISupport.showErrorMessage("wstools directory must be set in global preferences"); return; } String wsToolsExtension = UISupport.isWindows() ? ".bat" : ".sh"; File wstoolsFile = new File(wstoolsDir + File.separatorChar + "wstools" + wsToolsExtension); if (!wstoolsFile.exists()) { UISupport.showErrorMessage("Could not find wstools script at [" + wstoolsFile + "]"); return; } ProcessBuilder builder = new ProcessBuilder(); ArgumentBuilder args = buildArgs(values, UISupport.isWindows()); builder.command(args.getArgs()); builder.directory(new File(wstoolsDir)); toolHost.run( new ToolRunner(builder, new File(values.get(OUTPUT)), values.get(SERVICE_NAME), project)); }
public void actionPerformed(ActionEvent e) { String root = ModelSupport.getResourceRoot(testStep); File file = UISupport.getFileDialogs() .open( this, "Set properties source", "properties", "Properties Files (*.properties)", root); if (file != null) { updatingSource = true; testStep.setSource(file.getAbsolutePath()); sourceField.setText(testStep.getSource()); updatingSource = false; try { boolean createMissing = UISupport.confirm("Create missing properties?", "Set Properties Source"); int cnt = testStep.loadProperties(createMissing); UISupport.showInfoMessage( "Loaded " + cnt + " properties from [" + testStep.getSource() + "]"); } catch (IOException e1) { UISupport.showErrorMessage( "Failed to load properties from [" + testStep.getSource() + "]; " + e1); } } }
@Override protected boolean handleOk() { setVisible(false); int selectedRow = assertionsTable.getSelectedRow(); String selection = ((AssertionListEntry) assertionsListTableModel.getValueAt(selectedRow, 0)).getName(); if (selection == null) { return false; } if (!TestAssertionRegistry.getInstance().canAddMultipleAssertions(selection, assertable)) { UISupport.showErrorMessage("This assertion can only be added once"); return false; } TestAssertion assertion = assertable.addAssertion(selection); if (assertion == null) { UISupport.showErrorMessage("Failed to add assertion"); return false; } recentAssertionHandler.add(selection); if (assertion.isConfigurable()) { assertion.configure(); return true; } return true; }
public void actionPerformed(ActionEvent e) { String root = ModelSupport.getResourceRoot(testStep); File file = UISupport.getFileDialogs() .saveAs( this, "Set properties target", "properties", "Properties Files (*.properties)", new File(root)); if (file != null) { updatingTarget = true; testStep.setTarget(file.getAbsolutePath()); targetField.setText(testStep.getTarget()); updatingTarget = false; try { int cnt = testStep.saveProperties(); UISupport.showInfoMessage( "Saved " + cnt + " properties to [" + testStep.getTarget() + "]"); } catch (IOException e1) { UISupport.showErrorMessage( "Failed to save properties to [" + testStep.getTarget() + "]; " + e1); } } }
public void actionPerformed(ActionEvent e) { try { MockResult mockResult = mockResponse.getMockResult(); mockResponse.evaluateScript(mockResult == null ? null : mockResult.getMockRequest()); StringToStringMap values = null; if (mockResponse.getMockResult() != null) { values = mockResponse.getMockResult().getMockRequest().getContext().toStringToStringMap(); } if (values == null || values.isEmpty()) { UISupport.showInfoMessage("No values were returned"); } else { String msg = "<html><body>Returned values:<br>"; for (String name : values.keySet()) { msg += XmlUtils.entitize(name) + " : " + XmlUtils.entitize(values.get(name)) + "<br>"; } msg += "</body></html>"; UISupport.showExtendedInfo( "Result", "Result of MockResponse Script", msg, new Dimension(500, 400)); } } catch (Throwable e1) { responseScriptEditor.selectError(e1.getMessage()); UISupport.showErrorMessage(e1.toString()); } }
public SimpleDialog(String title, String description, String helpUrl, boolean okAndCancel) { super(UISupport.getMainFrame(), title, true); buttons = UISupport.initDialogActions(buildActions(helpUrl, okAndCancel), this); buttons.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); getContentPane() .add( UISupport.buildDescription( title, description, UISupport.createImageIcon(UISupport.TOOL_ICON_PATH)), BorderLayout.NORTH); getContentPane().add(buildContent(), BorderLayout.CENTER); buttons.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(1, 0, 0, 0, Color.GRAY), BorderFactory.createMatteBorder(1, 0, 0, 0, Color.WHITE)), BorderFactory.createEmptyBorder(3, 5, 3, 5))); getContentPane().add(buttons, BorderLayout.SOUTH); modifyButtons(); pack(); }
protected void generate(StringToStringMap values, ToolHost toolHost, Interface modelItem) throws Exception { String wsimportDir = SoapUI.getSettings().getString(ToolsSettings.JBOSSWS_WSTOOLS_LOCATION, null); if (Tools.isEmpty(wsimportDir)) { UISupport.showErrorMessage( "JBossWS wstools/wsconsume directory must be set in global preferences"); return; } String wsimportExtension = UISupport.isWindows() ? ".bat" : ".sh"; File wscompileFile = new File(wsimportDir + File.separatorChar + "wsconsume" + wsimportExtension); if (!wscompileFile.exists()) { UISupport.showErrorMessage("Could not find wsconsume script at [" + wscompileFile + "]"); return; } ProcessBuilder builder = new ProcessBuilder(); ArgumentBuilder args = buildArgs(UISupport.isWindows(), modelItem); builder.command(args.getArgs()); builder.directory(new File(wsimportDir)); toolHost.run(new ProcessToolRunner(builder, "JBossWS wsconsume", modelItem)); }
public FindAndReplaceDialog(FindAndReplaceable target) { super("Find / Replace"); if (UISupport.isMac()) { putValue(Action.ACCELERATOR_KEY, UISupport.getKeyStroke("meta F")); } else { putValue(Action.ACCELERATOR_KEY, UISupport.getKeyStroke("control F")); } this.target = new ProxyFindAndReplacable(target); }
private Component buildToolbar() { JXToolBar toolbar = UISupport.createSmallToolbar(); toolbar.addFixed(UISupport.createToolbarButton(new AddPartAction())); removePartButton = UISupport.createToolbarButton(new RemovePartAction()); toolbar.addFixed(removePartButton); return toolbar; }
public void actionPerformed(ActionEvent e) { try { if (dialog.validate()) { generate(dialog.getValues(), UISupport.getToolHost(), modelItem); } } catch (Exception e1) { UISupport.showErrorMessage(e1); } }
public void perform(RestService iface, Object param) { try { String path = exportDefinition(null, iface); if (path != null) { UISupport.showInfoMessage("WADL exported succesfully to [" + path + "]", "Export WADL"); } } catch (Exception e1) { UISupport.showErrorMessage(e1); } }
public void actionPerformed(ActionEvent e) { String name = UISupport.prompt("Specify unique property name", "Add Property", ""); if (StringUtils.hasContent(name)) { if (holder.hasProperty(name)) { UISupport.showErrorMessage("Property name [" + name + "] already exists.."); return; } ((MutableTestPropertyHolder) holder).addProperty(name); } }
protected void createTransfer(StringToStringMap values) { String propertyTransfer = values.get(TRANSFER_STEP); WsdlTestCase testCase = (WsdlTestCase) request.getTestCase(); TransferResponseValuesTestStep transferStep = (TransferResponseValuesTestStep) testCase.getTestStepByName(propertyTransfer); if (transferStep == null) { int index = testCase.getIndexOfTestStep(request.getRequestStep()); transferStep = (TransferResponseValuesTestStep) testCase.insertTestStep( TransferValuesStepFactory.TRANSFER_TYPE, propertyTransfer, index); } if (transferStep == null) { UISupport.showErrorMessage("Missing transfer step [" + propertyTransfer + "]"); return; } PropertyTransfer transfer = transferStep.getTransferByName(values.get(TRANSFER_NAME)); if (transfer == null) transfer = transferStep.addTransfer(values.get(TRANSFER_NAME)); transfer.setTargetStepName(request.getRequestStep().getName()); transfer.setTargetPropertyName("Request"); transfer.setTargetPath(values.get(TARGET_XPATH)); String sourceStepName = values.get(SOURCE_STEP); transfer.setSourceStepName(sourceStepName); TestStep sourceStep = testCase.getTestStepByName(sourceStepName); if (sourceStep == null) { sourceStep = (WsdlPropertiesTestStep) testCase.insertTestStep(PropertiesStepFactory.PROPERTIES_TYPE, sourceStepName, 0); } String sourcePropertyName = values.get(SOURCE_PROPERTY); if (sourceStep.getProperty(sourcePropertyName) == null && sourceStep instanceof WsdlPropertiesTestStep) { ((WsdlPropertiesTestStep) sourceStep).addProperty(sourcePropertyName); } transfer.setSourcePropertyName(sourcePropertyName); if (values.getBoolean(OPEN_EDITOR)) { TransferResponseValuesDesktopPanel panel = (TransferResponseValuesDesktopPanel) UISupport.showDesktopPanel(transferStep); panel.selectTransfer(transfer); } }
public void perform(WsdlTestCase testCase, Object param) { String name = UISupport.prompt("Specify name of TestCase", "Rename TestCase", testCase.getName()); if (name == null || name.equals(testCase.getName())) return; while (testCase.getTestSuite().getTestCaseByName(name.trim()) != null) { name = UISupport.prompt( "Specify unique name of TestCase", "Rename TestCase", testCase.getName()); if (name == null || name.equals(testCase.getName())) return; } testCase.setName(name); }
public void actionPerformed(ActionEvent e) { if (holder.getPropertyCount() == 0) { UISupport.showErrorMessage("No properties to sort!"); return; } try { UISupport.setHourglassCursor(); propertiesModel.sort(); } finally { UISupport.resetCursor(); } }
/** * Perform an * * @param target * @param param */ public void performHeadless(T target, Object param) { this.valuesSettingID = this.getClass().getName() + "@values"; if (target == null) this.valuesSettingID += "-global"; else this.valuesSettingID += "-local"; modelItem = target; try { generate(initValues((T) target, param), UISupport.getToolHost(), (T) target); } catch (Exception e1) { UISupport.showErrorMessage(e1); } }
public void actionPerformed(ActionEvent e) { int row = propertiesTable.getSelectedRow(); if (row == -1) { return; } UISupport.stopCellEditing(propertiesTable); String propertyName = propertiesModel.getValueAt(row, 0).toString(); if (UISupport.confirm("Remove property [" + propertyName + "]?", "Remove Property")) { ((MutableTestPropertyHolder) holder).removeProperty(propertyName); propertiesModel.fireTableRowsDeleted(row, row); } }
public SchemaTabs() { super(); conflicts = new JPanel(); conflicts.setLayout(new BorderLayout()); auto = new JCheckBox("Auto-Resolve"); auto.setToolTipText("Automatically modify inferred schema from received Responses"); auto.setOpaque(false); UISupport.setFixedSize(auto, 120, 20); XmlBeansSettingsImpl settings = getRequest().getSettings(); if (settings.isSet(AUTO_INFER_SCHEMAS)) { auto.setSelected(settings.getBoolean(AUTO_INFER_SCHEMAS)); } auto.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { getRequest().getSettings().setBoolean(AUTO_INFER_SCHEMAS, auto.isSelected()); } }); resolveButton = new JButton("Resolve conflicts"); resolveButton.setEnabled(false); resolveButton.setActionCommand("resolve"); resolveButton.addActionListener(this); JXToolBar toolbar = UISupport.createToolbar(); toolbar.addFixed(auto); toolbar.addFixed(resolveButton); log = new JLogList("Schema log"); conflicts.add(toolbar, BorderLayout.NORTH); conflicts.add(log, BorderLayout.CENTER); addTab("Conflicts", conflicts); schemaList = new JList(InferredSchemaManager.getInferredSchema(service).getNamespaces()); schemaList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); schemaList.addListSelectionListener(this); toolbar = UISupport.createToolbar(); toolbar.addFixed(UISupport.createToolbarButton(new RemoveNamespaceAction())); JPanel listPanel = new JPanel(); listPanel.setLayout(new BorderLayout()); listPanel.add(toolbar, BorderLayout.NORTH); listPanel.add(new JScrollPane(schemaList), BorderLayout.CENTER); xsd = JXEditTextArea.createXmlEditor(false); xsd.setEditable(false); update(); addTab( "Schemas", new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, listPanel, new JScrollPane(xsd))); }
public void keyPressed(KeyEvent e) { TreePath selectionPath = mainTree.getSelectionPath(); if (selectionPath == null || mainTree.getSelectionCount() == 0) { return; } if (mainTree.getSelectionCount() == 1) { SoapUITreeNode lastPathComponent = (SoapUITreeNode) selectionPath.getLastPathComponent(); ActionList actions = lastPathComponent.getActions(); if (actions != null) { actions.dispatchKeyEvent(e); } if (!e.isConsumed()) { KeyStroke ks = KeyStroke.getKeyStrokeForEvent(e); if (ks.equals(UISupport.getKeyStroke("alt C"))) { mainTree.collapsePath(selectionPath); e.consume(); } else if (ks.equals(UISupport.getKeyStroke("alt E"))) { mainTree.collapsePath(selectionPath); int row = mainTree.getSelectionRows()[0]; TreePath nextPath = mainTree.getPathForRow(row + 1); TreePath path = mainTree.getPathForRow(row); while (path != null && !path.equals(nextPath)) { mainTree.expandRow(row); path = mainTree.getPathForRow(++row); } e.consume(); } } } else { TreePath[] selectionPaths = mainTree.getSelectionPaths(); List<ModelItem> targets = new ArrayList<ModelItem>(); for (TreePath treePath : selectionPaths) { SoapUITreeNode node = (SoapUITreeNode) treePath.getLastPathComponent(); targets.add(node.getModelItem()); } if (targets.size() > 0) { ActionList actions = ActionListBuilder.buildMultiActions(targets.toArray(new ModelItem[targets.size()])); if (actions.getActionCount() > 0) { actions.dispatchKeyEvent(e); } } } }
public void perform(WsdlProject project, Object param) { String url = UISupport.prompt("Enter WSDL URL", "Add WSDL from URL", ""); if (url == null) return; try { Boolean createRequests = UISupport.confirmOrCancel("Create default requests for all operations", "Import WSDL"); if (createRequests == null) return; Interface[] ifaces = WsdlInterfaceFactory.importWsdl(project, url, createRequests); if (ifaces != null && ifaces.length > 0) UISupport.select(ifaces[0]); } catch (Exception ex) { UISupport.showErrorMessage(ex.getMessage() + ":" + ex.getCause()); } }
public void start(SoapMonitor soapMonitor, int localPort) { Settings settings = soapMonitor.getProject().getSettings(); server.setThreadPool(new SoapUIJettyThreadPool()); Context context = new Context(server, ROOT, 0); if (sslEndpoint != null) { if (sslEndpoint.startsWith(HTTPS)) { sslConnector = new SslSocketConnector(); sslConnector.setKeystore( settings.getString(SoapMonitorAction.SecurityTabForm.SSLTUNNEL_KEYSTORE, "JKS")); sslConnector.setPassword( settings.getString(SoapMonitorAction.SecurityTabForm.SSLTUNNEL_PASSWORD, "")); sslConnector.setKeyPassword( settings.getString(SoapMonitorAction.SecurityTabForm.SSLTUNNEL_KEYPASSWORD, "")); sslConnector.setTruststore( settings.getString(SoapMonitorAction.SecurityTabForm.SSLTUNNEL_TRUSTSTORE, "JKS")); sslConnector.setTrustPassword( settings.getString( SoapMonitorAction.SecurityTabForm.SSLTUNNEL_TRUSTSTORE_PASSWORD, "")); sslConnector.setNeedClientAuth(false); sslConnector.setMaxIdleTime(30000); sslConnector.setPort(localPort); server.addConnector(sslConnector); context.addServlet(new ServletHolder(new TunnelServlet(soapMonitor, sslEndpoint)), ROOT); } else { if (sslEndpoint.startsWith(HTTP)) { connector.setPort(localPort); server.addConnector(connector); context.addServlet(new ServletHolder(new TunnelServlet(soapMonitor, sslEndpoint)), ROOT); } else { UISupport.showErrorMessage("Unsupported/unknown protocol tunnel will not start"); return; } } proxyOrTunnel = false; } else { proxyOrTunnel = true; connector.setPort(localPort); server.addConnector(connector); context.addServlet(new ServletHolder(new ProxyServlet(soapMonitor)), ROOT); } try { server.start(); } catch (Exception e) { UISupport.showErrorMessage("Error starting monitor: " + e.getMessage()); } }
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component defaultRenderer = super.prepareRenderer(renderer, row, column); if (UISupport.isMac()) { JTableFactory.applyStripesToRenderer(row, defaultRenderer); } return defaultRenderer; }
public void run() { try { for (int i = 0; i < listeners.length; i++) { if (!listeners[i].beforeSubmit(this, context)) { status = Status.CANCELED; SoapUI.log.error("listener cancelled submit.."); return; } } status = Status.RUNNING; Object responseContent = executeAmfCall(getRequest()); createResponse(responseContent); if (status != Status.CANCELED && status != Status.ERROR) { status = Status.FINISHED; } } catch (Exception e) { UISupport.showErrorMessage("There's been an error in executing query " + e.toString()); error = e; } finally { if (status != Status.CANCELED) { for (int i = 0; i < listeners.length; i++) { try { listeners[i].afterSubmit(this, context); } catch (Throwable e) { SoapUI.logError(e); } } } } }