I have two spring boot apps one in src/test and the other in src/main. They have their separate app.properties and separate ports.
I want to make an integration test and before it runs I want it to start those two servers when I run integration test in maven. So far using pre and post maven integration test plugin has not helped and I can't seem to start both of them in Spring Boot programatically.
Also, I have realized that integration test won't connect to my main app even if I specify it with ActiveProfile and spring boot test, it just always launches my test app.
My main app:
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
@SpringBootApplication
public class App
{
public static void main( String[] args )
{
new SpringApplicationBuilder(App.class)
.build()
.run(args);
}
}
My test app:
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
@SpringBootApplication
public class MockServerApp {
public static void main(String[] args) {
// TODO Auto-generated method stub
new SpringApplicationBuilder(MockServerApp.class)
.build()
.run(args);
}
}
My integration-test
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.PropertySource;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import com.nulogix.billing.App;
import com.nulogix.billing.mockserver.MockServerApp;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,classes = {App.class})
public class BillingMediatorIT {
@Test
public void testOne(){
}
}
My App.class connects to port 28433 and my MockServerApp.class connects to port 9119.
My test still connects to MockServerApp.class for some reason because it uses port 9119.
How do I fix this and make it start up the two apps pre-integration test phase.
Aucun commentaire:
Enregistrer un commentaire