List of usage examples for org.springframework.core.io ClassPathResource ClassPathResource
public ClassPathResource(String path)
From source file:com.sammyun.service.impl.TemplateServiceImpl.java
@SuppressWarnings("unchecked") @Cacheable("template") public List<Template> getAll() { try {// w w w . jav a 2 s. c om File preschoolEduXmlFile = new ClassPathResource(CommonAttributes.PRESCHOOLEDU_XML_PATH).getFile(); Document document = new SAXReader().read(preschoolEduXmlFile); List<Template> templates = new ArrayList<Template>(); List<Element> elements = document.selectNodes("/preschoolEdu/template"); for (Element element : elements) { Template template = getTemplate(element); templates.add(template); } return templates; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:net.javacrumbs.springws.test.template.XsltTemplateProcessorTest.java
@Test public void testTemplate() throws IOException { WsTestContextHolder.getTestContext().setAttribute("number", 2); WebServiceMessage request = createMessage("xml/valid-message2.xml"); ClassPathResource template = new ClassPathResource("mock-responses/test/different-response.xml"); Resource resource = processor.processTemplate(template, request); Document controlDocument = getXmlUtil() .loadDocument(new ClassPathResource("xml/resolved-different-response.xml")); Document responseDocument = getXmlUtil().loadDocument(resource); Diff diff = new Diff(controlDocument, responseDocument); assertTrue(diff.toString(), diff.similar()); WsTestContextHolder.getTestContext().clear(); }
From source file:com.manning.siia.kitchen.domain.DomainTest.java
@Test public void shouldHydrateXmlFile() throws IOException { final Object o = xstream.fromXML(new ClassPathResource("pilav.xml").getInputStream()); assertThat(o, instanceOf(Recipe.class)); Recipe r = (Recipe) o;//w w w . ja v a 2 s . c o m assertThat(r.getIngredients().size(), is(6)); System.out.println(r.getIngredients()); }
From source file:org.springframework.cloud.config.monitor.GitlabPropertyPathNotificationExtractorTests.java
@Test public void pushEvent() throws Exception { // See http://doc.gitlab.com/ee/web_hooks/web_hooks.html#push-events Map<String, Object> value = new ObjectMapper().readValue( new ClassPathResource("gitlab.json").getInputStream(), new TypeReference<Map<String, Object>>() { });/*from w ww. j a va 2s. c om*/ this.headers.set("X-Gitlab-Event", "Push Hook"); PropertyPathNotification extracted = this.extractor.extract(this.headers, value); assertNotNull(extracted); String[] paths = extracted.getPaths(); assertThat("paths was wrong", paths, arrayContainingInAnyOrder("oldapp.yml", "newapp.properties", "application.yml")); }
From source file:com.scase.core.service.impl.TemplateServiceImpl.java
@SuppressWarnings("unchecked") @Cacheable("template") public List<Template> getAll() { try {//from ww w . jav a2 s . co m File shopxxXmlFile = new ClassPathResource(CommonAttributes.SCASE_XML_PATH).getFile(); Document document = new SAXReader().read(shopxxXmlFile); List<Template> templates = new ArrayList<Template>(); List<Element> elements = document.selectNodes("/shopxx/template"); for (Element element : elements) { Template template = getTemplate(element); templates.add(template); } return templates; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:net.javacrumbs.springws.test.common.DefaultMessageComparatorTest.java
@Test public void testValid() throws IOException { Document controlDocument = getXmlUtil().loadDocument(new ClassPathResource("xml/control-message-test.xml")); assertTrue(comparator.isSoap(controlDocument)); comparator.compareDocuments(controlDocument, getXmlUtil().loadDocument(getValidMessage())); }
From source file:nl.surfnet.coin.mock.MockSoapServerTest.java
/** * Test the MockHttpServer.//from w ww. ja v a2s . c o m * * @throws Exception */ @Test public void testMockHappyFlow() throws Exception { ClassPathResource responseResource = new ClassPathResource("test.json"); super.setResponseResource(responseResource); HttpClient client = new DefaultHttpClient(); HttpResponse response = client.execute(new HttpGet("http://localhost:8088/testUrl")); String contentType = response.getHeaders("Content-Type")[0].getValue(); Assert.assertEquals("application/json", contentType); InputStream is = response.getEntity().getContent(); OutputStream output = new ByteArrayOutputStream(); IOUtils.copy(is, output); Assert.assertEquals(IOUtils.toString(responseResource.getInputStream()), output.toString()); }
From source file:com.compomics.pladipus.core.control.updates.ProcessingBeanUpdater.java
private static void copyFromResources() { //loads the codontable from within the jar... if (beanXMLDefinitionFile != null && !beanXMLDefinitionFile.exists()) { try {//from w w w .j a va2 s. co m beanXMLDefinitionFile.getParentFile().mkdirs(); beanXMLDefinitionFile.createNewFile(); InputStream inputStream = new ClassPathResource("processing-beans.xml").getInputStream(); OutputStream outputStream = new FileOutputStream(beanXMLDefinitionFile); IOUtils.copy(inputStream, outputStream); } catch (IOException ex) { LOGGER.error(ex); } } }
From source file:com.acmemotors.filter.DataFilterTests.java
@Before public void setUp() { processor = new GroovyScriptExecutingMessageProcessor( new ResourceScriptSource(new ClassPathResource("DataFilter.groovy"))); }
From source file:fr.esiea.esieaddress.csv.ImportCsvTest.java
@Before public void setUp() throws Exception { URI = new ClassPathResource("csv").getFile().getAbsolutePath().toString(); URI = URI.concat(File.separator + "contacts.csv"); }