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 2005/03/05 00:11:03 UTC

svn commit: r156208 [2/2] - in incubator/apollo/trunk/src: java/org/apache/ws/resource/faults/ java/org/apache/ws/resource/i18n/ java/org/apache/ws/resource/lifetime/v1_2_draft01/porttype/impl/ java/org/apache/ws/resource/lifetime/v1_2_draft04/porttype/impl/ java/org/apache/ws/resource/properties/faults/ java/org/apache/ws/resource/properties/impl/ java/org/apache/ws/resource/properties/v1_2_draft01/impl/ java/org/apache/ws/resource/properties/v1_2_draft01/porttype/impl/ java/org/apache/ws/resource/properties/v1_2_draft05/impl/ java/org/apache/ws/resource/properties/v1_2_draft05/porttype/impl/ test/org/apache/ws/resource/properties/v1_2_draft01/porttype/impl/

Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v1_2_draft01/porttype/impl/AbstractWsrpPortTypeImplTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v1_2_draft01/porttype/impl/AbstractWsrpPortTypeImplTestCase.java?view=diff&r1=156207&r2=156208
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v1_2_draft01/porttype/impl/AbstractWsrpPortTypeImplTestCase.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v1_2_draft01/porttype/impl/AbstractWsrpPortTypeImplTestCase.java Fri Mar  4 15:10:51 2005
@@ -22,8 +22,10 @@
 import org.apache.xmlbeans.XmlOptions;
 import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyDocument;
 import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyResponseDocument;
-import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.InsertDocument;
 import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.InsertType;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.SetResourcePropertiesDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.UpdateType;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.DeleteType;
 
 import javax.xml.namespace.QName;
 
@@ -51,12 +53,8 @@
     protected void insertXsdAnyPropElem()
             throws XmlException
     {
-        SetResourcePropertiesPortTypeImpl set_provider = new SetResourcePropertiesPortTypeImpl( m_resourceContext );
-        InsertDocument insertDoc = InsertDocument.Factory.newInstance();
-        InsertType insertType = insertDoc.addNewInsert();
         XmlObject anyXBean = createXsdAnyPropElem();
-        XmlBeanUtils.addChildElement( insertType, anyXBean );
-        set_provider.insertResourceProperty( insertType );
+        insertResourceProperty( new XmlObject[] {anyXBean} );
     }
 
     protected void assertPropHasOneElemWithGivenValue( QName propName, String expectedValue )
@@ -79,6 +77,40 @@
         return getResourcePropertyResponse;
     }
 
+    protected void insertResourceProperty( XmlObject[] propElems )
+    {
+        SetResourcePropertiesPortTypeImpl setProvider = new SetResourcePropertiesPortTypeImpl( m_resourceContext );
+        SetResourcePropertiesDocument setDocument = SetResourcePropertiesDocument.Factory.newInstance();
+        SetResourcePropertiesDocument.SetResourceProperties setType = setDocument.addNewSetResourceProperties();
+        InsertType insertType = setType.addNewInsert();
+        for ( int i = 0; i < propElems.length; i++ )
+        {
+            XmlBeanUtils.addChildElement( insertType, propElems[i] );
+        }
+        setProvider.setResourceProperties( setDocument ).getSetResourcePropertiesResponse();
+    }
 
+    protected void updateResourceProperty( XmlObject[] propElems )
+    {
+        SetResourcePropertiesPortTypeImpl setProvider = new SetResourcePropertiesPortTypeImpl( m_resourceContext );
+        SetResourcePropertiesDocument setDocument = SetResourcePropertiesDocument.Factory.newInstance();
+        SetResourcePropertiesDocument.SetResourceProperties setType = setDocument.addNewSetResourceProperties();
+        UpdateType updateType = setType.addNewUpdate();
+        for ( int i = 0; i < propElems.length; i++ )
+        {
+            XmlBeanUtils.addChildElement( updateType, propElems[i] );
+        }
+        setProvider.setResourceProperties( setDocument ).getSetResourcePropertiesResponse();
+    }
+
+    protected void deleteResourceProperty( QName propName )
+    {
+        SetResourcePropertiesPortTypeImpl setProvider = new SetResourcePropertiesPortTypeImpl( m_resourceContext );
+        SetResourcePropertiesDocument setDocument = SetResourcePropertiesDocument.Factory.newInstance();
+        SetResourcePropertiesDocument.SetResourceProperties setType = setDocument.addNewSetResourceProperties();
+        DeleteType deleteType = setType.addNewDelete();
+        deleteType.setResourceProperty( propName );        
+        setProvider.setResourceProperties( setDocument ).getSetResourcePropertiesResponse();
+    }
 
 }

Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v1_2_draft01/porttype/impl/SetResourcePropertiesProviderTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v1_2_draft01/porttype/impl/SetResourcePropertiesProviderTestCase.java?view=diff&r1=156207&r2=156208
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v1_2_draft01/porttype/impl/SetResourcePropertiesProviderTestCase.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v1_2_draft01/porttype/impl/SetResourcePropertiesProviderTestCase.java Fri Mar  4 15:10:51 2005
@@ -28,15 +28,8 @@
 import org.apache.ws.util.XmlBeanUtils;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
-import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.DeleteDocument;
-import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.DeleteType;
 import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyResponseDocument;
-import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.InsertDocument;
-import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.InsertType;
-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;
 
 /**
@@ -54,29 +47,24 @@
     }
     /* ===================================== TESTS FOR 'INSERT' ====================================== */
 
-    public void testInsertResourcePropertiesCallback() throws XmlException, ResourceException, ResourceContextException
+    public void testInsertResourcePropertiesCallback() throws XmlException, ResourceException,
+            ResourceContextException
     {
         m_resourceContext = new SushiResourceContext();
-        //build callback obj
-        //setup callback on resource prop
         SushiResource resource = (SushiResource) m_resourceContext.getResource();
         ResourceProperty resourceProp = resource.getResourcePropertySet().get( SushiPropertyQNames.EBI );
         resourceProp.setCallback( m_callback );
 
-        SetResourcePropertiesPortTypeImpl set_provider = new SetResourcePropertiesPortTypeImpl( m_resourceContext );
-        InsertDocument insertDoc = InsertDocument.Factory.newInstance();
-        InsertType insertType = insertDoc.addNewInsert();
-
-        XmlObject xmlObject =
+        XmlObject xBean =
                 XmlObject.Factory.parse( "<foo:Ebi xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
                 + "0" + "</foo:Ebi>" );
-        XmlBeanUtils.addChildElement( insertType, xmlObject );
-
-        set_provider.insertResourceProperty( insertType );
-        GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty( SushiPropertyQNames.EBI );
+        insertResourceProperty( new XmlObject[]{xBean} );
+        GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(
+                SushiPropertyQNames.EBI );
 
         assertNotNull( getResourcePropertyResponse );
-        XmlObject[] childElements = XmlBeanUtils.getChildElements( getResourcePropertyResponse, SushiPropertyQNames.EBI );
+        XmlObject[] childElements = XmlBeanUtils.getChildElements( getResourcePropertyResponse,
+                SushiPropertyQNames.EBI );
         assertEquals( 2, childElements.length );
         assertTrue( m_callback.insertWasInvoked() );
     }
@@ -85,20 +73,15 @@
             throws XmlException
     {
         m_resourceContext = new SushiResourceContext();
-        SetResourcePropertiesPortTypeImpl set_provider = new SetResourcePropertiesPortTypeImpl( m_resourceContext );
-        InsertDocument insertDoc = InsertDocument.Factory.newInstance();
-        InsertType insertType = insertDoc.addNewInsert();
-
-        XmlObject xmlObject =
+        XmlObject xBean =
                 XmlObject.Factory.parse( "<foo:Ebi xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
                 + "0" + "</foo:Ebi>" );
-        XmlBeanUtils.addChildElement( insertType, xmlObject );
-
-        set_provider.insertResourceProperty( insertType );
-        GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty( SushiPropertyQNames.EBI );
-
+        insertResourceProperty( new XmlObject[]{xBean} );
+        GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(
+                SushiPropertyQNames.EBI );
         assertNotNull( getResourcePropertyResponse );
-        XmlObject[] childElements = XmlBeanUtils.getChildElements( getResourcePropertyResponse, SushiPropertyQNames.EBI );
+        XmlObject[] childElements = XmlBeanUtils.getChildElements( getResourcePropertyResponse,
+                SushiPropertyQNames.EBI );
         assertEquals( 2, childElements.length );
     }
 
@@ -119,7 +102,7 @@
         }
         catch ( InvalidResourcePropertyQNameFaultException expectedFault )
         {
-            return;
+            return; // success
         }
     }
 
@@ -130,7 +113,8 @@
     {
         m_resourceContext = new SushiResourceContext();
         deleteResourceProperty( SushiPropertyQNames.OHTORO );
-        GetResourcePropertyResponseDocument.GetResourcePropertyResponse response = getResourceProperty( SushiPropertyQNames.OHTORO );
+        GetResourcePropertyResponseDocument.GetResourcePropertyResponse response = getResourceProperty(
+                SushiPropertyQNames.OHTORO );
         XmlObject[] ohtoroPropElems = XmlBeanUtils.getChildElements( response, SushiPropertyQNames.OHTORO );
         assertNotNull( ohtoroPropElems );
         assertEquals( 0, ohtoroPropElems.length );
@@ -154,49 +138,34 @@
         }
         catch ( InvalidSetResourcePropertiesRequestContentFaultException expectedFault )
         {
-            return;
+            return; // success
         }
     }
 
     public void testDeleteOpenContent() throws IOException, XmlException
     {
         m_resourceContext = new SushiResourceContext( true );
-        SetResourcePropertiesPortTypeImpl set_provider = new SetResourcePropertiesPortTypeImpl( m_resourceContext );
-        DeleteDocument deleteDoc = DeleteDocument.Factory.newInstance();
-        DeleteType deleteType = deleteDoc.addNewDelete();
-        deleteType.setResourceProperty( SushiPropertyQNames.FUGU );
-        set_provider.deleteResourceProperty( deleteType );
-        GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty( SushiPropertyQNames.OHTORO );
+        deleteResourceProperty( SushiPropertyQNames.FUGU );
+        GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(
+                SushiPropertyQNames.OHTORO );
         //todo better way to validate
         assertNotNull( getResourcePropertyResponse );
     }
 
-    public void testDeleteResourcePropertiesCallback() throws ResourceException, ResourceContextException, XmlException
+    public void testDeleteResourcePropertiesCallback() throws ResourceException, ResourceContextException,
+            XmlException
     {
         m_resourceContext = new SushiResourceContext();
-        SetResourcePropertiesPortTypeImpl set_provider = new SetResourcePropertiesPortTypeImpl( m_resourceContext );
-        InsertDocument insertDoc = InsertDocument.Factory.newInstance();
-        InsertType insertType = insertDoc.addNewInsert();
-
-        XmlObject xmlObject =
+        XmlObject xBean =
                 XmlObject.Factory.parse( "<foo:Ika xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
                 + "my favorite!" + "</foo:Ika>" );
-        XmlBeanUtils.addChildElement( insertType, xmlObject );
-
-        set_provider.insertResourceProperty( insertType );
-
-        //setup callback on resource prop
+        insertResourceProperty( new XmlObject[]{xBean} );
         SushiResource resource = (SushiResource) m_resourceContext.getResource();
         ResourceProperty resourceProp = resource.getResourcePropertySet().get( SushiPropertyQNames.IKA );
         resourceProp.setCallback( m_callback );
-
-        DeleteDocument deleteDoc = DeleteDocument.Factory.newInstance();
-        DeleteType deleteType = deleteDoc.addNewDelete();
-        deleteType.setResourceProperty( SushiPropertyQNames.IKA );
-
-        set_provider.deleteResourceProperty( deleteType );
-        GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty( SushiPropertyQNames.OHTORO );
-
+        deleteResourceProperty( SushiPropertyQNames.IKA );
+        GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(
+                SushiPropertyQNames.OHTORO );
         assertNotNull( getResourcePropertyResponse );
         assertTrue( m_callback.deleteWasInvoked() );
     }
@@ -206,7 +175,8 @@
     /**
      * DOCUMENT_ME
      */
-    public void testUpdateResourcePropertiesCallback() throws ResourceException, ResourceContextException, XmlException
+    public void testUpdateResourcePropertiesCallback() throws ResourceException, ResourceContextException,
+            XmlException
     {
         String newValue = "99";
         m_resourceContext = new SushiResourceContext();
@@ -217,18 +187,10 @@
         SushiResource resource = (SushiResource) m_resourceContext.getResource();
         ResourceProperty resourceProp = resource.getResourcePropertySet().get( SushiPropertyQNames.EBI );
         resourceProp.setCallback( callback );
-
-        SetResourcePropertiesPortTypeImpl set_provider = new SetResourcePropertiesPortTypeImpl( m_resourceContext );
-        UpdateDocument updateDoc = UpdateDocument.Factory.newInstance();
-        UpdateType update = updateDoc.addNewUpdate();
-
-        XmlObject xmlObject =
+        XmlObject xBean =
                 XmlObject.Factory.parse( "<foo:Ebi xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
                 + newValue + "</foo:Ebi>" );
-        XmlBeanUtils.addChildElement( update, xmlObject );
-
-        set_provider.updateResourceProperty( updateDoc.getUpdate() );
-
+        updateResourceProperty( new XmlObject[]{xBean} );
         assertPropHasOneElemWithGivenValue( SushiPropertyQNames.EBI, newValue );
         assertTrue( callback.updateWasInvoked() );
     }
@@ -238,14 +200,10 @@
         m_resourceContext = new SushiResourceContext( true );
         insertXsdAnyPropElem();
         assertPropHasOneElemWithGivenValue( SushiPropertyQNames.FUGU, INITIAL_PROP_VALUE_FUGU );
-        SetResourcePropertiesPortTypeImpl set_provider = new SetResourcePropertiesPortTypeImpl( m_resourceContext );
-        UpdateDocument updateDoc = UpdateDocument.Factory.newInstance();
-        UpdateType update = updateDoc.addNewUpdate();
         XmlObject anyXBean = createXsdAnyPropElem();
         final String newValue = "yummy!";
         XmlBeanUtils.setValue( anyXBean, newValue );
-        XmlBeanUtils.addChildElement( update, anyXBean );
-        set_provider.updateResourceProperty( updateDoc.getUpdate() );
+        updateResourceProperty( new XmlObject[]{anyXBean} );
         assertPropHasOneElemWithGivenValue( SushiPropertyQNames.FUGU, newValue );
     }
 
@@ -257,27 +215,11 @@
     {
         final String newValue = "99";
         m_resourceContext = new SushiResourceContext();
-        SetResourcePropertiesPortTypeImpl set_provider = new SetResourcePropertiesPortTypeImpl( m_resourceContext );
-        UpdateDocument updateDoc = UpdateDocument.Factory.newInstance();
-        UpdateType update = updateDoc.addNewUpdate();
-
-        XmlObject xmlObject =
+        XmlObject xBean =
                 XmlObject.Factory.parse( "<foo:Ebi xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
                 + newValue + "</foo:Ebi>" );
-        XmlBeanUtils.addChildElement( update, xmlObject );
-
-        set_provider.updateResourceProperty( updateDoc.getUpdate() );
-
+        updateResourceProperty( new XmlObject[]{xBean} );
         assertPropHasOneElemWithGivenValue( SushiPropertyQNames.EBI, newValue );
-    }
-
-    private void deleteResourceProperty( QName propName )
-    {
-        SetResourcePropertiesPortTypeImpl set_provider = new SetResourcePropertiesPortTypeImpl( 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