通过Java

时间:2017-11-10 10:29:46

标签: soapui

我正在尝试通过java运行从SOAP项目导出的项目xml文件。基本上,我们的想法是在不打开SOAP UI的情况下运行测试。 当我使用TestNG或JUnit运行它时它运行成功,但是当我尝试通过gradle项目运行它时,它会给我连接拒绝错误。

以下是java代码:

package com.automation;

import org.testng.annotations.Test;

import com.eviware.soapui.tools.SoapUITestCaseRunner;

public class SOAPJenkinsTest {

   public static String xmlPath = System.getProperty("user.dir") + "\\resources\\Automation-soapui-project.xml";


   @Test
   public void testSoapUI() {
          // initialize SoapUITestCaseRunner class object
          SoapUITestCaseRunner soapUITestCaseRunner = new SoapUITestCaseRunner();

          // set your project absolute path of your project
          soapUITestCaseRunner.setProjectFile(xmlPath);
          try {
                 // call run method to execute all test of project.
                 soapUITestCaseRunner.run();
          } catch (Exception e) {
                 e.printStackTrace();
          }
   }

}

我使用build.gradle导入了依赖项,当我运行上面的java代码时,它给出了以下错误。您可以注意到,它成功运行了最初的几个步骤,当触发实际请求时,它会失败。包装com.automation;

import org.testng.annotations.Test;    
import com.eviware.soapui.tools.SoapUITestCaseRunner;    
public class SOAPJenkinsTest {    
soapUI 4.0.1 TestCase Runner    
03:30:28,850 WARN  [SoapUI] Missing folder [C:\SOAPJenkins\SOAP-Automation\.\ext] for external libraries    
03:30:29,170 INFO  [DefaultSoapUICore] initialized soapui-settings from [C:\Users\PAT6819\soapui-settings.xml]    
03:30:30,451 INFO  [WsdlProject] Loaded project from [file:/C:/SOAPJenkins/SOAP-Automation/resources/Automation-soapui-project.xml]    
03:30:30,548 WARN  [WsdlProject] Project 'Automation' is from a newer version (5.3.0) of soapUI than this (4.0.1) and parts of it may be incompatible or incorrect. Saving this project with this version of soapUI may cause it to function differently.    
03:30:31,148 INFO  [SoapUITestCaseRunner] Running soapUI tests in project [Automation]    
03:30:31,150 INFO  [SoapUITestCaseRunner] Running Project [Automation], runType = SEQUENTIAL    
03:30:31,163 INFO  [SoapUITestCaseRunner] Running soapUI testcase [getConsFldCompPlan TestCase]    
03:30:31,172 INFO  [SoapUITestCaseRunner] running step [ReadData]    
03:30:31,623 INFO  [log] C:\SOAPJenkins\SOAP-Automation\resources    
03:30:32,415 INFO  [SoapUITestCaseRunner] running step [ExtractInputValues]    
03:30:32,659 INFO  [SoapUITestCaseRunner] running step [DBToExcel]    
03:30:33,218 INFO  [SoapUITestCaseRunner] running step [getConsFldCompPlan]    
03:30:37,352 ERROR [WsdlSubmit] Exception in request: java.net.ConnectException: Connection refused: connect    
03:30:37,352 ERROR [SoapUI] An error occured [Connection refused: connect], see error log for details
03:30:37,358 ERROR [SoapUITestCaseRunner] getConsFldCompPlan failed, exporting to [C:\SOAPJenkins\SOAP-Automation\resources\ConsolidatedFieldCompensationPlanWebService_TestSuite-getConsFldCompPlan_TestCase-getConsFldCompPlan-0-FAILED.txt]
java.net.ConnectException: Connection refused: connect
       at java.net.DualStackPlainSocketImpl.connect0(Native Method)
       at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
       at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
       at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
       at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
       at java.net.PlainSocketImpl.connect(Unknown Source)
       at java.net.SocksSocketImpl.connect(Unknown Source)
       at java.net.Socket.connect(Unknown Source)
       at java.net.Socket.connect(Unknown Source)
       at java.net.Socket.<init>(Unknown Source)
       at java.net.Socket.<init>(Unknown Source)
       at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
       at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
       at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
       at com.eviware.soapui.impl.wsdl.support.http.SoapUIMultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(SoapUIMultiThreadedHttpConnectionManager.java:1637)
       at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
       at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
       at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
       at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.sendRequest(HttpClientRequestTransport.java:202)
       at com.eviware.soapui.impl.wsdl.WsdlSubmit.run(WsdlSubmit.java:123)
       at com.eviware.soapui.impl.wsdl.WsdlSubmit.submitRequest(WsdlSubmit.java:76)
       at com.eviware.soapui.impl.wsdl.WsdlRequest.submit(WsdlRequest.java:238)
       at com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep.run(WsdlTestRequestStep.java:366)
       at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:232)
       at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:48)
       at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:141)
       at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:42)
       at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:135)
       at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
       at java.util.concurrent.FutureTask.run(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
       at java.lang.Thread.run(Unknown Source)

0 个答案:

没有答案