Search in sources :

Example 26 with DefaultResourceLoader

use of org.springframework.core.io.DefaultResourceLoader in project spring-framework by spring-projects.

the class CallbacksSecurityTests method setUp.

@Before
public void setUp() throws Exception {
    final ProtectionDomain empty = new ProtectionDomain(null, new Permissions());
    provider = new SecurityContextProvider() {

        private final AccessControlContext acc = new AccessControlContext(new ProtectionDomain[] { empty });

        @Override
        public AccessControlContext getAccessControlContext() {
            return acc;
        }
    };
    DefaultResourceLoader drl = new DefaultResourceLoader();
    Resource config = drl.getResource("/org/springframework/beans/factory/support/security/callbacks.xml");
    beanFactory = new DefaultListableBeanFactory();
    new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(config);
    beanFactory.setSecurityContextProvider(provider);
}
Also used : SecurityContextProvider(org.springframework.beans.factory.support.SecurityContextProvider) ProtectionDomain(java.security.ProtectionDomain) AccessControlContext(java.security.AccessControlContext) XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) Permissions(java.security.Permissions) Resource(org.springframework.core.io.Resource) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Before(org.junit.Before)

Example 27 with DefaultResourceLoader

use of org.springframework.core.io.DefaultResourceLoader in project spring-boot by spring-projects.

the class SpringApplicationBuilderTests method parentContextWithClassLoader.

@Test
public void parentContextWithClassLoader() throws Exception {
    SpringApplicationBuilder application = new SpringApplicationBuilder(ChildConfig.class).contextClass(SpyApplicationContext.class);
    ClassLoader classLoader = new URLClassLoader(new URL[0], getClass().getClassLoader());
    application.resourceLoader(new DefaultResourceLoader(classLoader));
    application.parent(ExampleConfig.class);
    this.context = application.run();
    assertThat(((SpyApplicationContext) this.context).getResourceLoader().getClassLoader()).isEqualTo(classLoader);
}
Also used : URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Test(org.junit.Test)

Example 28 with DefaultResourceLoader

use of org.springframework.core.io.DefaultResourceLoader in project spring-boot by spring-projects.

the class AutoConfigurationImportSelectorTests method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    this.importSelector.setBeanFactory(this.beanFactory);
    this.importSelector.setEnvironment(this.environment);
    this.importSelector.setResourceLoader(new DefaultResourceLoader());
}
Also used : DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Before(org.junit.Before)

Example 29 with DefaultResourceLoader

use of org.springframework.core.io.DefaultResourceLoader in project spring-boot by spring-projects.

the class ImportAutoConfigurationImportSelectorTests method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    this.importSelector.setBeanFactory(this.beanFactory);
    this.importSelector.setEnvironment(this.environment);
    this.importSelector.setResourceLoader(new DefaultResourceLoader());
}
Also used : DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Before(org.junit.Before)

Example 30 with DefaultResourceLoader

use of org.springframework.core.io.DefaultResourceLoader in project spring-framework by spring-projects.

the class DefaultPersistenceUnitManagerTests method defaultDomainWithScan.

@Test
public void defaultDomainWithScan() {
    this.manager.setPackagesToScan("org.springframework.orm.jpa.domain");
    this.manager.setResourceLoader(new DefaultResourceLoader(CandidateComponentsTestClassLoader.disableIndex(getClass().getClassLoader())));
    testDefaultDomain();
}
Also used : DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Test(org.junit.Test)

Aggregations

DefaultResourceLoader (org.springframework.core.io.DefaultResourceLoader)39 Test (org.junit.Test)24 ResourceLoader (org.springframework.core.io.ResourceLoader)8 Before (org.junit.Before)5 AnnotatedGenericBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition)5 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)5 Resource (org.springframework.core.io.Resource)4 URLClassLoader (java.net.URLClassLoader)3 DefaultNamedComponent (example.scannable.DefaultNamedComponent)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 X509Certificate (java.security.cert.X509Certificate)2 SnmpAgentAddress (org.opennms.netmgt.snmp.SnmpAgentAddress)2 LoggerContext (ch.qos.logback.classic.LoggerContext)1 Context (ch.qos.logback.core.Context)1 DevComponent (example.profilescan.DevComponent)1 ProfileAnnotatedComponent (example.profilescan.ProfileAnnotatedComponent)1 ProfileMetaAnnotatedComponent (example.profilescan.ProfileMetaAnnotatedComponent)1 CustomStereotype (example.scannable.CustomStereotype)1 FooDao (example.scannable.FooDao)1