You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrf-dev@ws.apache.org by ip...@apache.org on 2004/12/10 02:38:36 UTC
svn commit: r111454 - in incubator/apollo/trunk/src: java/org/apache/ws/resource/properties/porttype/impl java/org/apache/ws/util test/org/apache/ws/resource/properties test/org/apache/ws/resource/properties/impl test/org/apache/ws/resource/properties/porttype/impl test/org/apache/ws/util
Author: ips
Date: Thu Dec 9 17:38:34 2004
New Revision: 111454
URL: http://svn.apache.org/viewcvs?view=rev&rev=111454
Log:
got all the new "any" tests to pass
Removed:
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/OhtoroOnlyProperties.xml
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties-NonOpen.xsd
Modified:
incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProvider.java
incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiHome.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xml
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xsd
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiPropertyQNames.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiResourceContext.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySetMetaDataTestCase.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java
incubator/apollo/trunk/src/test/org/apache/ws/util/XmlBeanUtilsTestCase.java
Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProvider.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProvider.java?view=diff&rev=111454&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProvider.java&r1=111453&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProvider.java&r2=111454
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProvider.java (original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProvider.java Thu Dec 9 17:38:34 2004
@@ -129,7 +129,13 @@
ResourceProperty prop = getProperties().get( nameOfPropToBeDeleted );
if ( prop == null )
{
- throw new InvalidResourcePropertyQNameFaultException( nameOfPropToBeDeleted );
+ if ( getProperties().getMetaData().isOpenContent() )
+ {
+ return;
+ } else
+ {
+ throw new InvalidResourcePropertyQNameFaultException( nameOfPropToBeDeleted );
+ }
}
throwFaultIfPropertyIsReadOnly( prop );
throwFaultIfDeletionViolatesSchema( prop );
Modified: incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java?view=diff&rev=111454&p1=incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java&r1=111453&p2=incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java&r2=111454
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java (original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java Thu Dec 9 17:38:34 2004
@@ -15,20 +15,21 @@
*=============================================================================*/
package org.apache.ws.util;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.util.i18n.Keys;
+import org.apache.ws.util.i18n.Messages;
+import org.apache.ws.util.i18n.MessagesImpl;
import org.apache.xmlbeans.SchemaType;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.Log;
-import org.apache.ws.util.i18n.MessagesImpl;
-import org.apache.ws.util.i18n.Messages;
-import org.apache.ws.util.i18n.Keys;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPElement;
import java.io.File;
@@ -41,8 +42,7 @@
import java.util.Map;
/**
- * LOG-DONE
- * Generic utility methods for working with Apache XMLBeans.
+ * LOG-DONE Generic utility methods for working with Apache XMLBeans.
*
* @author Ian P. Springer, Sal Campana
*/
@@ -50,379 +50,390 @@
{
private static final Log LOG = LogFactory.getLog( XmlBeanUtils.class );
public static final Messages MSG = MessagesImpl.getInstance();
- /**
- * TODO
- *
- * @param xBean
- * @param name name to look for, or null to return all child elements
- *
- * @return
- */
- public static XmlObject[] getChildElements( XmlObject xBean,
- QName name )
- {
- List foundElems = new ArrayList( );
- xBean = getRootElement( xBean );
- XmlCursor xCursor = xBean.newCursor( );
- for ( boolean hasNext = xCursor.toFirstChild( ); hasNext; hasNext = xCursor.toNextSibling( ) )
- {
- if ( ( name == null ) || getName(xCursor).equals( name ) )
- {
- foundElems.add( xCursor.getObject( ) );
- }
- }
-
- xCursor.dispose( );
- return (XmlObject[]) foundElems.toArray( new XmlObject[0] );
- }
-
- /**
- * TODO
- *
- * @param xBean
- *
- * @return
- */
- public static XmlObject[] getChildElements( XmlObject xBean )
- {
- return getChildElements( xBean, null );
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param docXBean DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public static boolean isDocument( XmlObject docXBean )
- {
- return docXBean.schemaType( ).isDocumentType( );
- }
-
- /**
- * @param xBean
- *
- * @return
- */
- public static QName getName( XmlObject xBean )
- {
- if ( xBean == null )
- {
- throw new IllegalArgumentException( MSG.getMessage( Keys.NULL_PARAM_NOT_ALLOWED) );
- }
- SchemaType docSchemaType;
- if ( isDocument( xBean ) )
- {
- docSchemaType = xBean.schemaType( );
- }
- else
- {
- docSchemaType = xBean.schemaType( ).getOuterType( );
- }
-
- QName name;
- if ( docSchemaType != null )
- {
- name = docSchemaType.getDocumentElementName( );
- }
- else
- {
- XmlCursor xCursor = xBean.newCursor( );
- name = getName(xCursor);
- xCursor.dispose( );
- }
- LOG.debug(MSG.getMessage( Keys.QNAME_OF_XMLOBJ,name.toString()));
- return name;
- }
+
+ /**
+ * TODO
+ *
+ * @param xBean
+ * @param name name to look for, or null to return all child elements
+ *
+ * @return
+ */
+ public static XmlObject[] getChildElements( XmlObject xBean,
+ QName name )
+ {
+ List foundElems = new ArrayList();
+ xBean = getRootElement( xBean );
+ XmlCursor xCursor = xBean.newCursor();
+ for ( boolean hasNext = xCursor.toFirstChild(); hasNext; hasNext = xCursor.toNextSibling() )
+ {
+ if ( ( name == null ) || getName( xCursor ).equals( name ) )
+ {
+ foundElems.add( xCursor.getObject() );
+ }
+ }
+
+ xCursor.dispose();
+ return (XmlObject[]) foundElems.toArray( new XmlObject[0] );
+ }
+
+ /**
+ * TODO
+ *
+ * @param xBean
+ *
+ * @return
+ */
+ public static XmlObject[] getChildElements( XmlObject xBean )
+ {
+ return getChildElements( xBean, null );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param docXBean DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public static boolean isDocument( XmlObject docXBean )
+ {
+ return docXBean.schemaType().isDocumentType();
+ }
+
+ /**
+ * @param xBean
+ *
+ * @return
+ */
+ public static QName getName( XmlObject xBean )
+ {
+ if ( xBean == null )
+ {
+ throw new IllegalArgumentException( MSG.getMessage( Keys.NULL_PARAM_NOT_ALLOWED ) );
+ }
+ SchemaType docSchemaType;
+ if ( isDocument( xBean ) )
+ {
+ docSchemaType = xBean.schemaType();
+ }
+ else
+ {
+ docSchemaType = xBean.schemaType().getOuterType();
+ }
+
+ QName name;
+ if ( docSchemaType != null )
+ {
+ name = docSchemaType.getDocumentElementName();
+ }
+ else
+ {
+ XmlCursor xCursor = xBean.newCursor();
+ name = getName( xCursor );
+ xCursor.dispose();
+ }
+ LOG.debug( MSG.getMessage( Keys.QNAME_OF_XMLOBJ, name.toString() ) );
+ return name;
+ }
/**
* Note. this method does not dispose of the cursor
*
* @param xCursor
+ *
* @return
*/
- public static QName getName(XmlCursor xCursor)
+ public static QName getName( XmlCursor xCursor )
{
QName name;
- if(xCursor.currentTokenType().equals(XmlCursor.TokenType.STARTDOC))
- {
+ if ( xCursor.currentTokenType().equals( XmlCursor.TokenType.STARTDOC ) )
+ {
xCursor.toFirstChild();
- }
- name = xCursor.getName( );
+ name = xCursor.getName();
+ xCursor.toParent();
+ }
+ else
+ {
+ name = xCursor.getName();
+ }
return name;
}
/**
- * DOCUMENT_ME
- *
- * @param docXBean DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public static XmlObject getRootElement( XmlObject docXBean )
- {
- XmlObject rootElemXBean;
- if ( isDocument( docXBean ) )
- {
- XmlCursor xCursor = docXBean.newCursor( );
- xCursor.toFirstChild( );
- rootElemXBean = xCursor.getObject( );
- xCursor.dispose( );
- }
- else
- {
- rootElemXBean = docXBean;
- }
-
- return rootElemXBean;
- }
-
- /**
- * @param xBean
- * @param value
- */
- public static void setValue( XmlObject xBean,
- String value )
- {
- if(LOG.isDebugEnabled())
- {
- LOG.debug(MSG.getMessage( Keys.SET_VAL_ON_XMLOBJ, value, xBean.toString() ));
- }
- XmlCursor xCursor = xBean.newCursor( );
- xCursor.setTextValue( value );
- xCursor.dispose( );
- }
-
- /**
- * @param xBean
- *
- * @return
- */
- public static String getValue( XmlObject xBean )
- {
- XmlCursor xCursor = xBean.newCursor( );
- String value = xCursor.getTextValue( );
- xCursor.dispose( );
- return value;
- }
-
- /**
- * Returns a Map keyed on Element QName to a List containing the "Any" XmlObjects types.
- * <p/>
- * The way we determine that an element is an Any is by asking for the element property of the schemaType for the
- * element by the element's QName.
- *
- * @param xmlObjectToSearch The XmlObject to find the Any elements in.
- *
- * @return Map keyed on Element QName to a List containing the "Any" XmlObjects
- */
- public static Map getXmlBeanAnyMap( XmlObject xmlObjectToSearch )
- {
- Map qnameToListMap = new HashMap( );
- XmlCursor xCursor = xmlObjectToSearch.newCursor( );
- for ( boolean hasNext = xCursor.toFirstChild( ); hasNext; hasNext = xCursor.toNextSibling( ) )
- {
- XmlObject siblingXmlObject = xCursor.getObject( );
- QName siblingXmlObjectQname = siblingXmlObject.schemaType( ).getName( );
-
- // TODO: should this be tested against the original bean
- //if it contains the ElementProperty, then it is not an Any
- if ( siblingXmlObject.schemaType( ).getElementProperty( siblingXmlObjectQname ) != null )
- {
- continue;
- }
-
- //check to see if we have a xmlObjectList to add to for this QName
- List xmlObjectList = (List) qnameToListMap.get( siblingXmlObjectQname );
-
- if ( xmlObjectList == null )
- {
- xmlObjectList = new ArrayList( );
- }
-
- xmlObjectList.add( siblingXmlObject );
- qnameToListMap.put( siblingXmlObjectQname, xmlObjectList );
- }
-
- xCursor.dispose( );
-
- return qnameToListMap;
- }
-
- /**
- * TODO
- *
- * @param parentXBean
- * @param childXBean
- */
- public static void addChildElement( XmlObject parentXBean,
- XmlObject childXBean )
- {
- XmlCursor xCursor = parentXBean.newCursor( );
- xCursor.toEndDoc( );
- childXBean = getRootElement( childXBean );
- xCursor.toPrevToken( );
- xCursor.insertElement( getName(childXBean.newCursor( )));
- xCursor.toPrevSibling( );
- xCursor.getObject( ).set( childXBean );
- xCursor.dispose( );
- }
-
- /**
- * Removes the specifed XMLBean from its parent element.
- *
- * @param xBean an XMLBean
- */
- public static void remove( XmlObject xBean )
- {
- XmlCursor xCursor = xBean.newCursor( );
- xCursor.removeXml( );
- xCursor.dispose( );
- }
-
- /**
- * TODO
- *
- * @param xBean
- * @param name
- *
- * @return
- */
- public static boolean removeChildElements( XmlObject xBean,
- QName name )
- {
- boolean succeeded = true;
- xBean = getRootElement( xBean );
- XmlCursor xCursor = xBean.newCursor( );
- for ( boolean hasNext = xCursor.toFirstChild( ); hasNext; hasNext = xCursor.toNextSibling( ) )
- {
- if ( getName( xCursor ).equals( name ) )
- {
- succeeded = succeeded && xCursor.removeXml( );
- }
- }
-
- xCursor.dispose( );
- return succeeded;
- }
-
- /**
- * @param xBean
- *
- * @return
- *
- * @throws Exception
- */
- public static SOAPElement toSOAPElement( XmlObject xBean )
- throws Exception
- {
- if(LOG.isDebugEnabled())
- {
- LOG.debug(MSG.getMessage( Keys.CONVERT_XMLOBJ_TO_SOAPELEM,xBean.toString()));
- }
- XmlOptions xBeanSaveOptions =
- new XmlOptions( ).setSavePrettyPrint( ).setSavePrettyPrintIndent( 2 ).setSaveOuter( );
- Node domNode = xBean.newDomNode( xBeanSaveOptions );
- Element domElem = null;
-
- if ( domNode instanceof Document )
- {
- domElem = ( (Document) domNode ).getDocumentElement( );
- }
- else if ( domNode instanceof DocumentFragment )
- {
- NodeList childNodes = domNode.getChildNodes( );
-
- for ( int i = 0; i < childNodes.getLength( ); i++ )
- {
- if ( childNodes.item( i ).getNodeType( ) == Node.ELEMENT_NODE )
+ * DOCUMENT_ME
+ *
+ * @param docXBean DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public static XmlObject getRootElement( XmlObject docXBean )
+ {
+ XmlObject rootElemXBean;
+ if ( isDocument( docXBean ) )
+ {
+ XmlCursor xCursor = docXBean.newCursor();
+ xCursor.toFirstChild();
+ rootElemXBean = xCursor.getObject();
+ xCursor.dispose();
+ }
+ else
+ {
+ rootElemXBean = docXBean;
+ }
+
+ return rootElemXBean;
+ }
+
+ /**
+ * @param xBean
+ * @param value
+ */
+ public static void setValue( XmlObject xBean,
+ String value )
+ {
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( MSG.getMessage( Keys.SET_VAL_ON_XMLOBJ, value, xBean.toString() ) );
+ }
+ XmlCursor xCursor = xBean.newCursor();
+ if ( xCursor.isStartdoc() )
+ {
+ xCursor.toFirstChild();
+ }
+ xCursor.setTextValue( value );
+ xCursor.dispose();
+ }
+
+ /**
+ * @param xBean
+ *
+ * @return
+ */
+ public static String getValue( XmlObject xBean )
+ {
+ XmlCursor xCursor = xBean.newCursor();
+ String value = xCursor.getTextValue();
+ xCursor.dispose();
+ return value;
+ }
+
+ /**
+ * Returns a Map keyed on Element QName to a List containing the "Any" XmlObjects types.
+ * <p/>
+ * The way we determine that an element is an Any is by asking for the element property of the schemaType for the
+ * element by the element's QName.
+ *
+ * @param xmlObjectToSearch The XmlObject to find the Any elements in.
+ *
+ * @return Map keyed on Element QName to a List containing the "Any" XmlObjects
+ */
+ public static Map getXmlBeanAnyMap( XmlObject xmlObjectToSearch )
+ {
+ Map qnameToListMap = new HashMap();
+ XmlCursor xCursor = xmlObjectToSearch.newCursor();
+ for ( boolean hasNext = xCursor.toFirstChild(); hasNext; hasNext = xCursor.toNextSibling() )
+ {
+ XmlObject siblingXmlObject = xCursor.getObject();
+ QName siblingXmlObjectQname = siblingXmlObject.schemaType().getName();
+
+ // TODO: should this be tested against the original bean
+ //if it contains the ElementProperty, then it is not an Any
+ if ( siblingXmlObject.schemaType().getElementProperty( siblingXmlObjectQname ) != null )
+ {
+ continue;
+ }
+
+ //check to see if we have a xmlObjectList to add to for this QName
+ List xmlObjectList = (List) qnameToListMap.get( siblingXmlObjectQname );
+
+ if ( xmlObjectList == null )
+ {
+ xmlObjectList = new ArrayList();
+ }
+
+ xmlObjectList.add( siblingXmlObject );
+ qnameToListMap.put( siblingXmlObjectQname, xmlObjectList );
+ }
+
+ xCursor.dispose();
+
+ return qnameToListMap;
+ }
+
+ /**
+ * TODO
+ *
+ * @param parentXBean
+ * @param childXBean
+ */
+ public static void addChildElement( XmlObject parentXBean,
+ XmlObject childXBean )
+ {
+ XmlCursor xCursor = parentXBean.newCursor();
+ xCursor.toEndDoc();
+ childXBean = getRootElement( childXBean );
+ xCursor.toPrevToken();
+ xCursor.insertElement( getName( childXBean ) );
+ xCursor.toPrevSibling();
+ xCursor.getObject().set( childXBean );
+ xCursor.dispose();
+ }
+
+ /**
+ * Removes the specifed XMLBean from its parent element.
+ *
+ * @param xBean an XMLBean
+ */
+ public static void remove( XmlObject xBean )
+ {
+ XmlCursor xCursor = xBean.newCursor();
+ xCursor.removeXml();
+ xCursor.dispose();
+ }
+
+ /**
+ * TODO
+ *
+ * @param xBean
+ * @param name
+ *
+ * @return
+ */
+ public static boolean removeChildElements( XmlObject xBean,
+ QName name )
+ {
+ boolean succeeded = true;
+ xBean = getRootElement( xBean );
+ XmlCursor xCursor = xBean.newCursor();
+ for ( boolean hasNext = xCursor.toFirstChild(); hasNext; hasNext = xCursor.toNextSibling() )
+ {
+ if ( getName( xCursor ).equals( name ) )
{
- domElem = (Element) childNodes.item( i );
+ succeeded = succeeded && xCursor.removeXml();
+ }
+ }
- break;
+ xCursor.dispose();
+ return succeeded;
+ }
+
+ /**
+ * @param xBean
+ *
+ * @return
+ *
+ * @throws Exception
+ */
+ public static SOAPElement toSOAPElement( XmlObject xBean )
+ throws Exception
+ {
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( MSG.getMessage( Keys.CONVERT_XMLOBJ_TO_SOAPELEM, xBean.toString() ) );
+ }
+ XmlOptions xBeanSaveOptions =
+ new XmlOptions().setSavePrettyPrint().setSavePrettyPrintIndent( 2 ).setSaveOuter();
+ Node domNode = xBean.newDomNode( xBeanSaveOptions );
+ Element domElem = null;
+
+ if ( domNode instanceof Document )
+ {
+ domElem = ( (Document) domNode ).getDocumentElement();
+ }
+ else if ( domNode instanceof DocumentFragment )
+ {
+ NodeList childNodes = domNode.getChildNodes();
+
+ for ( int i = 0; i < childNodes.getLength(); i++ )
+ {
+ if ( childNodes.item( i ).getNodeType() == Node.ELEMENT_NODE )
+ {
+ domElem = (Element) childNodes.item( i );
+
+ break;
+ }
}
- }
- }
+ }
- return SaajUtils.toSOAPElement( domElem );
- }
+ return SaajUtils.toSOAPElement( domElem );
+ }
- /**
- * DOCUMENT_ME
- *
- * @param elems DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- *
- * @throws Exception DOCUMENT_ME
- */
- public static SOAPElement[] toSOAPElementArray( final XmlObject[] elems )
- throws Exception
- {
- SOAPElement[] soapElems = new SOAPElement[elems.length];
-
- for ( int i = 0; i < elems.length; i++ )
- {
- soapElems[i] = toSOAPElement( elems[i] );
- }
-
- return soapElems;
- }
-
- /**
- * If possible, converts the specified object to an XMLBean.
- *
- * @param obj an object
- *
- * @return an XMLBean
- *
- * @throws Exception if the object cannot be converted to an XMLBean
- */
- public static XmlObject toXmlObject( Object obj )
- throws Exception
- {
- XmlObject xBean;
- if ( obj instanceof XmlObject )
- {
- xBean = (XmlObject) obj;
- }
- else if ( obj instanceof SOAPElement )
- {
- // !!!NOTE!!! It is critical to do parse( obj.toString() ) here, instead of parse( (Node)obj ),
- // because Axis 1.2's DOM impl (MessageElement) strips off all attributes, including
- // namespace decls! (TODO: file an Axis bug for the aforementioned issue)
- xBean = XmlObject.Factory.parse( obj.toString( ) );
- }
- else if ( obj instanceof Node )
- {
- xBean = XmlObject.Factory.parse( (Node) obj );
- }
- else if ( obj instanceof String )
- {
- xBean = XmlObject.Factory.parse( (String) obj );
- }
- else if ( obj instanceof InputStream )
- {
- xBean = XmlObject.Factory.parse( (InputStream) obj );
- }
- else if ( obj instanceof Reader )
- {
- xBean = XmlObject.Factory.parse( (Reader) obj );
- }
- else if ( obj instanceof File )
- {
- xBean = XmlObject.Factory.parse( (File) obj );
- }
- else if ( obj instanceof URL )
- {
- xBean = XmlObject.Factory.parse( (URL) obj );
- }
- else
- {
- throw new IllegalArgumentException( MSG.getMessage( Keys.PARAM_MUST_BE_TYPE) );
- }
+ /**
+ * DOCUMENT_ME
+ *
+ * @param elems DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ public static SOAPElement[] toSOAPElementArray( final XmlObject[] elems )
+ throws Exception
+ {
+ SOAPElement[] soapElems = new SOAPElement[elems.length];
+
+ for ( int i = 0; i < elems.length; i++ )
+ {
+ soapElems[i] = toSOAPElement( elems[i] );
+ }
+
+ return soapElems;
+ }
- return xBean;
- }
+ /**
+ * If possible, converts the specified object to an XMLBean.
+ *
+ * @param obj an object
+ *
+ * @return an XMLBean
+ *
+ * @throws Exception if the object cannot be converted to an XMLBean
+ */
+ public static XmlObject toXmlObject( Object obj )
+ throws Exception
+ {
+ XmlObject xBean;
+ if ( obj instanceof XmlObject )
+ {
+ xBean = (XmlObject) obj;
+ }
+ else if ( obj instanceof SOAPElement )
+ {
+ // !!!NOTE!!! It is critical to do parse( obj.toString() ) here, instead of parse( (Node)obj ),
+ // because Axis 1.2's DOM impl (MessageElement) strips off all attributes, including
+ // namespace decls! (TODO: file an Axis bug for the aforementioned issue)
+ xBean = XmlObject.Factory.parse( obj.toString() );
+ }
+ else if ( obj instanceof Node )
+ {
+ xBean = XmlObject.Factory.parse( (Node) obj );
+ }
+ else if ( obj instanceof String )
+ {
+ xBean = XmlObject.Factory.parse( (String) obj );
+ }
+ else if ( obj instanceof InputStream )
+ {
+ xBean = XmlObject.Factory.parse( (InputStream) obj );
+ }
+ else if ( obj instanceof Reader )
+ {
+ xBean = XmlObject.Factory.parse( (Reader) obj );
+ }
+ else if ( obj instanceof File )
+ {
+ xBean = XmlObject.Factory.parse( (File) obj );
+ }
+ else if ( obj instanceof URL )
+ {
+ xBean = XmlObject.Factory.parse( (URL) obj );
+ }
+ else
+ {
+ throw new IllegalArgumentException( MSG.getMessage( Keys.PARAM_MUST_BE_TYPE ) );
+ }
+
+ return xBean;
+ }
}
Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java?view=diff&rev=111454&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java&r1=111453&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java&r2=111454
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java Thu Dec 9 17:38:34 2004
@@ -16,17 +16,16 @@
package org.apache.ws.resource.properties;
import junit.framework.TestCase;
-import org.apache.ws.util.IoUtils;
import org.apache.ws.resource.properties.impl.XmlBeansResourcePropertySet;
-import org.apache.xmlbeans.impl.common.XmlErrorPrinter;
-import org.apache.xmlbeans.impl.tool.SchemaCompiler;
+import org.apache.ws.util.IoUtils;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.impl.common.XmlErrorPrinter;
+import org.apache.xmlbeans.impl.tool.SchemaCompiler;
-import javax.xml.namespace.QName;
import java.io.File;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
@@ -39,14 +38,14 @@
public class AbstractResourcePropertiesTestCase extends TestCase
{
+ public static final String NSURI_SUSHI = "http://ws.apache.org/resource/properties/test/sushi";
-
- protected static String RESOURCE_PATH_SUSHI_PROPS_XSD = "org/apache/ws/resource/properties/SushiProperties.xsd";
+ protected static final String RESOURCE_PATH_SUSHI_PROPS_XSD = "org/apache/ws/resource/properties/SushiProperties.xsd";
protected static final String RESOURCE_PATH_SUSHI_PROPS_XML = "org/apache/ws/resource/properties/SushiProperties.xml";;
- static final File TMP_DIR = new File( System.getProperty( "java.io.tmpdir" ) );
- static final File SRC_DIR = new File( TMP_DIR, "jwsrf/generated_src" );
- static final File CLASSES_DIR = new File( TMP_DIR, "jwsrf/generated_classes" );
+ protected static final File BASE_TMP_DIR = new File( System.getProperty( "java.io.tmpdir" ), "ws.apache.org/apollo" );;
+ protected static final File SRC_DIR = new File( BASE_TMP_DIR, "generated_src" );
+ protected static final File CLASSES_DIR = new File( BASE_TMP_DIR, "generated_classes" );
protected ResourcePropertySet m_resourcePropSet;
@@ -66,7 +65,7 @@
protected static void compileSushiPropsXsd() throws Exception
{
InputStream xsdInStream = ClassLoader.getSystemResourceAsStream( RESOURCE_PATH_SUSHI_PROPS_XSD );
- File xsdFile = new File( TMP_DIR, "jwsrf/SushiProperties.xsd" );
+ File xsdFile = new File( BASE_TMP_DIR, "SushiProperties.xsd" );
IoUtils.copy( xsdInStream, xsdFile );
if ( ! compileSchema( xsdFile ) )
{
@@ -110,8 +109,5 @@
CLASSES_DIR.mkdirs(); // necessary?
return SchemaCompiler.compile( scompParams );
}
- public static void setResourcePathPropsXsd(String xsd)
- {
- RESOURCE_PATH_SUSHI_PROPS_XSD = xsd;
- }
+
}
Deleted: /incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/OhtoroOnlyProperties.xml
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/OhtoroOnlyProperties.xml?view=auto&rev=111453
==============================================================================
Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiHome.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiHome.java?view=diff&rev=111454&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiHome.java&r1=111453&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiHome.java&r2=111454
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiHome.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiHome.java Thu Dec 9 17:38:34 2004
@@ -27,6 +27,8 @@
import org.apache.ws.resource.properties.impl.XmlBeansResourcePropertySet;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
+
+import javax.xml.namespace.QName;
import java.io.InputStream;
import java.io.Serializable;
@@ -34,84 +36,87 @@
* @author Sal Campana
*/
public class SushiHome
- extends AbstractResourceHome
- implements ResourceFactory,
- Serializable
+ extends AbstractResourceHome
+ implements ResourceFactory,
+ Serializable
{
+ /**
+ * DOCUMENT_ME
+ */
+ protected static String RESOURCE_PROPS_RESOURCE_PATH =
+ "org/apache/ws/resource/properties/SushiProperties.xml";
+ private boolean m_isOpenContent;
- /** DOCUMENT_ME */
- protected static String RESOURCE_PROPS_RESOURCE_PATH =
- "org/apache/ws/resource/properties/SushiProperties.xml";
-
- public SushiHome()
+ public SushiHome( boolean isOpenContent )
{
- setResourceKeyName(SimpleTypeResourceKey.class.getName());
- setResourceClassName(SushiResource.class.getName());
+ m_isOpenContent = isOpenContent;
+ setResourceKeyName( SimpleTypeResourceKey.class.getName() );
+ setResourceClassName( SushiResource.class.getName() );
try
{
init();
}
- catch (Exception e)
+ catch ( Exception e )
{
e.printStackTrace();
}
+ }
+ /**
+ * DOCUMENT_ME
+ *
+ * @param resourceContext DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ *
+ * @throws ResourceException DOCUMENT_ME
+ * @throws ResourceContextException DOCUMENT_ME
+ * @throws ResourceUnknownException DOCUMENT_ME
+ */
+ public Resource getInstance( ResourceContext resourceContext )
+ throws ResourceException,
+ ResourceContextException,
+ ResourceUnknownException
+ {
- }
+ Resource resource = null;
+ ResourceKey key = resourceContext.getResourceKey();
+ try
+ { //added because of AbstractPortType
+ resource = null;
+ try
+ {
+ resource = find( key );
+ }
+ catch ( ResourceException re )
+ {
+ ;
+ }
+ if ( resource == null )
+ {
+ InputStream in = getClass().getClassLoader().getResourceAsStream( RESOURCE_PROPS_RESOURCE_PATH );
+ XmlOptions parseOpts = new XmlOptions().setLoadStripWhitespace();
+ if ( ! m_isOpenContent ) {
+ parseOpts.setLoadReplaceDocumentElement( new QName( AbstractResourcePropertiesTestCase.NSURI_SUSHI, "ClosedSushiProperties", "sushi" ) );
+ }
+ XmlObject propsDocXBean = XmlObject.Factory.parse( in, parseOpts );
+ in.close();
+ ResourcePropertySet propSet = new XmlBeansResourcePropertySet( propsDocXBean );
+ resource = createInstance( key, propSet );
+ ( (PropertiesResource) resource ).setResourcePropertySet( propSet );
+ }
+ }
+ catch ( Exception e )
+ {
+ throw new ResourceException( e );
+ }
- /**
- * DOCUMENT_ME
- *
- * @param resourceContext DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- *
- * @throws ResourceException DOCUMENT_ME
- * @throws ResourceContextException DOCUMENT_ME
- * @throws ResourceUnknownException DOCUMENT_ME
- */
- public Resource getInstance( ResourceContext resourceContext )
- throws ResourceException,
- ResourceContextException,
- ResourceUnknownException
- {
-
- Resource resource = null;
- ResourceKey key = resourceContext.getResourceKey( );
- try
- { //added because of AbstractPortType
- resource = null;
- try
- {
- resource = find(key);
- }
- catch (ResourceException e)
- {
- ;
- }
- if(resource == null)
- {
- InputStream in = getClass( ).getClassLoader( ).getResourceAsStream( RESOURCE_PROPS_RESOURCE_PATH );
- XmlObject propsDocXBean = XmlObject.Factory.parse( in,
- new XmlOptions( ).setLoadStripWhitespace( ) );
- in.close( );
- ResourcePropertySet propSet = new XmlBeansResourcePropertySet( propsDocXBean );
- resource = createInstance( key, propSet );
-
- ( (PropertiesResource) resource ).setResourcePropertySet( propSet );
- }
- }
- catch ( Exception e )
- {
- throw new ResourceException( e );
- }
-
- add( key, resource );
- return resource;
- }
+ add( key, resource );
+ return resource;
+ }
- public void setResourcePropsDocPath(String propsDoc)
+ public void setResourcePropsDocPath( String propsDoc )
{
SushiHome.RESOURCE_PROPS_RESOURCE_PATH = propsDoc;
}
Deleted: /incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties-NonOpen.xsd
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties-NonOpen.xsd?view=auto&rev=111453
==============================================================================
Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xml
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xml?view=diff&rev=111454&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xml&r1=111453&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xml&r2=111454
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xml (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xml Thu Dec 9 17:38:34 2004
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<SushiProperties
+<OpenSushiProperties
xmlns="http://ws.apache.org/resource/properties/test/sushi"
xmlns:wsrl="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd">
@@ -17,4 +17,4 @@
<Flavor>exquisite</Flavor>
</Ohtoro>
-</SushiProperties>
+</OpenSushiProperties>
Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xsd
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xsd?view=diff&rev=111454&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xsd&r1=111453&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xsd&r2=111454
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xsd (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xsd Thu Dec 9 17:38:34 2004
@@ -8,7 +8,7 @@
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd"
- schemaLocation="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd"/>
+ schemaLocation="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd"/>
<element name="Akagi" type="xsd:int"/>
<element name="Anago" type="xsd:integer"/>
@@ -30,8 +30,8 @@
</complexType>
</element>
- <!-- Resource properties document schema -->
- <element name="SushiProperties">
+ <!-- a resource properties document type def w/ closed content -->
+ <element name="ClosedSushiProperties">
<complexType>
<sequence>
<!-- props for wsrl:ScheduledResourceTermination portType -->
@@ -46,19 +46,30 @@
<element ref="tns:Ika" minOccurs="0" maxOccurs="unbounded" />
<element ref="tns:Hamachi" minOccurs="1" maxOccurs="unbounded" />
<element ref="tns:Ohtoro" minOccurs="0" maxOccurs="1" />
-
- <any minOccurs="0" maxOccurs="unbounded" namespace="##other" processContents="lax"/>
</sequence>
</complexType>
</element>
- <!-- Resource properties document definition that does not have open content -->
- <element name="OhtoroOnlyProperties">
- <complexType>
- <sequence>
- <element ref="tns:Ohtoro" minOccurs="0" maxOccurs="unbounded" />
- </sequence>
- </complexType>
- </element>
+ <!-- a resource properties document type def w/ open content -->
+ <element name="OpenSushiProperties">
+ <complexType>
+ <sequence>
+ <!-- props for wsrl:ScheduledResourceTermination portType -->
+ <element ref="wsrl:CurrentTime"/>
+ <element ref="wsrl:TerminationTime"/>
+
+ <!-- custom props -->
+ <element ref="tns:Akagi" />
+ <element ref="tns:Anago" minOccurs="1" maxOccurs="2" />
+ <element ref="tns:Ebi" minOccurs="1" maxOccurs="unbounded" />
+ <element ref="tns:Uni" minOccurs="0" />
+ <element ref="tns:Ika" minOccurs="0" maxOccurs="unbounded" />
+ <element ref="tns:Hamachi" minOccurs="1" maxOccurs="unbounded" />
+ <element ref="tns:Ohtoro" minOccurs="0" maxOccurs="1" />
+
+ <any minOccurs="0" maxOccurs="unbounded" namespace="##other" processContents="lax"/>
+ </sequence>
+ </complexType>
+ </element>
</schema>
Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiPropertyQNames.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiPropertyQNames.java?view=diff&rev=111454&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiPropertyQNames.java&r1=111453&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiPropertyQNames.java&r2=111454
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiPropertyQNames.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiPropertyQNames.java Thu Dec 9 17:38:34 2004
@@ -18,28 +18,31 @@
import javax.xml.namespace.QName;
/**
- * TODO
+ * Constants for QNames of elements defined in SushiProperties.xsd.
*
* @author Ian P. Springer (Hewlett-Packard Company)
*/
public interface SushiPropertyQNames
{
- QName SUSHI_PROPERTIES =
- new QName( "http://ws.apache.org/resource/properties/test/sushi", "SushiProperties", "sushi" );
+ QName OPEN_SUSHI_PROPERTIES =
+ new QName( "http://ws.apache.org/resource/properties/test/sushi", "OpenSushiProperties", "sushi" );
- QName AKAGI =
- new QName( "http://ws.apache.org/resource/properties/test/sushi", "Akagi", "sushi" );
+ QName CLOSED_SUSHI_PROPERTIES =
+ new QName( "http://ws.apache.org/resource/properties/test/sushi", "ClosedSushiProperties", "sushi" );
- QName HAMACHI =
- new QName( "http://ws.apache.org/resource/properties/test/sushi", "Hamachi", "sushi" );
+ QName AKAGI =
+ new QName( "http://ws.apache.org/resource/properties/test/sushi", "Akagi", "sushi" );
- QName EBI = new QName( "http://ws.apache.org/resource/properties/test/sushi", "Ebi", "sushi" );
+ QName HAMACHI =
+ new QName( "http://ws.apache.org/resource/properties/test/sushi", "Hamachi", "sushi" );
- QName IKA = new QName( "http://ws.apache.org/resource/properties/test/sushi", "Ika", "sushi" );
+ QName EBI = new QName( "http://ws.apache.org/resource/properties/test/sushi", "Ebi", "sushi" );
- QName OHTORO = new QName( "http://ws.apache.org/resource/properties/test/sushi", "Ohtoro", "sushi" );
+ QName IKA = new QName( "http://ws.apache.org/resource/properties/test/sushi", "Ika", "sushi" );
+
+ QName OHTORO = new QName( "http://ws.apache.org/resource/properties/test/sushi", "Ohtoro", "sushi" );
QName FUGU = new QName( "http://ws.apache.org/resource/properties/test/sushi/blowfish", "Fugu", "fu" );
-
+
}
Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiResourceContext.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiResourceContext.java?view=diff&rev=111454&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiResourceContext.java&r1=111453&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiResourceContext.java&r2=111454
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiResourceContext.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiResourceContext.java Thu Dec 9 17:38:34 2004
@@ -8,7 +8,6 @@
import org.apache.ws.resource.ResourceHome;
import org.apache.ws.resource.ResourceKey;
import org.apache.ws.resource.faults.ResoureKeyHeaderNotFoundFaultException;
-import org.apache.ws.resource.impl.AbstractResourceContext;
import org.apache.ws.resource.impl.SimpleTypeResourceKey;
import org.apache.ws.util.NameUtils;
@@ -22,36 +21,41 @@
import java.net.URL;
import java.util.Iterator;
-
/**
* @author Sal Campana
*/
public class SushiResourceContext extends ResourceContext
{
- ResourceHome m_home = new SushiHome();
+ ResourceHome m_home;
private Resource m_resource = null;
private SimpleTypeResourceKey m_key = null;
public static final String ID_KEY = "1212";
- private String m_name = "sushi";
+ private String m_serviceName = "sushi";
/**
- * Creates a new {@link AbstractResourceContext} object.
- *
- * @param soapMsgContext DOCUMENT_ME
+ * Creates a new {@link SushiResourceContext} object.
*/
public SushiResourceContext()
{
+ this( true );
+ }
+ /**
+ * Creates a new {@link SushiResourceContext} object.
+ */
+ public SushiResourceContext( boolean isOpenContent )
+ {
+ m_home = new SushiHome( isOpenContent );
try
{
- ((SushiHome)m_home).getInstance(this);
- m_resource = m_home.find(this.m_key);
+ ( (SushiHome) m_home ).getInstance( this );
+ m_resource = m_home.find( this.m_key );
}
- catch (ResourceException e)
+ catch ( ResourceException e )
{
e.printStackTrace();
}
- catch (ResourceContextException e)
+ catch ( ResourceContextException e )
{
e.printStackTrace();
}
@@ -59,24 +63,24 @@
}
/**
- * Creates a new {@link AbstractResourceContext} object.
+ * Creates a new {@link SushiResourceContext} object.
*
- * @param soapMsgContext DOCUMENT_ME
+ * @param pathToPropsXsd
*/
- public SushiResourceContext(String pathToPropsXsd)
+ public SushiResourceContext( String pathToPropsXsd )
{
try
{
- ((SushiHome)m_home).setResourcePropsDocPath(pathToPropsXsd);
- ((SushiHome)m_home).getInstance(this);
- m_resource = m_home.find(this.m_key);
+ ( (SushiHome) m_home ).setResourcePropsDocPath( pathToPropsXsd );
+ ( (SushiHome) m_home ).getInstance( this );
+ m_resource = m_home.find( this.m_key );
}
- catch (ResourceException e)
+ catch ( ResourceException e )
{
e.printStackTrace();
}
- catch (ResourceContextException e)
+ catch ( ResourceContextException e )
{
e.printStackTrace();
}
@@ -88,19 +92,19 @@
return m_home;
}
- public ResourceKey getResourceKey(QName keyName, Class keyClass) throws ResourceContextException, ResoureKeyHeaderNotFoundFaultException
+ public ResourceKey getResourceKey( QName keyName, Class keyClass ) throws ResourceContextException, ResoureKeyHeaderNotFoundFaultException
{
return m_key;
}
public SOAPHeaderElement getResourceKeyHeader() throws ResourceContextException
{
- return (SOAPHeaderElement)m_key.toSOAPElement();
+ return (SOAPHeaderElement) m_key.toSOAPElement();
}
- public SOAPHeaderElement getResourceKeyHeader(QName keyName) throws ResourceContextException
+ public SOAPHeaderElement getResourceKeyHeader( QName keyName ) throws ResourceContextException
{
- return (SOAPHeaderElement)m_key.toSOAPElement();
+ return (SOAPHeaderElement) m_key.toSOAPElement();
}
public SOAPMessage getSOAPMessage()
@@ -109,7 +113,7 @@
{
return MessageFactory.newInstance().createMessage();
}
- catch (SOAPException e)
+ catch ( SOAPException e )
{
e.printStackTrace();
}
@@ -118,22 +122,22 @@
public ResourceKey getResourceKey() throws ResourceContextException
{
- if (m_key == null)
+ if ( m_key == null )
{
try
{
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
SOAPHeader soapHeader = message.getSOAPHeader();
- SOAPHeaderElement soapHeaderElement = soapHeader.addHeaderElement(NameUtils.toName(new QName(AbstractSushiService.TARGET_NSURI,"ResourceID",AbstractSushiService.TARGET_NSPREFIX)));
- soapHeaderElement.addTextNode(ID_KEY);
- m_key = new SimpleTypeResourceKey(soapHeaderElement);
+ SOAPHeaderElement soapHeaderElement = soapHeader.addHeaderElement( NameUtils.toName( new QName( AbstractSushiService.TARGET_NSURI, "ResourceID", AbstractSushiService.TARGET_NSPREFIX ) ) );
+ soapHeaderElement.addTextNode( ID_KEY );
+ m_key = new SimpleTypeResourceKey( soapHeaderElement );
}
- catch (SOAPException e)
+ catch ( SOAPException e )
{
e.printStackTrace();
}
- catch (InvalidResourceKeyException e)
+ catch ( InvalidResourceKeyException e )
{
e.printStackTrace();
}
@@ -143,38 +147,38 @@
public String getServiceName()
{
- return m_name;
+ return m_serviceName;
}
public URL getServiceURL()
{
try
{
- return new URL("http://localhost:8080/muse/sushi");
+ return new URL( "http://localhost:8080/muse/" + m_serviceName );
}
- catch (MalformedURLException e)
+ catch ( MalformedURLException murle )
{
- e.printStackTrace();
+ murle.printStackTrace();
}
return null;
}
- public boolean containsProperty(String name)
+ public boolean containsProperty( String name )
{
return false;
}
- public void removeProperty(String name)
+ public void removeProperty( String name )
{
}
- public void setProperty(String name, Object value)
+ public void setProperty( String name, Object value )
{
}
- public Object getProperty(String name)
+ public Object getProperty( String name )
{
return null;
}
Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySetMetaDataTestCase.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySetMetaDataTestCase.java?view=diff&rev=111454&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySetMetaDataTestCase.java&r1=111453&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySetMetaDataTestCase.java&r2=111454
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySetMetaDataTestCase.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySetMetaDataTestCase.java Thu Dec 9 17:38:34 2004
@@ -74,7 +74,7 @@
public void testGetName( )
throws Exception
{
- assertEquals( SushiPropertyQNames.SUSHI_PROPERTIES,
+ assertEquals( SushiPropertyQNames.OPEN_SUSHI_PROPERTIES,
m_resourcePropSet.getMetaData().getName( ) );
}
Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java?view=diff&rev=111454&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java&r1=111453&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java&r2=111454
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java Thu Dec 9 17:38:34 2004
@@ -3,6 +3,7 @@
import org.apache.ws.resource.properties.AbstractResourcePropertiesTestCase;
import org.apache.ws.resource.properties.SushiPropertyQNames;
import org.apache.ws.resource.properties.SushiResourceContext;
+import org.apache.ws.resource.properties.faults.InvalidResourcePropertyQNameFaultException;
import org.apache.ws.resource.properties.query.QueryConstants;
import org.apache.ws.util.XmlBeanUtils;
import org.apache.xmlbeans.XmlException;
@@ -23,81 +24,75 @@
import javax.xml.namespace.QName;
import java.io.IOException;
-
/**
* @author Sal Campana
*/
public class OpenContentHandlingTestCase extends AbstractResourcePropertiesTestCase
{
- private static final String NON_OPEN_CONTENT_PROP_FILE = "org/apache/ws/resource/properties/SushiProperties-NonOpen.xsd";
+
public void testInsertAnyIntoOpenContent() throws XmlException
{
-
- SushiResourceContext context = new SushiResourceContext();
- insertFugu(context);
-
-
+ SushiResourceContext context = new SushiResourceContext( true );
+ insertFugu( context );
}
- private void insertFugu(SushiResourceContext context)
+ private void insertFugu( SushiResourceContext context )
throws XmlException
{
- SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider(context);
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( context );
InsertDocument insertDoc = InsertDocument.Factory.newInstance();
InsertType insertType = insertDoc.addNewInsert();
+ XmlObject anyXBean = createFuguAnyXBean();
+ XmlBeanUtils.addChildElement( insertType, anyXBean );
- XmlObject xmlObject = getFuguAnyType();
- XmlBeanUtils.addChildElement(insertType, xmlObject);
-
- set_provider.insertResourceProperty(insertType);
- GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(context, SushiPropertyQNames.FUGU);
+ set_provider.insertResourceProperty( insertType );
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty( context, SushiPropertyQNames.FUGU );
- assertNotNull(getResourcePropertyResponse);
- XmlObject[] childElements = XmlBeanUtils.getChildElements(getResourcePropertyResponse, SushiPropertyQNames.FUGU);
- assertTrue(childElements.length == 1);
+ assertNotNull( getResourcePropertyResponse );
+ XmlObject[] childElements = XmlBeanUtils.getChildElements( getResourcePropertyResponse, SushiPropertyQNames.FUGU );
+ assertTrue( childElements.length == 1 );
}
- private XmlObject getFuguAnyType()
+ private XmlObject createFuguAnyXBean()
throws XmlException
{
- XmlOptions options = new XmlOptions();
- options.setSaveUseOpenFrag();
- XmlObject xmlObject =
- XmlObject.Factory.parse("<fu:Fugu xmlns:fu=\"http://ws.apache.org/resource/properties/test/sushi/blowfish\">"
- + "dangerous!" + "</fu:Fugu>", options);
- return xmlObject;
+ XmlOptions xOpts = new XmlOptions();
+ XmlObject xBean = XmlObject.Factory.parse( "<fu:Fugu xmlns:fu=\"http://ws.apache.org/resource/properties/test/sushi/blowfish\">"
+ + "dangerous!" + "</fu:Fugu>", xOpts );
+ return xBean;
}
public void testInsertAnyIntoNonOpenContent() throws Exception
{
- AbstractResourcePropertiesTestCase.setResourcePathPropsXsd(NON_OPEN_CONTENT_PROP_FILE);
AbstractResourcePropertiesTestCase.compileSushiPropsXsd();
- SushiResourceContext context = new SushiResourceContext(NON_OPEN_CONTENT_PROP_FILE);
- SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider(context);
+ SushiResourceContext context = new SushiResourceContext( false );
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( context );
InsertDocument insertDoc = InsertDocument.Factory.newInstance();
InsertType insertType = insertDoc.addNewInsert();
-
- XmlObject xmlObject = getFuguAnyType();
- XmlBeanUtils.addChildElement(insertType, xmlObject);
-
- set_provider.insertResourceProperty(insertType);
- //todo expect fault!
-
-
+ XmlObject anyXBean = createFuguAnyXBean();
+ XmlBeanUtils.addChildElement( insertType, anyXBean );
+ try
+ {
+ set_provider.insertResourceProperty( insertType );
+ fail();
+ }
+ catch ( InvalidResourcePropertyQNameFaultException expectedFault )
+ {
+ return;
+ }
}
public void testQueryOpenContent() throws XmlException
{
//insert to be able to query
- SushiResourceContext context =
- new SushiResourceContext();
- insertFugu(context);
+ SushiResourceContext context = new SushiResourceContext( true );
+ insertFugu( context );
//build provider and invoke
QueryResourcePropertiesProvider provider =
- new QueryResourcePropertiesProvider(context);
+ new QueryResourcePropertiesProvider( context );
QueryResourcePropertiesDocument doc =
QueryResourcePropertiesDocument.Factory.newInstance();
@@ -105,73 +100,70 @@
doc.addNewQueryResourceProperties();
QueryExpressionType queryExpressionType =
queryResourceProperties.addNewQueryExpression();
- queryExpressionType.setDialect(QueryConstants.DIALECT_URI__XPATH1_0.toString());
+ queryExpressionType.setDialect( QueryConstants.DIALECT_URI__XPATH1_0.toString() );
//XmlBeanUtils.addChildElement(queryExpressionType, );
- XmlBeanUtils.setValue(queryExpressionType, "*");
+ XmlBeanUtils.setValue( queryExpressionType, "*" );
QueryResourcePropertiesResponseDocument queryResourcePropertiesResponseDocument =
- provider.queryResourceProperties(doc);
+ provider.queryResourceProperties( doc );
QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse queryResourcePropertiesResponse =
queryResourcePropertiesResponseDocument.getQueryResourcePropertiesResponse();
XmlObject[] childElements =
- XmlBeanUtils.getChildElements(queryResourcePropertiesResponse, SushiPropertyQNames.FUGU);
- assertNotNull(childElements);
- assertTrue(childElements.length == 1);
+ XmlBeanUtils.getChildElements( queryResourcePropertiesResponse, SushiPropertyQNames.FUGU );
+ assertNotNull( childElements );
+ assertTrue( childElements.length == 1 );
}
public void testUpdateOpenContent() throws XmlException
{
- //add field
- SushiResourceContext context = new SushiResourceContext();
- insertFugu(context);
- SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider(context);
+ SushiResourceContext context = new SushiResourceContext( true );
+ insertFugu( context );
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( context );
UpdateDocument updateDoc = UpdateDocument.Factory.newInstance();
UpdateType update = updateDoc.addNewUpdate();
-
- XmlObject xmlObject = getFuguAnyType();
- XmlBeanUtils.setValue(xmlObject, "yummi!");
- XmlBeanUtils.addChildElement(update, xmlObject);
-
- set_provider.updateResourceProperty(updateDoc.getUpdate());
-
- verifyViaGet(context, "yummi!", SushiPropertyQNames.FUGU);
+ XmlObject anyXBean = createFuguAnyXBean();
+ final String newValue = "yummy!";
+ XmlBeanUtils.setValue( anyXBean, newValue );
+ XmlBeanUtils.addChildElement( update, anyXBean );
+ set_provider.updateResourceProperty( updateDoc.getUpdate() );
+ verifyViaGet( context, newValue, SushiPropertyQNames.FUGU );
}
public void testDeleteOpenContent() throws IOException, XmlException
{
initResourcePropsDoc();
- SushiResourceContext context = new SushiResourceContext();
- SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider(context);
+ SushiResourceContext context = new SushiResourceContext( true );
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( context );
DeleteDocument deleteDoc = DeleteDocument.Factory.newInstance();
DeleteType deleteType = deleteDoc.addNewDelete();
- deleteType.setResourceProperty(SushiPropertyQNames.FUGU);
+ deleteType.setResourceProperty( SushiPropertyQNames.FUGU );
- set_provider.deleteResourceProperty(deleteType);
- GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(context, SushiPropertyQNames.OHTORO);
+ set_provider.deleteResourceProperty( deleteType );
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty( context, SushiPropertyQNames.OHTORO );
//todo better way to validate
- assertNotNull(getResourcePropertyResponse);
+ assertNotNull( getResourcePropertyResponse );
}
- private void verifyViaGet(SushiResourceContext context,
- String expectedVariable,
- QName nameToFind)
+ private void verifyViaGet( SushiResourceContext context,
+ String expectedVariable,
+ QName nameToFind )
{
- GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(context, nameToFind);
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty( context, nameToFind );
XmlObject[] childElements =
- XmlBeanUtils.getChildElements(getResourcePropertyResponse, nameToFind);
- assertNotNull(childElements);
- String value = XmlBeanUtils.getValue(childElements[0]);
- assertEquals(expectedVariable, value);
+ XmlBeanUtils.getChildElements( getResourcePropertyResponse, nameToFind );
+ assertNotNull( childElements );
+ String value = XmlBeanUtils.getValue( childElements[0] );
+ assertEquals( expectedVariable, value );
}
- private GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourceProperty(SushiResourceContext context, QName nameToFind)
+ private GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourceProperty( SushiResourceContext context, QName nameToFind )
{
- GetResourcePropertyProvider get_provider = new GetResourcePropertyProvider(context);
+ GetResourcePropertyProvider get_provider = new GetResourcePropertyProvider( context );
GetResourcePropertyDocument get_document = GetResourcePropertyDocument.Factory.newInstance();
- get_document.setGetResourceProperty(nameToFind);
+ get_document.setGetResourceProperty( nameToFind );
GetResourcePropertyResponseDocument resourceProperty =
- get_provider.getResourceProperty(get_document);
+ get_provider.getResourceProperty( get_document );
GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse =
resourceProperty.getGetResourcePropertyResponse();
return getResourcePropertyResponse;
Modified: incubator/apollo/trunk/src/test/org/apache/ws/util/XmlBeanUtilsTestCase.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/util/XmlBeanUtilsTestCase.java?view=diff&rev=111454&p1=incubator/apollo/trunk/src/test/org/apache/ws/util/XmlBeanUtilsTestCase.java&r1=111453&p2=incubator/apollo/trunk/src/test/org/apache/ws/util/XmlBeanUtilsTestCase.java&r2=111454
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/util/XmlBeanUtilsTestCase.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/util/XmlBeanUtilsTestCase.java Thu Dec 9 17:38:34 2004
@@ -75,7 +75,7 @@
*/
public void testGetName( )
{
- assertEquals( SushiPropertyQNames.SUSHI_PROPERTIES,
+ assertEquals( SushiPropertyQNames.OPEN_SUSHI_PROPERTIES,
XmlBeanUtils.getName( m_propsDoc ) );
// TODO: use reflection to reenable the below assertions
//assertEquals( SushiPropertyQNames.SUSHI_PROPERTIES,
---------------------------------------------------------------------
To unsubscribe, e-mail: apollo-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: apollo-dev-help@ws.apache.org