/** * Do actual dependency copying and update project's copy dependency path. * * @throws IOException */ private boolean copyDependencies() throws IOException { boolean result = true; projectCopy.setResourceRoot("${projectDir}"); List<ExternalDependency> dependencies = projectCopy.getExternalDependencies(); for (ExternalDependency dependency : dependencies) { switch (dependency.getType()) { case FILE: File originalDependency = new File(dependency.getPath()); if (originalDependency.exists()) { File targetDependency = new File(tmpDir, originalDependency.getName()); FileUtils.copyFile(originalDependency, targetDependency); dependency.updatePath(targetDependency.getPath()); } else { SoapUI.log.warn( "Do not exists on local file system [" + originalDependency.getPath() + "]"); } break; case FOLDER: originalDependency = new File(dependency.getPath()); File targetDependency = new File(tmpDir, originalDependency.getName()); targetDependency.mkdir(); FileUtils.copyDirectory(originalDependency, targetDependency, false); dependency.updatePath(targetDependency.getPath()); break; default: break; } } return result; }
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); } } } }
@Before public void setUp() throws XmlException, IOException, SoapUIException { WsdlProject project = new WsdlProject(); RestService restService = (RestService) project.addNewInterface("Test", RestServiceFactory.REST_TYPE); restResource = restService.addNewResource("Resource", "/test"); }
private void copyToRequest( SubmitContext context, AbstractHttpRequestInterface<?> wsdlRequest, EndpointDefaults def, String requestUsername, String requestPassword, String requestDomain, String defUsername, String defPassword, String defDomain, com.eviware.soapui.config.CredentialsConfig.AuthType.Enum authType) { // only set if not set in request String wssType = def.getWssType(); if (wssType != null) { HttpAuthenticationRequestFilter.initRequestCredentials( context, null, project.getSettings(), null, null, null); } else { HttpAuthenticationRequestFilter.initRequestCredentials( context, defUsername, project.getSettings(), defPassword, defDomain, authType); } String wssTimeToLive = def.getWssTimeToLive(); if (wssTimeToLive == null) { wssTimeToLive = ""; } try { WssAuthenticationRequestFilter.setWssHeaders( context, defUsername, defPassword, wssType, wssTimeToLive); } catch (Exception e) { SoapUI.logError(e); } }
public AddAssertionPanel(Assertable assertable) { super( "Add Assertion", "Select the source property and which assertion to apply below ", HelpUrls.ADD_ASSERTION_PANEL); this.assertable = assertable; assertionEntryRenderer.setAssertable(assertable); categoriesListRenderer.setAssertable(assertable); selectionListener = new InternalListSelectionListener(); categoriesAssertionsMap = AssertionCategoryMapping.getCategoriesAssertionsMap(assertable, recentAssertionHandler); // load interfaces or have a issue with table and cell renderer WsdlProject project = (WsdlProject) ModelSupport.getModelItemProject(assertable.getModelItem()); for (Interface inf : project.getInterfaceList()) { try { // There seems to be no good reason to load the definitions for rest interfaces // hence that call has been removed for the time being. if (inf instanceof WsdlInterface) { ((WsdlInterface) inf).getWsdlContext().loadIfNecessary(); } } catch (Exception e) { // TODO Improve this e.printStackTrace(); } } }
private void complementRequest( SubmitContext context, AbstractHttpRequestInterface<?> httpRequest, EndpointDefaults def, String requestUsername, String requestPassword, String requestDomain, String defUsername, String defPassword, String defDomain, com.eviware.soapui.config.CredentialsConfig.AuthType.Enum authType) { String username = StringUtils.hasContent(requestUsername) ? requestUsername : defUsername; String password = StringUtils.hasContent(requestPassword) ? requestPassword : defPassword; if (httpRequest instanceof WsdlRequest) { WsdlRequest wsdlRequest = (WsdlRequest) httpRequest; // only set if not set in request String wssType = StringUtils.isNullOrEmpty(wsdlRequest.getWssPasswordType()) ? def.getWssType() : (StringUtils.hasContent(username) && StringUtils.hasContent(password)) ? null : wsdlRequest.getWssPasswordType(); String wssTimeToLive = StringUtils.isNullOrEmpty(wsdlRequest.getWssTimeToLive()) ? def.getWssTimeToLive() : null; if (!StringUtils.hasContent(wssType) && (StringUtils.hasContent(username) || StringUtils.hasContent(password))) { String domain = StringUtils.hasContent(requestDomain) ? requestDomain : defDomain; HttpAuthenticationRequestFilter.initRequestCredentials( context, username, project.getSettings(), password, domain, authType); } else if (StringUtils.hasContent(wssType) || StringUtils.hasContent(wssTimeToLive)) { try { // set to null so existing don't get removed if (wssTimeToLive != null && wssTimeToLive.length() == 0) { wssTimeToLive = null; } if (StringUtils.hasContent(username) || StringUtils.hasContent(password)) { WssAuthenticationRequestFilter.setWssHeaders( context, username, password, wssType, wssTimeToLive); } } catch (Exception e) { SoapUI.logError(e); } } } else { if ((StringUtils.hasContent(username) || StringUtils.hasContent(password))) { String domain = StringUtils.hasContent(requestDomain) ? requestDomain : defDomain; HttpAuthenticationRequestFilter.initRequestCredentials( context, username, project.getSettings(), password, domain, authType); } } }
public void release() { project.removeProjectListener(projectListener); for (Interface iface : project.getInterfaceList()) { iface.removePropertyChangeListener( AbstractInterface.ENDPOINT_PROPERTY, propertyChangeListener); } if (configurationPanel != null) { configurationPanel.release(); } }
/** * Creates project copy and save it in temporary directory. Set copy's project path and resource * root to ${projectDir} * * @return * @throws IOException * @throws SoapUIException * @throws XmlException */ private boolean createProjectCopy() throws IOException, XmlException, SoapUIException { project.saveIn(new File(tmpDir, project.getName() + "-soapui-project.xml")); projectCopy = (WsdlProject) ProjectFactoryRegistry.getProjectFactory("wsdl") .createNew( new File(tmpDir, project.getName() + "-soapui-project.xml") .getAbsolutePath()); // new WsdlProject( new File( tmpDir, project.getName() // + ".xml" ).getAbsolutePath() ); return projectCopy != null; }
public void release() { if (propertiesTable.isEditing()) { propertiesTable.getCellEditor().stopCellEditing(); } propertiesModel.release(); if (holder instanceof WsdlProject) { WsdlProject project = (WsdlProject) holder; project.removeEnvironmentListener(environmentListener); project.removeProjectListener(projectListener); } projectListener = null; }
private void removeUnusedEndpoints() { if (config == null) { return; } Set<String> endpoints = new HashSet<String>(); for (Interface iface : project.getInterfaceList()) { endpoints.addAll(Arrays.asList(iface.getEndpoints())); } StringList keys = new StringList(); synchronized (defaults) { for (String key : defaults.keySet()) { if (!endpoints.contains(key)) { keys.add(key); } } for (String key : keys) { EndpointDefaults def = defaults.remove(key); config.getEndpointList().remove(def); } } }
public void perform(final WsdlProject project, Object param) { try { UISupport.select(project.getWorkspace().openProject(project)); } catch (SoapUIException e) { UISupport.showErrorMessage(e); } }
/** * Creates packed project on given path * * @param exportPath * @return * @throws SoapUIException * @throws XmlException * @throws IOException */ public boolean exportProject(String exportPath) throws IOException, XmlException, SoapUIException { boolean result = false; if ((tmpDir = createTemporaryDirectory()) != null) { if (createProjectCopy()) { if (copyDependencies()) { projectCopy.setResourceRoot("${projectDir}"); projectCopy.save(); if (packageAll(exportPath)) result = true; } } deleteDir(tmpDir); } return result; }
public void onSave() { if (config == null) { return; } removeUnusedEndpoints(); // remove unused for (int c = 0; c < config.sizeOfEndpointArray(); c++) { EndpointConfig ec = config.getEndpointArray(c); if (StringUtils.isNullOrEmpty(ec.getDomain()) && StringUtils.isNullOrEmpty(ec.getUsername()) && StringUtils.isNullOrEmpty(ec.getPassword()) && StringUtils.isNullOrEmpty(ec.getWssType()) && StringUtils.isNullOrEmpty(ec.getWssTimeToLive()) && StringUtils.isNullOrEmpty(ec.getIncomingWss()) && StringUtils.isNullOrEmpty(ec.getOutgoingWss()) && ec.getMode() == EndpointConfig.Mode.COMPLEMENT) { synchronized (defaults) { defaults.remove(ec.getStringValue()); config.removeEndpoint(c); c--; } } } if (config.sizeOfEndpointArray() == 0) { project.getConfig().unsetEndpointStrategy(); config = null; } }
public RestResource makeRestResource() throws SoapUIException { String serviceName = "Interface_" + UUID.randomUUID().toString(); RestService service = (RestService) project.addNewInterface(serviceName, RestServiceFactory.REST_TYPE); service.setName(serviceName); RestResource restResource = service.addNewResource("root", "/"); return restResource; }
private void testLoader(String wsdlUrl) throws Exception { WsdlProject project = new WsdlProject(); project.getSettings().setBoolean(WsdlSettings.CACHE_WSDLS, true); WsdlInterface wsdlInterface = WsdlImporter.importWsdl(project, wsdlUrl)[0]; assertTrue(wsdlInterface.isCached()); WsdlDefinitionExporter exporter = new WsdlDefinitionExporter(wsdlInterface); String root = exporter.export("test" + File.separatorChar + "output"); WsdlProject project2 = new WsdlProject(); WsdlInterface wsdl2 = WsdlImporter.importWsdl(project2, new File(root).toURI().toURL().toString())[0]; assertEquals(wsdlInterface.getBindingName(), wsdl2.getBindingName()); assertEquals(wsdlInterface.getOperationCount(), wsdl2.getOperationCount()); assertEquals( wsdlInterface.getWsdlContext().getInterfaceDefinition().getDefinedNamespaces(), wsdl2.getWsdlContext().getInterfaceDefinition().getDefinedNamespaces()); }
public void testAssert() throws Exception { WsdlProject project = new WsdlProject( "src" + File.separatorChar + "test-resources" + File.separatorChar + "sample-soapui-project.xml"); TestSuite testSuite = project.getTestSuiteByName("Test Suite"); com.eviware.soapui.model.testsuite.TestCase testCase = testSuite.getTestCaseByName("Test Conversions"); WsdlTestRequestStep testStep = (WsdlTestRequestStep) testCase.getTestStepByName("SEK to USD Test"); MockTestRunner testRunner = new MockTestRunner((WsdlTestCase) testStep.getTestCase()); MockTestRunContext testRunContext = new MockTestRunContext(testRunner, (WsdlTestStep) testStep); TestStepResult result = testStep.run(testRunner, testRunContext); WsdlTestRequestStepResult wsdlResult = (WsdlTestRequestStepResult) result; assertNotNull(wsdlResult); // assertEquals(TestStepResult.TestStepStatus.OK, wsdlResult.getStatus()); }
private void overrideRequest( SubmitContext context, AbstractHttpRequestInterface<?> wsdlRequest, EndpointDefaults def, String requestUsername, String requestPassword, String requestDomain, String defUsername, String defPassword, String defDomain, com.eviware.soapui.config.CredentialsConfig.AuthType.Enum authType) { String username = StringUtils.hasContent(defUsername) ? defUsername : requestUsername; String password = StringUtils.hasContent(defPassword) ? defPassword : requestPassword; if (StringUtils.hasContent(username) || StringUtils.hasContent(password)) { // only set if not set in request String wssType = def.getWssType(); String wssTimeToLive = def.getWssTimeToLive(); if (wssType == null) { String domain = StringUtils.hasContent(defDomain) ? defDomain : requestDomain; HttpAuthenticationRequestFilter.initRequestCredentials( context, username, project.getSettings(), password, domain, authType); } if (StringUtils.hasContent(wssType) || StringUtils.hasContent(wssTimeToLive)) { try { // set to null so existing don't get removed if (wssTimeToLive != null && wssTimeToLive.length() == 0) { wssTimeToLive = null; } WssAuthenticationRequestFilter.setWssHeaders( context, username, password, wssType, wssTimeToLive); } catch (Exception e) { SoapUI.logError(e); } } } }
@Override protected boolean runRunner() throws Exception { WsdlProject project = (WsdlProject) ProjectFactoryRegistry.getProjectFactory("wsdl") .createNew(getProjectFile(), getProjectPassword()); String pFile = getProjectFile(); project.getSettings().setString(ProjectSettings.SHADOW_PASSWORD, null); File tmpProjectFile = new File(System.getProperty("java.io.tmpdir")); tmpProjectFile = new File(tmpProjectFile, project.getName() + "-project.xml"); project.beforeSave(); project.saveIn(tmpProjectFile); pFile = tmpProjectFile.getAbsolutePath(); String endpoint = StringUtils.hasContent(localEndpoint) ? localEndpoint : project.getName(); log.info("Creating WAR file with endpoint [" + endpoint + "]"); MockAsWar mockAsWar = new MockAsWar( pFile, getSettingsFile(), getOutputFolder(), warFile, includeLibraries, includeActions, includeListeners, endpoint, enableWebUI, project); mockAsWar.createMockAsWarArchive(); log.info("WAR Generation complete"); return true; }
protected void runProject(WsdlProject project) { // add listener for counting.. InternalProjectRunListener projectRunListener = new InternalProjectRunListener(); project.addProjectRunListener(projectRunListener); try { log.info(("Running Project [" + project.getName() + "], runType = " + project.getRunType())); WsdlProjectRunner runner = project.run(new StringToObjectMap(), false); log.info( "Project [" + project.getName() + "] finished with status [" + runner.getStatus() + "] in " + runner.getTimeTaken() + "ms"); } catch (Exception e) { e.printStackTrace(); } finally { project.removeProjectRunListener(projectRunListener); } }
public void perform(WsdlTestRequestStep target, Object param) { this.testStep = target; if (dialog == null) { dialog = ADialogBuilder.buildDialog(Form.class); dialog .getFormField(Form.INTERFACE) .addFormFieldListener( new XFormFieldListener() { public void valueChanged(XFormField sourceField, String newValue, String oldValue) { WsdlProject project = testStep.getTestCase().getTestSuite().getProject(); dialog.setOptions( Form.OPERATION, ModelSupport.getNames( project.getInterfaceByName(newValue).getOperationList())); dialog.setValue(Form.OPERATION, testStep.getOperationName()); } }); dialog .getFormField(Form.RECREATE_REQUEST) .addFormFieldListener( new XFormFieldListener() { public void valueChanged(XFormField sourceField, String newValue, String oldValue) { boolean enabled = Boolean.parseBoolean(newValue); dialog.getFormField(Form.CREATE_OPTIONAL).setEnabled(enabled); dialog.getFormField(Form.KEEP_EXISTING).setEnabled(enabled); } }); dialog.getFormField(Form.CREATE_OPTIONAL).setEnabled(false); dialog.getFormField(Form.KEEP_EXISTING).setEnabled(false); } WsdlProject project = target.getTestCase().getTestSuite().getProject(); dialog.setOptions( Form.INTERFACE, ModelSupport.getNames( project.getInterfaceList(), new ModelSupport.InterfaceTypeFilter(WsdlInterfaceFactory.WSDL_TYPE))); dialog.setValue(Form.INTERFACE, target.getInterfaceName()); dialog.setOptions( Form.OPERATION, ModelSupport.getNames( project.getInterfaceByName(target.getInterfaceName()).getOperationList())); dialog.setValue(Form.OPERATION, target.getOperationName()); dialog.setValue(Form.NAME, target.getName()); if (dialog.show()) { String ifaceName = dialog.getValue(Form.INTERFACE); String operationName = dialog.getValue(Form.OPERATION); WsdlInterface iface = (WsdlInterface) project.getInterfaceByName(ifaceName); WsdlOperation operation = iface.getOperationByName(operationName); target.setOperation(operation); String name = dialog.getValue(Form.NAME).trim(); if (name.length() > 0 && !target.getName().equals(name)) target.setName(name); if (dialog.getBooleanValue(Form.RECREATE_REQUEST)) { String req = operation.createRequest(dialog.getBooleanValue(Form.CREATE_OPTIONAL)); if (req == null) { UISupport.showErrorMessage("Request creation failed"); return; } WsdlTestRequest request = target.getTestRequest(); if (dialog.getBooleanValue(Form.KEEP_EXISTING)) { req = XmlUtils.transferValues(request.getRequestContent(), req); } request.setRequestContent(req); } } }
public void perform(WsdlTestCase testCase, Object param) { if (dialog == null) { dialog = ADialogBuilder.buildDialog(Form.class); dialog .getFormField(Form.PROJECT) .addFormFieldListener( new XFormFieldListener() { public void valueChanged(XFormField sourceField, String newValue, String oldValue) { if (newValue.equals(CREATE_NEW_OPTION)) dialog.setOptions(Form.TESTSUITE, new String[] {CREATE_NEW_OPTION}); else { Project project = SoapUI.getWorkspace().getProjectByName(newValue); dialog.setOptions( Form.TESTSUITE, ModelSupport.getNames( project.getTestSuiteList(), new String[] {CREATE_NEW_OPTION})); } } }); dialog .getFormField(Form.CLONE_DESCRIPTION) .addFormFieldListener( new XFormFieldListener() { public void valueChanged(XFormField sourceField, String newValue, String oldValue) { if (dialog.getBooleanValue(Form.CLONE_DESCRIPTION)) { dialog.getFormField(Form.DESCRIPTION).setEnabled(false); } else { dialog.getFormField(Form.DESCRIPTION).setEnabled(true); } } }); } dialog.setBooleanValue(Form.MOVE, false); dialog.setBooleanValue(Form.CLONE_DESCRIPTION, true); dialog.getFormField(Form.DESCRIPTION).setEnabled(false); dialog.setValue(Form.DESCRIPTION, testCase.getDescription()); dialog.setValue(Form.NAME, "Copy of " + testCase.getName()); WorkspaceImpl workspace = testCase.getTestSuite().getProject().getWorkspace(); dialog.setOptions( Form.PROJECT, ModelSupport.getNames(workspace.getOpenProjectList(), new String[] {CREATE_NEW_OPTION})); dialog.setValue(Form.PROJECT, testCase.getTestSuite().getProject().getName()); dialog.setOptions( Form.TESTSUITE, ModelSupport.getNames( testCase.getTestSuite().getProject().getTestSuiteList(), new String[] {CREATE_NEW_OPTION})); dialog.setValue(Form.TESTSUITE, testCase.getTestSuite().getName()); boolean hasLoadTests = testCase.getLoadTestCount() > 0; dialog.setBooleanValue(Form.CLONE_LOADTESTS, hasLoadTests); dialog.getFormField(Form.CLONE_LOADTESTS).setEnabled(hasLoadTests); if (dialog.show()) { String targetProjectName = dialog.getValue(Form.PROJECT); String targetTestSuiteName = dialog.getValue(Form.TESTSUITE); String name = dialog.getValue(Form.NAME); WsdlProject project = testCase.getTestSuite().getProject(); WsdlTestSuite targetTestSuite = null; Set<Interface> requiredInterfaces = new HashSet<Interface>(); // to another project project? if (!targetProjectName.equals(project.getName())) { // get required interfaces for (int y = 0; y < testCase.getTestStepCount(); y++) { WsdlTestStep testStep = testCase.getTestStepAt(y); requiredInterfaces.addAll(testStep.getRequiredInterfaces()); } project = (WsdlProject) workspace.getProjectByName(targetProjectName); if (project == null) { targetProjectName = UISupport.prompt("Enter name for new Project", "Clone TestCase", ""); if (targetProjectName == null) return; try { project = workspace.createProject(targetProjectName, null); } catch (SoapUIException e) { UISupport.showErrorMessage(e); } if (project == null) return; } if (requiredInterfaces.size() > 0 && project.getInterfaceCount() > 0) { Map<String, Interface> bindings = new HashMap<String, Interface>(); for (Interface iface : requiredInterfaces) { bindings.put(iface.getTechnicalId(), iface); } for (Interface iface : project.getInterfaceList()) { bindings.remove(iface.getTechnicalId()); } requiredInterfaces.retainAll(bindings.values()); } if (requiredInterfaces.size() > 0) { String msg = "Target project [" + targetProjectName + "] is missing required Interfaces;\r\n\r\n"; for (Interface iface : requiredInterfaces) { msg += iface.getName() + " [" + iface.getTechnicalId() + "]\r\n"; } msg += "\r\nThese will be cloned to the targetProject as well"; if (!UISupport.confirm(msg, "Clone TestCase")) return; for (Interface iface : requiredInterfaces) { project.importInterface((AbstractInterface<?>) iface, true, true); } } } targetTestSuite = project.getTestSuiteByName(targetTestSuiteName); if (targetTestSuite == null) { targetTestSuiteName = UISupport.prompt( "Specify name for new TestSuite", "Clone TestCase", "Copy of " + testCase.getTestSuite().getName()); if (targetTestSuiteName == null) return; targetTestSuite = project.addNewTestSuite(targetTestSuiteName); } boolean move = dialog.getBooleanValue(Form.MOVE); WsdlTestCase newTestCase = targetTestSuite.importTestCase( testCase, name, -1, dialog.getBooleanValue(Form.CLONE_LOADTESTS), !move); UISupport.select(newTestCase); if (move) { testCase.getTestSuite().removeTestCase(testCase); } boolean cloneDescription = dialog.getBooleanValue(Form.CLONE_DESCRIPTION); if (!cloneDescription) { newTestCase.setDescription(dialog.getValue(Form.DESCRIPTION)); } } }
public Response sendRequest(SubmitContext submitContext, Request request) throws Exception { AbstractHttpRequestInterface<?> httpRequest = (AbstractHttpRequestInterface<?>) request; HttpClient httpClient = HttpClientSupport.getHttpClient(); ExtendedHttpMethod httpMethod = createHttpMethod(httpRequest); boolean createdState = false; HttpState httpState = (HttpState) submitContext.getProperty(SubmitContext.HTTP_STATE_PROPERTY); if (httpState == null) { httpState = new HttpState(); submitContext.setProperty(SubmitContext.HTTP_STATE_PROPERTY, httpState); createdState = true; } HostConfiguration hostConfiguration = new HostConfiguration(); String localAddress = System.getProperty("soapui.bind.address", httpRequest.getBindAddress()); if (localAddress == null || localAddress.trim().length() == 0) localAddress = SoapUI.getSettings().getString(HttpSettings.BIND_ADDRESS, null); if (localAddress != null && localAddress.trim().length() > 0) { try { hostConfiguration.setLocalAddress(InetAddress.getByName(localAddress)); } catch (Exception e) { SoapUI.logError(e); } } submitContext.removeProperty(RESPONSE); submitContext.setProperty(HTTP_METHOD, httpMethod); submitContext.setProperty(POST_METHOD, httpMethod); submitContext.setProperty(HTTP_CLIENT, httpClient); submitContext.setProperty(REQUEST_CONTENT, httpRequest.getRequestContent()); submitContext.setProperty(HOST_CONFIGURATION, hostConfiguration); submitContext.setProperty(WSDL_REQUEST, httpRequest); submitContext.setProperty(RESPONSE_PROPERTIES, new StringToStringMap()); for (RequestFilter filter : filters) { filter.filterRequest(submitContext, httpRequest); } try { Settings settings = httpRequest.getSettings(); // custom http headers last so they can be overridden StringToStringMap headers = httpRequest.getRequestHeaders(); for (String header : headers.keySet()) { String headerValue = headers.get(header); headerValue = PropertyExpander.expandProperties(submitContext, headerValue); httpMethod.setRequestHeader(header, headerValue); } // do request WsdlProject project = (WsdlProject) ModelSupport.getModelItemProject(httpRequest); WssCrypto crypto = null; if (project != null) { crypto = project .getWssContainer() .getCryptoByName( PropertyExpander.expandProperties(submitContext, httpRequest.getSslKeystore())); } if (crypto != null && WssCrypto.STATUS_OK.equals(crypto.getStatus())) { hostConfiguration .getParams() .setParameter( SoapUIHostConfiguration.SOAPUI_SSL_CONFIG, crypto.getSource() + " " + crypto.getPassword()); } // dump file? httpMethod.setDumpFile( PathUtils.expandPath( httpRequest.getDumpFile(), (AbstractWsdlModelItem<?>) httpRequest, submitContext)); // include request time? if (settings.getBoolean(HttpSettings.INCLUDE_REQUEST_IN_TIME_TAKEN)) httpMethod.initStartTime(); // submit! httpClient.executeMethod(hostConfiguration, httpMethod, httpState); httpMethod.getTimeTaken(); } catch (Throwable t) { httpMethod.setFailed(t); if (t instanceof Exception) throw (Exception) t; SoapUI.logError(t); throw new Exception(t); } finally { for (int c = filters.size() - 1; c >= 0; c--) { filters.get(c).afterRequest(submitContext, httpRequest); } if (!submitContext.hasProperty(RESPONSE)) { createDefaultResponse(submitContext, httpRequest, httpMethod); } Response response = (Response) submitContext.getProperty(BaseHttpRequestTransport.RESPONSE); StringToStringMap responseProperties = (StringToStringMap) submitContext.getProperty(BaseHttpRequestTransport.RESPONSE_PROPERTIES); for (String key : responseProperties.keySet()) { response.setProperty(key, responseProperties.get(key)); } if (httpMethod != null) { httpMethod.releaseConnection(); } else log.error("PostMethod is null"); if (createdState) { submitContext.setProperty(SubmitContext.HTTP_STATE_PROPERTY, null); } } return (Response) submitContext.getProperty(BaseHttpRequestTransport.RESPONSE); }
public ProxyServlet( final WsdlProject project, final SoapMonitorListenerCallBack listenerCallBack) { this.listenerCallBack = listenerCallBack; this.project = project; settings = project.getSettings(); }
@Override public boolean runRunner() throws Exception { AnalyticsHelper.initializeAnalytics(); Analytics.trackSessionStart(); initGroovyLog(); assertions.clear(); String projectFile = getProjectFile(); WsdlProject project = (WsdlProject) ProjectFactoryRegistry.getProjectFactory("wsdl") .createNew(projectFile, getProjectPassword()); if (project.isDisabled()) { throw new Exception("Failed to load SoapUI project file [" + projectFile + "]"); } initProject(project); ensureOutputFolder(project); if (this.printAlertSiteReport) { testCaseRunLogReport = new TestCaseRunLogReport(getAbsoluteOutputFolder(project)); } log.info("Running SoapUI tests in project [" + project.getName() + "]"); long startTime = System.nanoTime(); List<TestCase> testCasesToRun = new ArrayList<TestCase>(); // validate testSuite argument if (testSuite != null && project.getTestSuiteByName(testSuite) == null) { throw new Exception( "TestSuite with name [" + testSuite + "] is missing in Project [" + project.getName() + "]"); } // start by listening to all testcases.. (since one testcase can call // another) for (int c = 0; c < project.getTestSuiteCount(); c++) { TestSuite suite = project.getTestSuiteAt(c); for (int i = 0; i < suite.getTestCaseCount(); i++) { TestCase tc = suite.getTestCaseAt(i); if ((testSuite == null || suite.getName().equals(testSuite)) && testCase != null && tc.getName().equals(testCase)) { testCasesToRun.add(tc); } addListeners(tc); } } try { // validate testSuite argument if (testCase != null && testCasesToRun.size() == 0) { if (testSuite == null) { throw new Exception( "TestCase with name [" + testCase + "] is missing in Project [" + project.getName() + "]"); } else { throw new Exception( "TestCase with name [" + testCase + "] in TestSuite [" + testSuite + "] is missing in Project [" + project.getName() + "]"); } } // decide what to run if (testCasesToRun.size() > 0) { for (TestCase testCase : testCasesToRun) { runTestCase((WsdlTestCase) testCase); } } else if (testSuite != null) { WsdlTestSuite ts = project.getTestSuiteByName(testSuite); if (ts == null) { throw new Exception("TestSuite with name [" + testSuite + "] not found in project"); } else { runSuite(ts); } } else { runProject(project); } long timeTaken = (System.nanoTime() - startTime) / 1000000; if (printReport) { printReport(timeTaken); } exportReports(project); if (saveAfterRun && !project.isRemote()) { try { project.save(); } catch (Throwable t) { log.error("Failed to save project", t); } } if ((assertions.size() > 0 || failedTests.size() > 0) && !ignoreErrors) { throwFailureException(); } return true; } finally { for (int c = 0; c < project.getTestSuiteCount(); c++) { TestSuite suite = project.getTestSuiteAt(c); for (int i = 0; i < suite.getTestCaseCount(); i++) { TestCase tc = suite.getTestCaseAt(i); removeListeners(tc); } } } }
/** * Runs SoapUI TestCase project * * @param project new WsdlProject("/path/to/soapui/testcase.xml") */ protected void run(WsdlProject project) { for (TestSuite testSuite : project.getTestSuiteList()) { run(testSuite); } }