Search in sources :

Example 81 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project Activiti by Activiti.

the class SpringAutoDeployTest method testResourceRedeploymentAfterProcessDefinitionChange.

// Updating the bpmn20 file should lead to a new deployment when restarting
// the Spring container
public void testResourceRedeploymentAfterProcessDefinitionChange() throws Exception {
    createAppContext(CTX_PATH);
    assertEquals(1, repositoryService.createDeploymentQuery().count());
    ((AbstractXmlApplicationContext) applicationContext).destroy();
    String filePath = "org/activiti/spring/test/autodeployment/autodeploy.a.bpmn20.xml";
    String originalBpmnFileContent = IoUtil.readFileAsString(filePath);
    String updatedBpmnFileContent = originalBpmnFileContent.replace("flow1", "fromStartToEndFlow");
    assertTrue(updatedBpmnFileContent.length() > originalBpmnFileContent.length());
    IoUtil.writeStringToFile(updatedBpmnFileContent, filePath);
    // Classic produced/consumer problem here:
    // The file is already written in Java, but not yet completely persisted by
    // the OS
    // Constructing the new app context reads the same file which is sometimes
    // not yet fully written to disk
    waitUntilFileIsWritten(filePath, updatedBpmnFileContent.length());
    try {
        applicationContext = new ClassPathXmlApplicationContext(CTX_NO_DROP_PATH);
        repositoryService = (RepositoryService) applicationContext.getBean("repositoryService");
    } finally {
        // Reset file content such that future test are not seeing something funny
        IoUtil.writeStringToFile(originalBpmnFileContent, filePath);
    }
    // Assertions come AFTER the file write! Otherwise the process file is
    // messed up if the assertions fail.
    assertEquals(2, repositoryService.createDeploymentQuery().count());
    assertEquals(6, repositoryService.createProcessDefinitionQuery().count());
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) AbstractXmlApplicationContext(org.springframework.context.support.AbstractXmlApplicationContext)

Example 82 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project ORCID-Source by ORCID.

the class LoadRinggoldData method init.

@SuppressWarnings("resource")
private void init() {
    ApplicationContext context = new ClassPathXmlApplicationContext("orcid-core-context.xml");
    orgDisambiguatedDao = (OrgDisambiguatedDao) context.getBean("orgDisambiguatedDao");
    orgDisambiguatedSolrDao = (OrgDisambiguatedSolrDao) context.getBean("orgDisambiguatedSolrDao");
    orgManager = (OrgManager) context.getBean("orgManager");
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext)

Example 83 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project ORCID-Source by ORCID.

the class MigrateAddressData method init.

@SuppressWarnings("resource")
private void init() {
    ApplicationContext context = new ClassPathXmlApplicationContext("orcid-persistence-context.xml");
    addressDao = (AddressDao) context.getBean("addressDao");
    transactionTemplate = (TransactionTemplate) context.getBean("transactionTemplate");
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext)

Example 84 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project ORCID-Source by ORCID.

the class MigrateEmails method init.

@SuppressWarnings("resource")
private void init() {
    ApplicationContext context = new ClassPathXmlApplicationContext("orcid-core-context.xml");
    profileDao = (ProfileDao) context.getBean("profileDao");
    orcidProfileManager = (OrcidProfileManager) context.getBean("orcidProfileManager");
    transactionTemplate = (TransactionTemplate) context.getBean("transactionTemplate");
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext)

Example 85 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project ORCID-Source by ORCID.

the class LoadIdentityProviders method main.

@SuppressWarnings("resource")
public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("orcid-core-context.xml");
    IdentityProviderManager identityProviderManager = (IdentityProviderManager) context.getBean("identityProviderManager");
    identityProviderManager.loadIdentityProviders();
    System.exit(0);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) IdentityProviderManager(org.orcid.core.manager.IdentityProviderManager)

Aggregations

ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)561 Test (org.junit.Test)265 ApplicationContext (org.springframework.context.ApplicationContext)167 Before (org.junit.Before)53 ConfigurableMessenger (org.springframework.scripting.ConfigurableMessenger)33 ITestBean (org.springframework.tests.sample.beans.ITestBean)30 Messenger (org.springframework.scripting.Messenger)29 CamelContext (org.apache.camel.CamelContext)25 Refreshable (org.springframework.aop.target.dynamic.Refreshable)23 AbstractXmlApplicationContext (org.springframework.context.support.AbstractXmlApplicationContext)22 DataSource (javax.sql.DataSource)18 SpringCamelContext (org.apache.camel.spring.SpringCamelContext)16 AbstractApplicationContext (org.springframework.context.support.AbstractApplicationContext)16 Bus (org.apache.cxf.Bus)14 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)14 ArrayList (java.util.ArrayList)13 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)12 DemoService (com.alibaba.dubbo.config.spring.api.DemoService)11 IOException (java.io.IOException)10 ProducerTemplate (org.apache.camel.ProducerTemplate)10