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 sc...@apache.org on 2004/12/09 20:24:52 UTC
svn commit: r111416 - incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl
Author: scamp
Date: Thu Dec 9 11:24:49 2004
New Revision: 111416
URL: http://svn.apache.org/viewcvs?view=rev&rev=111416
Log:
renamed
Added:
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetResourcePropertyProviderTestCase.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/QueryResourcePropertiesProviderTestCase.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTestCase.java
Removed:
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetMultipleResourcePropertiesProviderTest.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetResourcePropertyProviderTest.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/QueryResourcePropertiesProviderTest.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTest.java
Deleted: /incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetMultipleResourcePropertiesProviderTest.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetMultipleResourcePropertiesProviderTest.java?view=auto&rev=111415
==============================================================================
Added: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java?view=auto&rev=111416
==============================================================================
--- (empty file)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java Thu Dec 9 11:24:49 2004
@@ -0,0 +1,120 @@
+/*=============================================================================*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.porttype.impl;
+
+import org.apache.ws.resource.ResourceContextException;
+import org.apache.ws.resource.ResourceException;
+import org.apache.ws.resource.properties.AbstractResourcePropertiesTestCase;
+import org.apache.ws.resource.properties.ResourceProperty;
+import org.apache.ws.resource.properties.SushiCallback;
+import org.apache.ws.resource.properties.SushiPlate;
+import org.apache.ws.resource.properties.SushiPropertyQNames;
+import org.apache.ws.resource.properties.SushiResource;
+import org.apache.ws.resource.properties.SushiResourceContext;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlObject;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetMultipleResourcePropertiesDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetMultipleResourcePropertiesResponseDocument;
+
+/**
+ * @author Sal Campana
+ */
+public class GetMultipleResourcePropertiesProviderTestCase
+ extends AbstractResourcePropertiesTestCase
+{
+ /**
+ * DOCUMENT_ME
+ */
+ public void testGetMultipleResourceProperties( )
+ {
+ SushiResourceContext context =
+ new SushiResourceContext( );
+ GetMultipleResourcePropertiesProvider provider =
+ new GetMultipleResourcePropertiesProvider( context );
+ GetMultipleResourcePropertiesDocument doc =
+ GetMultipleResourcePropertiesDocument.Factory.newInstance( );
+ GetMultipleResourcePropertiesDocument.GetMultipleResourceProperties getMultipleResourceProperties =
+ doc.addNewGetMultipleResourceProperties( );
+ getMultipleResourceProperties.addResourceProperty( SushiPropertyQNames.EBI );
+ getMultipleResourceProperties.addResourceProperty( SushiPropertyQNames.HAMACHI );
+
+ GetMultipleResourcePropertiesResponseDocument resourceProperties =
+ provider.getMultipleResourceProperties( doc );
+ GetMultipleResourcePropertiesResponseDocument.GetMultipleResourcePropertiesResponse getResourcePropertyResponse =
+ resourceProperties.getGetMultipleResourcePropertiesResponse( );
+ XmlObject[] childElements =
+ XmlBeanUtils.getChildElements( getResourcePropertyResponse, null );
+ assertNotNull( childElements );
+ assertTrue( childElements.length == 2 );
+ String value = XmlBeanUtils.getValue( childElements[0] );
+ assertEquals( "ohlala",value );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ protected void setUp( )
+ throws Exception
+ {
+ initResourcePropsDoc( );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws ResourceException DOCUMENT_ME
+ * @throws ResourceContextException DOCUMENT_ME
+ */
+ public void testGetMultipleResourcePropertiesCallback( )
+ throws ResourceException,
+ ResourceContextException
+ {
+ //build custom "test" context
+ SushiResourceContext context = new SushiResourceContext( );
+
+ //build callback obj
+ SushiPlate plate = new SushiPlate( );
+ SushiCallback callback = new SushiCallback( plate );
+
+ //setup callback on resource prop
+ SushiResource resource = (SushiResource) context.getResource( );
+ ResourceProperty resourceProp = resource.getResourcePropertySet( ).get( SushiPropertyQNames.EBI );
+ resourceProp.setCallback( callback );
+
+ //build provider and invoke
+ GetMultipleResourcePropertiesProvider provider = new GetMultipleResourcePropertiesProvider( context );
+ GetMultipleResourcePropertiesDocument doc = GetMultipleResourcePropertiesDocument.Factory.newInstance( );
+ GetMultipleResourcePropertiesDocument.GetMultipleResourceProperties getMultipleResourceProperties = doc.addNewGetMultipleResourceProperties();
+ getMultipleResourceProperties.addResourceProperty(SushiPropertyQNames.EBI);
+ getMultipleResourceProperties.addResourceProperty(SushiPropertyQNames.HAMACHI);
+
+ GetMultipleResourcePropertiesResponseDocument resourceProperty = provider.getMultipleResourceProperties( doc );
+
+ //retrieve the response value
+ GetMultipleResourcePropertiesResponseDocument.GetMultipleResourcePropertiesResponse getResourcePropertyResponse =
+ resourceProperty.getGetMultipleResourcePropertiesResponse( );
+ XmlObject[] childElements =
+ XmlBeanUtils.getChildElements( getResourcePropertyResponse, null );
+
+ //assert the values
+ assertNotNull( childElements );
+ String value = XmlBeanUtils.getValue( childElements[0] );
+ assertEquals( "10", value );
+ }
+
+}
\ No newline at end of file
Deleted: /incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetResourcePropertyProviderTest.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetResourcePropertyProviderTest.java?view=auto&rev=111415
==============================================================================
Added: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetResourcePropertyProviderTestCase.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetResourcePropertyProviderTestCase.java?view=auto&rev=111416
==============================================================================
--- (empty file)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetResourcePropertyProviderTestCase.java Thu Dec 9 11:24:49 2004
@@ -0,0 +1,109 @@
+/*=============================================================================*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.porttype.impl;
+
+import org.apache.ws.resource.ResourceContextException;
+import org.apache.ws.resource.ResourceException;
+import org.apache.ws.resource.properties.AbstractResourcePropertiesTestCase;
+import org.apache.ws.resource.properties.ResourceProperty;
+import org.apache.ws.resource.properties.SushiCallback;
+import org.apache.ws.resource.properties.SushiPlate;
+import org.apache.ws.resource.properties.SushiPropertyQNames;
+import org.apache.ws.resource.properties.SushiResource;
+import org.apache.ws.resource.properties.SushiResourceContext;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlObject;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyResponseDocument;
+
+/**
+ * @author Sal Campana
+ */
+public class GetResourcePropertyProviderTestCase
+ extends AbstractResourcePropertiesTestCase
+{
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testGetResourceProperty( )
+ {
+ SushiResourceContext context = new SushiResourceContext( );
+ GetResourcePropertyProvider provider = new GetResourcePropertyProvider( context );
+ GetResourcePropertyDocument doc = GetResourcePropertyDocument.Factory.newInstance( );
+ doc.setGetResourceProperty( SushiPropertyQNames.EBI );
+ GetResourcePropertyResponseDocument resourceProperty =
+ provider.getResourceProperty( doc );
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse =
+ resourceProperty.getGetResourcePropertyResponse( );
+ XmlObject[] childElements =
+ XmlBeanUtils.getChildElements( getResourcePropertyResponse, SushiPropertyQNames.EBI );
+ assertNotNull( childElements );
+ String value = XmlBeanUtils.getValue( childElements[0] );
+ assertEquals( value, "ohlala" );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws ResourceException DOCUMENT_ME
+ * @throws ResourceContextException DOCUMENT_ME
+ */
+ public void testGetResourcePropertyCallback( )
+ throws ResourceException,
+ ResourceContextException
+ {
+ //build custom "test" context
+ SushiResourceContext context = new SushiResourceContext( );
+
+ //build callback obj
+ SushiPlate plate = new SushiPlate( );
+ SushiCallback callback = new SushiCallback( plate );
+
+ //setup callback on resource prop
+ SushiResource resource = (SushiResource) context.getResource( );
+ ResourceProperty resourceProp = resource.getResourcePropertySet( ).get( SushiPropertyQNames.EBI );
+ resourceProp.setCallback( callback );
+
+ //build provider and invoke
+ GetResourcePropertyProvider provider = new GetResourcePropertyProvider( context );
+ GetResourcePropertyDocument doc = GetResourcePropertyDocument.Factory.newInstance( );
+ doc.setGetResourceProperty( SushiPropertyQNames.EBI );
+ GetResourcePropertyResponseDocument resourceProperty = provider.getResourceProperty( doc );
+
+ //retrieve the response value
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse =
+ resourceProperty.getGetResourcePropertyResponse( );
+ XmlObject[] childElements =
+ XmlBeanUtils.getChildElements( getResourcePropertyResponse, SushiPropertyQNames.EBI );
+
+ //assert the values
+ assertNotNull( childElements );
+ String value = XmlBeanUtils.getValue( childElements[0] );
+ assertEquals( "10", value );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ protected void setUp( )
+ throws Exception
+ {
+ initResourcePropsDoc( );
+ }
+}
\ No newline at end of file
Added: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java?view=auto&rev=111416
==============================================================================
--- (empty file)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java Thu Dec 9 11:24:49 2004
@@ -0,0 +1,53 @@
+package org.apache.ws.resource.properties.porttype.impl;
+
+import org.apache.ws.resource.properties.SushiResourceContext;
+import org.apache.ws.resource.properties.AbstractResourcePropertiesTestCase;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlObject;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyResponseDocument;
+
+import javax.xml.namespace.QName;
+
+
+/**
+ * @author Sal Campana
+ */
+public class OpenContentHandlingTestCase extends AbstractResourcePropertiesTestCase
+{
+ public void testInsertAnyIntoOpenContent()
+ {
+
+ }
+
+ public void testInsertAnyIntoNonOpenContent()
+ {
+
+ }
+
+ public void testQueryOpenContent()
+ {
+
+ }
+
+ public void testUpdateOpenContent()
+ {
+
+ }
+
+ public void testDeleteOpenContent()
+ {
+
+ }
+
+ private void verifyViaGet(SushiResourceContext context,
+ String expectedVariable,
+ QName nameToFind)
+ {
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(context, nameToFind);
+ XmlObject[] childElements =
+ XmlBeanUtils.getChildElements(getResourcePropertyResponse, nameToFind);
+ assertNotNull(childElements);
+ String value = XmlBeanUtils.getValue(childElements[0]);
+ assertEquals(expectedVariable,value );
+ }
+}
Deleted: /incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/QueryResourcePropertiesProviderTest.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/QueryResourcePropertiesProviderTest.java?view=auto&rev=111415
==============================================================================
Added: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/QueryResourcePropertiesProviderTestCase.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/QueryResourcePropertiesProviderTestCase.java?view=auto&rev=111416
==============================================================================
--- (empty file)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/QueryResourcePropertiesProviderTestCase.java Thu Dec 9 11:24:49 2004
@@ -0,0 +1,128 @@
+/*=============================================================================*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.porttype.impl;
+
+import org.apache.ws.resource.ResourceContextException;
+import org.apache.ws.resource.ResourceException;
+import org.apache.ws.resource.properties.AbstractResourcePropertiesTestCase;
+import org.apache.ws.resource.properties.ResourceProperty;
+import org.apache.ws.resource.properties.SushiCallback;
+import org.apache.ws.resource.properties.SushiPlate;
+import org.apache.ws.resource.properties.SushiPropertyQNames;
+import org.apache.ws.resource.properties.SushiResource;
+import org.apache.ws.resource.properties.SushiResourceContext;
+import org.apache.ws.resource.properties.query.QueryConstants;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlObject;
+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.QueryExpressionType;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.QueryResourcePropertiesDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.QueryResourcePropertiesResponseDocument;
+
+/**
+ * @author Sal Campana
+ */
+public class QueryResourcePropertiesProviderTestCase
+ extends AbstractResourcePropertiesTestCase
+{
+ /**
+ * DOCUMENT_ME
+ */
+ public void testQueryResourceProperties( )
+ {
+ SushiResourceContext context =
+ new SushiResourceContext( );
+
+ QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse queryResourcePropertiesResponse =
+ queryAll( context );
+
+ XmlObject[] childElements =
+ XmlBeanUtils.getChildElements( queryResourcePropertiesResponse, null );
+ assertNotNull( childElements );
+ assertTrue( childElements.length == 8 );
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testQueryResourcePropertiesCallback( )
+ throws ResourceException,
+ ResourceContextException
+ {
+ //build custom "test" context
+ SushiResourceContext context = new SushiResourceContext( );
+
+ //build callback obj
+ SushiPlate plate = new SushiPlate( );
+ SushiCallback callback = new SushiCallback( plate );
+
+ //check whats there
+ QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse queryResourcePropertiesResponse =
+ queryAll( context );
+ XmlObject[] childElements =
+ XmlBeanUtils.getChildElements( queryResourcePropertiesResponse, SushiPropertyQNames.EBI );
+ String value =
+ XmlBeanUtils.getValue( childElements[0] );
+ assertEquals( "ohlala", value );
+
+ //setup callback to modify resource prop
+ SushiResource resource = (SushiResource) context.getResource( );
+ ResourceProperty resourceProp = resource.getResourcePropertySet( ).get( SushiPropertyQNames.EBI );
+ resourceProp.setCallback( callback );
+
+ queryResourcePropertiesResponse = queryAll( context );
+
+ childElements = XmlBeanUtils.getChildElements( queryResourcePropertiesResponse, SushiPropertyQNames.EBI );
+ assertNotNull( childElements );
+ value = XmlBeanUtils.getValue( childElements[0] );
+ assertEquals( "10", value );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ protected void setUp( )
+ throws Exception
+ {
+ initResourcePropsDoc( );
+ }
+
+ private QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse queryAll( SushiResourceContext context )
+ {
+ //build provider and invoke
+ QueryResourcePropertiesProvider provider =
+ new QueryResourcePropertiesProvider( context );
+ QueryResourcePropertiesDocument doc =
+ QueryResourcePropertiesDocument.Factory.newInstance( );
+
+ QueryResourcePropertiesDocument.QueryResourceProperties queryResourceProperties =
+ doc.addNewQueryResourceProperties( );
+ QueryExpressionType queryExpressionType =
+ queryResourceProperties.addNewQueryExpression( );
+ queryExpressionType.setDialect( QueryConstants.DIALECT_URI__XPATH1_0.toString( ) );
+
+ //XmlBeanUtils.addChildElement(queryExpressionType, );
+ XmlBeanUtils.setValue( queryExpressionType, "*" );
+ QueryResourcePropertiesResponseDocument queryResourcePropertiesResponseDocument =
+ provider.queryResourceProperties( doc );
+ QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse queryResourcePropertiesResponse =
+ queryResourcePropertiesResponseDocument.getQueryResourcePropertiesResponse( );
+ return queryResourcePropertiesResponse;
+ }
+}
\ No newline at end of file
Deleted: /incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTest.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTest.java?view=auto&rev=111415
==============================================================================
Added: 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=auto&rev=111416
==============================================================================
--- (empty file)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTestCase.java Thu Dec 9 11:24:49 2004
@@ -0,0 +1,233 @@
+/*=============================================================================*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.porttype.impl;
+
+import org.apache.ws.resource.ResourceContextException;
+import org.apache.ws.resource.ResourceException;
+import org.apache.ws.resource.properties.AbstractResourcePropertiesTestCase;
+import org.apache.ws.resource.properties.ResourceProperty;
+import org.apache.ws.resource.properties.SushiCallback;
+import org.apache.ws.resource.properties.SushiPlate;
+import org.apache.ws.resource.properties.SushiPropertyQNames;
+import org.apache.ws.resource.properties.SushiResource;
+import org.apache.ws.resource.properties.SushiResourceContext;
+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.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.UpdateDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.UpdateType;
+
+import javax.xml.namespace.QName;
+
+/**
+ * @author Sal Campana
+ */
+public class SetResourcePropertiesProviderTestCase
+ extends AbstractResourcePropertiesTestCase
+{
+ /**
+ * DOCUMENT_ME
+ */
+ public void testUpdateResourcePropertiesCallback() throws ResourceException, ResourceContextException, XmlException
+ {
+ String expectedValue = "thisisatest";
+ SushiResourceContext context = new SushiResourceContext();
+ SushiPlate plate = new SushiPlate();
+ SushiCallback callback = new SushiCallback(plate);
+
+ //setup callback on resource prop
+ SushiResource resource = (SushiResource) context.getResource();
+ ResourceProperty resourceProp = resource.getResourcePropertySet().get(SushiPropertyQNames.EBI);
+ resourceProp.setCallback(callback);
+
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider(context);
+ UpdateDocument updateDoc = UpdateDocument.Factory.newInstance();
+ UpdateType update = updateDoc.addNewUpdate();
+
+ XmlObject xmlObject =
+ XmlObject.Factory.parse("<foo:Ebi xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
+ + expectedValue + "</foo:Ebi>");
+ XmlBeanUtils.addChildElement(update, xmlObject);
+
+ set_provider.updateResourceProperty(updateDoc.getUpdate());
+
+ verifyViaGet(context, expectedValue, SushiPropertyQNames.EBI);
+ assertTrue(callback.isUpdateInvoked());
+ }
+
+ public void testInsertResourcePropertiesCallback() throws XmlException, ResourceException, ResourceContextException
+ {
+ SushiResourceContext context = new SushiResourceContext();
+ //build callback obj
+ SushiPlate plate = new SushiPlate();
+ SushiCallback callback = new SushiCallback(plate);
+ //setup callback on resource prop
+ SushiResource resource = (SushiResource) context.getResource();
+ ResourceProperty resourceProp = resource.getResourcePropertySet().get(SushiPropertyQNames.EBI);
+ resourceProp.setCallback(callback);
+
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider(context);
+ InsertDocument insertDoc = InsertDocument.Factory.newInstance();
+ InsertType insertType = insertDoc.addNewInsert();
+
+ XmlObject xmlObject =
+ XmlObject.Factory.parse("<foo:Ebi xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
+ + "my favorite!" + "</foo:Ebi>");
+ XmlBeanUtils.addChildElement(insertType, xmlObject);
+
+ set_provider.insertResourceProperty(insertType);
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(context, SushiPropertyQNames.EBI);
+
+ assertNotNull(getResourcePropertyResponse);
+ XmlObject[] childElements = XmlBeanUtils.getChildElements(getResourcePropertyResponse, SushiPropertyQNames.EBI);
+ assertTrue(childElements.length == 2);
+ assertTrue(callback.isInsertInvoked());
+ }
+
+ public void testDeleteResourcePropertiesCallback() throws ResourceException, ResourceContextException, XmlException
+ {
+ SushiResourceContext context = new SushiResourceContext();
+ //build callback obj
+ SushiPlate plate = new SushiPlate();
+ SushiCallback callback = new SushiCallback(plate);
+
+ //insert a prop
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider(context);
+ InsertDocument insertDoc = InsertDocument.Factory.newInstance();
+ InsertType insertType = insertDoc.addNewInsert();
+
+ XmlObject xmlObject =
+ 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
+ SushiResource resource = (SushiResource) context.getResource();
+ ResourceProperty resourceProp = resource.getResourcePropertySet().get(SushiPropertyQNames.IKA);
+ resourceProp.setCallback(callback);
+
+ DeleteDocument deleteDoc = DeleteDocument.Factory.newInstance();
+ DeleteType deleteType = deleteDoc.addNewDelete();
+ deleteType.setResourceProperty(SushiPropertyQNames.IKA);
+
+ set_provider.deleteResourceProperty(deleteType);
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(context, SushiPropertyQNames.OHTORO);
+
+ assertNotNull(getResourcePropertyResponse);
+ assertTrue(callback.isDeleteInvoked());
+ }
+
+ public void testInsertResourceProperty()
+ throws XmlException
+ {
+ SushiResourceContext context = new SushiResourceContext();
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider(context);
+ InsertDocument insertDoc = InsertDocument.Factory.newInstance();
+ InsertType insertType = insertDoc.addNewInsert();
+
+ XmlObject xmlObject =
+ XmlObject.Factory.parse("<foo:Ebi xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
+ + "my favorite!" + "</foo:Ebi>");
+ XmlBeanUtils.addChildElement(insertType, xmlObject);
+
+ set_provider.insertResourceProperty(insertType);
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(context, SushiPropertyQNames.EBI);
+
+ assertNotNull(getResourcePropertyResponse);
+ XmlObject[] childElements = XmlBeanUtils.getChildElements(getResourcePropertyResponse, SushiPropertyQNames.EBI);
+ assertTrue(childElements.length == 2);
+ }
+
+ public void testDeleteResourceProperty()
+ throws XmlException
+ {
+ SushiResourceContext context = new SushiResourceContext();
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider(context);
+ DeleteDocument deleteDoc = DeleteDocument.Factory.newInstance();
+ DeleteType deleteType = deleteDoc.addNewDelete();
+ deleteType.setResourceProperty(SushiPropertyQNames.OHTORO);
+
+ set_provider.deleteResourceProperty(deleteType);
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(context, SushiPropertyQNames.OHTORO);
+
+ assertNotNull(getResourcePropertyResponse);
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testUpdateResourceProperty()
+ throws XmlException
+ {
+ String expectedValue = "thisisatest";
+ SushiResourceContext context = new SushiResourceContext();
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider(context);
+ UpdateDocument updateDoc = UpdateDocument.Factory.newInstance();
+ UpdateType update = updateDoc.addNewUpdate();
+
+ XmlObject xmlObject =
+ XmlObject.Factory.parse("<foo:Ebi xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
+ + expectedValue + "</foo:Ebi>");
+ XmlBeanUtils.addChildElement(update, xmlObject);
+
+ set_provider.updateResourceProperty(updateDoc.getUpdate());
+
+ verifyViaGet(context, expectedValue, SushiPropertyQNames.EBI);
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ protected void setUp()
+ throws Exception
+ {
+ initResourcePropsDoc();
+ }
+
+ private void verifyViaGet(SushiResourceContext context,
+ String expectedVariable,
+ QName nameToFind)
+ {
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(context, nameToFind);
+ XmlObject[] childElements =
+ XmlBeanUtils.getChildElements(getResourcePropertyResponse, nameToFind);
+ assertNotNull(childElements);
+ String value = XmlBeanUtils.getValue(childElements[0]);
+ assertEquals(expectedVariable,value );
+ }
+
+ private GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourceProperty(SushiResourceContext context, QName nameToFind)
+ {
+ GetResourcePropertyProvider get_provider = new GetResourcePropertyProvider(context);
+ GetResourcePropertyDocument get_document = GetResourcePropertyDocument.Factory.newInstance();
+ get_document.setGetResourceProperty(nameToFind);
+ GetResourcePropertyResponseDocument resourceProperty =
+ get_provider.getResourceProperty(get_document);
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse =
+ resourceProperty.getGetResourcePropertyResponse();
+ return getResourcePropertyResponse;
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: apollo-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: apollo-dev-help@ws.apache.org