Package org.springframework.core.io

Examples of org.springframework.core.io.Resource


        PayloadValidatingInterceptor interceptor = new PayloadValidatingInterceptor();
        interceptor.setSchema(new ClassPathResource("codexws.xsd", getClass()));
        interceptor.afterPropertiesSet();

        Resource resource = new ClassPathResource("axiom.xml", getClass());
        TransportInputStream tis = new MockTransportInputStream(resource.getInputStream());
        WebServiceMessage message = messageFactory.createWebServiceMessage(tis);
        MessageContext context = new DefaultMessageContext(message, messageFactory);
        boolean result = interceptor.handleRequest(context, null);
        Assert.assertTrue("Invalid response from interceptor", result);
View Full Code Here


        PayloadValidatingInterceptor interceptor = new PayloadValidatingInterceptor();
        interceptor.setSchema(new ClassPathResource("multipleNamespaces.xsd", getClass()));
        interceptor.afterPropertiesSet();

        Resource resource = new ClassPathResource("multipleNamespaces.xml", getClass());
        TransportInputStream tis = new MockTransportInputStream(resource.getInputStream());
        WebServiceMessage message = messageFactory.createWebServiceMessage(tis);
        MessageContext context = new DefaultMessageContext(message, messageFactory);
        boolean result = interceptor.handleRequest(context, null);
        Assert.assertTrue("Invalid response from interceptor", result);
View Full Code Here

        return new CommonsXsdSchema(schema);
    }

    @Test
    public void testXmime() throws Exception {
        Resource resource = new ClassPathResource("xmime.xsd", AbstractXsdSchemaTestCase.class);
        XsdSchema schema = createSchema(resource);
        String namespace = "urn:test";
        assertEquals("Invalid target namespace", namespace, schema.getTargetNamespace());
        Document result = (Document) ((DOMSource) schema.getSource()).getNode();
        Element schemaElement = result.getDocumentElement();
View Full Code Here

        XMLUnit.setIgnoreWhitespace(true);
    }

    @Test
    public void testSingle() throws Exception {
        Resource resource = new ClassPathResource("single.xsd", AbstractXsdSchemaTestCase.class);
        collection.setXsds(new Resource[]{resource});
        collection.afterPropertiesSet();
        Assert.assertEquals("Invalid amount of XSDs loaded", 1, collection.getXsdSchemas().length);
    }
View Full Code Here

        Assert.assertEquals("Invalid amount of XSDs loaded", 1, collection.getXsdSchemas().length);
    }

    @Test
    public void testInlineComplex() throws Exception {
        Resource a = new ClassPathResource("A.xsd", AbstractXsdSchemaTestCase.class);
        collection.setXsds(new Resource[]{a});
        collection.setInline(true);
        collection.afterPropertiesSet();
        XsdSchema[] schemas = collection.getXsdSchemas();
        Assert.assertEquals("Invalid amount of XSDs loaded", 2, schemas.length);

        Assert.assertEquals("Invalid target namespace", "urn:1", schemas[0].getTargetNamespace());
        Resource abc = new ClassPathResource("ABC.xsd", AbstractXsdSchemaTestCase.class);
        Document expected = documentBuilder.parse(SaxUtils.createInputSource(abc));
        DOMResult domResult = new DOMResult();
        transformer.transform(schemas[0].getSource(), domResult);
        assertXMLEqual("Invalid XSD generated", expected, (Document) domResult.getNode());

        Assert.assertEquals("Invalid target namespace", "urn:2", schemas[1].getTargetNamespace());
        Resource cd = new ClassPathResource("CD.xsd", AbstractXsdSchemaTestCase.class);
        expected = documentBuilder.parse(SaxUtils.createInputSource(cd));
        domResult = new DOMResult();
        transformer.transform(schemas[1].getSource(), domResult);
        assertXMLEqual("Invalid XSD generated", expected, (Document) domResult.getNode());
    }
View Full Code Here

        assertXMLEqual("Invalid XSD generated", expected, (Document) domResult.getNode());
    }

    @Test
    public void testCircular() throws Exception {
        Resource resource = new ClassPathResource("circular-1.xsd", AbstractXsdSchemaTestCase.class);
        collection.setXsds(new Resource[]{resource});
        collection.setInline(true);
        collection.afterPropertiesSet();
        XsdSchema[] schemas = collection.getXsdSchemas();
        Assert.assertEquals("Invalid amount of XSDs loaded", 1, schemas.length);
View Full Code Here

        Assert.assertEquals("Invalid amount of XSDs loaded", 1, schemas.length);
    }

    @Test
    public void testXmlNamespace() throws Exception {
        Resource resource = new ClassPathResource("xmlNamespace.xsd", AbstractXsdSchemaTestCase.class);
        collection.setXsds(new Resource[]{resource});
        collection.setInline(true);
        collection.afterPropertiesSet();
        XsdSchema[] schemas = collection.getXsdSchemas();
        Assert.assertEquals("Invalid amount of XSDs loaded", 1, schemas.length);
View Full Code Here

        Assert.assertEquals("Invalid amount of XSDs loaded", 1, schemas.length);
    }

    @Test
    public void testCreateValidator() throws Exception {
        Resource a = new ClassPathResource("A.xsd", AbstractXsdSchemaTestCase.class);
        collection.setXsds(new Resource[]{a});
        collection.setInline(true);
        collection.afterPropertiesSet();

        XmlValidator validator = collection.createValidator();
View Full Code Here

        Assert.assertNotNull("No XmlValidator returned", validator);
    }

    @Test
    public void testInvalidSchema() throws Exception {
        Resource invalid = new ClassPathResource("invalid.xsd", AbstractXsdSchemaTestCase.class);
        collection.setXsds(new Resource[]{invalid});
        try {
            collection.afterPropertiesSet();
            Assert.fail("CommonsXsdSchemaException expected");
        }
View Full Code Here

        }
    }

    @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

TOP

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

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.