Example usage for org.springframework.core.io ClassPathResource ClassPathResource

List of usage examples for org.springframework.core.io ClassPathResource ClassPathResource

Introduction

In this page you can find the example usage for org.springframework.core.io ClassPathResource ClassPathResource.

Prototype

public ClassPathResource(String path, @Nullable Class<?> clazz) 

Source Link

Document

Create a new ClassPathResource for Class usage.

Usage

From source file:org.springmodules.jcr.jackrabbit.JackrabbitNamespaceHandlerTests.java

protected void setUp() throws Exception {
    this.beanFactory = new XmlBeanFactory(new ClassPathResource(
            "/org/springmodules/jcr/jackrabbit/config/jackrabbitNamespaceHandlerTests.xml", getClass()));
}

From source file:org.web4thejob.module.AbstractModule.java

protected AbstractModule() {
    properties = new Properties();
    try {/* www .  j  ava 2  s. c o m*/
        properties.load(new ClassPathResource(getPropertiesName(), getClass()).getInputStream());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.beanio.spring.BeanIOFlatFileItemReaderTest.java

@Test
public void testInputFileNotFound() throws Exception {
    BeanIOFlatFileItemReader<Object> reader = new BeanIOFlatFileItemReader<Object>();
    reader.setStrict(false);/*from www . j  ava2s  .co  m*/
    reader.setStreamName("stream1");
    reader.setStreamMapping(new ClassPathResource("spring_mapping1.xml", getClass()));
    reader.setResource(new ClassPathResource("doesnotexist.txt", getClass()));
    reader.afterPropertiesSet();

    ExecutionContext ctx = new ExecutionContext();

    reader.open(ctx);
    assertNull(reader.read());
}

From source file:org.sakaiproject.genericdao.springutil.ResourceFinder.java

private static List<Resource> makeResources(List<String> paths) {
    List<Resource> rs = new ArrayList<Resource>();
    if (paths != null && !paths.isEmpty()) {
        ClassLoader cl = ResourceFinder.class.getClassLoader();
        for (String path : paths) {
            Resource r = new ClassPathResource(path, cl);
            if (r.exists()) {
                rs.add(r);/*from ww w .ja v  a 2s. c  o  m*/
            }
        }
    }
    return rs;
}

From source file:org.springmodules.jcr.config.JcrNamespaceHandlerTests.java

protected void setUp() throws Exception {
    this.beanFactory = new XmlBeanFactory(
            new ClassPathResource("/org/springmodules/jcr/config/jcrNamespaceHandlerTests.xml", getClass()));
}

From source file:com.springsource.greenhouse.database.GreenhouseTestDatabaseBuilder.java

public GreenhouseTestDatabaseBuilder member() {
    populator.addScript(new ClassPathResource("install/Member.sql", DatabaseUpgrader.class));
    return this;
}

From source file:org.cloudfoundry.samples.handson.ex5.Ex5Config.java

public void databasePopulator() {
    try {/*ww w  .j a  v  a2s. co  m*/
        ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
        populator.addScript(new ClassPathResource("schema.sql", Ex5Config.class));
        DatabasePopulatorUtils.execute(populator, fromDataSource());
    } catch (DataAccessResourceFailureException e) {
        //ignore if table already exists
    }
}

From source file:org.obiba.onyx.engine.StageManagerTest.java

@Test
public void testGetStage() throws Exception {
    StageManagerImpl stageManager = new StageManagerImpl();
    stageManager.setStageDescriptor(new ClassPathResource("testStages.xml", StageManagerTest.class));
    stageManager.afterPropertiesSet();/*w ww .jav  a  2 s . c  o m*/

    Stage stage = stageManager.getStage("Stage2");
    Assert.assertNotNull(stage);
    Assert.assertEquals(stage.getName(), "Stage2");
}

From source file:org.beanio.spring.BeanIOStreamFactoryTest.java

@Test(expected = BeanIOConfigurationException.class)
public void testInvalidMapping() throws Exception {
    Resource res = new ClassPathResource("invalid_mapping.xml", BeanIOStreamFactoryTest.class);

    BeanIOStreamFactory sf = new BeanIOStreamFactory();
    sf.setStreamMappings(Arrays.asList(new Resource[] { res }));
    sf.createStreamFactory();//from   w  ww .  j  a  va 2  s  .  c  o m
}

From source file:com.springsource.greenhouse.database.GreenhouseTestDatabaseBuilder.java

public GreenhouseTestDatabaseBuilder group() {
    populator.addScript(new ClassPathResource("install/Group.sql", DatabaseUpgrader.class));
    return this;
}