Package org.springframework.context

Examples of org.springframework.context.ApplicationContext


*/
public class TextFileCopyTest {

  @Test
  public void testTextBasedCopy() throws Exception{
    ApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/integration/fileCopyDemo-text.xml", TextFileCopyTest.class);
    FileCopyDemoCommon.displayDirectories(context);
    Thread.sleep(5000);
  }
View Full Code Here


    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    public ConfigurableApplicationContext getConfigurableApplicationContext() {
        ApplicationContext applicationContext = getApplicationContext();
        if (applicationContext instanceof ConfigurableApplicationContext) {
            return (ConfigurableApplicationContext)applicationContext;
        } else {
            throw new IllegalArgumentException("Class: " + applicationContext.getClass().getName() + " is not an instanceof ConfigurableApplicationContext.");
        }
    }
View Full Code Here

  }

  public void testInterceptorWriterSuccess() throws Exception {
    System.out.println("1");
    try {
      ApplicationContext context = new ClassPathXmlApplicationContext(getConfigLocation());
      IndexDao test = (IndexDao)context.getBean(BEAN_ID);
      MockIndexFactory mockIndexFactory = (MockIndexFactory)context.getBean(INDEX_FACTORY_ID);

      test.myMethod1();

      assertEquals(mockIndexFactory.getCallNumberWriter(), 1);
      assertEquals(mockIndexFactory.getCallNumberReader(), 0);
View Full Code Here

      ex.printStackTrace();
    }
  }

  public void testInterceptorWriterError() throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext(getConfigLocation());
    IndexDao test = (IndexDao)context.getBean(BEAN_ID);
    MockIndexFactory mockIndexFactory = (MockIndexFactory)context.getBean(INDEX_FACTORY_ID);

    try {
      test.myMethod2();
      fail();
    } catch(LuceneIndexingException ex) { }
View Full Code Here

    assertEquals(mockIndexFactory.getCallNumberWriter(), 1);
    assertEquals(mockIndexFactory.getCallNumberReader(), 0);
  }

  public void testInterceptorReaderSuccess() throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext(getConfigLocation());
    IndexDao test = (IndexDao)context.getBean(BEAN_ID);
    MockIndexFactory mockIndexFactory = (MockIndexFactory)context.getBean(INDEX_FACTORY_ID);

    test.myMethod3();

    assertEquals(mockIndexFactory.getCallNumberWriter(), 0);
    assertEquals(mockIndexFactory.getCallNumberReader(), 1);
View Full Code Here

    assertEquals(mockIndexFactory.getCallNumberWriter(), 0);
    assertEquals(mockIndexFactory.getCallNumberReader(), 1);
  }

  public void testInterceptorReaderError() throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext(getConfigLocation());
    IndexDao test = (IndexDao)context.getBean(BEAN_ID);
    MockIndexFactory mockIndexFactory = (MockIndexFactory)context.getBean(INDEX_FACTORY_ID);

    try {
      test.myMethod4();
      fail();
    } catch(LuceneIndexingException ex) { }
View Full Code Here

  private String getConfigIndexLocation() {
    return "/org/springmodules/lucene/index/config/applicationContext-index.xml";
  }
 
  public void testLuceneIndexNamespace() throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext(getConfigIndexLocation());
   
    Analyzer analyzer = (Analyzer)context.getBean("analyzer");
   
    testRamDirectoryCreation(context, analyzer);
    testFSDirectoryCreation(context, analyzer);
  }
View Full Code Here

  private String getConfigConcurrentIndexLocation() {
    return "/org/springmodules/lucene/index/config/applicationContext-index-concurrent.xml";
  }
 
  public void testLuceneConcurrentIndexNamespace() throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext(getConfigConcurrentIndexLocation());
   
    Analyzer analyzer = (Analyzer)context.getBean("analyzer");
   
    testConcurrentFSDirectoryCreation(context, analyzer);
  }
View Full Code Here

  private String getConfigDocumentHandlerLocation() {
    return "/org/springmodules/lucene/index/config/applicationContext-document-handler.xml";
  }
 
  public void testLuceneDocumentHandlerNamespace() throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext(getConfigDocumentHandlerLocation());
   
    DocumentHandlerManagerFactoryBean documentHandlerManagerFB1
            = (DocumentHandlerManagerFactoryBean)context.getBean("&documentHandlerManager1");
    assertNotNull(documentHandlerManagerFB1);
    assertEquals(documentHandlerManagerFB1.getDocumentMatchingClass(), ExtensionDocumentMatching.class);
    assertEquals(documentHandlerManagerFB1.getDocumentHandlerManagerClass(), ExtensionDocumentHandlerManager.class);

    DocumentHandlerManager documentHandlerManager1
            = (DocumentHandlerManager)context.getBean("documentHandlerManager1");
    assertNotNull(documentHandlerManager1);
    assertTrue(documentHandlerManager1 instanceof ExtensionDocumentHandlerManager);
    assertNotNull(documentHandlerManager1.getDocumentHandler("test.txt"));
    assertNotNull(documentHandlerManager1.getDocumentHandler("test.properties"));

    DocumentHandlerManagerFactoryBean documentHandlerManagerFB2
            = (DocumentHandlerManagerFactoryBean)context.getBean("&documentHandlerManager2");
    assertNotNull(documentHandlerManagerFB2);
    assertEquals(documentHandlerManagerFB2.getDocumentMatchingClass(), IdentityDocumentMatching.class);
    assertEquals(documentHandlerManagerFB2.getDocumentHandlerManagerClass(), DefaultDocumentHandlerManager.class);

    DocumentHandlerManager documentHandlerManager2
            = (DocumentHandlerManager)context.getBean("documentHandlerManager2");
    assertNotNull(documentHandlerManager2);
  }
View Full Code Here

      applicationContextServiceTracker.close();
    }
  }

  public ApplicationContext getApplicationContext(int timeout) {
    ApplicationContext applicationContext = null;
    if (applicationContextServiceTracker != null) {
      try {
        applicationContext = (ApplicationContext) applicationContextServiceTracker
            .waitForService(timeout);
      } catch (InterruptedException e) {
View Full Code Here

TOP

Related Classes of org.springframework.context.ApplicationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.