Example usage for org.springframework.context.support StaticApplicationContext StaticApplicationContext

List of usage examples for org.springframework.context.support StaticApplicationContext StaticApplicationContext

Introduction

In this page you can find the example usage for org.springframework.context.support StaticApplicationContext StaticApplicationContext.

Prototype

public StaticApplicationContext() throws BeansException 

Source Link

Document

Create a new StaticApplicationContext.

Usage

From source file:org.jasig.cas.web.ProxyControllerTests.java

@Before
public void onSetUp() throws Exception {
    this.proxyController = new ProxyController();
    this.proxyController.setCentralAuthenticationService(getCentralAuthenticationService());

    StaticApplicationContext context = new StaticApplicationContext();
    context.refresh();/* w ww .  j  a  v a2s  .co m*/
    this.proxyController.setApplicationContext(context);
}

From source file:org.jasig.cas.web.ServiceValidateControllerTests.java

@Before
public void onSetUp() throws Exception {
    StaticApplicationContext context = new StaticApplicationContext();
    context.refresh();/*from  w  ww . j a  v a 2 s .c  o  m*/
    this.serviceValidateController = new ServiceValidateController();
    this.serviceValidateController.setCentralAuthenticationService(getCentralAuthenticationService());
    final Cas20ProxyHandler proxyHandler = new Cas20ProxyHandler();
    proxyHandler.setHttpClient(new HttpClient());
    this.serviceValidateController.setProxyHandler(proxyHandler);
    this.serviceValidateController.setApplicationContext(context);
    this.serviceValidateController.setArgumentExtractor(new CasArgumentExtractor());
}

From source file:de.itsvs.cwtrpc.controller.PreparedRemoteServiceConfigBuilderTest.java

@BeforeClass
public static void initClass() {
    StaticApplicationContext appContext;

    appContext = new StaticApplicationContext();
    appContext.registerSingleton("testService1", TestService1Impl.class);
    appContext.registerPrototype("testService2", TestService2Impl.class);
    appContext.registerSingleton("testService3", TestService3Impl.class);
    appContext.registerPrototype("testService4", TestService4Impl.class);
    appContext.registerSingleton("testService5", TestService5Impl.class);
    appContext.registerPrototype("testService10", TestService10Impl.class);
    appContext.registerSingleton("testService20", TestService20Impl.class);
    appContext.registerSingleton("rpcTokenValidatorXyz", TestRpcTokenValidator1Impl.class);
    appContext.registerSingleton("rpcTokenValidator100", TestRpcTokenValidator1Impl.class);
    appContext.registerSingleton("rpcTokenValidator200", TestRpcTokenValidator1Impl.class);
    appContext.registerSingleton("rpcTokenService", DefaultXsrfTokenService.class);

    PreparedRemoteServiceConfigBuilderTest.appContext = appContext;
}

From source file:org.wte4j.examples.showcase.server.hsql.ShowCaseDbInitializerTest.java

@Test
public void createDatabaseFilesWithoutOveride() throws IOException, SQLException {
    ApplicationContext context = new StaticApplicationContext();
    Path directory = Files.createTempDirectory("database");
    Path dummyFile = directory.resolve("wte4j-showcase.script");
    Files.createFile(dummyFile);//from  w w w.j  a  v  a 2 s  .  co m
    try {
        ShowCaseDbInitializer showCaseDbInitializer = new ShowCaseDbInitializer(context);
        showCaseDbInitializer.createDateBaseFiles(directory, false);

        Set<String> fileNamesInDirectory = listFiles(directory);
        Set<String> expectedFileNames = new HashSet<String>();
        expectedFileNames.add("wte4j-showcase.script");
        assertEquals(expectedFileNames, fileNamesInDirectory);
        assertEquals(0, Files.size(dummyFile));
    } finally {
        deleteDirectory(directory);
    }
}

From source file:de.itsvs.cwtrpc.controller.AutowiredRemoteServiceGroupConfigTest.java

@Test
public void testAfterPropertiesSet1() {
    final StaticApplicationContext appContext;
    final AutowiredRemoteServiceGroupConfig config;

    appContext = new StaticApplicationContext();
    appContext.registerSingleton("testService1", TestService1Impl.class);
    appContext.registerSingleton("testService10", TestService10Impl.class);
    appContext.registerSingleton("testService20", TestService20Impl.class);

    config = new AutowiredRemoteServiceGroupConfig();
    config.setBasePackages(Arrays.asList(new String[] { "de.itsvs.cwtrpc.controller.config." }));
    config.setApplicationContext(appContext);
    config.afterPropertiesSet();//www. j  a  v  a2  s. co m

    Assert.assertTrue(config.getChildGroupConfigs().isEmpty());
    Assert.assertEquals(1, config.getServiceConfigs().size());
    Assert.assertTrue(containsServiceConfig(appContext, config.getServiceConfigs(), TestService1Impl.class));
}

From source file:org.langera.freud.optional.spring.SpringBeanIteratorTest.java

@Test
public void shouldIterateOverEmptyList() {
    StaticApplicationContext staticApplicationContext = new StaticApplicationContext();
    SpringBeanIterator iterator = new SpringBeanIterator(staticApplicationContext, false);
    Assert.assertFalse(iterator.hasNext());
}

From source file:com.github.pjungermann.config.specification.dsl.groovy.GroovyDSLSpecificationReaderTest.java

@Before
public void setUp() {
    applicationContext = new StaticApplicationContext();
    applicationContext.registerSingleton(NullableConstraintFactory.class.getName(),
            NullableConstraintFactory.class);
    applicationContext.registerSingleton(MatchesConstraintFactory.class.getName(),
            MatchesConstraintFactory.class);
    applicationContext.registerSingleton(RangeConstraintFactory.class.getName(), RangeConstraintFactory.class);
    applicationContext.registerSingleton(SizeConstraintFactory.class.getName(), SizeConstraintFactory.class);
    applicationContext.registerSingleton(MaxSizeConstraintFactory.class.getName(),
            MaxSizeConstraintFactory.class);
    applicationContext.registerSingleton("typeConverter", AsTypeConverter.class);
    BeanDefinition beanDefinition = BeanDefinitionBuilder.rootBeanDefinition(ConstraintRegistry.class)
            .setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR).getBeanDefinition();
    applicationContext.registerBeanDefinition("constraintRegistry", beanDefinition);
    applicationContext.refresh();//from w w  w .  ja v  a2  s . c om

    reader = new GroovyDSLSpecificationReader(applicationContext);
}

From source file:org.wte4j.examples.showcase.server.hsql.ShowCaseDbInitializerTest.java

@Test
public void createDatabaseFilesWithOveride() throws IOException, SQLException {
    ApplicationContext context = new StaticApplicationContext();
    Path directory = Files.createTempDirectory("database");
    Path dummyFile = directory.resolve("wte4j-showcase.script");
    Files.createFile(dummyFile);/*from   w  w w.java 2  s . com*/

    try {

        ShowCaseDbInitializer showCaseDbInitializer = new ShowCaseDbInitializer(context);
        showCaseDbInitializer.createDateBaseFiles(directory, true);

        Set<String> fileNamesInDirectory = listFiles(directory);
        Set<String> expectedFileNames = new HashSet<String>();
        expectedFileNames.add("wte4j-showcase.lobs");
        expectedFileNames.add("wte4j-showcase.properties");
        expectedFileNames.add("wte4j-showcase.script");
        assertEquals(expectedFileNames, fileNamesInDirectory);
        assertTrue(Files.size(dummyFile) > 0);

    } finally {
        deleteDirectory(directory);
    }
}

From source file:io.nuun.plugin.spring.SpringPluginTest.java

@Test
public void canHandle_should_return_true_for_application_context_classes() {
    InternalDependencyInjectionProvider provider = new InternalDependencyInjectionProvider();
    ApplicationContext application = new StaticApplicationContext();
    assertThat(provider.canHandle(application.getClass())).isTrue();
}

From source file:de.itsvs.cwtrpc.controller.AutowiredRemoteServiceGroupConfigTest.java

@Test
public void testAfterPropertiesSet2() {
    final StaticApplicationContext appContext;
    final AutowiredRemoteServiceGroupConfig config;

    appContext = new StaticApplicationContext();
    appContext.registerSingleton("testService1", TestService1Impl.class);

    config = new AutowiredRemoteServiceGroupConfig();
    config.setBasePackages(Arrays.asList(new String[] { "de.itsvs.cwtrpc.controller.config." }));
    config.setApplicationContext(appContext);
    config.afterPropertiesSet();/*from   ww  w .  j  a v  a  2s. co  m*/

    Assert.assertTrue(config.getChildGroupConfigs().isEmpty());
    Assert.assertEquals(1, config.getServiceConfigs().size());
}