You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by sc...@apache.org on 2006/06/02 19:33:13 UTC
svn commit: r411218 [29/34] - in /webservices/muse: branches/1.0/
branches/1.0/src/examples/broker/ branches/1.0/src/examples/broker/WEB-INF/
branches/1.0/src/examples/consumer/ branches/1.0/src/examples/consumer/epr/
branches/1.0/src/examples/consumer...
Added: webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySetTestCase.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySetTestCase.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySetTestCase.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySetTestCase.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,186 @@
+/*=============================================================================*
+ * 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.impl;
+
+import junit.framework.Test;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.apache.ws.resource.properties.AbstractResourcePropertiesTestCase;
+import org.apache.ws.resource.properties.ResourceProperty;
+import org.apache.ws.resource.properties.SushiPropertyQNames;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlObject;
+import org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceDocument;
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * Test case for {@link XmlBeansResourcePropertySet}.
+ *
+ * @author Ian P. Springer
+ */
+public class XmlBeansResourcePropertySetTestCase
+ extends AbstractResourcePropertiesTestCase
+{
+ private static final QName EPR_TYPE_QNAME =
+ new QName( "http://schemas.xmlsoap.org/ws/2003/03/addressing", "EndpointReference", "wsa" );
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void setUp( )
+ throws Exception
+ {
+ initResourcePropsDoc( );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param args DOCUMENT_ME
+ */
+ public static void main( String[] args )
+ {
+ TestResult result = TestRunner.run( XmlBeansResourcePropertySetTestCase.suite( ) );
+ if ( !result.wasSuccessful( ) )
+ {
+ System.exit( 1 );
+ }
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public static Test suite( )
+ {
+ return new TestSuite( XmlBeansResourcePropertySetTestCase.class );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testAdd( )
+ throws Exception
+ {
+ XmlBeansResourcePropertyMetaData metaData =
+ new XmlBeansResourcePropertyMetaData( EndpointReferenceDocument.type.getElementProperty( EPR_TYPE_QNAME ),
+ false );
+ m_resourcePropSet.add( metaData.create( m_resourcePropSet ) );
+ ResourceProperty resourceProp = m_resourcePropSet.get( EPR_TYPE_QNAME );
+ assertNotNull( resourceProp );
+ assertEquals( EPR_TYPE_QNAME,
+ resourceProp.getMetaData( ).getName( ) );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testCreate( )
+ throws Exception
+ {
+ XmlBeansResourcePropertyMetaData metaData =
+ new XmlBeansResourcePropertyMetaData( EndpointReferenceDocument.type.getElementProperty( EPR_TYPE_QNAME ),
+ false );
+ ResourceProperty resourceProp = metaData.create( m_resourcePropSet );
+ assertNotNull( resourceProp );
+ assertEquals( EPR_TYPE_QNAME,
+ resourceProp.getMetaData( ).getName( ) );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testGet( )
+ throws Exception
+ {
+ ResourceProperty resourceProp = m_resourcePropSet.get( SushiPropertyQNames.AKAGI );
+ assertEquals( 1,
+ resourceProp.size( ) );
+ assertEquals( SushiPropertyQNames.AKAGI,
+ resourceProp.getMetaData( ).getName( ) );
+ XmlObject propElemXBean = (XmlObject) resourceProp.get( 0 );
+ assertEquals( "24",
+ XmlBeanUtils.getValue( propElemXBean ) );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testIterator( )
+ throws Exception
+ {
+ Iterator iter = m_resourcePropSet.iterator( );
+ int i = 0;
+ while ( iter.hasNext( ) )
+ {
+ assertTrue( iter.next( ) instanceof ResourceProperty );
+ i++;
+ }
+
+ assertEquals( 9, i );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testRemove( )
+ throws Exception
+ {
+ ResourceProperty resourceProp = m_resourcePropSet.get( SushiPropertyQNames.IKA );
+ assertEquals( 1,
+ resourceProp.size( ) );
+ m_resourcePropSet.remove( SushiPropertyQNames.IKA );
+ resourceProp = m_resourcePropSet.get( SushiPropertyQNames.IKA );
+ assertNull( resourceProp );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testToElement( )
+ throws Exception
+ {
+ // TODO (low priority): implement
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testToSOAPElement( )
+ throws Exception
+ {
+ //TODO (low priority): implement
+ }
+}
\ No newline at end of file
Added: webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertyTestCase.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertyTestCase.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertyTestCase.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertyTestCase.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,246 @@
+/*=============================================================================*
+ * 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.impl;
+
+import junit.framework.Test;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.apache.ws.resource.properties.AbstractResourcePropertiesTestCase;
+import org.apache.ws.resource.properties.ResourceProperty;
+import org.apache.ws.resource.properties.ResourcePropertyMetaData;
+import org.apache.ws.resource.properties.SushiPropertyQNames;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlInt;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlString;
+
+/**
+ * Test case for {@link XmlBeansResourceProperty}.
+ *
+ * @author Ian P. Springer
+ */
+public class XmlBeansResourcePropertyTestCase
+ extends AbstractResourcePropertiesTestCase
+{
+ /**
+ * @throws Exception
+ */
+ public void setUp( )
+ throws Exception
+ {
+ initResourcePropsDoc( );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param args DOCUMENT_ME
+ */
+ public static void main( String[] args )
+ {
+ TestResult result = TestRunner.run( XmlBeansResourcePropertyTestCase.suite( ) );
+ if ( !result.wasSuccessful( ) )
+ {
+ System.exit( 1 );
+ }
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public static Test suite( )
+ {
+ return new TestSuite( XmlBeansResourcePropertyTestCase.class );
+ }
+
+ /**
+ * Test for XmlBeansResourceProperty#add.
+ */
+ public void testAdd( )
+ throws Exception
+ {
+ ResourceProperty prop = m_resourcePropSet.get( SushiPropertyQNames.IKA );
+ final String stringValue = "somethang";
+ prop.add( XmlObject.Factory.parse( "<" + SushiPropertyQNames.IKA.getLocalPart( ) + " xmlns=\""
+ + SushiPropertyQNames.IKA.getNamespaceURI( ) + "\">" + stringValue
+ + "</" + SushiPropertyQNames.IKA.getLocalPart( ) + ">" ) );
+ assertEquals( 2,
+ prop.size( ) );
+ XmlString xString = (XmlString) prop.get( 1 );
+ assertEquals( stringValue,
+ xString.getStringValue( ) );
+ }
+
+ /**
+ * Test for XmlBeansResourceProperty#clear.
+ */
+ public void testClear( )
+ throws Exception
+ {
+ ResourceProperty manufacturerProp = m_resourcePropSet.get( SushiPropertyQNames.IKA );
+ manufacturerProp.clear( );
+ assertTrue( manufacturerProp.isEmpty( ) );
+ }
+
+ /**
+ * Test for XmlBeansResourceProperty#get.
+ */
+ public void testGet( )
+ throws Exception
+ {
+ ResourceProperty manufacturerProp = m_resourcePropSet.get( SushiPropertyQNames.AKAGI );
+ Object propObj = manufacturerProp.get( 0 );
+ assertTrue( propObj instanceof XmlInt );
+ XmlInt xInt = (XmlInt) propObj;
+ assertEquals( "24",
+ xInt.getStringValue( ) );
+ }
+
+ /**
+ * Test for XmlBeansResourceProperty#getMetaData.
+ */
+ public void testGetMetaData( )
+ throws Exception
+ {
+ ResourceProperty blockSize = m_resourcePropSet.get( SushiPropertyQNames.EBI );
+ ResourcePropertyMetaData metaData = blockSize.getMetaData( );
+ assertNotNull( metaData );
+ assertEquals( SushiPropertyQNames.EBI,
+ metaData.getName( ) );
+ assertEquals( 1,
+ metaData.getMinOccurs( ) );
+ assertEquals( -1,
+ metaData.getMaxOccurs( ) );
+ assertFalse( metaData.isNillable( ) );
+ assertFalse( metaData.isReadOnly( ) );
+
+ // TODO: add some more cases to test props that are nillable and/or read-only
+ }
+
+ /**
+ * Test for XmlBeansResourceProperty#isEmpty.
+ */
+ public void testIsEmpty( )
+ throws Exception
+ {
+ ResourceProperty prop = m_resourcePropSet.get( SushiPropertyQNames.IKA );
+ assertFalse( prop.isEmpty( ) );
+ prop.clear( );
+ assertTrue( prop.isEmpty( ) );
+ assertEquals( 0,
+ prop.size( ) );
+ }
+
+ /**
+ * Another test for XmlBeansResourceProperty#remove.
+ */
+ public void testRemoveAddedElement( )
+ throws Exception
+ {
+ ResourceProperty prop = m_resourcePropSet.get( SushiPropertyQNames.HAMACHI );
+ prop.clear( );
+ XmlObject hamachiDoc =
+ XmlObject.Factory.parse( "<Hamachi xmlns=\"http://ws.apache.org/resource/properties/test/sushi\">\n"
+ + " <Flavor>disgusting</Flavor>\n" + "</Hamachi>" );
+ prop.add( hamachiDoc );
+ assertEquals( 1,
+ prop.size( ) );
+ assertEquals( 1,
+ XmlBeanUtils.getChildElements( m_resourcePropSet.toXmlObject( ),
+ SushiPropertyQNames.HAMACHI ).length );
+ prop.remove( prop.get( 0 ) );
+ assertTrue( prop.isEmpty( ) );
+ assertEquals( 0,
+ XmlBeanUtils.getChildElements( m_resourcePropSet.toXmlObject( ),
+ SushiPropertyQNames.HAMACHI ).length );
+ }
+
+ /**
+ * Test for XmlBeansResourceProperty#remove.
+ */
+ public void testRemoveExistingElement( )
+ throws Exception
+ {
+ ResourceProperty prop = m_resourcePropSet.get( SushiPropertyQNames.HAMACHI );
+ prop.remove( prop.get( 0 ) );
+ assertTrue( prop.isEmpty( ) );
+ assertEquals( 0,
+ XmlBeanUtils.getChildElements( m_resourcePropSet.toXmlObject( ),
+ SushiPropertyQNames.HAMACHI ).length );
+ }
+
+ /**
+ * Test for XmlBeansResourceProperty#set.
+ */
+ public void testSet( )
+ throws Exception
+ {
+ ResourceProperty prop = m_resourcePropSet.get( SushiPropertyQNames.IKA );
+ final String stringValue = "somethang";
+ prop.set( 0,
+ XmlObject.Factory.parse( "<" + SushiPropertyQNames.IKA.getLocalPart( ) + " xmlns=\""
+ + SushiPropertyQNames.IKA.getNamespaceURI( ) + "\">" + stringValue
+ + "</" + SushiPropertyQNames.IKA.getLocalPart( ) + ">" ) );
+ XmlString xString = (XmlString) prop.get( 0 );
+ assertEquals( stringValue,
+ xString.getStringValue( ) );
+ }
+
+ /**
+ * Test for XmlBeansResourceProperty#size.
+ */
+ public void testSize( )
+ throws Exception
+ {
+ ResourceProperty prop = m_resourcePropSet.get( SushiPropertyQNames.IKA );
+ assertEquals( 1,
+ prop.size( ) );
+ final String stringValue = "somethang";
+ prop.add( XmlObject.Factory.parse( "<" + SushiPropertyQNames.IKA.getLocalPart( ) + " xmlns=\""
+ + SushiPropertyQNames.IKA.getNamespaceURI( ) + "\">" + stringValue
+ + "</" + SushiPropertyQNames.IKA.getLocalPart( ) + ">" ) );
+ prop.add( XmlObject.Factory.parse( "<" + SushiPropertyQNames.IKA.getLocalPart( ) + " xmlns=\""
+ + SushiPropertyQNames.IKA.getNamespaceURI( ) + "\">" + stringValue
+ + "</" + SushiPropertyQNames.IKA.getLocalPart( ) + ">" ) );
+ assertEquals( 3,
+ prop.size( ) );
+ prop.remove( prop.get( 0 ) );
+ prop.remove( prop.get( 0 ) );
+ assertEquals( 1,
+ prop.size( ) );
+ }
+
+ /**
+ * Test for XmlBeansResourceProperty#toElements.
+ */
+ public void testToElements( )
+ throws Exception
+ {
+ // TODO (low priority): implement
+ }
+
+ /**
+ * Test for XmlBeansResourceProperty#toSOAPElements.
+ */
+ public void testToSOAPElements( )
+ throws Exception
+ {
+ // TODO (low priority): implement
+ }
+}
\ No newline at end of file
Added: webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/AbstractWsrpPortTypeImplTestCase.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/AbstractWsrpPortTypeImplTestCase.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/AbstractWsrpPortTypeImplTestCase.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/AbstractWsrpPortTypeImplTestCase.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,175 @@
+/*=============================================================================*
+ * 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.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.InsertType;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.SetResourcePropertiesDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.UpdateType;
+import javax.xml.namespace.QName;
+
+/**
+ * Base class for test cases for WSRP portType impls.
+ *
+ * @author Ian Springer
+ */
+public abstract class AbstractWsrpPortTypeImplTestCase
+ extends AbstractResourcePropertiesTestCase
+{
+ /** DOCUMENT_ME */
+ protected static final String INITIAL_PROP_VALUE_FUGU = "dangerous!";
+
+ /** DOCUMENT_ME */
+ protected static final QName BOGUS_PROP_NAME = new QName( "http://blah.com/", "Bogus" );
+
+ /** DOCUMENT_ME */
+ protected static final QName ANOTHER_BOGUS_PROP_NAME = new QName( "http://blah.com/", "EvenMoreBogus" );
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param propName DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ 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;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param propName DOCUMENT_ME
+ * @param expectedValue DOCUMENT_ME
+ */
+ 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 );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ *
+ * @throws XmlException DOCUMENT_ME
+ */
+ 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;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param propName DOCUMENT_ME
+ */
+ 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( );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param propElems DOCUMENT_ME
+ */
+ 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( );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws XmlException DOCUMENT_ME
+ */
+ protected void insertXsdAnyPropElem( )
+ throws XmlException
+ {
+ XmlObject anyXBean = createXsdAnyPropElem( );
+ insertResourceProperty( new XmlObject[]
+ {
+ anyXBean
+ } );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param propElems DOCUMENT_ME
+ */
+ 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( );
+ }
+}
\ No newline at end of file
Added: webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,166 @@
+/*=============================================================================*
+ * 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;
+
+/**
+ * Test case for {@link GetMultipleResourcePropertiesPortTypeImpl}.
+ *
+ * @author Sal Campana, Ian Springer
+ */
+public class GetMultipleResourcePropertiesProviderTestCase
+ extends AbstractWsrpPortTypeImplTestCase
+{
+ /**
+ * DOCUMENT_ME
+ */
+ public void testGetMultiExistingProps( )
+ throws Exception
+ {
+ 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( )
+ throws Exception
+ {
+ 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( )
+ throws Exception
+ {
+ 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: webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetResourcePropertyProviderTestCase.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetResourcePropertyProviderTestCase.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetResourcePropertyProviderTestCase.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/GetResourcePropertyProviderTestCase.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,124 @@
+/*=============================================================================*
+ * 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 {@link GetResourcePropertyPortTypeImpl}, which consists of only one
+ * operation: {@link 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( )
+ throws Exception
+ {
+ 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 an invalid prop QName throws a fault exception,
+ * wether or not the RP doc permits open content.
+ */
+ public void testGetInvalidProp( )
+ throws Exception
+ {
+ m_resourceContext = new SushiResourceContext( true );
+ assertGetRequestForInvalidPropThrowsFault( );
+ m_resourceContext = new SushiResourceContext( false );
+ assertGetRequestForInvalidPropThrowsFault( );
+ }
+
+ /**
+ * Tests that a GetRP request for a non-existing optional prop returns an empty GetRPResponse elem.
+ */
+ public void testGetNonexistingOptionalProp( )
+ throws Exception
+ {
+ m_resourceContext = new SushiResourceContext( );
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse response =
+ getResourceProperty( SushiPropertyQNames.UNI );
+ XmlObject[] uniPropElems =
+ XmlBeanUtils.getChildElements( response, SushiPropertyQNames.UNI );
+ assertNotNull( uniPropElems );
+ assertEquals( 0, uniPropElems.length );
+ }
+
+ /**
+ * Test that {@link GetResourcePropertyPortTypeImpl#getResourceProperty(org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyDocument)}
+ * invokes a {@link 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: webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/QueryResourcePropertiesProviderTestCase.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/QueryResourcePropertiesProviderTestCase.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/QueryResourcePropertiesProviderTestCase.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/QueryResourcePropertiesProviderTestCase.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,179 @@
+/*=============================================================================*
+ * 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.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.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 {@link QueryResourcePropertiesPortTypeImpl}.
+ * TODO: add some tests with query expressions that contain prefixes
+ *
+ * @author Sal Campana, Ian Springer
+ */
+public class QueryResourcePropertiesProviderTestCase
+ extends AbstractWsrpPortTypeImplTestCase
+{
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testQueryOpenContent( )
+ throws Exception
+ {
+ 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 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 testQueryResourcePropertiesCallback( )
+ throws Exception
+ {
+ 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 );
+ }
+
+ /**
+ * 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;
+ }
+ }
+
+ 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: webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/SetResourcePropertiesProviderTestCase.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/SetResourcePropertiesProviderTestCase.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/SetResourcePropertiesProviderTestCase.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/resource/properties/v2004_06/porttype/impl/SetResourcePropertiesProviderTestCase.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,353 @@
+/*=============================================================================*
+ * 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.ThrowsCallback;
+import org.apache.ws.resource.properties.faults.InvalidResourcePropertyQNameFaultException;
+import org.apache.ws.resource.properties.faults.InvalidSetResourcePropertiesRequestContentFaultException;
+import org.apache.ws.resource.properties.faults.SetResourcePropertyRequestFailedFaultException;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlObject;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyResponseDocument;
+
+/**
+ * Test case for {@link SetResourcePropertiesPortTypeImpl}.
+ *
+ * @author Sal Campana, Ian Springer
+ */
+public class SetResourcePropertiesProviderTestCase
+ extends AbstractWsrpPortTypeImplTestCase
+{
+ private SushiCallback m_callback;
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testDeleteAnyPropFromOpenContentPropsDoc( )
+ throws Exception
+ {
+ m_resourceContext = new SushiResourceContext( true );
+ deleteResourceProperty( SushiPropertyQNames.FUGU );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testDeleteExistingNonOptionalProp( )
+ throws Exception
+ {
+ m_resourceContext = new SushiResourceContext( );
+ try
+ {
+ deleteResourceProperty( SushiPropertyQNames.EBI );
+ fail( );
+ }
+ catch ( InvalidSetResourcePropertiesRequestContentFaultException 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 );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testDeleteNonExistingOptionalProp( )
+ throws Exception
+ {
+ m_resourceContext = new SushiResourceContext( );
+ deleteResourceProperty( SushiPropertyQNames.UNI );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testDeleteResourcePropertiesCallback( )
+ throws Exception
+ {
+ 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( ) );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testDeleteResourcePropertiesFailedCallback( )
+ throws Exception
+ {
+ 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( new ThrowsCallback( ) );
+ try
+ {
+ deleteResourceProperty( SushiPropertyQNames.IKA );
+ }
+ catch ( RuntimeException e )
+ {
+ assertEquals( SetResourcePropertyRequestFailedFaultException.class.getName( ),
+ e.getClass( ).getName( ) );
+ return;
+ }
+
+ fail( );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testInsertAnyIntoNonOpenContent( )
+ throws Exception
+ {
+ m_resourceContext = new SushiResourceContext( false );
+ try
+ {
+ insertXsdAnyPropElem( );
+ fail( );
+ }
+ catch ( InvalidResourcePropertyQNameFaultException expectedFault )
+ {
+ return; // success
+ }
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testInsertAnyIntoOpenContent( )
+ throws Exception
+ {
+ m_resourceContext = new SushiResourceContext( );
+ insertXsdAnyPropElem( );
+ assertPropHasOneElemWithGivenValue( SushiPropertyQNames.FUGU, INITIAL_PROP_VALUE_FUGU );
+ }
+
+ /* ===================================== TESTS FOR 'INSERT' ====================================== */
+ public void testInsertResourcePropertiesCallback( )
+ throws Exception
+ {
+ 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( ) );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testInsertResourcePropertiesFailedCallback( )
+ throws Exception
+ {
+ m_resourceContext = new SushiResourceContext( );
+ SushiResource resource = (SushiResource) m_resourceContext.getResource( );
+ ResourceProperty resourceProp = resource.getResourcePropertySet( ).get( SushiPropertyQNames.EBI );
+ resourceProp.setCallback( new ThrowsCallback( ) );
+
+ XmlObject xBean =
+ XmlObject.Factory.parse( "<foo:Ebi xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
+ + "0" + "</foo:Ebi>" );
+ try
+ {
+ insertResourceProperty( new XmlObject[]
+ {
+ xBean
+ } );
+ }
+ catch ( RuntimeException e )
+ {
+ assertEquals( SetResourcePropertyRequestFailedFaultException.class.getName( ),
+ e.getClass( ).getName( ) );
+ return;
+ }
+
+ fail( );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testInsertResourceProperty( )
+ throws Exception
+ {
+ 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 );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void testUpdateOpenContent( )
+ throws Exception
+ {
+ 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 );
+ }
+
+ /* ===================================== TESTS FOR 'UPDATE' ====================================== */
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testUpdateResourcePropertiesCallback( )
+ throws Exception
+ {
+ 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( ) );
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testUpdateResourceProperty( )
+ throws Exception
+ {
+ 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 );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ protected void setUp( )
+ throws Exception
+ {
+ super.setUp( );
+ m_callback = new SushiCallback( new SushiPlate( ) );
+ }
+}
\ No newline at end of file
Added: webservices/muse/branches/1.0/src/test/org/apache/ws/util/XmlBeanUtilsTestCase.java
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/test/org/apache/ws/util/XmlBeanUtilsTestCase.java?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/test/org/apache/ws/util/XmlBeanUtilsTestCase.java (added)
+++ webservices/muse/branches/1.0/src/test/org/apache/ws/util/XmlBeanUtilsTestCase.java Fri Jun 2 10:32:46 2006
@@ -0,0 +1,282 @@
+/*=============================================================================*
+ * 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.util;
+
+import org.apache.ws.resource.properties.AbstractResourcePropertiesTestCase;
+import org.apache.ws.resource.properties.SushiPropertyQNames;
+import org.apache.ws.resource.properties.impl.XmlBeansResourcePropertySet;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.XmlString;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSBaseFaults12Draft01.BaseFaultType;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceLifetime12Draft01.CurrentTimeDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.QueryExpressionDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.QueryExpressionType;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.ResourcePropertyValueChangeNotificationDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.ResourcePropertyValueChangeNotificationType;
+import org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceDocument;
+import org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType;
+import org.xmlsoap.schemas.ws.x2003.x03.addressing.ReferencePropertiesType;
+import javax.xml.namespace.QName;
+import java.util.Calendar;
+
+/**
+ * Test case for {@link XmlBeanUtils}.
+ *
+ * @author Ian Springer
+ */
+public class XmlBeanUtilsTestCase
+ extends AbstractResourcePropertiesTestCase
+{
+ private XmlObject m_propsDoc;
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public void setUp( )
+ throws Exception
+ {
+ initResourcePropsDoc( );
+ m_propsDoc = ( (XmlBeansResourcePropertySet) m_resourcePropSet ).toXmlObject( );
+ }
+
+ /**
+ * Test for {@link XmlBeanUtils#addChildElement(org.apache.xmlbeans.XmlObject, org.apache.xmlbeans.XmlObject)}.
+ * NOTE: This test relies on {@link XmlBeanUtils#getChildElements(org.apache.xmlbeans.XmlObject, javax.xml.namespace.QName)},
+ * so it assumes that method has been tested elsewhere.
+ *
+ * @throws Exception on error
+ */
+ public void testAddChildElement( )
+ throws Exception
+ {
+ ResourcePropertyValueChangeNotificationType resourcePropertyValueChangeNotificationType =
+ ResourcePropertyValueChangeNotificationType.Factory.newInstance( );
+ ResourcePropertyValueChangeNotificationType.OldValue oldValue =
+ resourcePropertyValueChangeNotificationType.addNewOldValue( );
+ XmlBeanUtils.addChildElement( oldValue,
+ XmlObject.Factory.parse( "<fo>fum</fo>" ) );
+
+ // add a second one, so we can make sure they get added in the right order...
+ XmlBeanUtils.addChildElement( oldValue,
+ XmlObject.Factory.parse( "<fo>nub</fo>" ) );
+ XmlObject[] childElems = XmlBeanUtils.getChildElements( oldValue,
+ new QName( "fo" ) );
+ assertEquals( 2, childElems.length );
+ XmlObject[] grandchildElems = XmlBeanUtils.getChildElements( childElems[0],
+ new QName( "fo" ) );
+ assertEquals( 0, grandchildElems.length ); // this tests the nefarious "redundant grandchild" cursor bug
+ assertEquals( "fum",
+ XmlBeanUtils.getValue( childElems[0] ) );
+ assertEquals( "nub",
+ XmlBeanUtils.getValue( childElems[1] ) );
+
+ resourcePropertyValueChangeNotificationType =
+ ResourcePropertyValueChangeNotificationType.Factory.newInstance( );
+ oldValue = resourcePropertyValueChangeNotificationType.addNewOldValue( );
+ CurrentTimeDocument currentTimeDocument = CurrentTimeDocument.Factory.newInstance( );
+ currentTimeDocument.setCurrentTime( Calendar.getInstance( ) );
+ XmlObject newXBean = XmlBeanUtils.copyXmlBean( currentTimeDocument.xgetCurrentTime( ) );
+ XmlBeanUtils.addChildElement( oldValue, newXBean );
+ childElems =
+ XmlBeanUtils.getChildElements( oldValue,
+ new QName( "http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd",
+ "CurrentTime" ) );
+ assertEquals( 1, childElems.length );
+ XmlObject currentTimeElem = childElems[0];
+ childElems =
+ XmlBeanUtils.getChildElements( currentTimeElem,
+ new QName( "http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd",
+ "CurrentTime" ) );
+ assertEquals( 0, childElems.length );
+
+ QName elemName = SushiPropertyQNames.IKA;
+ String elemValue = "whatever";
+ XmlObject xBean =
+ XmlObject.Factory.parse( "<" + elemName.getLocalPart( ) + " xmlns=\"" + elemName.getNamespaceURI( )
+ + "\">" + elemValue + "</" + elemName.getLocalPart( ) + ">" );
+
+ // first test adding to an element that already has children...
+ XmlBeanUtils.addChildElement( m_propsDoc, xBean );
+ childElems = XmlBeanUtils.getChildElements( m_propsDoc, elemName );
+ assertEquals( 2, childElems.length );
+ assertTrue( childElems[1] instanceof XmlString );
+
+ // now test adding to a childless element...
+ EndpointReferenceDocument eprDoc = EndpointReferenceDocument.Factory.newInstance( );
+ EndpointReferenceType epr = eprDoc.addNewEndpointReference( );
+ ReferencePropertiesType refPropsType = epr.addNewReferenceProperties( );
+ XmlBeanUtils.addChildElement( refPropsType, xBean );
+ childElems = XmlBeanUtils.getChildElements( refPropsType, elemName );
+ assertEquals( 1, childElems.length );
+ assertTrue( childElems[0] instanceof XmlString );
+ }
+
+ /**
+ * Test for {@link XmlBeanUtils#addChildElement(org.apache.xmlbeans.XmlObject, QName)}.
+ * NOTE: This test relies on {@link XmlBeanUtils#getChildElements(org.apache.xmlbeans.XmlObject, javax.xml.namespace.QName)},
+ * so it assumes that method has been tested elsewhere.
+ *
+ * @throws Exception on error
+ */
+ public void testAddChildElementByName( )
+ throws Exception
+ {
+ final QName elemName = SushiPropertyQNames.IKA;
+
+ // first test adding to an element that already has children...
+ XmlBeanUtils.addChildElement( m_propsDoc, elemName );
+ XmlObject[] childElems = XmlBeanUtils.getChildElements( m_propsDoc, elemName );
+ assertEquals( 2, childElems.length );
+
+ // now test adding to a childless element...
+ EndpointReferenceDocument eprDoc = EndpointReferenceDocument.Factory.newInstance( );
+ EndpointReferenceType epr = eprDoc.addNewEndpointReference( );
+ ReferencePropertiesType refPropsType = epr.addNewReferenceProperties( );
+ XmlBeanUtils.addChildElement( refPropsType, elemName );
+ childElems = XmlBeanUtils.getChildElements( refPropsType, elemName );
+ assertEquals( 1, childElems.length );
+ }
+
+ /**
+ * Test for {@link XmlBeanUtils#copyXmlBean(XmlObject)}.
+ */
+ public void testCopyXmlBean( )
+ {
+ // TODO: write this test
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testGetChildElements( )
+ {
+ XmlObject[] childElems = XmlBeanUtils.getChildElements( m_propsDoc, SushiPropertyQNames.IKA );
+ assertEquals( 1, childElems.length );
+ assertTrue( childElems[0] instanceof XmlString );
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testGetName( )
+ {
+ assertEquals( SushiPropertyQNames.OPEN_SUSHI_PROPERTIES,
+ XmlBeanUtils.getName( m_propsDoc ) );
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testRemoveChildElements( )
+ {
+ XmlObject[] ebiChildElems = XmlBeanUtils.getChildElements( m_propsDoc, SushiPropertyQNames.EBI );
+ assertEquals( 1, ebiChildElems.length );
+ int totalChildElemsBefore = XmlBeanUtils.getChildElements( m_propsDoc, SushiPropertyQNames.EBI ).length;
+ XmlBeanUtils.removeChildElements( m_propsDoc, SushiPropertyQNames.EBI );
+ ebiChildElems = XmlBeanUtils.getChildElements( m_propsDoc, SushiPropertyQNames.EBI );
+ assertEquals( 0, ebiChildElems.length );
+ int totalChildElemsAfter = XmlBeanUtils.getChildElements( m_propsDoc, SushiPropertyQNames.EBI ).length;
+ assertEquals( 1, totalChildElemsBefore - totalChildElemsAfter );
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testSet( )
+ {
+ XmlString xString1 = XmlString.Factory.newInstance( );
+ xString1.setStringValue( "one" );
+ XmlString xString2 = XmlString.Factory.newInstance( );
+ xString2.setStringValue( "two" );
+ XmlCursor xmlCursor = xString1.newCursor( );
+ xmlCursor.toPrevToken( );
+ XmlObject object = xmlCursor.getObject( );
+ xString1 = (XmlString) object.set( xString2 );
+ System.out.println( xString1 );
+
+ ResourcePropertyValueChangeNotificationDocument resourcePropertyValueChangeNotificationDocument =
+ ResourcePropertyValueChangeNotificationDocument.Factory.newInstance( );
+ ResourcePropertyValueChangeNotificationType resourcePropertyValueChangeNotificationType =
+ resourcePropertyValueChangeNotificationDocument.addNewResourcePropertyValueChangeNotification( );
+ ResourcePropertyValueChangeNotificationType.OldValue oldValue =
+ resourcePropertyValueChangeNotificationType.addNewOldValue( );
+ XmlCursor parentCursor = oldValue.newCursor( );
+ if ( parentCursor.toLastChild( ) )
+ {
+ parentCursor.toEndToken( );
+ parentCursor.toNextToken( );
+ }
+
+ parentCursor.toEndToken( );
+ parentCursor.insertElement( new QName( "http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-BaseFaults-1.2-draft-01.xsd",
+ "BaseFault" ) );
+ System.out.println( "BEFORE:\n" + oldValue.xmlText( new XmlOptions( ).setSaveOuter( ) ) );
+ parentCursor.toPrevSibling( );
+ XmlObject childXBean = parentCursor.getObject( );
+ parentCursor.dispose( );
+
+ //BaseFaultDocument baseFaultDocument = BaseFaultDocument.Factory.newInstance( );
+ //BaseFaultType baseFaultType = baseFaultDocument.addNewBaseFault();
+ BaseFaultType baseFaultType = BaseFaultType.Factory.newInstance( );
+ baseFaultType.setTimestamp( Calendar.getInstance( ) );
+ childXBean.set( baseFaultType );
+ System.out.println( "AFTER:\n" + oldValue.xmlText( new XmlOptions( ).setSaveOuter( ) ) );
+
+ ResourcePropertyValueChangeNotificationDocument resourcePropertyValueChangeNotificationDocument1 =
+ ResourcePropertyValueChangeNotificationDocument.Factory.newInstance( );
+ ResourcePropertyValueChangeNotificationType resourcePropertyValueChangeNotificationType1 =
+ resourcePropertyValueChangeNotificationDocument.addNewResourcePropertyValueChangeNotification( );
+ ResourcePropertyValueChangeNotificationType.OldValue oldValue1 =
+ resourcePropertyValueChangeNotificationType1.addNewOldValue( );
+ oldValue1.newCursor( ).setTextValue( "one" );
+ System.out.println( resourcePropertyValueChangeNotificationDocument );
+
+ ResourcePropertyValueChangeNotificationType resourcePropertyValueChangeNotificationType2 =
+ ResourcePropertyValueChangeNotificationType.Factory.newInstance( );
+ ResourcePropertyValueChangeNotificationType.OldValue oldValue2 =
+ resourcePropertyValueChangeNotificationType2.addNewOldValue( );
+ oldValue2.newCursor( ).setTextValue( "two" );
+ oldValue1 = (ResourcePropertyValueChangeNotificationType.OldValue) oldValue1.set( oldValue2 );
+ System.out.println( resourcePropertyValueChangeNotificationDocument1 );
+
+ GetResourcePropertyDocument getResourcePropertyDoc1 = GetResourcePropertyDocument.Factory.newInstance( );
+ getResourcePropertyDoc1.setGetResourceProperty( new QName( "one" ) );
+ GetResourcePropertyDocument getResourcePropertyDoc2 = GetResourcePropertyDocument.Factory.newInstance( );
+ getResourcePropertyDoc2.setGetResourceProperty( new QName( "two" ) );
+ getResourcePropertyDoc1 =
+ (GetResourcePropertyDocument) getResourcePropertyDoc1.set( getResourcePropertyDoc2 );
+ System.out.println( getResourcePropertyDoc1 );
+ }
+
+ /**
+ * Test for {@link XmlBeanUtils#setValueAsQName(XmlObject, QName)}.
+ */
+ public void testSetValueAsQName( )
+ {
+ QueryExpressionDocument queryExpressionDocument = QueryExpressionDocument.Factory.newInstance( );
+ QueryExpressionType queryExpressionType = queryExpressionDocument.addNewQueryExpression( );
+ XmlBeanUtils.setValueAsQName( queryExpressionType, SushiPropertyQNames.AKAGI );
+ XmlCursor xCursor = queryExpressionType.newCursor( );
+ String prefix = xCursor.prefixForNamespace( SushiPropertyQNames.AKAGI.getNamespaceURI( ) );
+ String value = xCursor.getTextValue( );
+ assertEquals( prefix + ":" + SushiPropertyQNames.AKAGI.getLocalPart( ), value );
+ }
+}
\ No newline at end of file
Added: webservices/muse/branches/1.0/src/wsdl/SubscriptionManager.wsdl
URL: http://svn.apache.org/viewvc/webservices/muse/branches/1.0/src/wsdl/SubscriptionManager.wsdl?rev=411218&view=auto
==============================================================================
--- webservices/muse/branches/1.0/src/wsdl/SubscriptionManager.wsdl (added)
+++ webservices/muse/branches/1.0/src/wsdl/SubscriptionManager.wsdl Fri Jun 2 10:32:46 2006
@@ -0,0 +1,258 @@
+<?xml version="1.0"?>
+
+<definitions name="SubscriptionManagerDefinitions"
+ targetNamespace="http://ws.apache.org/notification/base/service/SubscriptionManager"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsrpw="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl"
+ xmlns:wsrp="ttp://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.xsd"
+ xmlns:wsrlw="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.wsdl"
+ xmlns:wsnt="http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd"
+ xmlns:wsntw="http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.wsdl"
+ xmlns:tns="http://ws.apache.org/notification/base/service/SubscriptionManager"
+ xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"
+ xmlns:wsa04="http://schemas.xmlsoap.org/ws/2004/08/addressing">
+
+ <import namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl"
+ location="../spec/wsrf/WS-ResourceProperties-1_2-Draft_01.wsdl"/>
+
+ <import namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.wsdl"
+ location="../spec/wsrf/WS-ResourceLifetime-1_2-Draft_01.wsdl"/>
+
+ <import namespace="http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.wsdl"
+ location="../spec/wsn/WS-BaseNotification-1_2-Draft_01.wsdl"/>
+
+ <import namespace="http://schemas.xmlsoap.org/ws/2004/09/mex"
+ location="../spec/wsx/WS-MetadataExchange-2004_09.wsdl" />
+
+ <portType name="SubscriptionManagerPortType" wsrp:ResourceProperties="wsnt:SubscriptionManagerRP">
+
+ <operation name="GetResourceProperty">
+ <input name="GetResourcePropertyRequest" message="wsrpw:GetResourcePropertyRequest"/>
+ <output name="GetResourcePropertyResponse" message="wsrpw:GetResourcePropertyResponse"/>
+ <fault name="ResourceUnknownFault" message="wsrpw:ResourceUnknownFault"/>
+ <fault name="InvalidResourcePropertyQNameFault" message="wsrpw:InvalidResourcePropertyQNameFault"/>
+ </operation>
+
+ <operation name="GetMultipleResourceProperties">
+ <input name="GetMultipleResourcePropertiesRequest" message="wsrpw:GetMultipleResourcePropertiesRequest"/>
+ <output name="GetMultipleResourcePropertiesResponse" message="wsrpw:GetMultipleResourcePropertiesResponse"/>
+ <fault name="ResourceUnknownFault" message="wsrpw:ResourceUnknownFault"/>
+ <fault name="InvalidResourcePropertyQNameFault" message="wsrpw:InvalidResourcePropertyQNameFault"/>
+ </operation>
+
+ <operation name="SetResourceProperties">
+ <input name="SetResourcePropertiesRequest" message="wsrpw:SetResourcePropertiesRequest"/>
+ <output name="SetResourcePropertiesResponse" message="wsrpw:SetResourcePropertiesResponse"/>
+ <fault name="ResourceUnknownFault" message="wsrpw:ResourceUnknownFault"/>
+ <fault name="InvalidResourcePropertyQNameFault" message="wsrpw:InvalidResourcePropertyQNameFault"/>
+ <fault name="InvalidSetResourcePropertiesRequestContentFault" message="wsrpw:InvalidSetResourcePropertiesRequestContentFault"/>
+ <fault name="UnableToModifyResourcePropertyFault" message="wsrpw:UnableToModifyResourcePropertyFault"/>
+ <fault name="SetResourcePropertyRequestFailedFault" message="wsrpw:SetResourcePropertyRequestFailedFault"/>
+ </operation>
+
+ <operation name="Destroy">
+ <input message="wsrlw:DestroyRequest"/>
+ <output message="wsrlw:DestroyResponse"/>
+ <fault name="ResourceUnknownFault" message="wsrlw:ResourceUnknownFault"/>
+ <fault name="ResourceNotDestroyedFault" message="wsrlw:ResourceNotDestroyedFault"/>
+ </operation>
+
+ <operation name="SetTerminationTime">
+ <input message="wsrlw:SetTerminationTimeRequest"/>
+ <output message="wsrlw:SetTerminationTimeResponse"/>
+ <fault name="ResourceUnknownFault" message="wsrlw:ResourceUnknownFault"/>
+ <fault name="UnableToSetTerminationTimeFault" message="wsrlw:UnableToSetTerminationTimeFault"/>
+ <fault name="TerminationTimeChangeRejectedFault" message="wsrlw:TerminationTimeChangeRejectedFault"/>
+ </operation>
+
+ <operation name="PauseSubcription">
+ <input message="wsntw:PauseSubscriptionRequest"/>
+ <output message="wsntw:PauseSubscriptionResponse"/>
+ <fault name="ResourceUnknownFault" message="wsntw:ResourceUnknownFault"/>
+ <fault name="PauseFailedFault" message="wsntw:PauseFailedFault"/>
+ </operation>
+
+ <operation name="ResumeSubscription">
+ <input message="wsntw:ResumeSubscriptionRequest"/>
+ <output message="wsntw:ResumeSubscriptionResponse"/>
+ <fault name="ResourceUnknownFault" message="wsntw:ResourceUnknownFault"/>
+ <fault name="ResumeFailedFault" message="wsntw:ResumeFailedFault"/>
+ </operation>
+
+ <operation name="GetMetadata" >
+ <input message="wsx:GetMetadataMsg"
+ wsa04:Action="http://schemas.xmlsoap.org/ws/2004/09/mex/GetMetadata/Request" />
+ <output message="wsx:GetMetadataResponseMsg"
+ wsa04:Action="http://schemas.xmlsoap.org/ws/2004/09/mex/GetMetadata/Response" />
+ </operation>
+ <operation name="Get" >
+ <input message="wsx:GetMsg"
+ wsa04:Action="http://schemas.xmlsoap.org/ws/2004/09/mex/Get/Request" />
+ <output message="wsx:GetResponseMsg"
+ wsa04:Action="http://schemas.xmlsoap.org/ws/2004/09/mex/Get/Response" />
+ </operation>
+
+ </portType>
+
+ <binding name="SubscriptionManagerHttpBinding" type="tns:SubscriptionManagerPortType">
+
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <operation name="GetResourceProperty">
+ <soap:operation style="document"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="ResourceUnknownFault">
+ <soap:fault name="ResourceUnknownFault" use="literal"/>
+ </fault>
+ <fault name="InvalidResourcePropertyQNameFault">
+ <soap:fault name="InvalidResourcePropertyQNameFault" use="literal"/>
+ </fault>
+ </operation>
+
+ <operation name="GetMultipleResourceProperties">
+ <soap:operation style="document"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="ResourceUnknownFault">
+ <soap:fault name="ResourceUnknownFault" use="literal"/>
+ </fault>
+ <fault name="InvalidResourcePropertyQNameFault">
+ <soap:fault name="InvalidResourcePropertyQNameFault" use="literal"/>
+ </fault>
+ </operation>
+
+ <operation name="SetResourceProperties">
+ <soap:operation style="document"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="ResourceUnknownFault">
+ <soap:fault name="ResourceUnknownFault" use="literal"/>
+ </fault>
+ <fault name="InvalidResourcePropertyQNameFault">
+ <soap:fault name="InvalidResourcePropertyQNameFault" use="literal"/>
+ </fault>
+ <fault name="UnableToModifyResourcePropertyFault">
+ <soap:fault name="UnableToModifyResourcePropertyFault" use="literal"/>
+ </fault>
+ <fault name="InvalidSetResourcePropertiesRequestContentFault">
+ <soap:fault name="InvalidSetResourcePropertiesRequestContentFault" use="literal"/>
+ </fault>
+ <fault name="SetResourcePropertyRequestFailedFault">
+ <soap:fault name="SetResourcePropertyRequestFailedFault" use="literal"/>
+ </fault>
+ </operation>
+
+ <operation name="Destroy">
+ <soap:operation style="document"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="ResourceUnknownFault">
+ <soap:fault name="ResourceUnknownFault" use="literal"/>
+ </fault>
+ <fault name="ResourceNotDestroyedFault">
+ <soap:fault name="ResourceNotDestroyedFault" use="literal"/>
+ </fault>
+ </operation>
+
+ <operation name="SetTerminationTime">
+ <soap:operation style="document"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="ResourceUnknownFault">
+ <soap:fault name="ResourceUnknownFault" use="literal"/>
+ </fault>
+ <fault name="UnableToSetTerminationTimeFault">
+ <soap:fault name="UnableToSetTerminationTimeFault" use="literal"/>
+ </fault>
+ <fault name="TerminationTimeChangeRejectedFault">
+ <soap:fault name="TerminationTimeChangeRejectedFault" use="literal"/>
+ </fault>
+ </operation>
+
+ <operation name="PauseSubcription">
+ <soap:operation style="document"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="ResourceUnknownFault">
+ <soap:fault name="ResourceUnknownFault" use="literal"/>
+ </fault>
+ <fault name="PauseFailedFault">
+ <soap:fault name="PauseFailedFault" use="literal"/>
+ </fault>
+ </operation>
+
+ <operation name="ResumeSubscription">
+ <soap:operation style="document"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="ResourceUnknownFault">
+ <soap:fault name="ResourceUnknownFault" use="literal"/>
+ </fault>
+ <fault name="ResumeFailedFault">
+ <soap:fault name="ResumeFailedFault" use="literal"/>
+ </fault>
+ </operation>
+
+ <operation name="GetMetadata" >
+ <soap:operation style="document"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+
+ <operation name="Get" >
+ <soap:operation style="document"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+
+ </binding>
+
+ <service name="SubscriptionManagerService">
+
+ <port name="SubscriptionManager" binding="tns:SubscriptionManagerHttpBinding">
+ <soap:address location="http://localhost:8080/wsrf/services/SubscriptionManager"/>
+ </port>
+
+ </service>
+
+</definitions>
---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org