我正在尝试为使REST端点可用的捆绑软件构建集成测试。
一段时间后,我努力将bundle和maven依赖项组合在一起以运行集成测试,我认为这一切都可以按预期进行,但是似乎端点不可用。
至少,这就是我为执行测试而创建的球衣客户端所告诉的内容。
除了球衣客户端返回的拒绝连接外,我没有其他错误。
下面,我列出了集成测试“ pom.xml”中的PAX EXAM和FELIX版本(以及主要相关的依赖项):
<dependency>
<groupId>br.com.company.application.offerbase.model</groupId>
<artifactId>offer-base-model</artifactId>
</dependency>
<dependency>
<groupId>br.com.company.application.offerbase</groupId>
<artifactId>offer-base</artifactId>
</dependency>
<dependency>
<groupId>br.com.company.application.offerbase.client</groupId>
<artifactId>offer-base-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>5.4.0</version>
<scope>test</scope>
</dependency>
...
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit4</artifactId>
<version>4.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-forked</artifactId>
<version>4.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-link-mvn</artifactId>
<version>4.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-cm</artifactId>
<version>4.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.url</groupId>
<artifactId>pax-url-wrap</artifactId>
<version>2.5.2</version>
</dependency>
有必要添加大约90个maven / bundle依赖关系,以使集成测试运行在此处可能非常冗长。
如果需要发布,请告诉我。
端点应位于:
http://0.0.0.0:9001/rest/api/v1/offer-base-service/
有关此配置的代码段也如下所示:
<osgi:reference id="httpService" interface="org.osgi.service.http.HttpService" />
<osgi:service depends-on="httpService" interface="br.com.company.application.offerbase.api.v1.controller.OfferBaseApiController">
<osgi:service-properties>
<entry key="service.exported.interfaces" value="*" />
<entry key="service.exported.configs" value="org.apache.cxf.rs" />
<entry key="service.exported.intents" value="HTTP" />
<entry key="org.apache.cxf.rs.databinding" value="jaxb" />
<entry key="org.apache.cxf.rs.invoker" value="br.com.company.application.api.service.exporter.invoker.WebServiceInvoker" />
<entry key="org.apache.cxf.rs.provider" value="br.com.company.application.componente.json.JacksonJsonProviderDecorator" />
<!--<entry key="org.apache.cxf.rs.provider" value-ref="jsonProviderDecorator" />-->
<entry key="org.apache.cxf.rs.address" value="http://0.0.0.0:9001/rest/api/v1/offer-base-service" />
</osgi:service-properties>
<ref bean="offerBaseApiControllerImpl" />
</osgi:service>
当然,该捆绑包可以在我的测试环境中完美运行,并且在Felix服务器启动并运行时,客户端(由上面的“ offer-base-client”依赖性提供)可以正常访问它,但是我正使用PAX EXAM为避免使服务器运行以执行集成测试。
<<球衣球衣客户端错误>>
我做错什么了吗?
#编辑1:
似乎集成测试不起作用,因为捆绑包尚未启动并运行。
在jersey客户端连接到端点出现问题之后,我试图直接获得对该服务的引用,但也无法。
增加了等待服务检索的时间,我能够注意到某些捆绑初始化时放弃了错误。
似乎原因是关于数据库连接的依赖关系(这很有意义),如下所示:
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor] : Unable to create application context for [br.com.company.application.api.log.listener.application-log-listener], unsatisfied dependencies: Dependency on [(objectClass=br.com.company.application.api.log.service.ApplicationLogService)] (from bean [&logService])
org.springframework.context.ApplicationContextException: Application context initialization for 'br.com.company.application.api.log.listener.application-log-listener' has timed out
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.timeout(DependencyWaiterApplicationContextExecutor.java:454)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.access$000(DependencyWaiterApplicationContextExecutor.java:50)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$WatchDogTask.run(DependencyWaiterApplicationContextExecutor.java:105)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.activator.ContextLoaderListener] : Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=br.com.company.application.api.log.listener.application-log-listener, config=osgibundle:/META-INF/spring/*.xml))
org.springframework.context.ApplicationContextException: Application context initialization for 'br.com.company.application.api.log.listener.application-log-listener' has timed out
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.timeout(DependencyWaiterApplicationContextExecutor.java:454)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.access$000(DependencyWaiterApplicationContextExecutor.java:50)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$WatchDogTask.run(DependencyWaiterApplicationContextExecutor.java:105)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyServiceManager] : Deregistering service dependency dependencyDetector for OsgiBundleXmlApplicationContext(bundle=br.com.company.application.api.log.application-log-service, config=osgibundle:/META-INF/spring/*.xml)
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor] : Timeout occurred before finding service dependencies for [OsgiBundleXmlApplicationContext(bundle=br.com.company.application.api.log.application-log-service, config=osgibundle:/META-INF/spring/*.xml)]
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor] : Cancelled dependency watchdog...
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor] : Closing appCtx for OsgiBundleXmlApplicationContext(bundle=br.com.company.application.api.log.application-log-service, config=osgibundle:/META-INF/spring/*.xml)
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor] : Cleaning up appCtx OsgiBundleXmlApplicationContext(bundle=br.com.company.application.api.log.application-log-service, config=osgibundle:/META-INF/spring/*.xml)
org.springframework.beans[org.springframework.beans.factory.support.DefaultListableBeanFactory] : Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@23f65af2: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,applicationLogRepositoryImpl,applicationLogServiceImpl,persistenceUnitManager,entityManagerFactory,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,dataSource,applicationLogServiceOsgi]; root of factory hierarchy
org.springframework.beans[org.springframework.beans.factory.support.DisposableBeanAdapter] : Invoking destroy() on bean with name 'dataSource'
org.springframework.beans[org.springframework.beans.factory.support.DisposableBeanAdapter] : Invoking destroy() on bean with name 'transactionManager'
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyServiceManager] : Deregistering service dependency dependencyDetector for OsgiBundleXmlApplicationContext(bundle=br.com.company.application.api.log.application-log-service, config=osgibundle:/META-INF/spring/*.xml)
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor] : Unable to create application context for [br.com.company.application.api.log.application-log-service], unsatisfied dependencies: Dependency on [(objectClass=org.springframework.transaction.PlatformTransactionManager)] (from bean [&transactionManager]), Dependency on [(&(objectClass=javax.sql.DataSource)(osgi.jndi.service.name=jdbc/dataSourceAPP))] (from bean [&dataSource])
org.springframework.context.ApplicationContextException: Application context initialization for 'br.com.company.application.api.log.application-log-service' has timed out
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.timeout(DependencyWaiterApplicationContextExecutor.java:454)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.access$000(DependencyWaiterApplicationContextExecutor.java:50)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$WatchDogTask.run(DependencyWaiterApplicationContextExecutor.java:105)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
因此,我添加了“ pax-jdbc-config”库及其依赖项,并创建了“ .cfg”文件,但由于无法正常工作,恐怕我不会将其放在正确的位置。 / p>
“ org.ops4j.datasource-general.cfg”文件的内容为:
osgi.jndi.service.name=jdbc/dataSourceAPP
osgi.jdbc.driver.class=oracle.jdbc.pool.OracleDataSource
dataSourceName=ds
url=<ORACLE_DATABASE_URL>
user=<ORACLE_DATABASE_USER>
password=<ORACLE_DATABASE_PASSWORD>
运行测试之前的最后几行是:
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor] : Pre-refresh completed; determining dependencies...
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyServiceManager] : Discovered local dependency factories: []
org.springframework.beans[org.springframework.beans.factory.support.DefaultListableBeanFactory] : Creating shared instance of singleton bean 'springDatasource'
org.springframework.beans[org.springframework.beans.factory.support.DefaultListableBeanFactory] : Creating instance of bean 'springDatasource'
org.springframework.beans[org.springframework.beans.factory.support.DefaultListableBeanFactory] : Eagerly caching bean 'springDatasource' to allow for resolving potential circular references
org.springframework.beans[org.springframework.beans.factory.support.DefaultListableBeanFactory] : Invoking afterPropertiesSet() on bean with name 'springDatasource'
org.springframework.beans[org.springframework.beans.factory.support.DefaultListableBeanFactory] : Finished creating instance of bean 'springDatasource'
org.springframework.beans[org.springframework.beans.factory.support.DefaultListableBeanFactory] : Creating shared instance of singleton bean 'transactionManager'
org.springframework.beans[org.springframework.beans.factory.support.DefaultListableBeanFactory] : Creating instance of bean 'transactionManager'
org.springframework.beans[org.springframework.beans.factory.support.DefaultListableBeanFactory] : Eagerly caching bean 'transactionManager' to allow for resolving potential circular references
org.springframework.beans[org.springframework.beans.factory.support.DefaultListableBeanFactory] : Invoking afterPropertiesSet() on bean with name 'transactionManager'
org.springframework.beans[org.springframework.beans.factory.support.DefaultListableBeanFactory] : Finished creating instance of bean 'transactionManager'
org.springframework.beans[org.springframework.beans.factory.support.DefaultListableBeanFactory] : Creating shared instance of singleton bean 'httpService'
org.springframework.beans[org.springframework.beans.factory.support.DefaultListableBeanFactory] : Creating instance of bean 'httpService'
org.springframework.beans[org.springframework.beans.factory.support.DefaultListableBeanFactory] : Eagerly caching bean 'httpService' to allow for resolving potential circular references
org.springframework.beans[org.springframework.beans.factory.support.DefaultListableBeanFactory] : Invoking afterPropertiesSet() on bean with name 'httpService'
org.springframework.beans[org.springframework.beans.factory.support.DefaultListableBeanFactory] : Finished creating instance of bean 'httpService'
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyServiceManager] : Adding OSGi service dependency for importer [&springDatasource] matching OSGi filter [(objectClass=javax.sql.DataSource)]
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyServiceManager] : Adding OSGi service dependency for importer [&transactionManager] matching OSGi filter [(objectClass=org.springframework.transaction.PlatformTransactionManager)]
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyServiceManager] : Adding OSGi service dependency for importer [&httpService] matching OSGi filter [(objectClass=org.osgi.service.http.HttpService)]
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyServiceManager] : 3 OSGi service dependencies, 3 unsatisfied (for beans [&springDatasource, &transactionManager, &httpService]) in OsgiBundleXmlApplicationContext(bundle=br.com.algartelecom.algarcrm.offerbase.offer-base, config=osgibundle:/META-INF/spring/*.xml)
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyServiceManager] : OsgiBundleXmlApplicationContext(bundle=br.com.algartelecom.algarcrm.offerbase.offer-base, config=osgibundle:/META-INF/spring/*.xml) is waiting for unsatisfied dependencies [[&springDatasource, &transactionManager, &httpService]]
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor] : Registering service dependency dependencyDetector for OsgiBundleXmlApplicationContext(bundle=br.com.algartelecom.algarcrm.offerbase.offer-base, config=osgibundle:/META-INF/spring/*.xml)
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyServiceManager] : OsgiBundleXmlApplicationContext(bundle=br.com.algartelecom.algarcrm.offerbase.offer-base, config=osgibundle:/META-INF/spring/*.xml) has registered service dependency dependencyDetector with filter: (|(objectClass=javax.sql.DataSource)(objectClass=org.springframework.transaction.PlatformTransactionManager)(objectClass=org.osgi.service.http.HttpService))
org.springframework.osgi.extender[org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor] : Asynch wait-for-dependencies started...
org.ops4j.pax.exam.invoker.junit[org.ops4j.pax.exam.invoker.junit.internal.ContainerTestRunner] : running findOfferProductsByNameAndFeatureValueCodeTest_NoFilters in reactor
ago 17, 2018 9:00:19 AM org.ops4j.pax.jdbc.config.impl.ServiceTrackerHelper track
INFORMAÇÕES: Waiting for service dependency: (&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc.driver.class=oracle.jdbc.pool.OracleDataSource))
org.apache.aries.blueprint.core[org.apache.aries.blueprint.container.BlueprintExtender] : Stopping blueprint extender...
我已经尝试将“ .cfg”文件放在以下位置:
<PROJECT_BASE_PATH>/ -- same place of the "pom.xml" file.
<PROJECT_BASE_PATH>/src
<PROJECT_BASE_PATH>/src/test
<PROJECT_BASE_PATH>/src/test/resources
<PROJECT_BASE_PATH>/etc
<PROJECT_BASE_PATH>/src/etc
<PROJECT_BASE_PATH>/src/test/etc
<PROJECT_BASE_PATH>/src/test/resources/etc
有什么想法吗?
感谢和问候, 毛罗。