We have a standard Spring test class which loads an application context:
@ContextConfiguration(locations = {"classpath:app-context.xml" })
@RunWith(SpringJUnit4ClassRunner.class)
public class AppTest {
...
}
The XML context uses standard placeholders e.g.: ${key}
When the full application is run normally (not as a test), the main class will load the application context as follows so that the command line arguments are seen by Spring :
PropertySource ps = new SimpleCommandLinePropertySource(args);
context.getEnvironment().getPropertySources().addLast(ps);
context.load("classpath:META-INF/app-context.xml");
context.refresh();
context.start();
When running the Spring test, what code needs to be added to ensure that program arguments (e.g. --key=value
): are passed from the IDE (in our case Eclipse) into the application context?
Thanks