SoapUI步骤会覆盖log4j设置

时间:2013-01-16 15:59:32

标签: maven log4j soapui jbehave

我正在设置一个在Maven构建期间运行JBehave测试的设置。

测试步骤包括使用SoapUI Java类向Web服务发送请求。

一切都运行良好,测试。我的问题是进度的SoapUI部分似乎覆盖了log4j设置,因此后续的日志调用不会打印到控制台(也不是文件)。

我尝试过调用

的解决方法
    ClassLoader loader = this.getClass().getClassLoader();
    URL resource = loader.getResource("log4j.xml");
    PropertyConfigurator.configure(resource);

尝试将配置重置为原始配置,但到目前为止没有成功。

Log4j(1.2)和SoapUI(4.5.1)在pom中使用普通设置。记录器创建为 protected final Log log = LogFactory.getLog(getClass());

我得到的控制台输出如下:

    pool-1-thread-1 16:36:08,212 DEBUG ästeps.LoginSteps:25 - logging in user: testfir
    pool-1-thread-1 16:36:08,213 DEBUG äpages.LoginPage:26 - Create LoginPage
    pool-1-thread-1 16:36:08,985 DEBUG äpages.LoginPage:38 - login user: testfir
    pool-1-thread-1 16:36:10,343 DEBUG äpages.WorkspacePage:36 - creating WorkspacePage
    Givet user testfir has logged in
    16:36:11,634 WARN  [SoapUI] Missing folder [D:\proj\src\test\functional-tests\.\ext] for external libraries
    16:36:11,809 INFO  [DefaultSoapUICore] initialized soapui-settings from [C:\Users\xxx\soapui-settings.xml]
    16:36:12,176 INFO  [WsdlProject] Loaded project from [file:/D:/proj/src/test/functional-tests/src/test/resources/ReceiveCase-soapui.xml]
    16:36:12,640 DEBUG [HttpClientSupport$SoapUIHttpClient] Attempt 1 to execute request
    16:36:12,640 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Sending request: POST /soa-infra/services/default/ReceiveCases/ReceiveCase_v1_0_ep HTTP/1.1
    16:36:13,841 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Receiving response: HTTP/1.1 200 OK
    16:36:13,842 DEBUG [HttpClientSupport$SoapUIHttpClient] Connection can be kept alive indefinitely
    And a case exists
    When case is choosen
    16:36:46,832 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Connection closed
    Then the details are displyed

我希望用

输出日志
  

将案例ID设置为:123456

与“创建登录页面”的方式相同。

无法理解为什么这样做以及如何让我的日志条目显示出来。那里有什么想法吗?

致以最诚挚的问候,Christian

1 个答案:

答案 0 :(得分:0)

管理以找到问题的根源。 Maven扭曲了文件编码。添加

    <configuration>
      <encoding>UTF-8</encoding>
      <inputEncoding>UTF-8</inputEncoding>
      <outputEncoding>UTF-8</outputEncoding>
      <argLine>-Dfile.encoding=UTF-8</argLine>
    </configuration>

到pom文件中的maven-surefire-plugin部分解决了我的问题。

/干杯