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) 

Source Link

Document

Create a new ClassPathResource for ClassLoader usage.

Usage

From source file:demo.wssec.sts.Server.java

protected Server() throws Exception {
    System.out.println("Starting STS");

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = new ClassPathResource("wssec-sts.xml").getURL();
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);//from   w w w  .ja  v  a2s.co m
}

From source file:net.javacrumbs.springws.test.lookup.SimpleResourceLookupTest.java

@Test
public void testSimple() throws IOException {
    SimpleResourceLookup lookup = new SimpleResourceLookup(new ClassPathResource("xml/valid-message2.xml"));
    Resource res = lookup.lookupResource(null, null);
    assertNotNull(res);/*www .j a v a  2s.  co  m*/
    assertEquals("valid-message2.xml", res.getFilename());
}

From source file:demo.wssec.server.Server.java

protected Server() throws Exception {
    System.out.println("Starting Server");

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = new ClassPathResource("wssec-server.xml").getURL();
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);/*from   w  ww . j av  a2  s  . co m*/
}

From source file:org.deeplearning4j.cli.flags.PropertiesFlagTest.java

@Test
public void test() throws Exception {
    File file = new ClassPathResource("testConfig.txt").getFile();
    Properties propertiesFlag = new Properties();
    Configuration testConfig = propertiesFlag.value(file.getAbsolutePath());

    assertEquals("1", testConfig.get("one"));
    assertEquals("2", testConfig.get("two"));

}

From source file:kr.co.skysoft.framework.taglib.JSR303JSCodebaseTag.java

/**
 * Returns a <code>Reader</code> for accessing the JavaScript codebase used by the
 * translated validation rules./* w w w  . ja v a 2  s  . c  o  m*/
 *
 * @return a Reader for accessing the JavaScript codebase used by the translated validation rules
 * @throws java.io.IOException
 */
public static Reader getCodebaseReader() throws IOException {
    Resource codebaseResource = new ClassPathResource("jsr303js-codebase.js");
    return new InputStreamReader(codebaseResource.getInputStream());
}

From source file:net.javacrumbs.springws.test.common.MessageGeneratorTest.java

@Test
public void testAlwaysCreateEnvelope() throws IOException {
    MessageGenerator generator = new MessageGenerator();
    generator.setAlwaysCreateEnvelope(true);
    assertTrue(generator/* w  ww. j av a2  s  .c om*/
            .shouldCreateSoapEnvelope(new ClassPathResource("mock-responses/test/default-response.xml")));
}

From source file:uta.ak.usttmp.common.textmining.FileExcludeStopWord.java

public FileExcludeStopWord() {

    //Load stopword file
    InputStreamReader isr = null;
    try {//from   w w  w  . j  a v  a 2 s.com
        stopWordsList = new CopyOnWriteArraySet<>();
        Resource res = new ClassPathResource("StopWordTable2.txt");
        //                File stopwords=res.getFile();
        //      File stopwords=new File("/Users/zhangcong/dev/corpus/StopWordTable2.txt");
        isr = new InputStreamReader(res.getInputStream());
        BufferedReader stops = null;
        try {
            String tempString = null;
            stops = new BufferedReader(isr);
            tempString = stops.readLine();
            while ((tempString = stops.readLine()) != null) {
                if (!tempString.isEmpty()) {
                    stopWordsList.add(tempString.toLowerCase().trim());
                }
            }

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    } catch (IOException ex) {
        Logger.getLogger(FileExcludeStopWord.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            isr.close();
        } catch (IOException ex) {
            Logger.getLogger(FileExcludeStopWord.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:org.hdiv.AbstractTestCase.java

protected void setUp() throws Exception {

    XmlBeanFactory context = new XmlBeanFactory(
            new ClassPathResource("/org/hdiv/config/hdiv-core-applicationContext.xml"));
    context = new XmlBeanFactory(new ClassPathResource("/hdiv-validations.xml"), context);
    context = new XmlBeanFactory(new ClassPathResource("/hdiv-config.xml"), context);

    this.config = (HDIVConfig) context.getBean("config");

}

From source file:org.nd4j.linalg.jcublas.kernel.KernelFunctionLoaderTests.java

@Test
public void testLoader() throws Exception {
    Nd4j.dtype = DataBuffer.DOUBLE;

    KernelFunctionLoader loader = KernelFunctionLoader.getInstance();
    loader.load();/*from ww  w  . j ava  2s .co m*/
    ClassPathResource res = new ClassPathResource("/cudafunctions.properties");
    if (!res.exists())
        throw new IllegalStateException("Please put a cudafunctions.properties in your class path");
    Properties props = new Properties();
    props.load(res.getInputStream());
    loader.unload();

}

From source file:org.cloudfoundry.identity.api.web.ApiControllerTests.java

@Test
public void testNoUser() throws Exception {
    controller.setInfo(new ClassPathResource("info.tmpl"));
    HashMap<String, Object> model = new HashMap<String, Object>();
    View view = controller.info(model, null);
    MockHttpServletResponse response = new MockHttpServletResponse();
    view.render(model, new MockHttpServletRequest(), response);
    String content = response.getContentAsString();
    assertFalse("Wrong content: " + content, content.contains("\"user\""));
}