List of usage examples for org.springframework.core.io ClassPathResource ClassPathResource
public ClassPathResource(String path)
From source file:org.ligoj.app.plugin.prov.aws.in.CsvForBeanEc2Test.java
@Test public void readNAOs() throws IOException { final BufferedReader reader = new BufferedReader(new InputStreamReader( new ClassPathResource("mock-server/aws/index-small-na-os.csv").getInputStream())); Assertions.assertNull(new CsvForBeanEc2(reader).read()); }
From source file:org.alfresco.util.bean.AbstractClasspathContextLoaderEvaluator.java
public Resource getContextResource() { return new ClassPathResource(contextClasspath); }
From source file:com.manning.siia.kitchen.EndToEndIntegrationTest.java
@Test public void shouldCreateAMeal() throws IOException { final TimedPollableChannel timed = new TimedPollableChannel(meals); File resource = new ClassPathResource("/pilav.xml").getFile(); //copy//ww w .j a v a2 s.com File recipeWriting = recipeBookLocation.newFile("pilav.xml.writing"); FileUtils.copyFile(resource, recipeWriting); //then rename recipeWriting.renameTo(recipeBookLocation.newFile("pilav.xml")); Message<?> message = timed.receive(3500); assertThat(message, is(notNullValue())); Meal meal = (Meal) message.getPayload(); assertThat(meal.getRecipe().getName(), is("Pilav")); assertThat(meal.isDone(), is(true)); }
From source file:net.javacrumbs.springws.test.validator.AxiomSchemaValidatorTest.java
@Test(expected = WsTestException.class) public void testSetSchema() throws Exception { SchemaRequestValidator validator = new SchemaRequestValidator(); validator.setXsdSchema(new SimpleXsdSchema(new ClassPathResource("xml/schema.xsd"))); validator.afterPropertiesSet();/*ww w . j ava 2s . c o m*/ assertNotNull(validator.getValidator()); WebServiceMessage message = getInvalidMessage(); createValidator().validateRequest(null, message); }
From source file:example.springdata.mongodb.util.BlogPostInitializer.java
@SuppressWarnings({ "unchecked", "rawtypes" }) private void loadFromClasspathSource(MongoOperations operations) throws Exception { Jackson2ResourceReader reader = new Jackson2ResourceReader(); Object source = reader.readFrom(new ClassPathResource("spring-blog.atom.json"), this.getClass().getClassLoader()); if (source instanceof Iterable) { ((Iterable) source).forEach(element -> operations.save(element)); } else {/*w ww. ja v a 2 s .com*/ operations.save(source); } log.info("Imported blog posts from classpath!"); }
From source file:it.geosolutions.geoserver.rest.publisher.GeoserverRESTPublishShpCollectionTest.java
@Test public void testLocalZip() throws Exception { if (!enabled()) { return;/*from ww w . java 2 s. c o m*/ } URI location = new ClassPathResource("testdata/multipleshp.zip").getFile().toURI(); test(location); }
From source file:com.shopzilla.api.service.ProductServiceIntegrationTest.java
@Before public void setUp() throws IOException, JAXBException { // open our sample file, which is located at src/test/resources/sample-data/product.xml InputStream in = new ClassPathResource("sample-data/product.xml").getInputStream(); // pass the inputStream to the service we want to test, and return an object representing the // result of teh XML call productResponse = productService.xmlInputStreamToJava(in); productOrOffer = productResponse.getProducts().getProductOrOffer(); }
From source file:ch.tatool.app.util.ContextUtils.java
/** * Create a new BeanFactory using the main ApplicationContext as parent. * //from w ww .j ava2 s. c o m * @param classpath the path to the bean definition file in the classpath * @param properties set of properties that should be replaced in the definitions * @return a BeanFactory instance */ public static BeanFactory createBeanFactory(String classpath, Properties properties) { // create an empty bean factory DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); // load the context file - has to be done here, otherwise properties won't get resolved XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory); Resource resource = new ClassPathResource(classpath); reader.loadBeanDefinitions(resource); // apply the properties to the context PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); configurer.setProperties(properties); configurer.setIgnoreUnresolvablePlaceholders(false); configurer.setIgnoreResourceNotFound(false); configurer.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_FALLBACK); configurer.postProcessBeanFactory(beanFactory); return beanFactory; }
From source file:hu.petabyte.redflags.engine.gear.indicator.hu.ContrDescCartellingIndicator.java
@Override public void beforeSession() throws Exception { keywords.clear();// w ww . ja v a 2 s .c o m Scanner s = new Scanner(new ClassPathResource(filename).getInputStream(), "UTF-8"); while (s.hasNextLine()) { keywords.add(s.nextLine()); } s.close(); LOG.debug("Loaded {} expressions for cartelling", keywords.size()); setWeight(0.5); super.beforeSession(); }