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);
}
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();
}
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();
}
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);
}
Aggregations