From 3cdd19992314a0aed86b9e32d80ab7e318c00b71 Mon Sep 17 00:00:00 2001 From: Andrea Gazzarini Date: Mon, 16 Feb 2009 10:40:39 +0000 Subject: QPID-1604 : Implementation of wrsf-rp:PutResourcePropertyDocument interface git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@744885 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/java/management/client/src/main/java/muse.xml | 12 +-- .../management/wsdm/capabilities/WsdlBuilder.java | 3 +- .../client/src/main/java/wsdl/QManAdapter.rmd | 25 ----- .../client/src/main/java/wsdl/QManAdapter.wsdl | 21 +--- .../client/src/main/java/wsdl/QManWsResource.rmd | 12 ++- .../client/src/main/java/wsdl/QManWsResource.wsdl | 113 +++++---------------- .../qpid/management/wsdm/WsDmAdapterTest.java | 89 ++++++++++++---- 7 files changed, 110 insertions(+), 165 deletions(-) diff --git a/qpid/java/management/client/src/main/java/muse.xml b/qpid/java/management/client/src/main/java/muse.xml index 2b047d01f7..d2f499cef9 100644 --- a/qpid/java/management/client/src/main/java/muse.xml +++ b/qpid/java/management/client/src/main/java/muse.xml @@ -143,14 +143,6 @@ http://schemas.xmlsoap.org/ws/2004/09/mex/GetMetadata org.apache.qpid.management.wsdm.capabilities.QManMetadataExchangeCapability - - http://docs.oasis-open.org/wsrf/rlw-2/ImmediateResourceTermination - org.apache.muse.ws.resource.lifetime.impl.SimpleImmediateTermination - - - http://docs.oasis-open.org/wsrf/rlw-2/ScheduledResourceTermination - org.apache.muse.ws.resource.lifetime.impl.SimpleScheduledTermination - http://docs.oasis-open.org/wsrf/rpw-2/Get org.apache.muse.ws.resource.properties.get.impl.SimpleGetCapability @@ -163,6 +155,10 @@ http://docs.oasis-open.org/wsrf/rpw-2/Set org.apache.muse.ws.resource.properties.set.impl.SimpleSetCapability + + http://docs.oasis-open.org/wsrf/rpw-2/Put + org.apache.muse.ws.resource.properties.set.impl.SimpleSetCapability + ServiceGroupEntry diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/WsdlBuilder.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/WsdlBuilder.java index bce0e30e62..02b25eb02f 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/WsdlBuilder.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/WsdlBuilder.java @@ -96,7 +96,7 @@ class WsdlBuilder implements IArtifactBuilder { propertyRef.setAttribute( "ref", Names.PREFIX+":"+attributeMetadata.getName()); - + propertyRef.setAttribute("minOccurs", "0"); wsrpProperties.appendChild(propertyRef); } catch(Exception exception) @@ -197,6 +197,7 @@ class WsdlBuilder implements IArtifactBuilder { Element propertyDeclaration = XmlUtils.createElement(_document, XSD_ELEMENT_QNAME); propertyDeclaration.setAttribute("name",attributeName); propertyDeclaration.setAttribute("type", serializer.getXmlType(Class.forName(type))); + return propertyDeclaration; } } diff --git a/qpid/java/management/client/src/main/java/wsdl/QManAdapter.rmd b/qpid/java/management/client/src/main/java/wsdl/QManAdapter.rmd index 0663acb548..31e921a06b 100644 --- a/qpid/java/management/client/src/main/java/wsdl/QManAdapter.rmd +++ b/qpid/java/management/client/src/main/java/wsdl/QManAdapter.rmd @@ -4,7 +4,6 @@ xmlns:wsrf-sg="http://docs.oasis-open.org/wsrf/sg-2" xmlns:wsrf-rp="http://docs.oasis-open.org/wsrf/rp-2" xmlns:wsrl="http://docs.oasis-open.org/wsrf/rl-2" - xmlns:myns="http://ws.apache.org/muse/test/wsrf" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wst="http://docs.oasis-open.org/wsn/t-1" xmlns:muws1="http://docs.oasis-open.org/wsdm/muws1-2.xsd" @@ -20,33 +19,9 @@ - - - - - - diff --git a/qpid/java/management/client/src/main/java/wsdl/QManAdapter.wsdl b/qpid/java/management/client/src/main/java/wsdl/QManAdapter.wsdl index 9a956c22a2..4b26862604 100644 --- a/qpid/java/management/client/src/main/java/wsdl/QManAdapter.wsdl +++ b/qpid/java/management/client/src/main/java/wsdl/QManAdapter.wsdl @@ -61,32 +61,13 @@ - - - - + - diff --git a/qpid/java/management/client/src/main/java/wsdl/QManWsResource.rmd b/qpid/java/management/client/src/main/java/wsdl/QManWsResource.rmd index 397a134a79..c4944440e0 100644 --- a/qpid/java/management/client/src/main/java/wsdl/QManWsResource.rmd +++ b/qpid/java/management/client/src/main/java/wsdl/QManWsResource.rmd @@ -1,13 +1,17 @@ - - + \ No newline at end of file diff --git a/qpid/java/management/client/src/main/java/wsdl/QManWsResource.wsdl b/qpid/java/management/client/src/main/java/wsdl/QManWsResource.wsdl index f3ad6c6012..69647521ba 100644 --- a/qpid/java/management/client/src/main/java/wsdl/QManWsResource.wsdl +++ b/qpid/java/management/client/src/main/java/wsdl/QManWsResource.wsdl @@ -54,9 +54,7 @@ - - - + @@ -118,17 +116,14 @@ - - + + - - + + - - - - - + + @@ -196,33 +191,6 @@ name="GetMetadataResponseMsg" message="qman:GetMetadataResponseMsg"/> - - - - - - - - - - - - - - - + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - + - - - - + + name="UnableToPutResourcePropertyDocumentFault"/> @@ -523,16 +472,6 @@ name="SetResourcePropertyRequestFailedFault"/> - - - - - - - - - diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WsDmAdapterTest.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WsDmAdapterTest.java index a181a8652f..5012ff95cd 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WsDmAdapterTest.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WsDmAdapterTest.java @@ -46,6 +46,7 @@ import junit.framework.TestSuite; import org.apache.muse.core.proxy.ProxyHandler; import org.apache.muse.core.proxy.ReflectionProxyHandler; import org.apache.muse.core.serializer.SerializerRegistry; +import org.apache.muse.util.xml.XmlUtils; import org.apache.muse.ws.addressing.EndpointReference; import org.apache.muse.ws.addressing.soap.SoapFault; import org.apache.muse.ws.resource.remote.WsResourceClient; @@ -366,27 +367,75 @@ public class WsDmAdapterTest extends TestCase { } } + + /** + * Tests the WS-RP PutResourcePropertyDocument interface of the WS-DM adapter. + * + *
precondition : a ws resource exists and is registered. + *
postcondition : A read / write property is correctly set according to WSRP interface. + */ + public void testGetAndPutResourcePropertyDocumentOK() throws Exception + { + String expectedMgmtPubIntervalValue = "4321"; + String propertyName = "MgmtPubInterval"; + + Element propertiesDocument = _resourceClient.getResourcePropertyDocument(); + Element [] properties = XmlUtils.getAllElements(propertiesDocument); + + for (Element element : properties) + { + if (propertyName.equals(element.getLocalName())) { + element.setTextContent(expectedMgmtPubIntervalValue); + } else { + propertiesDocument.removeChild(element); + } + } + + _resourceClient.putResourcePropertyDocument(propertiesDocument); + + Element newProperties = _resourceClient.getResourcePropertyDocument(); + + Element mgmtPubInterval = XmlUtils.getElement( + newProperties, new QName( + Names.NAMESPACE_URI, + propertyName, + Names.PREFIX)); + + assertEquals(expectedMgmtPubIntervalValue,mgmtPubInterval.getTextContent()); + } -// public void testGetAndPutResourcePropertyDocumentOK() throws Exception -// { -// Element properties = _resourceClient.getResourcePropertyDocument(); -// -// Element mgmtPubInterval = XmlUtils.getElement(properties, new QName(Names.NAMESPACE_URI,"MgmtPubInterval",Names.PREFIX)); -// mgmtPubInterval.setTextContent(String.valueOf(Long.MAX_VALUE)); -// -// Element durable = XmlUtils.getElement(properties, new QName(Names.NAMESPACE_URI,"Durable",Names.PREFIX)); -// durable.setTextContent(String.valueOf(Boolean.FALSE)); -// -// Element consumerCount = XmlUtils.getElement(properties, new QName(Names.NAMESPACE_URI,"ConsumerCount",Names.PREFIX)); -// consumerCount.setTextContent(String.valueOf(13)); -// -// fail("PutResourcePropertyDocument not yet implemented!"); -//// _resourceClient.putResourcePropertyDocument(properties); -//// -//// Element newProperties = _resourceClient.getResourcePropertyDocument(); -//// -//// assertEquals(properties,newProperties); -// } + /** + * Tests the WS-RP PutResourcePropertyDocument interface of the WS-DM adapter. + * Specifically it tries to update the value of a read-only property. + * + *
precondition : a ws resource exists, it is registered and has at least one read-only property. + *
postcondition : An exception is thrown indicating the failure. + */ + public void testGetAndPutResourcePropertyDocumentKO_WithReadOnlyProperty() throws Exception + { + String propertyName = "Name"; + + Element propertiesDocument = _resourceClient.getResourcePropertyDocument(); + Element [] properties = XmlUtils.getAllElements(propertiesDocument); + + for (Element element : properties) + { + if (propertyName.equals(element.getLocalName())) { + element.setTextContent("ThisIsTheNewValueOfNameProperty"); + } else { + propertiesDocument.removeChild(element); + } + } + + try + { + _resourceClient.putResourcePropertyDocument(propertiesDocument); + fail("It's not possible to update the value of a read-only property."); + } catch (SoapFault expected) + { + + } + } /** * Test the WS-RP GetResourceProperties interface of the WS-DM adapter. -- cgit v1.2.1