Author: ips
Date: Fri Mar 18 15:20:51 2005
New Revision: 158165
URL: http://svn.apache.org/viewcvs?view=rev&rev=158165
Log:
package name refactoring
Added:
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/AbstractWsrpPortTypeImplTestCase.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetResourcePropertyProviderTestCase.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/QueryResourcePropertiesProviderTestCase.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/SetResourcePropertiesProviderTestCase.java
Removed:
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v1_2_draft01/
Added:
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/AbstractWsrpPortTypeImplTestCase.java
URL:
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/AbstractWsrpPortTypeImplTestCase.java?view=auto&rev=158165
==============================================================================
---
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/AbstractWsrpPortTypeImplTestCase.java
(added)
+++
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/AbstractWsrpPortTypeImplTestCase.java
Fri Mar 18 15:20:51 2005
@@ -0,0 +1,116 @@
+/*=============================================================================*
+ * 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.v2004_06.porttype.impl;
+
+import org.apache.ws.resource.properties.AbstractResourcePropertiesTestCase;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+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.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;
+
+/**
+ * TODO
+ *
+ * @author Ian P. Springer (Hewlett-Packard Company)
+ */
+public class AbstractWsrpPortTypeImplTestCase extends
AbstractResourcePropertiesTestCase
+{
+
+ protected static final String INITIAL_PROP_VALUE_FUGU = "dangerous!";
+ protected static final QName BOGUS_PROP_NAME = new QName(
"http://blah.com/", "Bogus" );
+ protected static final QName ANOTHER_BOGUS_PROP_NAME = new QName(
"http://blah.com/", "EvenMoreBogus" );
+
+ protected XmlObject createXsdAnyPropElem()
+ throws XmlException
+ {
+ XmlOptions xOpts = new XmlOptions();
+ XmlObject xBean = XmlObject.Factory.parse( "<fu:Fugu
xmlns:fu=\"http://ws.apache.org/resource/properties/test/sushi/blowfish\">"
+ + INITIAL_PROP_VALUE_FUGU + "</fu:Fugu>", xOpts );
+ return xBean;
+ }
+
+ protected void insertXsdAnyPropElem()
+ throws XmlException
+ {
+ XmlObject anyXBean = createXsdAnyPropElem();
+ insertResourceProperty( new XmlObject[] {anyXBean} );
+ }
+
+ protected void assertPropHasOneElemWithGivenValue( QName propName, String
expectedValue )
+ {
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse
getResourcePropertyResponse = getResourceProperty( propName );
+ XmlObject[] propElems = XmlBeanUtils.getChildElements(
getResourcePropertyResponse, propName );
+ assertNotNull( propElems );
+ String value = XmlBeanUtils.getValue( propElems[0] );
+ assertEquals( expectedValue, value );
+ }
+
+ protected GetResourcePropertyResponseDocument.GetResourcePropertyResponse
getResourceProperty( QName propName )
+ {
+ GetResourcePropertyPortTypeImpl get_provider = new
GetResourcePropertyPortTypeImpl( m_resourceContext );
+ GetResourcePropertyDocument get_document =
GetResourcePropertyDocument.Factory.newInstance();
+ get_document.setGetResourceProperty( propName );
+ GetResourcePropertyResponseDocument resourceProperty =
get_provider.getResourceProperty( get_document );
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse
getResourcePropertyResponse =
+ resourceProperty.getGetResourcePropertyResponse();
+ 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();
+ }
+
+}
Added:
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java
URL:
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java?view=auto&rev=158165
==============================================================================
---
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java
(added)
+++
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java
Fri Mar 18 15:20:51 2005
@@ -0,0 +1,127 @@
+/*=============================================================================*
+ * 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.v2004_06.porttype.impl;
+
+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.faults.InvalidResourcePropertyQNameFaultException;
+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;
+
+import javax.xml.namespace.QName;
+
+/**
+ * @author Sal Campana, Ian Springer
+ */
+public class GetMultipleResourcePropertiesProviderTestCase
+ extends AbstractWsrpPortTypeImplTestCase
+{
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testGetMultiExistingProps()
+ {
+ m_resourceContext = new SushiResourceContext();
+ final QName[] propNames = new QName[]{SushiPropertyQNames.EBI,
SushiPropertyQNames.IKA};
+
GetMultipleResourcePropertiesResponseDocument.GetMultipleResourcePropertiesResponse
response = getMultipleResourceProperties( propNames );
+ XmlObject[] propElems = XmlBeanUtils.getChildElements( response, null
);
+ assertNotNull( propElems );
+ assertEquals( propNames.length, propElems.length );
+ assertEquals( propNames[0], XmlBeanUtils.getName( propElems[0] ) );
+ assertEquals( "9", XmlBeanUtils.getValue( propElems[0] ) );
+ assertEquals( propNames[1], XmlBeanUtils.getName( propElems[1] ) );
+ assertEquals( "mamamia", XmlBeanUtils.getValue( propElems[1] ) );
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testGetMultiWithAllInvalidPropNames()
+ {
+ m_resourceContext = new SushiResourceContext( true );
+ assertGetMultiRequestThrowsFault( new QName[]{BOGUS_PROP_NAME,
ANOTHER_BOGUS_PROP_NAME} );
+ m_resourceContext = new SushiResourceContext( false );
+ assertGetMultiRequestThrowsFault( new QName[]{BOGUS_PROP_NAME,
ANOTHER_BOGUS_PROP_NAME} );
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testGetMultiWithSomeInvalidPropNames()
+ {
+ m_resourceContext = new SushiResourceContext( true );
+ assertGetMultiRequestThrowsFault( new
QName[]{SushiPropertyQNames.OHTORO, BOGUS_PROP_NAME} );
+ m_resourceContext = new SushiResourceContext( false );
+ assertGetMultiRequestThrowsFault( new
QName[]{SushiPropertyQNames.OHTORO, BOGUS_PROP_NAME} );
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testGetMultipleResourcePropertiesCallback()
+ throws Exception
+ {
+ m_resourceContext = new SushiResourceContext();
+ SushiPlate plate = new SushiPlate();
+ SushiCallback callback = new SushiCallback( plate );
+ SushiResource resource = (SushiResource)
m_resourceContext.getResource();
+ ResourceProperty resourceProp = resource.getResourcePropertySet().get(
SushiPropertyQNames.EBI );
+ resourceProp.setCallback( callback );
+ final QName[] propNames = new QName[]{SushiPropertyQNames.EBI,
SushiPropertyQNames.IKA};
+
GetMultipleResourcePropertiesResponseDocument.GetMultipleResourcePropertiesResponse
response = getMultipleResourceProperties( propNames );
+ XmlObject[] propElems = XmlBeanUtils.getChildElements( response );
+ assertNotNull( propElems );
+ assertEquals( propNames[0], XmlBeanUtils.getName( propElems[0] ) );
+ assertEquals( plate.getEbi().getNumberOfPieces(),
XmlBeanUtils.getValue( propElems[0] ) );
+ }
+
+ private
GetMultipleResourcePropertiesResponseDocument.GetMultipleResourcePropertiesResponse
getMultipleResourceProperties( QName[] propNames )
+ {
+ GetMultipleResourcePropertiesPortTypeImpl provider = new
GetMultipleResourcePropertiesPortTypeImpl( m_resourceContext );
+ GetMultipleResourcePropertiesDocument doc =
GetMultipleResourcePropertiesDocument.Factory.newInstance();
+ GetMultipleResourcePropertiesDocument.GetMultipleResourceProperties
getMultipleResourceProperties = doc.addNewGetMultipleResourceProperties();
+ for ( int i = 0; i < propNames.length; i++ )
+ {
+ getMultipleResourceProperties.addResourceProperty( propNames[i] );
+ }
+ GetMultipleResourcePropertiesResponseDocument responseDoc =
provider.getMultipleResourceProperties( doc );
+
GetMultipleResourcePropertiesResponseDocument.GetMultipleResourcePropertiesResponse
response =
+ responseDoc.getGetMultipleResourcePropertiesResponse();
+ return response;
+ }
+
+ private void assertGetMultiRequestThrowsFault( QName[] propNames )
+ {
+
GetMultipleResourcePropertiesResponseDocument.GetMultipleResourcePropertiesResponse
response = null;
+ try
+ {
+ response = getMultipleResourceProperties( propNames );
+ fail( response != null ? "Expected fault, but received response."
: null );
+ }
+ catch ( InvalidResourcePropertyQNameFaultException expectedFault )
+ {
+ return;
+ }
+ }
+
+}
\ No newline at end of file
Added:
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetResourcePropertyProviderTestCase.java
URL:
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetResourcePropertyProviderTestCase.java?view=auto&rev=158165
==============================================================================
---
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetResourcePropertyProviderTestCase.java
(added)
+++
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetResourcePropertyProviderTestCase.java
Fri Mar 18 15:20:51 2005
@@ -0,0 +1,111 @@
+/*=============================================================================*
+ * 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.v2004_06.porttype.impl;
+
+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.faults.InvalidResourcePropertyQNameFaultException;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlObject;
+import
org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyResponseDocument;
+
+/**
+ * Test case for [EMAIL PROTECTED] GetResourcePropertyPortTypeImpl}, which
consists of only one
+ * operation: [EMAIL PROTECTED]
GetResourcePropertyPortTypeImpl#getResourceProperty(org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyDocument)}
+ *
+ * @author Sal Campana, Ian Springer
+ */
+public class GetResourcePropertyProviderTestCase
+ extends AbstractWsrpPortTypeImplTestCase
+{
+
+ /**
+ * Tests that a GetRP request for an existing prop returns a GetRPResponse
elem containing that prop.
+ */
+ public void testGetExistingProp()
+ {
+ m_resourceContext = new SushiResourceContext();
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse
response = getResourceProperty( SushiPropertyQNames.IKA );
+ XmlObject[] ebiPropElems = XmlBeanUtils.getChildElements( response,
SushiPropertyQNames.IKA );
+ assertNotNull( ebiPropElems );
+ assertEquals( 1, ebiPropElems.length );
+ assertEquals( "mamamia", XmlBeanUtils.getValue( ebiPropElems[0] ) );
+ }
+
+ /**
+ * Tests that a GetRP request for a non-existing optional prop returns an
empty GetRPResponse elem.
+ */
+ public void testGetNonexistingOptionalProp()
+ {
+ m_resourceContext = new SushiResourceContext();
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse
response = getResourceProperty( SushiPropertyQNames.UNI );
+ XmlObject[] uniPropElems = XmlBeanUtils.getChildElements( response,
SushiPropertyQNames.UNI );
+ assertNotNull( uniPropElems );
+ assertEquals( 0, uniPropElems.length );
+ }
+
+ /**
+ * Tests that a GetRP request for an invalid prop QName throws a fault
exception,
+ * wether or not the RP doc permits open content.
+ */
+ public void testGetInvalidProp()
+ {
+ m_resourceContext = new SushiResourceContext( true );
+ assertGetRequestForInvalidPropThrowsFault();
+ m_resourceContext = new SushiResourceContext( false );
+ assertGetRequestForInvalidPropThrowsFault();
+ }
+
+ /**
+ * Test that [EMAIL PROTECTED]
GetResourcePropertyPortTypeImpl#getResourceProperty(org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyDocument)}
+ * invokes a [EMAIL PROTECTED]
org.apache.ws.resource.properties.ResourcePropertyCallback} if one is
registered for the
+ * requested property.
+ */
+ public void testGetPropertyTriggersCallback() throws Exception
+ {
+ m_resourceContext = new SushiResourceContext();
+ // create and register callback object
+ SushiPlate plate = new SushiPlate();
+ SushiCallback callback = new SushiCallback( plate );
+ SushiResource resource = (SushiResource)
m_resourceContext.getResource();
+ ResourceProperty resourceProp = resource.getResourcePropertySet().get(
SushiPropertyQNames.EBI );
+ resourceProp.setCallback( callback );
+ // send GetRP request and make sure prop got updated by
callback.refreshProperty()
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse
response = getResourceProperty( SushiPropertyQNames.EBI );
+ XmlObject[] ebiPropElems = XmlBeanUtils.getChildElements( response,
SushiPropertyQNames.EBI );
+ assertNotNull( ebiPropElems );
+ assertEquals( 1, ebiPropElems.length );
+ assertEquals( plate.getEbi().getNumberOfPieces(),
XmlBeanUtils.getValue( ebiPropElems[0] ) );
+ }
+
+ private void assertGetRequestForInvalidPropThrowsFault()
+ {
+ try
+ {
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse
response = getResourceProperty( BOGUS_PROP_NAME );
+ fail( response != null ? "Expected fault, but received response."
: null );
+ }
+ catch ( InvalidResourcePropertyQNameFaultException expectedFault )
+ {
+ return;
+ }
+ }
+
+}
\ No newline at end of file
Added:
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/QueryResourcePropertiesProviderTestCase.java
URL:
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/QueryResourcePropertiesProviderTestCase.java?view=auto&rev=158165
==============================================================================
---
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/QueryResourcePropertiesProviderTestCase.java
(added)
+++
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/QueryResourcePropertiesProviderTestCase.java
Fri Mar 18 15:20:51 2005
@@ -0,0 +1,159 @@
+/*=============================================================================*
+ * 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.v2004_06.porttype.impl;
+
+import org.apache.ws.resource.ResourceContextException;
+import org.apache.ws.resource.ResourceException;
+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.faults.QueryEvaluationErrorFaultException;
+import
org.apache.ws.resource.properties.faults.UnknownQueryExpressionDialectFaultException;
+import org.apache.ws.resource.properties.query.QueryConstants;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+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;
+
+import java.net.URI;
+
+/**
+ * Test case for [EMAIL PROTECTED] QueryResourcePropertiesPortTypeImpl}.
+ *
+ * @author Sal Campana, Ian Springer
+ */
+public class QueryResourcePropertiesProviderTestCase
+ extends AbstractWsrpPortTypeImplTestCase
+{
+ /**
+ * DOCUMENT_ME
+ */
+ public void testQueryResourceProperties() throws Exception
+ {
+ m_resourceContext = new SushiResourceContext();
+
QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse
queryResourcePropertiesResponse = queryResourceProperties( "*" );
+ XmlObject[] allPropElems = XmlBeanUtils.getChildElements(
queryResourcePropertiesResponse );
+ assertNotNull( allPropElems );
+ assertTrue( allPropElems.length == 8 );
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testQueryWithInvalidDialect() throws Exception
+ {
+ m_resourceContext = new SushiResourceContext();
+ try
+ {
+
QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse
response = queryResourceProperties( "*", new URI( "http://blah.com/NotADialect"
) );
+ fail( response != null ? "Expected fault, but received response."
: null );
+ }
+ catch ( UnknownQueryExpressionDialectFaultException expectedFault )
+ {
+ return;
+ }
+
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testQueryWithInvalidExpr() throws Exception
+ {
+ m_resourceContext = new SushiResourceContext();
+ try
+ {
+
QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse
response = queryResourceProperties( "\\/\\/\\/\\/\\/" );
+ fail( response != null ? "Expected fault, but received response."
: null );
+ }
+ catch ( QueryEvaluationErrorFaultException expectedFault )
+ {
+ return;
+ }
+
+ }
+
+ public void testQueryOpenContent() throws XmlException
+ {
+ m_resourceContext = new SushiResourceContext();
+ insertXsdAnyPropElem();
+
QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse
queryResourcePropertiesResponse = queryResourceProperties( "*" );
+ XmlObject[] allPropElems = XmlBeanUtils.getChildElements(
queryResourcePropertiesResponse );
+ assertNotNull( allPropElems );
+ assertEquals( 9, allPropElems.length );
+ XmlObject[] fuguPropElems = XmlBeanUtils.getChildElements(
queryResourcePropertiesResponse, SushiPropertyQNames.FUGU );
+ assertNotNull( fuguPropElems );
+ assertEquals( 1, fuguPropElems.length );
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testQueryResourcePropertiesCallback()
+ throws ResourceException,
+ ResourceContextException
+ {
+ m_resourceContext = new SushiResourceContext();
+
+ //build callback obj
+ SushiPlate plate = new SushiPlate();
+ SushiCallback callback = new SushiCallback( plate );
+
+ //check whats there
+
QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse
queryResourcePropertiesResponse =
+ queryResourceProperties( "*" );
+ XmlObject[] ebiPropElems =
+ XmlBeanUtils.getChildElements(
queryResourcePropertiesResponse, SushiPropertyQNames.EBI );
+ String value = XmlBeanUtils.getValue( ebiPropElems[0] );
+ assertEquals( "9", value );
+
+ //setup callback to modify resource prop
+ SushiResource resource = (SushiResource)
m_resourceContext.getResource();
+ ResourceProperty resourceProp = resource.getResourcePropertySet().get(
SushiPropertyQNames.EBI );
+ resourceProp.setCallback( callback );
+
+ queryResourcePropertiesResponse = queryResourceProperties( "*" );
+
+ ebiPropElems = XmlBeanUtils.getChildElements(
queryResourcePropertiesResponse, SushiPropertyQNames.EBI );
+ assertNotNull( ebiPropElems );
+ value = XmlBeanUtils.getValue( ebiPropElems[0] );
+ assertEquals( plate.getEbi().getNumberOfPieces(), value );
+ }
+
+ private
QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse
queryResourceProperties( String xPathExpr )
+ {
+ return queryResourceProperties( xPathExpr,
QueryConstants.DIALECT_URI__XPATH1_0 );
+ }
+
+ private
QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse
queryResourceProperties( String xPathExpr, URI dialect )
+ {
+ QueryResourcePropertiesPortTypeImpl provider = new
QueryResourcePropertiesPortTypeImpl( m_resourceContext );
+ QueryResourcePropertiesDocument doc =
QueryResourcePropertiesDocument.Factory.newInstance();
+ QueryResourcePropertiesDocument.QueryResourceProperties
queryResourceProperties = doc.addNewQueryResourceProperties();
+ QueryExpressionType queryExpressionType =
queryResourceProperties.addNewQueryExpression();
+ queryExpressionType.setDialect( dialect.toString() );
+ XmlBeanUtils.setValue( queryExpressionType, xPathExpr );
+ QueryResourcePropertiesResponseDocument
queryResourcePropertiesResponseDocument = provider.queryResourceProperties( doc
);
+
QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse
queryResourcePropertiesResponse =
+
queryResourcePropertiesResponseDocument.getQueryResourcePropertiesResponse();
+ return queryResourcePropertiesResponse;
+ }
+}
\ No newline at end of file
Added:
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/SetResourcePropertiesProviderTestCase.java
URL:
http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/SetResourcePropertiesProviderTestCase.java?view=auto&rev=158165
==============================================================================
---
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/SetResourcePropertiesProviderTestCase.java
(added)
+++
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/SetResourcePropertiesProviderTestCase.java
Fri Mar 18 15:20:51 2005
@@ -0,0 +1,225 @@
+/*=============================================================================*
+ * 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.v2004_06.porttype.impl;
+
+import org.apache.ws.resource.ResourceContextException;
+import org.apache.ws.resource.ResourceException;
+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.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;
+import
org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyResponseDocument;
+
+import java.io.IOException;
+
+/**
+ * @author Sal Campana, Ian Springer
+ */
+public class SetResourcePropertiesProviderTestCase
+ extends AbstractWsrpPortTypeImplTestCase
+{
+ private SushiCallback m_callback;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ m_callback = new SushiCallback( new SushiPlate() );
+ }
+ /* ===================================== TESTS FOR 'INSERT'
====================================== */
+
+ public void testInsertResourcePropertiesCallback() throws XmlException,
ResourceException,
+ ResourceContextException
+ {
+ m_resourceContext = new SushiResourceContext();
+ SushiResource resource = (SushiResource)
m_resourceContext.getResource();
+ ResourceProperty resourceProp = resource.getResourcePropertySet().get(
SushiPropertyQNames.EBI );
+ resourceProp.setCallback( m_callback );
+
+ XmlObject xBean =
+ XmlObject.Factory.parse( "<foo:Ebi
xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
+ + "0" + "</foo:Ebi>" );
+ insertResourceProperty( new XmlObject[]{xBean} );
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse
getResourcePropertyResponse = getResourceProperty(
+ SushiPropertyQNames.EBI );
+
+ assertNotNull( getResourcePropertyResponse );
+ XmlObject[] childElements = XmlBeanUtils.getChildElements(
getResourcePropertyResponse,
+ SushiPropertyQNames.EBI );
+ assertEquals( 2, childElements.length );
+ assertTrue( m_callback.insertWasInvoked() );
+ }
+
+ public void testInsertResourceProperty()
+ throws XmlException
+ {
+ m_resourceContext = new SushiResourceContext();
+ XmlObject xBean =
+ XmlObject.Factory.parse( "<foo:Ebi
xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
+ + "0" + "</foo:Ebi>" );
+ insertResourceProperty( new XmlObject[]{xBean} );
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse
getResourcePropertyResponse = getResourceProperty(
+ SushiPropertyQNames.EBI );
+ assertNotNull( getResourcePropertyResponse );
+ XmlObject[] childElements = XmlBeanUtils.getChildElements(
getResourcePropertyResponse,
+ SushiPropertyQNames.EBI );
+ assertEquals( 2, childElements.length );
+ }
+
+ public void testInsertAnyIntoOpenContent() throws XmlException
+ {
+ m_resourceContext = new SushiResourceContext();
+ insertXsdAnyPropElem();
+ assertPropHasOneElemWithGivenValue( SushiPropertyQNames.FUGU,
INITIAL_PROP_VALUE_FUGU );
+ }
+
+ public void testInsertAnyIntoNonOpenContent() throws Exception
+ {
+ m_resourceContext = new SushiResourceContext( false );
+ try
+ {
+ insertXsdAnyPropElem();
+ fail();
+ }
+ catch ( InvalidResourcePropertyQNameFaultException expectedFault )
+ {
+ return; // success
+ }
+ }
+
+ /* ===================================== TESTS FOR 'DELETE'
====================================== */
+
+ public void testDeleteExistingOptionalProp()
+ throws Exception
+ {
+ m_resourceContext = new SushiResourceContext();
+ 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; // success
+ }
+ }
+
+ public void testDeleteOpenContent() throws IOException, XmlException
+ {
+ m_resourceContext = new SushiResourceContext( true );
+ deleteResourceProperty( SushiPropertyQNames.FUGU );
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse
getResourcePropertyResponse = getResourceProperty(
+ SushiPropertyQNames.OHTORO );
+ //todo better way to validate
+ assertNotNull( getResourcePropertyResponse );
+ }
+
+ public void testDeleteResourcePropertiesCallback() throws
ResourceException, ResourceContextException,
+ XmlException
+ {
+ m_resourceContext = new SushiResourceContext();
+ XmlObject xBean =
+ XmlObject.Factory.parse( "<foo:Ika
xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
+ + "my favorite!" + "</foo:Ika>" );
+ insertResourceProperty( new XmlObject[]{xBean} );
+ SushiResource resource = (SushiResource)
m_resourceContext.getResource();
+ ResourceProperty resourceProp = resource.getResourcePropertySet().get(
SushiPropertyQNames.IKA );
+ resourceProp.setCallback( m_callback );
+ deleteResourceProperty( SushiPropertyQNames.IKA );
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse
getResourcePropertyResponse = getResourceProperty(
+ SushiPropertyQNames.OHTORO );
+ assertNotNull( getResourcePropertyResponse );
+ assertTrue( m_callback.deleteWasInvoked() );
+ }
+
+ /* ===================================== TESTS FOR 'UPDATE'
====================================== */
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testUpdateResourcePropertiesCallback() throws
ResourceException, ResourceContextException,
+ XmlException
+ {
+ String newValue = "99";
+ m_resourceContext = new SushiResourceContext();
+ SushiPlate plate = new SushiPlate();
+ SushiCallback callback = new SushiCallback( plate );
+
+ //setup callback on resource prop
+ SushiResource resource = (SushiResource)
m_resourceContext.getResource();
+ ResourceProperty resourceProp = resource.getResourcePropertySet().get(
SushiPropertyQNames.EBI );
+ resourceProp.setCallback( callback );
+ XmlObject xBean =
+ XmlObject.Factory.parse( "<foo:Ebi
xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
+ + newValue + "</foo:Ebi>" );
+ updateResourceProperty( new XmlObject[]{xBean} );
+ assertPropHasOneElemWithGivenValue( SushiPropertyQNames.EBI, newValue
);
+ assertTrue( callback.updateWasInvoked() );
+ }
+
+ public void testUpdateOpenContent() throws XmlException
+ {
+ m_resourceContext = new SushiResourceContext( true );
+ insertXsdAnyPropElem();
+ assertPropHasOneElemWithGivenValue( SushiPropertyQNames.FUGU,
INITIAL_PROP_VALUE_FUGU );
+ XmlObject anyXBean = createXsdAnyPropElem();
+ final String newValue = "yummy!";
+ XmlBeanUtils.setValue( anyXBean, newValue );
+ updateResourceProperty( new XmlObject[]{anyXBean} );
+ assertPropHasOneElemWithGivenValue( SushiPropertyQNames.FUGU, newValue
);
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testUpdateResourceProperty()
+ throws XmlException
+ {
+ final String newValue = "99";
+ m_resourceContext = new SushiResourceContext();
+ XmlObject xBean =
+ XmlObject.Factory.parse( "<foo:Ebi
xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
+ + newValue + "</foo:Ebi>" );
+ updateResourceProperty( new XmlObject[]{xBean} );
+ assertPropHasOneElemWithGivenValue( SushiPropertyQNames.EBI, newValue
);
+ }
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]