Search in sources :

Example 11 with ApplicationContext

use of org.springframework.context.ApplicationContext in project head by mifos.

the class PPITestDataGenerator method loadTestDataFiles.

public void loadTestDataFiles(String[] args) throws IOException, TaskSystemException, PersistenceException, ConfigurationException, FinancialException {
    parseOptions(args);
    ApplicationContext applicationContext = initializeSpring();
    customerDao = applicationContext.getBean(CustomerDaoHibernate.class);
    questionnaireServiceFacade = applicationContext.getBean(QuestionnaireServiceFacade.class);
    if (testDataDirectoryName != null) {
        File directory = new File(testDataDirectoryName);
        File[] listOfFiles = directory.listFiles();
        if (listOfFiles != null) {
            int totalFilesToLoad = countFilesToUpgrade(listOfFiles);
            int filesLoaded = 0;
            for (File listOfFile : listOfFiles) {
                String currentFilename = listOfFile.getName();
                if (listOfFile.isFile() && currentFilename.endsWith("Testing.properties")) {
                    String dataFileName = testDataDirectoryName + File.separator + currentFilename;
                    loadData(dataFileName, applicationContext);
                    filesLoaded++;
                    System.out.println("Finished " + filesLoaded + "/" + totalFilesToLoad);
                }
            }
        } else {
            fail("No files found in directory: " + testDataDirectoryName);
        }
    } else {
        loadData(dataSetName, applicationContext);
    }
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) QuestionnaireServiceFacade(org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade) File(java.io.File) CustomerDaoHibernate(org.mifos.customers.persistence.CustomerDaoHibernate)

Example 12 with ApplicationContext

use of org.springframework.context.ApplicationContext in project head by mifos.

the class JNDIException method checkConfigurationDwDatabase.

public void checkConfigurationDwDatabase(HttpServletRequest request) {
    new ApplicationContextHolder();
    ApplicationContext ach = ApplicationContextHolder.getApplicationContext();
    DriverManagerDataSource dsDW = (DriverManagerDataSource) ach.getBean("dataSourcePentahoDW");
    Pattern pat = Pattern.compile("(jdbc:mysql://)(.*)(:)([0-9]+)(/)([a-zA-Z]*)(?)(.*)");
    Matcher m = pat.matcher(dsDW.getUrl());
    String nameOfDataBase = null;
    if (m.find()) {
        nameOfDataBase = m.group(6);
    }
    if (nameOfDataBase.equals("")) {
        request.getSession().setAttribute("configureDwDatabase", "false");
    } else {
        try {
            dsDW.getConnection();
            request.getSession().setAttribute("configureDwDatabase", "true");
        } catch (SQLException ex) {
            request.getSession().setAttribute("configureDwDatabase", "false");
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) ApplicationContext(org.springframework.context.ApplicationContext) Matcher(java.util.regex.Matcher) SQLException(java.sql.SQLException) DriverManagerDataSource(org.springframework.jdbc.datasource.DriverManagerDataSource) ApplicationContextHolder(org.mifos.application.servicefacade.ApplicationContextHolder)

Example 13 with ApplicationContext

use of org.springframework.context.ApplicationContext in project pinpoint by naver.

the class LambdaIT method test.

@Test
public void test() throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext("lambda-test.xml");
    Maru maru = context.getBean(Maru.class);
    Morae morae = context.getBean(Morae.class);
    maru.test(morae);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    verifier.verifyTrace(Expectations.event("SPRING_BEAN", Maru.class.getMethod("test", Morae.class)));
    verifier.verifyTrace(Expectations.event("SPRING_BEAN", Morae.class.getMethod("test", Predicate.class)));
    verifier.verifyTrace(Expectations.event("SPRING_BEAN", Mozzi.class.getMethod("getAge")));
    verifier.verifyTraceCount(0);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 14 with ApplicationContext

use of org.springframework.context.ApplicationContext in project centipede by paulhoule.

the class CentipedeShell method parseOptions.

private CentipedeShellOptions parseOptions(String[] arguments) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    ApplicationContext bootstrapContext = newContext(getBootstrapApplicationContextPath());
    OptionParser parser = new OptionParser(CentipedeShellOptions.class);
    wireupOptionParser(bootstrapContext, parser);
    closeContext(bootstrapContext);
    return (CentipedeShellOptions) parser.parse(newArrayList(arguments));
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) AbstractApplicationContext(org.springframework.context.support.AbstractApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) OptionParser(com.ontology2.centipede.parser.OptionParser)

Example 15 with ApplicationContext

use of org.springframework.context.ApplicationContext in project centipede by paulhoule.

the class StaticCentipedeShellTest method defaultEvaluationIsDefinedInFiles.

@Test
public void defaultEvaluationIsDefinedInFiles() {
    ApplicationContext c = newContext(objectCountingContext());
    assertEquals(1, ObjectThatCountsClassInstances.get());
    Object that = c.getBean("l");
    assertEquals(2, ObjectThatCountsClassInstances.get());
    ((AbstractApplicationContext) c).close();
    assertEquals(0, ObjectThatCountsClassInstances.get());
}
Also used : AbstractApplicationContext(org.springframework.context.support.AbstractApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) AbstractApplicationContext(org.springframework.context.support.AbstractApplicationContext) Test(org.junit.Test)

Aggregations

ApplicationContext (org.springframework.context.ApplicationContext)532 Test (org.junit.Test)256 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)161 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)38 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)32 ConfigurableMessenger (org.springframework.scripting.ConfigurableMessenger)28 File (java.io.File)24 Messenger (org.springframework.scripting.Messenger)24 DataSource (javax.sql.DataSource)23 GenericWebApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext)21 Refreshable (org.springframework.aop.target.dynamic.Refreshable)20 StubCloudConnectorTest (org.springframework.cloud.StubCloudConnectorTest)17 SchedulerException (org.quartz.SchedulerException)16 HashMap (java.util.HashMap)15 Map (java.util.Map)14 WebApplicationContext (org.springframework.web.context.WebApplicationContext)14 MovieMapper (com.mapper.MovieMapper)13 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)13 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)13 ArrayList (java.util.ArrayList)12