Search in sources :

Example 11 with DefaultResourceLoader

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

the class ClassPathScanningCandidateComponentProviderTests method defaultsWithScan.

@Test
public void defaultsWithScan() {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true);
    provider.setResourceLoader(new DefaultResourceLoader(CandidateComponentsTestClassLoader.disableIndex(getClass().getClassLoader())));
    testDefault(provider, ScannedGenericBeanDefinition.class);
}
Also used : DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Test(org.junit.Test)

Example 12 with DefaultResourceLoader

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

the class DefaultPersistenceUnitManagerTests method defaultDomainWithIndex.

@Test
public void defaultDomainWithIndex() {
    this.manager.setPackagesToScan("org.springframework.orm.jpa.domain");
    this.manager.setResourceLoader(new DefaultResourceLoader(CandidateComponentsTestClassLoader.index(getClass().getClassLoader(), new ClassPathResource("spring.components", Person.class))));
    testDefaultDomain();
}
Also used : Person(org.springframework.orm.jpa.domain.Person) ClassPathResource(org.springframework.core.io.ClassPathResource) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) Test(org.junit.Test)

Example 13 with DefaultResourceLoader

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

the class EnableAutoConfigurationImportSelectorTests method setup.

@Before
public void setup() {
    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 14 with DefaultResourceLoader

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

the class DataSourceInitializerTests method multipleScriptsAppliedInLexicalOrder.

@Test
public void multipleScriptsAppliedInLexicalOrder() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.initialize:true", "spring.datasource.schema:" + ClassUtils.addResourcePathToPackagePath(getClass(), "lexical-schema-*.sql"), "spring.datasource.data:" + ClassUtils.addResourcePathToPackagePath(getClass(), "data.sql"));
    this.context.register(DataSourceAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
    ReverseOrderResourceLoader resourceLoader = new ReverseOrderResourceLoader(new DefaultResourceLoader());
    this.context.setResourceLoader(resourceLoader);
    this.context.refresh();
    DataSource dataSource = this.context.getBean(DataSource.class);
    assertThat(dataSource instanceof org.apache.tomcat.jdbc.pool.DataSource).isTrue();
    assertThat(dataSource).isNotNull();
    JdbcOperations template = new JdbcTemplate(dataSource);
    assertThat(template.queryForObject("SELECT COUNT(*) from FOO", Integer.class)).isEqualTo(1);
}
Also used : JdbcOperations(org.springframework.jdbc.core.JdbcOperations) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 15 with DefaultResourceLoader

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

the class FreeMarkerConfigurerTests method freeMarkerConfigurationAsBean.

// SPR-12448
@Test
public void freeMarkerConfigurationAsBean() {
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    RootBeanDefinition loaderDef = new RootBeanDefinition(SpringTemplateLoader.class);
    loaderDef.getConstructorArgumentValues().addGenericArgumentValue(new DefaultResourceLoader());
    loaderDef.getConstructorArgumentValues().addGenericArgumentValue("/freemarker");
    RootBeanDefinition configDef = new RootBeanDefinition(Configuration.class);
    configDef.getPropertyValues().add("templateLoader", loaderDef);
    beanFactory.registerBeanDefinition("freeMarkerConfig", configDef);
    beanFactory.getBean(Configuration.class);
}
Also used : DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) 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