protected void attachPathToProject(String projectPath) throws XmlException, IOException, SoapUIException { project = new WsdlProject( projectPath ); }
@Override public List<Service> getServiceDefinitions() throws MockRepositoryImportException { List<Service> result = new ArrayList<>(); // Add Soap and then Rest services definitions. result.addAll(getSoapServiceDefinitions(project.getMockServiceList())); result.addAll(getRestServiceDefinitions(project.getRestMockServiceList())); return result; }
@Override public Map<Request, Response> getMessageDefinitions(Service service, Operation operation) throws MockRepositoryImportException { // First try with a Soap Service mock... MockService mockService = project.getMockServiceByName(service.getName()); if (mockService != null){ try { return getSoapMessageDefinitions(mockService, operation); } catch (XPathExpressionException xpe) { log.error("Got a XPathExpressionException while retrieving soap messages", xpe); throw new MockRepositoryImportException("XPathExpressionExcpetion while retrieving soap messages", xpe); } } // ... then with a Rest Service mock. RestMockService restMockService = project.getRestMockServiceByName(service.getName()); if (restMockService != null){ return getRestMessageDefinitions(restMockService, operation); } return new HashMap<>(); }
protected Map<QName, WsdlInterface> matchBindings(WsdlProject project, Map<String, QName> services) throws WsdlBindingException List<AbstractInterface<?>> interfaceList = project.getInterfaces(WsdlInterfaceFactory.WSDL_TYPE); if (interfaceList.size() < 1) throw new WsdlBindingException("There are no WSDL interfaces in current project"); result.put(services.get(key),(WsdlInterface) project.getInterfaceByName(val));
/** * Collect and filter by operation all the WsldTestrequest from the current project. */ private Map<String, RestTestRequest> collectRestTestRequests(Operation operation){ Map<String, RestTestRequest> result = new HashMap<String, RestTestRequest>(); for (TestSuite testsuite : project.getTestSuiteList()){ for (TestCase testcase : testsuite.getTestCaseList()){ for (TestStep teststep : testcase.getTestStepList()){ if (teststep instanceof RestTestRequestStep){ RestTestRequestStep rs = (RestTestRequestStep)teststep; RestTestRequest rr = rs.getTestRequest(); if (rs.getResourcePath().equals(operation.getName())){ result.put(rr.getName(), rr); } } } } } return result; }
WsdlMockService wsdlMockService = project.getMockServiceByName(service.getName()); WsdlInterface wi = project.getMockServiceByName(service.getName()).getMockedInterfaces()[0];
/** * Collect and filter by operation all the WsldTestrequest from the current project. */ private Map<String, WsdlTestRequest> collectWsdlTestRequests(Operation operation){ Map<String, WsdlTestRequest> result = new HashMap<>(); for (TestSuite testsuite : project.getTestSuiteList()){ for (TestCase testcase : testsuite.getTestCaseList()){ for (TestStep teststep : testcase.getTestStepList()){ if (teststep instanceof WsdlTestRequestStep){ WsdlTestRequestStep ws = (WsdlTestRequestStep)teststep; WsdlTestRequest wr = ws.getHttpRequest(); if (wr.getOperationName().equals(operation.getName())){ result.put(wr.getName(), wr); } } } } } return result; }
log.warn("No request found for response " + mockResponse.getName() + " into SoapUI project " + project.getName()); continue;
/** * Build a new importer. * @param projectFilePath The path to local SoapUI project file * @throws IOException if project file cannot be found */ public SoapUIProjectImporter(String projectFilePath) throws IOException{ try{ project = new WsdlProject(projectFilePath); } catch (Exception e) { throw new IOException("SoapUI project file"); } }
for (TestSuite testSuite : project.getTestSuiteList()){ for (TestCase testCase : testSuite.getTestCaseList()){
/** * Build a new SoapUITestStepsRunner for a project. * @param projectFilePath The path to SoapUI project file * @throws java.io.IOException if file cannot be found or accessed. */ public SoapUITestStepsRunner(String projectFilePath) throws IOException{ try{ project = new WsdlProject(projectFilePath); } catch (Exception e) { throw new IOException("SoapUI project file cannot be found or accessed"); } }
public SoapuiWsdlTemplate() throws SoapUIException, XmlException, IOException { this(new WsdlProject(), new SoapuiProperties()); }
public WsdlInfo(String wsdlUrl) throws SoapUIException { try { this.wsdlUrl = wsdlUrl; // create new project WsdlProject project = new WsdlProject(); WsdlInterface[] wsdlInterfaces = WsdlImporter.importWsdl(project, wsdlUrl); if (null != wsdlInterfaces) { List<WsdlInterfaceInfo> interfaces = new ArrayList<WsdlInterfaceInfo>(); for (WsdlInterface wsdlInterface : wsdlInterfaces) { WsdlInterfaceInfo interfaceInfo = new WsdlInterfaceInfo(wsdlInterface); interfaces.add(interfaceInfo); } this.interfaces = interfaces; } } catch (Exception e) { throw new SoapUIException("Failed to import WSDL '" + wsdlUrl + "'.", e); } }