You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrf-dev@ws.apache.org by ip...@apache.org on 2004/12/14 00:23:38 UTC

svn commit: r111761 - /incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTestCase.java

Author: ips
Date: Mon Dec 13 15:23:29 2004
New Revision: 111761

URL: http://svn.apache.org/viewcvs?view=rev&rev=111761
Log:
updated Delete tests

Modified:
   incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTestCase.java

Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTestCase.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTestCase.java?view=diff&rev=111761&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTestCase.java&r1=111760&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTestCase.java&r2=111761
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTestCase.java	(original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTestCase.java	Mon Dec 13 15:23:29 2004
@@ -24,6 +24,7 @@
 import org.apache.ws.resource.properties.SushiResource;
 import org.apache.ws.resource.properties.SushiResourceContext;
 import org.apache.ws.resource.properties.faults.InvalidResourcePropertyQNameFaultException;
+import org.apache.ws.resource.properties.faults.InvalidSetResourcePropertiesRequestContentFaultException;
 import org.apache.ws.util.XmlBeanUtils;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
@@ -35,6 +36,7 @@
 import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.UpdateDocument;
 import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.UpdateType;
 
+import javax.xml.namespace.QName;
 import java.io.IOException;
 
 /**
@@ -123,22 +125,41 @@
 
     /* ===================================== TESTS FOR 'DELETE' ====================================== */
 
-    public void testDeleteResourceProperty()
-            throws XmlException
+    public void testDeleteExistingOptionalProp()
+            throws Exception
     {
         m_resourceContext = new SushiResourceContext();
-        SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( m_resourceContext );
-        DeleteDocument deleteDoc = DeleteDocument.Factory.newInstance();
-        DeleteType deleteType = deleteDoc.addNewDelete();
-        deleteType.setResourceProperty( SushiPropertyQNames.OHTORO );
-        set_provider.deleteResourceProperty( deleteType );
-        GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty( SushiPropertyQNames.OHTORO );
-        assertNotNull( getResourcePropertyResponse );
+        deleteResourceProperty( SushiPropertyQNames.OHTORO );
+        GetResourcePropertyResponseDocument.GetResourcePropertyResponse response = getResourceProperty( SushiPropertyQNames.OHTORO );
+        XmlObject[] ohtoroPropElems = XmlBeanUtils.getChildElements( response, SushiPropertyQNames.OHTORO );
+        assertNotNull( ohtoroPropElems );
+        assertEquals( 0, ohtoroPropElems.length );
+    }
+
+    public void testDeleteNonExistingOptionalProp()
+            throws Exception
+    {
+        m_resourceContext = new SushiResourceContext();
+        deleteResourceProperty( SushiPropertyQNames.UNI );
+    }
+
+    public void testDeleteExistingNonOptionalProp()
+            throws Exception
+    {
+        m_resourceContext = new SushiResourceContext();
+        try
+        {
+            deleteResourceProperty( SushiPropertyQNames.EBI );
+            fail();
+        }
+        catch ( InvalidSetResourcePropertiesRequestContentFaultException expectedFault )
+        {
+            return;
+        }
     }
 
     public void testDeleteOpenContent() throws IOException, XmlException
     {
-        //initResourcePropsDoc();
         m_resourceContext = new SushiResourceContext( true );
         SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( m_resourceContext );
         DeleteDocument deleteDoc = DeleteDocument.Factory.newInstance();
@@ -234,7 +255,7 @@
     public void testUpdateResourceProperty()
             throws XmlException
     {
-        String newValue = "99";
+        final String newValue = "99";
         m_resourceContext = new SushiResourceContext();
         SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( m_resourceContext );
         UpdateDocument updateDoc = UpdateDocument.Factory.newInstance();
@@ -248,6 +269,15 @@
         set_provider.updateResourceProperty( updateDoc.getUpdate() );
 
         assertPropHasOneElemWithGivenValue( SushiPropertyQNames.EBI, newValue );
+    }
+
+    private void deleteResourceProperty( QName propName )
+    {
+        SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( m_resourceContext );
+        DeleteDocument deleteDoc = DeleteDocument.Factory.newInstance();
+        DeleteType deleteType = deleteDoc.addNewDelete();
+        deleteType.setResourceProperty( propName );
+        set_provider.deleteResourceProperty( deleteType );
     }
 
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: apollo-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: apollo-dev-help@ws.apache.org