Package org.springframework.core.io

Examples of org.springframework.core.io.ClassPathResource


        }
    }

    @Test
    public void testIncludesAndImports() throws Exception {
        Resource hr = new ClassPathResource("hr.xsd", getClass());
        collection.setXsds(new Resource[]{hr});
        collection.setInline(true);
        collection.afterPropertiesSet();

        XsdSchema[] schemas = collection.getXsdSchemas();
        Assert.assertEquals("Invalid amount of XSDs loaded", 2, schemas.length);

        Assert.assertEquals("Invalid target namespace", "http://mycompany.com/hr/schemas", schemas[0].getTargetNamespace());
        Resource hr_employee = new ClassPathResource("hr_employee.xsd", getClass());
        Document expected = documentBuilder.parse(SaxUtils.createInputSource(hr_employee));
        DOMResult domResult = new DOMResult();
        transformer.transform(schemas[0].getSource(), domResult);
        assertXMLEqual("Invalid XSD generated", expected, (Document) domResult.getNode());

        Assert.assertEquals("Invalid target namespace", "http://mycompany.com/hr/schemas/holiday", schemas[1].getTargetNamespace());
        Resource holiday = new ClassPathResource("holiday.xsd", getClass());
        expected = documentBuilder.parse(SaxUtils.createInputSource(holiday));
        domResult = new DOMResult();
        transformer.transform(schemas[1].getSource(), domResult);
        assertXMLEqual("Invalid XSD generated", expected, (Document) domResult.getNode());
View Full Code Here


    }

    @After
    public void tearDown() throws Exception {
        BasicConfigurator.resetConfiguration();
        ClassPathResource resource = new ClassPathResource("log4j.properties");
        PropertyConfigurator.configure(resource.getURL());
    }
View Full Code Here

    @Before
    public void setUp() throws Exception {
        interceptor = new PayloadTransformingInterceptor();
        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        transformer = transformerFactory.newTransformer();
        input = new ClassPathResource("transformInput.xml", getClass());
        output = new ClassPathResource("transformOutput.xml", getClass());
        xslt = new ClassPathResource("transformation.xslt", getClass());
        XMLUnit.setIgnoreWhitespace(true);
    }
View Full Code Here

        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document document = builder.parse(getClass().getResourceAsStream("soapMessage.xml"));
        SOAPMessage soapMessage =
                SaajUtils.loadMessage(new ClassPathResource("soapMessage.xml", getClass()), messageFactory);
        assertXMLEqual(soapMessage.getSOAPPart(), document);
    }
View Full Code Here

        Assert.assertEquals("Invalid SAAJ version", SaajUtils.SAAJ_13, SaajUtils.getSaajVersion());
    }

    @Test(expected = SOAPException.class)
    public void testGetSaajVersionInvalidEnvelope() throws Exception {
        Resource resource = new ClassPathResource("invalidNamespaceReferenceSoapMessage.xml", getClass());
        InputStream in = resource.getInputStream();
        MimeHeaders headers = new MimeHeaders();
        SOAPMessage soapMessage = messageFactory.createMessage(headers, in);
        SaajUtils.getSaajVersion(soapMessage);
    }
View Full Code Here

    }

    @After
    public void tearDown() throws Exception {
        BasicConfigurator.resetConfiguration();
        ClassPathResource resource = new ClassPathResource("log4j.properties");
        PropertyConfigurator.configure(resource.getURL());
    }
View Full Code Here

     * multiple resource servers in the same war. Then look for second best apis-resource-server.properties file, then
     * try to use the filter config if parameters are present. If this also
     * fails trust on the setters (e.g. probably in test modus), but apply
     * fail-fast strategy
     */
    ClassPathResource res = null;
    String propertiesFile = filterConfig.getInitParameter("apis-resource-server.properties.file");
    if (StringUtils.isNotEmpty(propertiesFile)) {
      res = new ClassPathResource(propertiesFile);
    }
    if (res == null || !res.exists()) {
      res = new ClassPathResource("apis-resource-server.properties");
    }
    if (res != null && res.exists()) {
      Properties prop = new Properties();
      try {
        prop.load(res.getInputStream());
      } catch (IOException e) {
        throw new RuntimeException("Error in reading the apis-resource-server.properties file", e);
      }
      resourceServerKey = prop.getProperty("adminService.resourceServerKey");
      resourceServerSecret = prop.getProperty("adminService.resourceServerSecret");
View Full Code Here

       
        Date dte = new Date();
        String emailSubject = "grepster testSendMessageWithAttachment: " + dte;
        String emailBody = "Body of the grepster testSendMessageWithAttachment message sent at: " + dte;
       
        ClassPathResource cpResource = new ClassPathResource("/test-attachment.txt");
        // a null from should work
        mailEngine.sendMessage(new String[] {
            "foo@bar.com"
        }, null, cpResource, emailBody, emailSubject, ATTACHMENT_NAME);
View Full Code Here

  @Override
  public YarnEnvironmentConfigurer propertiesLocationId(String id, String[] locations) throws IOException {
    for (String location : locations) {
      PropertiesFactoryBean fb = new PropertiesFactoryBean();
      fb.setLocation(new ClassPathResource(location));
      fb.afterPropertiesSet();
      getDataHolder(id).properties.putAll(fb.getObject());
    }
    return this;
  }
View Full Code Here

  @Before
  public void setUp() throws SAXException, IOException, ParserConfigurationException {

    parser = new TypeFilterParser(context, classLoader);

    Resource sampleXmlFile = new ClassPathResource("type-filter-test.xml", TypeFilterParserUnitTests.class);

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);

    documentElement = factory.newDocumentBuilder().parse(sampleXmlFile.getInputStream()).getDocumentElement();
  }
View Full Code Here

TOP

Related Classes of org.springframework.core.io.ClassPathResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.