diff options
| author | Andrea Gazzarini <agazzarini@apache.org> | 2009-02-16 10:40:39 +0000 |
|---|---|---|
| committer | Andrea Gazzarini <agazzarini@apache.org> | 2009-02-16 10:40:39 +0000 |
| commit | c31de6ea2d65a3e8cb8002de2b6e608de972e0ea (patch) | |
| tree | 175822edbe199dd2019db6b73b0940a498f1a3c9 /java/management/client/src/test | |
| parent | e7c2b273e54d8aa73fc949d53341e4c397830f7d (diff) | |
| download | qpid-python-c31de6ea2d65a3e8cb8002de2b6e608de972e0ea.tar.gz | |
QPID-1604 : Implementation of wrsf-rp:PutResourcePropertyDocument interface
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@744885 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/management/client/src/test')
| -rw-r--r-- | java/management/client/src/test/java/org/apache/qpid/management/wsdm/WsDmAdapterTest.java | 89 |
1 files changed, 69 insertions, 20 deletions
diff --git a/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WsDmAdapterTest.java b/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WsDmAdapterTest.java index a181a8652f..5012ff95cd 100644 --- a/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WsDmAdapterTest.java +++ b/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.
+ *
+ * <br>precondition : a ws resource exists and is registered.
+ * <br>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.
+ *
+ * <br>precondition : a ws resource exists, it is registered and has at least one read-only property.
+ * <br>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.
|
