title: Launching two spring boot apps in integration test
body: <p>I have a spring boot integration test. Currently it is running on the test through my test server app(MockServerApp.java) which is located in src/test/resources.</p>
  
  <p>I want to also launch my spring boot app (App.java) before the integration tests are launched so it could connect and exercise soap calls that I will be adding to the integration test rather than manually running the main app server and then launching my integration test</p>
  
  <p>My MockServerApp is configured to port 9119. 
  My App(main app) is configured to port 28433. 
  They are both running on localhost.</p>
  
  <p>At first I tried running the two apps at the same time using SpringBootTest</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,classes = {App.class,MockServerApp.class
  })
  public class BillingMediatorIT {
  
          @Test
          public void testOne(){
  
  
              }
          }
  </code></pre>
  
  <p>But this only launches the mock server on port 9119. </p>
  
  <p>I then tried launching it before integration tests like this </p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,classes = {App.class,MockServerApp.class
  })
  public class BillingMediatorIT {
  
  
          static ConfigurableApplicationContext context;
          @BeforeClass
          static public void  setup(){
              SpringApplication springApplication = new SpringApplicationBuilder()           
                      .sources(App.class)
                      .build();
              context = springApplication.run();
          }
          @Test
          public void testOne(){
  
  
              }
          }
  </code></pre>
  
  <p>This gave me an error though saying that the address is already in use. </p>
  
  <p>my test.properties</p>
  
  <pre><code>server.ssl.enabled=false
  logging.config=classpath:logback-spring.xml
  logging.file=messages
  logging.file.max-size=50MB
  logging.level.com.nulogix=DEBUG
  billing.engine.address=127.0.0.1
  billing.engine.port=9119
  billing.engine.api.version=0.97
  billing.engine.core.version=0.97
  billing.engine.core.name=Patient_Responsibility
  </code></pre>
  
  <p>my app.properties</p>
  
  <pre><code>server.port=28433
  server.ssl.enabled=true
  server.ssl.key-store=/Users/asluborski/Documents/mock.jks
  server.ssl.key-store-password=Nul0gix
  logging.config=classpath:logback-spring.xml
  logging.file=messages
  logging.file.max-size=50MB
  logging.level.com.nulogix=DEBUG
  billing.engine.address=127.0.0.1
  billing.engine.port=9119
  billing.engine.api.version=0.97
  billing.engine.core.version=0.97
  billing.engine.core.name=Patient_Responsibility
  </code></pre>
  
  <p>So after playing around and changing the server.ports in both properties files, I've realized that the integration test is still running with my MockServerApp although my spring boot test is directing towards the main app class. I've tried using property source but it didn't work.</p>
  
  <p>Something I should add is that both my properties in src/test/resources and src/main/resources are both named application.properties. I am not sure if this could be causing the conflict but I simply copied over the properties from main and then just changed the server.port inside the file. I am not sure how to change the name of the .properties.  </p>