簡體   English   中英

將測試套件公開為休息服務時,無法關閉CITRUS SPRING IOC容器

[英]Unable to close CITRUS SPRING IOC container while exposing the test suite as a rest service

我正在使用TESTNG來執行CITRUS測試類,同時執行以下柑橘代碼並正確執行了該操作,並在最后關閉了spring容器。

TestNG testng = new TestNG();
    List<String> suites = Lists.newArrayList();
    suites.add("C:/Users/mounika/citrusrest/CitrusDemoServices/src/test/java/com/citrus/samples/TestSuit.xml");//path to testng xml..
    testng.setTestSuites(suites);
    testng.run();

測試類執行得很好,但是在將以上代碼作為其余服務公開時,柑桔彈簧容器沒有關閉。 通常在正常運行而最終沒有休息的情況下,我得到以下日志

 18:26:08.459 [Thread-0] INFO 
org.springframework.context.support.GenericApplicationContext - Closing 
org.springframework.context.support.GenericApplicationContext@6b1274d2: 
startup date [Mon Nov 27 18:26:02 IST 2017]; root of context hierarchy
18:26:08.459 [Thread-0] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - 
Returning cached instance of singleton bean 'lifecycleProcessor'
18:26:08.459 [Thread-0] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory - 
Destroying singletons in org.springframework.beans.factory.support.
DefaultListableBeanFactory@25d250c6: defining beans 
[org.springframework.context.annotation.
internalConfigurationAnnotationProcessor,org.springframework.context.
annotation.internalAutowiredAnnotationProcessor,org.springframework.
context.annotation.internalRequiredAnnotationProcessor,org.
springframework.
context.annotation.internalCommonAnnotationProcessor,
org.springframework.context.event.internalEventListenerProcessor,
org.springframework.context.event.internalEventListenerFactory,
citrusSpringConfig,com.consol.citrus.functions.FunctionConfig,
functionRegistry,citrusFunctionLibrary,
com.consol.citrus.validation.matcher.ValidationMatcherConfig,
validationMatcherRegistry,xmlValidationMatcher,
citrusValidationMatcherLibrary,
com.consol.citrus.validation.MessageValidatorConfig,
defaultXmlMessageValidator,defaultMessageHeaderValidator,
defaultXpathMessageValidator,defaultJsonMessageValidator,
defaultJsonPathMessageValidator,defaultPlaintextMessageValidator,
defaultBinaryBase64MessageValidator,defaultGzipBinaryBase64MessageValidator,
defaultXhtmlMessageValidator,defaultXhtmlXpathMessageValidator,
defaultGroovyXmlMessageValidator,defaultGroovyJsonMessageValidator,
defaultGroovyTextMessageValidator,citrusMessageValidatorRegistry,
testContextFactory,endpointFactory,referenceResolver,
messageConstructionInterceptors,loggingReporter,htmlReporter,
testListeners,testActionListeners,testSuiteListeners,messageListeners,
failureStackTestListener]; root of factory hierarchy

但是,在作為REST服務調用時,由於在第一次REST命中之后,因此沒有在結束時顯示以上日志,在第二個REST命中,柑桔也在執行相同的XML測試用例。 我想為每個Rest命中更改測試用例xml名稱。

如果未明確手動關閉,則Citrus中使用的Spring應用程序上下文將綁定到JVM關閉。 如果您的JVM運行時終止,Spring應用程序上下文將自動關閉。

如果您正在將TestNG進程作為服務器JVM的一部分運行,則只要服務器正在運行,就不會終止。 因此,我為您提供了兩種選擇:

  1. 使用Java java.lang.ProcessBuilder API在單獨的JVM進程中運行測試。
  2. 向后套件TestNG階段添加一些邏輯,該邏輯可以手動正常關閉Spring應用程序上下文。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM