Question: How can you access the application context in a Spring integration test?

  1. The context is present in a ThreadLocal so you can just call getSpringApplicationContextInstance() anywhere in a test to get the current context.
  2. Test classes can implement the ApplicationContextAware interface or autowire the ApplicationContext.
  3. The context is automatically injected in every test so you can just call getSpringApplicationContextInstance() anywhere in a test to get the current context.
  4. You can just add the parameter Context context to any method so that the context is automatically wired in.

Answer: The correct answer of the above question is Option B:Test classes can implement the ApplicationContextAware interface or autowire the ApplicationContext.