List of usage examples for org.springframework.core.io ClassPathResource ClassPathResource
public ClassPathResource(String path)
From source file:org.mule.modules.freshbooks.automation.util.RequestAndResponseUtil.java
protected void assertRequest(String file, Object req) throws IOException, SAXException, JAXBException { JAXBElement jaxbElement = MessageUtils.getInstance().createJaxbElement(req); String documentToPost = MessageUtils.getInstance().getXmlDocument(jaxbElement); XMLUnit.setIgnoreComments(true);/*from www .j a v a 2s . c o m*/ XMLUnit.setIgnoreWhitespace(true); assertXMLEqual(getResourceAsString(new ClassPathResource(file).getInputStream()), documentToPost); }
From source file:com.googlecode.flyway.commandline.MainMediumTest.java
@Test public void loadConfigurationFile() throws Exception { Properties properties = new Properties(); properties.put("existing", "still there!"); properties.put("override", "loses :-("); String filename = new ClassPathResource("test.properties").getFile().getPath(); String[] args = new String[] { "-configFile=" + filename, "-configFileEncoding=UTF-8" }; Main.loadConfigurationFile(properties, args); assertEquals(4, properties.size());//from ww w . j a va 2 s. co m assertEquals("still there!", properties.getProperty("existing")); assertEquals("rbbit 123", properties.getProperty("roger")); assertEquals("wins :-)", properties.getProperty("override")); }
From source file:wsconfig.WebServiceConfigPays.java
@Bean public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) { ClassPathResource cpr = new ClassPathResource("applicationContext.xml"); ListableBeanFactory bf = new XmlBeanFactory(cpr); WsConfig conf = (WsConfig) bf.getBean("config"); MessageDispatcherServlet servlet = new MessageDispatcherServlet(); servlet.setApplicationContext(applicationContext); servlet.setTransformWsdlLocations(true); /*return new ServletRegistrationBean(servlet, "/ws/*");*/ return new ServletRegistrationBean(servlet, conf.getLocationUri() + "/*"); }
From source file:com.graphaware.neo4j.webexpo.util.FileScannerTest.java
@Test public void verifyCorrectlyScannedLines() throws IOException { List<String> lines = FileScanner.produceLines(new ClassPathResource("scanner-test.csv").getFile(), 1); assertEquals(3, lines.size());/*from w w w . j a v a 2 s . c om*/ assertEquals("line1;bla", lines.get(0)); assertEquals("line2;bla", lines.get(1)); assertEquals("line3;bla", lines.get(2)); }
From source file:org.energyos.espi.thirdparty.mocks.MockRestTemplate.java
@SuppressWarnings("unchecked") public <T> T getForObject(String url, Class<T> responseType, Object... urlVariables) throws RestClientException { ClassPathResource sourceFile = new ClassPathResource("/fixtures/test_usage_data.xml"); String inputStreamString;//from w w w. j a v a 2 s.co m try { inputStreamString = new Scanner(sourceFile.getInputStream(), "UTF-8").useDelimiter("\\A").next(); return (T) inputStreamString; } catch (IOException e) { e.printStackTrace(); throw new RestClientException("The file import broke."); } }
From source file:ru.elcor.mis.scheduler.config.AppConfig.java
@Bean public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { PropertySourcesPlaceholderConfigurer properties = new PropertySourcesPlaceholderConfigurer(); Properties Props = new Properties(); Props.setProperty("cron", "0-59/2 * * * * *"); properties.setProperties(Props);// w w w . j a v a 2s .com properties.setLocation(new ClassPathResource("scheduler.properties")); properties.setIgnoreResourceNotFound(false); return properties; }
From source file:twitter4j.SpringCompatibilityTest.java
protected void setUp() throws Exception { super.setUp(); writeFile("./twitter4j.properties", "user=one" + "\n" + "password=pasword-one"); Resource res = new ClassPathResource("spring-beans.xml"); beanFactory = new XmlBeanFactory(res); }
From source file:org.kurento.test.sanity.KurentoJsBowerTest.java
@BeforeClass public static void runBower() throws IOException { String bowerClientTag = KurentoServicesTestHelper.getBowerKurentoClientTag(); String bowerUtilsTag = KurentoServicesTestHelper.getBowerKurentoUtilsTag(); if (!bowerClientTag.isEmpty()) { bowerClientTag = "#" + bowerClientTag; }// w w w. ja v a 2s . c o m if (!bowerUtilsTag.isEmpty()) { bowerUtilsTag = "#" + bowerUtilsTag; } log.debug("Using bower to download kurento-client" + bowerClientTag + "\n" + Shell.runAndWait("sh", "-c", "bower install kurento-client" + bowerClientTag)); log.debug("Using bower to download kurento-utils" + bowerUtilsTag + "\n" + Shell.runAndWait("sh", "-c", "bower install kurento-utils" + bowerUtilsTag)); final String outputFolder = new ClassPathResource("static").getFile().getAbsolutePath() + File.separator; log.debug("Copying files from bower_components/kurento-utils/js to " + outputFolder + Shell.runAndWait("sh", "-c", "cp -r bower_components/kurento-utils/js " + outputFolder)); log.debug("Copying files from bower_components/kurento-client/js to " + outputFolder + Shell.runAndWait("sh", "-c", "cp -r bower_components/kurento-client/js " + outputFolder)); }
From source file:org.impotch.calcul.impot.cantonal.ge.param.dao.ResidentParCommuneFichierTxtDaoTest.java
@Before public void init() { dao = new ResidentParCommuneFichierTxtDao(); dao.setCharsetName("UTF-8"); dao.setFichier(new ClassPathResource("parametrage/ge/PopulationParCommuneGenevoise.csv")); try {/* w w w . j av a 2s . com*/ dao.chargerResource(); } catch (IOException ioe) { } }
From source file:nz.co.senanque.madura.bundle.BundleRootTest.java
@Test @Ignore // fails because of parent bean which is undefined. public void testGetApplicationContext() { GenericApplicationContext ctx = new GenericApplicationContext(); XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx); xmlReader.loadBeanDefinitions(new ClassPathResource("/bundle-spring.xml")); ctx.refresh();/*from w w w. j a v a 2 s . com*/ Object bundleName = ctx.getBean("bundleName"); bundleName.toString(); }