I have two spring boot apps, one contained in my src/test and one in my src/main.
I am using Maven verify to run SOAP integration tests. I have successfully booted my main app but also want to boot my test app pre-integration. I want to run the tests on my test app and then I need the main app to be open as well so it can connect to the SOAP endpoint.
When I run mvn verify, it starts up my main app in pre-integration and then runs ONLY my integration tests. Is it possible to launch another app? If yes, how do I configure it into my maven-springboot-plugin?
[INFO] --- spring-boot-maven-plugin:2.1.0.RELEASE:start (pre-integration-test) @ billing_mediator ---
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.0.RELEASE)
2019-08-21 09:20:41.577 INFO 53762 --- [ling.App.main()] com.nulogix.billing.App : Starting App on Alexs-MacBook-Pro.local with PID 53762 (/Users/Alex/Documents/billing/billing_mediator/target/classes started by asluborski in /Users/asluborski/Documents/billing/billing_mediator)
2019-08-21 09:20:41.582 DEBUG 53762 --- [ling.App.main()] com.nulogix.billing.App : Running with Spring Boot v2.1.0.RELEASE, Spring v5.1.2.RELEASE
2019-08-21 09:20:41.585 INFO 53762 --- [ling.App.main()] com.nulogix.billing.App : No active profile set, falling back to default profiles: default
2019-08-21 09:20:42.541 INFO 53762 --- [ling.App.main()] trationDelegate$BeanPostProcessorChecker : Bean 'webServiceConfig' of type [com.nulogix.billing.ws.endpoint.WebServiceConfig$$EnhancerBySpringCGLIB$$ad324219] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-08-21 09:20:42.544 INFO 53762 --- [ling.App.main()] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$668ea787] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-08-21 09:20:42.593 INFO 53762 --- [ling.App.main()] .w.s.a.s.AnnotationActionEndpointMapping : Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
2019-08-21 09:20:43.099 INFO 53762 --- [ling.App.main()] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 28443 (https)
2019-08-21 09:20:43.128 INFO 53762 --- [ling.App.main()] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-08-21 09:20:43.129 INFO 53762 --- [ling.App.main()] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/9.0.12
2019-08-21 09:20:43.144 INFO 53762 --- [ling.App.main()] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/asluborski/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2019-08-21 09:20:43.258 INFO 53762 --- [ling.App.main()] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-08-21 09:20:43.258 INFO 53762 --- [ling.App.main()] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1625 ms
2019-08-21 09:20:43.300 INFO 53762 --- [ling.App.main()] o.s.b.w.servlet.ServletRegistrationBean : Servlet messageDispatcherServlet mapped to [/nulogix/ws/*]
2019-08-21 09:20:43.302 INFO 53762 --- [ling.App.main()] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2019-08-21 09:20:43.307 INFO 53762 --- [ling.App.main()] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-08-21 09:20:43.308 INFO 53762 --- [ling.App.main()] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-08-21 09:20:43.308 INFO 53762 --- [ling.App.main()] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'formContentFilter' to: [/*]
2019-08-21 09:20:43.308 INFO 53762 --- [ling.App.main()] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2019-08-21 09:20:43.350 DEBUG 53762 --- [ling.App.main()] c.n.b.service.PredictionEngineService : billing.engine.address=127.0.0.1
2019-08-21 09:20:43.351 DEBUG 53762 --- [ling.App.main()] c.n.b.service.PredictionEngineService : billing.engine.port=9119
2019-08-21 09:20:43.351 DEBUG 53762 --- [ling.App.main()] c.n.b.service.PredictionEngineService : Using http://127.0.0.1:9119
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/Users/asluborski/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.11/jaxb-impl-2.2.11.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of com.sun.xml.bind.v2.runtime.reflect.opt.Injector
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2019-08-21 09:20:43.847 DEBUG 53762 --- [ling.App.main()] c.n.billing.ws.endpoint.AnalyzeEndPoint : billing.engine.api.version=0.97
2019-08-21 09:20:43.847 DEBUG 53762 --- [ling.App.main()] c.n.billing.ws.endpoint.AnalyzeEndPoint : billing.engine.core.version=0.97
2019-08-21 09:20:43.848 DEBUG 53762 --- [ling.App.main()] c.n.billing.ws.endpoint.AnalyzeEndPoint : billing.engine.core.name=Nulogix_Patient_Responsibility
2019-08-21 09:20:43.851 DEBUG 53762 --- [ling.App.main()] c.n.b.ws.endpoint.GetVersionEndPoint : billing.engine.api.version=0.97
2019-08-21 09:20:44.099 INFO 53762 --- [ling.App.main()] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-08-21 09:20:45.055 INFO 53762 --- [ling.App.main()] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 28443 (https) with context path ''
2019-08-21 09:20:45.060 INFO 53762 --- [ling.App.main()] com.nulogix.billing.App : Started App in 4.044 seconds (JVM running for 13.722)
[INFO]
[INFO] --- maven-failsafe-plugin:2.18.1:integration-test (default) @ billing_mediator ---
EDIT:
So I edited my POM and added multiple executions like this(not sure if this is correct, can't find any documentation on how to do this for spring boot maven plugin)
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includePom>true</includePom>
</configuration>
<executions>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
<configuration>
<mainClass>com.nulogix.billing.App</mainClass>
</configuration>
</execution>
<execution>
<id>pre-integration-test2</id>
<goals>
<goal>start</goal>
</goals>
<configuration>
<mainClass>com.nulogix.billing.mockserver.MockServerApp</mainClass>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
<configuration>
<mainClass>com.nulogix.billing.App</mainClass>
</configuration>
</execution>
<execution>
<id>post-integration-test2</id>
<goals>
<goal>stop</goal>
</goals>
<configuration>
<mainClass>com.nulogix.billing.mockserver.MockServerApp</mainClass>
</configuration>
</execution>
</executions>
</plugin>
This gives me an error though when it tries to start up my test server(MockServerApp).
java.lang.ClassNotFoundException: com.nulogix.billing.mockserver.MockServerApp
at java.net.URLClassLoader.findClass (URLClassLoader.java:436)
at java.lang.ClassLoader.loadClass (ClassLoader.java:588)
at java.lang.ClassLoader.loadClass (ClassLoader.java:521)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:553)
at java.lang.Thread.run (Thread.java:835)
Not sure why it is giving me this error since it is the correct class path and the class exists under src/test/java
EDIT:
I added this into configuration of plugin
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includePom>true</includePom>
<additionalClasspathElements>
<additionalClasspathElement>${basedir}/target/test-classes</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
but I get the same error.
Adding classpathscope also doesn't fix:
<execution>
<id>pre-integration-test2</id>
<goals>
<goal>start</goal>
</goals>
<configuration>
<mainClass>com.nulogix.billing.mockserver.MockServerApp</mainClass>
<classpathScope>test</classpathScope>
</configuration>
</execution>