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

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

Introduction

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

Prototype

public FileSystemResource(Path filePath) 

Source Link

Document

Create a new FileSystemResource from a Path handle, performing all file system interactions via NIO.2 instead of File .

Usage

From source file:org.osgpfoundation.osgp.webdemoapp.infra.platform.KeyStoreHelper.java

public KeyStoreHelper(final String trustStoreType, final String trustStoreLoc, final String trustStorePw,
        final String keyStoreLocation, final String keyStoreType, final String keyStorePw) {

    this.keyStorePw = keyStorePw;

    this.trustStoreFactory = new KeyStoreFactoryBean();
    this.trustStoreFactory.setType(trustStoreType);
    this.trustStoreFactory.setLocation(new FileSystemResource(trustStoreLoc));
    this.trustStoreFactory.setPassword(trustStorePw);

    this.keyStoreFactory = new KeyStoreFactoryBean();
    this.keyStoreFactory.setType(keyStoreType);
    this.keyStoreFactory.setLocation(new FileSystemResource(keyStoreLocation));
    this.keyStoreFactory.setPassword(keyStorePw);
    try {// w  w  w.java 2s . c o  m
        this.keyStoreFactory.afterPropertiesSet();
        this.trustStoreFactory.afterPropertiesSet();
    } catch (GeneralSecurityException | IOException e) {
        e.printStackTrace();
    }
}

From source file:com.alibaba.citrus.service.velocity.PreloadedResourceLoaderTests.java

@BeforeClass
public static void initFactory() {
    factory = new ResourceLoadingXmlApplicationContext(
            new FileSystemResource(new File(srcdir, "services.xml")));
}

From source file:org.jasig.services.persondir.support.TomlLdapPersonAttributeDaoTests.java

@Test
public void testTomlConfigFileStuffedIntoDao() throws Exception {
    final Resource tomlConfigFile = new FileSystemResource("src/test/resources/ldap.toml");
    final TomlLdapPersonAttributeDao dao = new TomlLdapPersonAttributeDao(tomlConfigFile);

    assertNotNull(dao.getBaseDN());//  ww  w .  ja  v a2s  .  c o  m
    assertNotNull(dao.getQueryAttributeMapping());
    assertNotNull(dao.getQueryType());
    assertNotNull(dao.getResultAttributeMapping());
    assertNotNull(dao.getContextSource());
}

From source file:de.tudarmstadt.lt.ltbot.writer.SentenceWriterTest.java

@Test
public void testbean() {
    Resource xmlResource = new FileSystemResource(
            "jobs/profile-ltbot-default-seedfile/profile-crawler-beans-ltbot.cxml");
    BeanFactory factory = new XmlBeanFactory(xmlResource);
    SentenceWriter w = (SentenceWriter) factory.getBean("sentenceWriterHtml");
    SentenceMaker m = (SentenceMaker) factory.getBean("sentenceMaker");

}

From source file:org.mybatis.spring.boot.autoconfigure.AdditionalConfigurationMetadataTest.java

@Test
public void testProperties() throws IOException {

    DocumentContext documentContext = JsonPath.parse(
            new FileSystemResource("src/main/resources/META-INF/additional-spring-configuration-metadata.json")
                    .getInputStream());/*from w w w .jav a2 s.  c  o  m*/

    List<Map<String, String>> properties = documentContext.read("$.properties");

    assertThat(properties.size(), is(2));

    // assert for default-scripting-language
    {
        Map<String, String> element = properties.get(0);
        assertThat(element.get("sourceType"), is("org.apache.ibatis.session.Configuration"));
        assertThat(element.get("defaultValue"), is("org.apache.ibatis.scripting.xmltags.XMLLanguageDriver"));
        assertThat(element.get("name"), is("mybatis.configuration.default-scripting-language"));
        assertThat(element.get("type"),
                is("java.lang.Class<? extends org.apache.ibatis.scripting.LanguageDriver>"));
    }

    // assert for default-enum-type-handler
    {
        Map<String, String> element = properties.get(1);
        assertThat(element.get("sourceType"), is("org.apache.ibatis.session.Configuration"));
        assertThat(element.get("defaultValue"), is("org.apache.ibatis.type.EnumTypeHandler"));
        assertThat(element.get("name"), is("mybatis.configuration.default-enum-type-handler"));
        assertThat(element.get("type"), is("java.lang.Class<? extends org.apache.ibatis.type.TypeHandler>"));
    }

}

From source file:org.cloudfoundry.identity.uaa.config.YamlMapFactoryBeanTests.java

@Test
public void testSetIgnoreResourceNotFound() throws Exception {
    factory.setResolutionMethod(YamlMapFactoryBean.ResolutionMethod.OVERRIDE_AND_IGNORE);
    factory.setResources(new FileSystemResource[] { new FileSystemResource("non-exsitent-file.yml") });
    assertEquals(0, factory.getObject().size());
}

From source file:org.dspace.app.cris.ws.WSConfigurationService.java

public Resource getFileMainSchema() {
    return new FileSystemResource(getXSDFolder() + "crisrequest.xsd");
}

From source file:org.apereo.services.persondir.support.TomlLdapPersonAttributeDaoTests.java

public TomlLdapPersonAttributeDaoTests() throws Exception {
    final Resource tomlConfigFile = new FileSystemResource("src/test/resources/ldap.toml");
    this.dao = new TomlLdapPersonAttributeDao(tomlConfigFile);
}

From source file:com.wavemaker.tools.project.upgrade.swamis.PanesRenameUpgradeTest.java

public void testUpgrade() throws Exception {

    File root = IOUtils.createTempDirectory("testUpgrade", "_dir");

    Project p = new Project(new FileSystemResource(root.getAbsolutePath() + "/"), new LocalStudioFileSystem());
    p.getWebAppRoot().getFile().mkdir();
    File panes = new File(p.getWebAppRoot().getFile(), "panes");
    panes.mkdir();/*  w ww  .  j  a v  a2s .  co  m*/
    File panesFile = new File(panes, "foo.txt");
    FileUtils.writeStringToFile(panesFile, "foo");
    File pages = new File(p.getWebAppRoot().getFile(), ProjectConstants.PAGES_DIR);
    assertFalse(pages.exists());

    PanesRenameUpgrade pru = new PanesRenameUpgrade();
    pru.doUpgrade(p, new UpgradeInfo());

    assertTrue(pages.exists());
    assertFalse(panes.exists());

    File pagesFile = new File(pages, "foo.txt");
    assertTrue(pagesFile.exists());
    assertEquals("foo", FileUtils.readFileToString(pagesFile));
}

From source file:com.ar.dev.tierra.api.controller.FiscalController.java

@RequestMapping(value = "/ticket", method = RequestMethod.POST)
@ResponseBody/*w w  w  .  j ava2 s .com*/
public FileSystemResource getTicket(@PathParam("factura") int factura)
        throws IOException, InterruptedException {
    List<DetalleFactura> detalles = facadeService.getDetalleFacturaDAO().facturaDetalle(factura);
    facadeService.getFiscalDAO().ticket(detalles);
    return new FileSystemResource("command/ticket.200");
}