jeudi 19 février 2015

Java - spring @IntegrationTest always on 8080

I'm trying to run an integration test on a random port using Spring annotation @IntegrationTest. However, I'm getting 8080 all the time. Any ideas?


The code I' using:



import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional;

import com.github.springtestdbunit.DbUnitTestExecutionListener;
import com.github.springtestdbunit.annotation.DatabaseSetup;

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DbUnitTestExecutionListener.class })
@SpringApplicationConfiguration(classes = {FooConfig.class})
@DatabaseSetup("/db/Foo.xml")
@IntegrationTest("server.port:0")
@Transactional
public class Foo{

@Value("${local.server.port}")
private int port;

@Test
public void test() {
System.out.println(port);
}
}




Aucun commentaire:

Enregistrer un commentaire