Search in sources :

Example 26 with ResourceManager

use of org.apache.cxf.ws.transfer.manager.ResourceManager in project cxf by apache.

the class FragmentGetXPath10Test method getNumberTest.

@Test
public void getNumberTest() throws XMLStreamException {
    String content = "<root><a><b>Text</b><b>Text2</b></a></root>";
    ResourceManager resourceManager = new MemoryResourceManager();
    ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
    Server resource = createLocalResource(resourceManager);
    Resource client = createClient(refParams);
    ObjectFactory objectFactory = new ObjectFactory();
    Get request = new Get();
    request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
    ExpressionType expression = new ExpressionType();
    expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
    expression.getContent().add("count(//b)");
    request.getAny().add(objectFactory.createExpression(expression));
    GetResponse response = client.get(request);
    ValueType value = getValue(response);
    Assert.assertEquals(1, value.getContent().size());
    Assert.assertEquals("2", value.getContent().get(0));
    resource.destroy();
}
Also used : Server(org.apache.cxf.endpoint.Server) ObjectFactory(org.apache.cxf.ws.transfer.dialect.fragment.ObjectFactory) ValueType(org.apache.cxf.ws.transfer.dialect.fragment.ValueType) Get(org.apache.cxf.ws.transfer.Get) Resource(org.apache.cxf.ws.transfer.resource.Resource) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) ResourceManager(org.apache.cxf.ws.transfer.manager.ResourceManager) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) ExpressionType(org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType) GetResponse(org.apache.cxf.ws.transfer.GetResponse) Test(org.junit.Test)

Example 27 with ResourceManager

use of org.apache.cxf.ws.transfer.manager.ResourceManager in project cxf by apache.

the class TestUtils method createStudentsServers.

protected static void createStudentsServers(String port, String port2) {
    UIDManager.reset();
    ResourceManager studentsResourceManager = new MemoryResourceManager();
    resourceFactoryServer = createResourceFactory(studentsResourceManager, port, port2);
    studentsResourceServer = createStudentsResource(studentsResourceManager, port);
}
Also used : MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) ResourceManager(org.apache.cxf.ws.transfer.manager.ResourceManager) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager)

Example 28 with ResourceManager

use of org.apache.cxf.ws.transfer.manager.ResourceManager 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 29 with ResourceManager

use of org.apache.cxf.ws.transfer.manager.ResourceManager in project cxf by apache.

the class FragmentPutAddTest method addSiblingTest.

@Test
public void addSiblingTest() throws XMLStreamException {
    String content = "<a><b/></a>";
    ResourceManager resourceManager = new MemoryResourceManager();
    ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
    Server resource = createLocalResource(resourceManager);
    Resource client = createClient(refParams);
    Put request = new Put();
    request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
    Fragment fragment = new Fragment();
    ExpressionType expression = new ExpressionType();
    expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
    expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_ADD);
    expression.getContent().add("/a");
    Element addedElement = DOMUtils.getEmptyDocument().createElement("c");
    ValueType value = new ValueType();
    value.getContent().add(addedElement);
    fragment.setExpression(expression);
    fragment.setValue(value);
    request.getAny().add(fragment);
    PutResponse response = client.put(request);
    Element rootEl = (Element) response.getRepresentation().getAny();
    Element child0 = (Element) rootEl.getChildNodes().item(0);
    Element child1 = (Element) rootEl.getChildNodes().item(1);
    Assert.assertEquals("a", rootEl.getNodeName());
    Assert.assertEquals("b", child0.getNodeName());
    Assert.assertEquals("c", child1.getNodeName());
    resource.destroy();
}
Also used : Server(org.apache.cxf.endpoint.Server) ValueType(org.apache.cxf.ws.transfer.dialect.fragment.ValueType) Element(org.w3c.dom.Element) Resource(org.apache.cxf.ws.transfer.resource.Resource) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) ResourceManager(org.apache.cxf.ws.transfer.manager.ResourceManager) PutResponse(org.apache.cxf.ws.transfer.PutResponse) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) Fragment(org.apache.cxf.ws.transfer.dialect.fragment.Fragment) ExpressionType(org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType) Put(org.apache.cxf.ws.transfer.Put) Test(org.junit.Test)

Example 30 with ResourceManager

use of org.apache.cxf.ws.transfer.manager.ResourceManager in project cxf by apache.

the class FragmentPutAddTest method addToEmptyDocumentTest.

@Test
public void addToEmptyDocumentTest() {
    ResourceManager resourceManager = new MemoryResourceManager();
    ReferenceParametersType refParams = resourceManager.create(new Representation());
    Server resource = createLocalResource(resourceManager);
    Resource client = createClient(refParams);
    Put request = new Put();
    request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
    Fragment fragment = new Fragment();
    ExpressionType expression = new ExpressionType();
    expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
    expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_ADD);
    expression.getContent().add("/");
    Element addedElement = DOMUtils.getEmptyDocument().createElement("a");
    ValueType value = new ValueType();
    value.getContent().add(addedElement);
    fragment.setExpression(expression);
    fragment.setValue(value);
    request.getAny().add(fragment);
    PutResponse response = client.put(request);
    Element rootEl = (Element) response.getRepresentation().getAny();
    Assert.assertEquals("a", rootEl.getNodeName());
    resource.destroy();
}
Also used : Server(org.apache.cxf.endpoint.Server) ValueType(org.apache.cxf.ws.transfer.dialect.fragment.ValueType) Element(org.w3c.dom.Element) Resource(org.apache.cxf.ws.transfer.resource.Resource) ReferenceParametersType(org.apache.cxf.ws.addressing.ReferenceParametersType) Representation(org.apache.cxf.ws.transfer.Representation) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) ResourceManager(org.apache.cxf.ws.transfer.manager.ResourceManager) PutResponse(org.apache.cxf.ws.transfer.PutResponse) MemoryResourceManager(org.apache.cxf.ws.transfer.manager.MemoryResourceManager) Fragment(org.apache.cxf.ws.transfer.dialect.fragment.Fragment) ExpressionType(org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType) Put(org.apache.cxf.ws.transfer.Put) Test(org.junit.Test)

Aggregations

ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)55 ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)53 MemoryResourceManager (org.apache.cxf.ws.transfer.manager.MemoryResourceManager)53 Test (org.junit.Test)53 Server (org.apache.cxf.endpoint.Server)52 Resource (org.apache.cxf.ws.transfer.resource.Resource)51 ExpressionType (org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType)48 ValueType (org.apache.cxf.ws.transfer.dialect.fragment.ValueType)44 Element (org.w3c.dom.Element)39 Put (org.apache.cxf.ws.transfer.Put)33 Fragment (org.apache.cxf.ws.transfer.dialect.fragment.Fragment)32 PutResponse (org.apache.cxf.ws.transfer.PutResponse)25 Get (org.apache.cxf.ws.transfer.Get)17 GetResponse (org.apache.cxf.ws.transfer.GetResponse)16 ObjectFactory (org.apache.cxf.ws.transfer.dialect.fragment.ObjectFactory)16 Representation (org.apache.cxf.ws.transfer.Representation)9 JAXBElement (javax.xml.bind.JAXBElement)2 Create (org.apache.cxf.ws.transfer.Create)2 CreateResponse (org.apache.cxf.ws.transfer.CreateResponse)2 ResourceFactory (org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory)2