Package org.springframework.core.io

Examples of org.springframework.core.io.ClassPathResource


        Assert.assertFalse("Invalid response from interceptor", validated);
    }

    @Test
    public void testHandleValidRequestMultipleSchemas() throws Exception {
        interceptor.setSchemas(new Resource[]{new ClassPathResource(PRODUCT_SCHEMA, getClass()),
                new ClassPathResource(SIZE_SCHEMA, getClass())});
        interceptor.afterPropertiesSet();
        MockWebServiceMessage request = new MockWebServiceMessage(new ClassPathResource(VALID_MESSAGE, getClass()));
        context = new DefaultMessageContext(request, new MockWebServiceMessageFactory());

        boolean result = interceptor.handleRequest(context);
        Assert.assertTrue("Invalid response from interceptor", result);
        Assert.assertFalse("Response set", context.hasResponse());
View Full Code Here


        Assert.assertFalse("Response set", context.hasResponse());
    }

    @Test
    public void testHandleInvalidResponseMultipleSchemas() throws Exception {
        interceptor.setSchemas(new Resource[]{new ClassPathResource(PRODUCT_SCHEMA, getClass()),
                new ClassPathResource(SIZE_SCHEMA, getClass())});
        interceptor.afterPropertiesSet();
        MockWebServiceMessage request = new MockWebServiceMessage();
        context = new DefaultMessageContext(request, new MockWebServiceMessageFactory());
        MockWebServiceMessage response = (MockWebServiceMessage) context.getResponse();
        response.setPayload(new ClassPathResource(INVALID_MESSAGE, getClass()));
        boolean result = interceptor.handleResponse(context);
        Assert.assertFalse("Invalid response from interceptor", result);
    }
View Full Code Here

        Assert.assertFalse("Invalid response from interceptor", result);
    }

    @Test
    public void testHandleValidResponseMultipleSchemas() throws Exception {
        interceptor.setSchemas(new Resource[]{new ClassPathResource(PRODUCT_SCHEMA, getClass()),
                new ClassPathResource(SIZE_SCHEMA, getClass())});
        interceptor.afterPropertiesSet();
        MockWebServiceMessage request = new MockWebServiceMessage();
        context = new DefaultMessageContext(request, new MockWebServiceMessageFactory());
        MockWebServiceMessage response = (MockWebServiceMessage) context.getResponse();
        response.setPayload(new ClassPathResource(VALID_MESSAGE, getClass()));
        boolean result = interceptor.handleResponse(context);
        Assert.assertTrue("Invalid response from interceptor", result);
    }
View Full Code Here

    }

    @Test
    public void testXsdSchema() throws Exception {
        PayloadValidatingInterceptor interceptor = new PayloadValidatingInterceptor();
        SimpleXsdSchema schema = new SimpleXsdSchema(new ClassPathResource(SCHEMA, getClass()));
        schema.afterPropertiesSet();
        interceptor.setXsdSchema(schema);
        interceptor.setValidateRequest(true);
        interceptor.setValidateResponse(true);
        interceptor.afterPropertiesSet();
        MockWebServiceMessage request = new MockWebServiceMessage();
        request.setPayload(new ClassPathResource(VALID_MESSAGE, getClass()));
        context = new DefaultMessageContext(request, new MockWebServiceMessageFactory());
        boolean result = interceptor.handleRequest(context);
        Assert.assertTrue("Invalid response from interceptor", result);
        Assert.assertFalse("Response set", context.hasResponse());
    }
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

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.