Search in sources :

Example 1 with XSLTResourceTransformer

use of org.apache.cxf.ws.transfer.validationtransformation.XSLTResourceTransformer in project cxf by apache.

the class TestUtils method createTeachersServers.

protected static void createTeachersServers(String port) {
    ResourceManager teachersResourceManager = new MemoryResourceManager();
    ResourceRemote resource = new ResourceRemote();
    resource.setManager(teachersResourceManager);
    resource.getResourceTypeIdentifiers().add(new XSDResourceTypeIdentifier(new StreamSource(TestUtils.class.getResourceAsStream("/schema/teacher.xsd")), new XSLTResourceTransformer(new StreamSource(TestUtils.class.getResourceAsStream("/xslt/teacherDefaultValues.xsl")), new TeacherResourceValidator())));
    teachersResourceFactoryServer = createTeachersResourceFactoryEndpoint(resource, port);
    teachersResourceServer = createTeacherResourceEndpoint(resource, port);
}
Also used : ResourceRemote(org.apache.cxf.ws.transfer.resource.ResourceRemote) StreamSource(javax.xml.transform.stream.StreamSource) TeacherResourceValidator(org.apache.cxf.systest.ws.transfer.validator.TeacherResourceValidator) XSLTResourceTransformer(org.apache.cxf.ws.transfer.validationtransformation.XSLTResourceTransformer) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) ResourceManager(org.apache.cxf.ws.transfer.manager.ResourceManager) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) XSDResourceTypeIdentifier(org.apache.cxf.ws.transfer.validationtransformation.XSDResourceTypeIdentifier)

Example 2 with XSLTResourceTransformer

use of org.apache.cxf.ws.transfer.validationtransformation.XSLTResourceTransformer in project cxf by apache.

the class TestUtils method createStudentsResource.

private static Server createStudentsResource(ResourceManager resourceManager, String port) {
    ResourceLocal resourceLocal = new ResourceLocal();
    resourceLocal.setManager(resourceManager);
    resourceLocal.getResourceTypeIdentifiers().add(new XSDResourceTypeIdentifier(new StreamSource(TestUtils.class.getResourceAsStream("/schema/studentPut.xsd")), new XSLTResourceTransformer(new StreamSource(TestUtils.class.getResourceAsStream("/xslt/studentPut.xsl")), new StudentPutResourceValidator())));
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceClass(Resource.class);
    factory.setServiceBean(resourceLocal);
    factory.setAddress("http://localhost:" + port + "/ResourceStudents");
    return factory.create();
}
Also used : StreamSource(javax.xml.transform.stream.StreamSource) ResourceLocal(org.apache.cxf.ws.transfer.resource.ResourceLocal) StudentPutResourceValidator(org.apache.cxf.systest.ws.transfer.validator.StudentPutResourceValidator) XSLTResourceTransformer(org.apache.cxf.ws.transfer.validationtransformation.XSLTResourceTransformer) XSDResourceTypeIdentifier(org.apache.cxf.ws.transfer.validationtransformation.XSDResourceTypeIdentifier) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 3 with XSLTResourceTransformer

use of org.apache.cxf.ws.transfer.validationtransformation.XSLTResourceTransformer in project cxf by apache.

the class TestUtils method createResourceFactory.

private static Server createResourceFactory(ResourceManager resourceManager, String port, String port2) {
    ResourceFactoryImpl resourceFactory = new ResourceFactoryImpl();
    resourceFactory.setResourceResolver(new MyResourceResolver("http://localhost:" + port + "/ResourceStudents", resourceManager, "http://localhost:" + port2 + "/ResourceTeachers"));
    resourceFactory.getResourceTypeIdentifiers().add(new XSDResourceTypeIdentifier(new StreamSource(TestUtils.class.getResourceAsStream("/schema/studentCreate.xsd")), new XSLTResourceTransformer(new StreamSource(TestUtils.class.getResourceAsStream("/xslt/studentCreate.xsl")))));
    resourceFactory.getResourceTypeIdentifiers().add(new XSDResourceTypeIdentifier(new StreamSource(TestUtils.class.getResourceAsStream("/schema/teacherCreateBasic.xsd")), new XSLTResourceTransformer(new StreamSource(TestUtils.class.getResourceAsStream("/xslt/teacherCreateBasic.xsl")))));
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceClass(org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory.class);
    factory.setServiceBean(resourceFactory);
    factory.setAddress("http://localhost:" + port + "/ResourceFactory");
    return factory.create();
}
Also used : MyResourceResolver(org.apache.cxf.systest.ws.transfer.resolver.MyResourceResolver) StreamSource(javax.xml.transform.stream.StreamSource) XSLTResourceTransformer(org.apache.cxf.ws.transfer.validationtransformation.XSLTResourceTransformer) ResourceFactoryImpl(org.apache.cxf.ws.transfer.resourcefactory.ResourceFactoryImpl) XSDResourceTypeIdentifier(org.apache.cxf.ws.transfer.validationtransformation.XSDResourceTypeIdentifier) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Example 4 with XSLTResourceTransformer

use of org.apache.cxf.ws.transfer.validationtransformation.XSLTResourceTransformer in project cxf by apache.

the class XSLTResourceTransformerTest method transformTest.

@Test
public void transformTest() throws XMLStreamException {
    ResourceTransformer transformer = new XSLTResourceTransformer(new StreamSource(getClass().getResourceAsStream("/xml/xsltresourcetransformer/stylesheet.xsl")));
    Representation representation = loadRepresentation(getClass().getResourceAsStream("/xml/xsltresourcetransformer/representation.xml"));
    transformer.transform(representation, null);
    Element representationEl = (Element) representation.getAny();
    Assert.assertEquals("Expected root element with name \"person\".", "person", representationEl.getLocalName());
    Assert.assertTrue("Expected one element \"firstname\".", representationEl.getElementsByTagName("firstname").getLength() == 1);
    Assert.assertTrue("Expected one element \"lastname\".", representationEl.getElementsByTagName("lastname").getLength() == 1);
}
Also used : StreamSource(javax.xml.transform.stream.StreamSource) Element(org.w3c.dom.Element) XSLTResourceTransformer(org.apache.cxf.ws.transfer.validationtransformation.XSLTResourceTransformer) Representation(org.apache.cxf.ws.transfer.Representation) XSLTResourceTransformer(org.apache.cxf.ws.transfer.validationtransformation.XSLTResourceTransformer) ResourceTransformer(org.apache.cxf.ws.transfer.validationtransformation.ResourceTransformer) Test(org.junit.Test)

Aggregations

StreamSource (javax.xml.transform.stream.StreamSource)4 XSLTResourceTransformer (org.apache.cxf.ws.transfer.validationtransformation.XSLTResourceTransformer)4 XSDResourceTypeIdentifier (org.apache.cxf.ws.transfer.validationtransformation.XSDResourceTypeIdentifier)3 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)2 MyResourceResolver (org.apache.cxf.systest.ws.transfer.resolver.MyResourceResolver)1 StudentPutResourceValidator (org.apache.cxf.systest.ws.transfer.validator.StudentPutResourceValidator)1 TeacherResourceValidator (org.apache.cxf.systest.ws.transfer.validator.TeacherResourceValidator)1 Representation (org.apache.cxf.ws.transfer.Representation)1 MemoryResourceManager (org.apache.cxf.ws.transfer.manager.MemoryResourceManager)1 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)1 ResourceLocal (org.apache.cxf.ws.transfer.resource.ResourceLocal)1 ResourceRemote (org.apache.cxf.ws.transfer.resource.ResourceRemote)1 ResourceFactoryImpl (org.apache.cxf.ws.transfer.resourcefactory.ResourceFactoryImpl)1 ResourceTransformer (org.apache.cxf.ws.transfer.validationtransformation.ResourceTransformer)1 Test (org.junit.Test)1 Element (org.w3c.dom.Element)1