title: AbstractApplicationContext has not been refreshed yet exception
body: <p>I have a standalone jar application which uses spring context as below:</p>
  
  <pre><code>class MainClass {    
      public static void main(final String[] args) {
          AbstractApplicationContext applicationContext = new 
          GenericXmlApplicationContext("file-path-to-xml-config");
          ClassA classA = applicationContext.getBean(ClassA.class);
          ...
      } 
  }
  </code></pre>
  
  <p>Am trying to integration-test above method as below:</p>
  
  <pre><code>@ContextConfiguration(locations = { "file-path-to-test-xml-config" })
  public class AbstractIT extends AbstractTestNGSpringContextTests {
      @Inject
      private ClassB classB;
  
      @Test
      public void testMain() {
          classB.someMethod();
          MainClass.main(null);
      }
  }
  </code></pre>
  
  <p>Above setup throws below exception:</p>
  
  <blockquote>
    <p>java.lang.IllegalStateException:
    org.springframework.context.support.AbstractApplicationContext__Generated_OpenPojo@356f20b7
    has not been refreshed yet</p>
  </blockquote>
  
  <p>It seems like creating context from within test case as well as from within main is clashing and thus it is throwing an exception while instantiating it from main method.</p>
  
  <p>I don't want to change spring initialization from within main method as this is a standalone application. Also, I wanted to load spring context in test as am loading test-context in the test.</p>
  
  <p>Is there a way I can get rid of this exception?</p>