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/11 01:21:42 UTC
svn commit: r111559 - in incubator/apollo/trunk/src: java/org/apache/ws/resource/i18n java/org/apache/ws/resource/properties/impl 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: Fri Dec 10 16:21:40 2004
New Revision: 111559
URL: http://svn.apache.org/viewcvs?view=rev&rev=111559
Log:
expanded and improved unit tests
Added:
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/AbstractWsrpPortTypeImplTestCase.java
Removed:
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java
Modified:
incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java
incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/Ebi.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiCallback.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/impl/XmlBeansResourcePropertyTestCase.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetResourcePropertyProviderTestCase.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/QueryResourcePropertiesProviderTestCase.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTestCase.java
incubator/apollo/trunk/src/test/org/apache/ws/util/XmlBeanUtilsTestCase.java
Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java?view=diff&rev=111559&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java&r1=111558&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java&r2=111559
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java (original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java Fri Dec 10 16:21:40 2004
@@ -407,9 +407,9 @@
*/
String XMLOBJECT_DOC = "XMLOBJECT_DOC";
/**
- * @msg The resource properties document schema does not allow open content.
+ * @msg Properties that are explicitly defined in the RP doc schema cannot be removed from the property set.
*/
- String NOT_ALLOW_OPEN_CONTENT = "NOT_ALLOW_OPEN_CONTENT";
+ String NON_ANY_PROP_CANNOT_BE_REMOVED = "NON_ANY_PROP_CANNOT_BE_REMOVED";
/**
* @msg The resource properties document already contains a resource property named {0}
*/
Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java?view=diff&rev=111559&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java&r1=111558&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java&r2=111559
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java (original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertySet.java Fri Dec 10 16:21:40 2004
@@ -106,7 +106,7 @@
{
if ( !m_metaData.isOpenContent( ) )
{
- throw new MetaDataViolationException( MSG.getMessage( Keys.NOT_ALLOW_OPEN_CONTENT) );
+ throw new MetaDataViolationException( MSG.getMessage( Keys.NON_ANY_PROP_CANNOT_BE_REMOVED) );
}
if ( m_propsMap.containsKey( prop.getMetaData( ).getName( ) ) )
@@ -180,7 +180,7 @@
{
if ( !m_metaData.isOpenContent( ) )
{
- throw new MetaDataViolationException( MSG.getMessage( Keys.NOT_ALLOW_OPEN_CONTENT) );
+ throw new MetaDataViolationException( MSG.getMessage( Keys.NON_ANY_PROP_CANNOT_BE_REMOVED) );
}
LOG.debug(MSG.getMessage( Keys.REMOVING_PROP,propName.toString()));
ResourceProperty resourceProp = (ResourceProperty) m_propsMap.get( propName );
@@ -298,10 +298,10 @@
private void initProperties( )
throws MetaDataViolationException
{
- SchemaProperty[] propElemSchemaProps = m_propsXBean.schemaType( ).getElementProperties( );
- for ( int i = 0; i < propElemSchemaProps.length; i++ )
+ SchemaProperty[] propElemDefs = m_propsXBean.schemaType( ).getElementProperties( );
+ for ( int i = 0; i < propElemDefs.length; i++ )
{
- XmlBeansResourceProperty prop = createProperty( propElemSchemaProps[i], false );
+ XmlBeansResourceProperty prop = createProperty( propElemDefs[i], false );
populateProperty( prop );
addPropertyToMap( prop );
}
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=111559&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java&r1=111558&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java&r2=111559
==============================================================================
--- 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 Fri Dec 10 16:21:40 2004
@@ -17,12 +17,16 @@
import junit.framework.TestCase;
import org.apache.ws.resource.properties.impl.XmlBeansResourcePropertySet;
+import org.apache.ws.resource.properties.porttype.impl.SetResourcePropertiesProvider;
import org.apache.ws.util.IoUtils;
+import org.apache.ws.util.XmlBeanUtils;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
import org.apache.xmlbeans.impl.common.XmlErrorPrinter;
import org.apache.xmlbeans.impl.tool.SchemaCompiler;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.InsertDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.InsertType;
import java.io.File;
import java.io.IOException;
@@ -49,6 +53,7 @@
protected static final File CLASSES_DIR = new File( BASE_TMP_DIR, "generated_classes" );
protected ResourcePropertySet m_resourcePropSet;
+ protected SushiResourceContext m_resourceContext;
static
{
@@ -110,14 +115,5 @@
CLASSES_DIR.mkdirs(); // necessary?
return SchemaCompiler.compile( scompParams );
}
-
- protected XmlObject createAnyXBean()
- throws XmlException
- {
- 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;
- }
-
+
}
Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/Ebi.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/Ebi.java?view=diff&rev=111559&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/Ebi.java&r1=111558&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/Ebi.java&r2=111559
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/Ebi.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/Ebi.java Fri Dec 10 16:21:40 2004
@@ -5,7 +5,8 @@
*/
public class Ebi
{
- private String m_pieces = "10";
+
+ private String m_pieces = "8";
public String getNumberOfPieces()
{
@@ -16,4 +17,5 @@
{
m_pieces = value;
}
+
}
Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiCallback.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiCallback.java?view=diff&rev=111559&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiCallback.java&r1=111558&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiCallback.java&r2=111559
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiCallback.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiCallback.java Fri Dec 10 16:21:40 2004
@@ -1,41 +1,39 @@
package org.apache.ws.resource.properties;
-import org.apache.xmlbeans.impl.values.XmlStringImpl;
-import org.apache.xmlbeans.XmlObject;
import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.impl.values.XmlIntImpl;
import javax.xml.namespace.QName;
-
/**
* @author Sal Campana
*/
public class SushiCallback implements SetResourcePropertyCallback
{
private SushiPlate m_plate;
- boolean m_deleteInvoked =false, m_insertInvoked = false,m_updateInvoked = false;
+ boolean m_deleteInvoked, m_insertInvoked, m_updateInvoked;
- public SushiCallback( SushiPlate plate)
+ public SushiCallback( SushiPlate plate )
{
m_plate = plate;
}
- public ResourceProperty refreshProperty(ResourceProperty prop)
+ public ResourceProperty refreshProperty( ResourceProperty prop )
{
- QName propName = getPropName(prop);
+ QName propName = getPropName( prop );
- if(SushiPropertyQNames.EBI.equals(propName))
+ if ( SushiPropertyQNames.EBI.equals( propName ) )
{
Ebi ebi = m_plate.getEbi();
String pieces = ebi.getNumberOfPieces();
try
{
- XmlStringImpl xmlstring = (XmlStringImpl) prop.get(0);
- XmlBeanUtils.setValue(xmlstring,pieces);
-
+ XmlIntImpl xmlstring = (XmlIntImpl) prop.get( 0 );
+ XmlBeanUtils.setValue( xmlstring, pieces );
}
- catch (Exception e)
+ catch ( Exception e )
{
e.printStackTrace();
}
@@ -43,35 +41,34 @@
return prop;
}
- private QName getPropName(ResourceProperty prop)
+ private QName getPropName( ResourceProperty prop )
{
return prop.getMetaData().getName();
}
- public void deleteProperty(QName propQName)
+ public void deleteProperty( QName propQName )
{
- m_deleteInvoked = true;
+ m_deleteInvoked = true;
}
- public void insertProperty(Object[] prop)
+ public void insertProperty( Object[] prop )
{
m_insertInvoked = true;
}
- public void updateProperty(Object[] prop)
+ public void updateProperty( Object[] prop )
{
- m_updateInvoked = true;
+ m_updateInvoked = true;
Object o = prop[0];
- if(o instanceof XmlObject)
+ if ( o instanceof XmlObject )
{
- XmlObject xmlObject = (XmlObject)o;
- QName name = XmlBeanUtils.getName(xmlObject);
- if(name.getLocalPart().equals("Ebi"))
+ XmlObject xmlObject = (XmlObject) o;
+ QName name = XmlBeanUtils.getName( xmlObject );
+ if ( name.getLocalPart().equals( "Ebi" ) )
{
- m_plate.getEbi().setNumberOfPieces(XmlBeanUtils.getValue(xmlObject));
+ m_plate.getEbi().setNumberOfPieces( XmlBeanUtils.getValue( xmlObject ) );
}
}
-
}
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=111559&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xml&r1=111558&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xml&r2=111559
==============================================================================
--- 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 Fri Dec 10 16:21:40 2004
@@ -8,7 +8,7 @@
<wsrl:TerminationTime>2005-12-17T09:30:47-05:00</wsrl:TerminationTime>
<Akagi>24</Akagi>
<Anago>9999999999999999999999999999</Anago>
- <Ebi>ohlala</Ebi>
+ <Ebi>9</Ebi>
<Ika>mamamia</Ika>
<Hamachi>
<Flavor>delicious</Flavor>
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=111559&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xsd&r1=111558&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties.xsd&r2=111559
==============================================================================
--- 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 Fri Dec 10 16:21:40 2004
@@ -12,7 +12,7 @@
<element name="Akagi" type="xsd:int"/>
<element name="Anago" type="xsd:integer"/>
- <element name="Ebi" type="xsd:string"/>
+ <element name="Ebi" type="xsd:int"/>
<element name="Ika" type="xsd:string"/>
<element name="Uni" type="xsd:anyURI"/>
<element name="Hamachi">
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=111559&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiPropertyQNames.java&r1=111558&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiPropertyQNames.java&r2=111559
==============================================================================
--- 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 Fri Dec 10 16:21:40 2004
@@ -45,4 +45,6 @@
QName FUGU = new QName( "http://ws.apache.org/resource/properties/test/sushi/blowfish", "Fugu", "fu" );
+ QName UNI = new QName( "http://ws.apache.org/resource/properties/test/sushi", "Uni", "sushi" );
+
}
Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertyTestCase.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertyTestCase.java?view=diff&rev=111559&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertyTestCase.java&r1=111558&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertyTestCase.java&r2=111559
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertyTestCase.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/impl/XmlBeansResourcePropertyTestCase.java Fri Dec 10 16:21:40 2004
@@ -75,9 +75,9 @@
public void testAdd()
throws Exception
{
- ResourceProperty prop = m_resourcePropSet.get( SushiPropertyQNames.EBI );
+ ResourceProperty prop = m_resourcePropSet.get( SushiPropertyQNames.IKA );
final String stringValue = "somethang";
- prop.add( XmlObject.Factory.parse( "<" + SushiPropertyQNames.EBI.getLocalPart() + " xmlns=\"" + SushiPropertyQNames.EBI.getNamespaceURI() + "\">" + stringValue + "</" + SushiPropertyQNames.EBI.getLocalPart() + ">" ) );
+ 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 );
@@ -161,10 +161,10 @@
public void testSet()
throws Exception
{
- ResourceProperty prop = m_resourcePropSet.get( SushiPropertyQNames.EBI );
+ ResourceProperty prop = m_resourcePropSet.get( SushiPropertyQNames.IKA );
final String stringValue = "somethang";
prop.set( 0,
- XmlObject.Factory.parse( "<" + SushiPropertyQNames.EBI.getLocalPart() + " xmlns=\"" + SushiPropertyQNames.EBI.getNamespaceURI() + "\">" + stringValue + "</" + SushiPropertyQNames.EBI.getLocalPart() + ">" ) );
+ XmlObject.Factory.parse( "<" + SushiPropertyQNames.IKA.getLocalPart() + " xmlns=\"" + SushiPropertyQNames.IKA.getNamespaceURI() + "\">" + stringValue + "</" + SushiPropertyQNames.IKA.getLocalPart() + ">" ) );
XmlString xString = (XmlString) prop.get( 0 );
assertEquals( stringValue,
xString.getStringValue() );
@@ -176,12 +176,12 @@
public void testSize()
throws Exception
{
- ResourceProperty prop = m_resourcePropSet.get( SushiPropertyQNames.EBI );
+ ResourceProperty prop = m_resourcePropSet.get( SushiPropertyQNames.IKA );
assertEquals( 1,
prop.size() );
final String stringValue = "somethang";
- prop.add( XmlObject.Factory.parse( "<" + SushiPropertyQNames.EBI.getLocalPart() + " xmlns=\"" + SushiPropertyQNames.EBI.getNamespaceURI() + "\">" + stringValue + "</" + SushiPropertyQNames.EBI.getLocalPart() + ">" ) );
- prop.add( XmlObject.Factory.parse( "<" + SushiPropertyQNames.EBI.getLocalPart() + " xmlns=\"" + SushiPropertyQNames.EBI.getNamespaceURI() + "\">" + stringValue + "</" + SushiPropertyQNames.EBI.getLocalPart() + ">" ) );
+ 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 ) );
Added: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/AbstractWsrpPortTypeImplTestCase.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/AbstractWsrpPortTypeImplTestCase.java?view=auto&rev=111559
==============================================================================
--- (empty file)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/AbstractWsrpPortTypeImplTestCase.java Fri Dec 10 16:21:40 2004
@@ -0,0 +1,85 @@
+/*=============================================================================*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.properties.porttype.impl;
+
+import org.apache.ws.resource.properties.AbstractResourcePropertiesTestCase;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlOptions;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.InsertDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.InsertType;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyResponseDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetMultipleResourcePropertiesResponseDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetMultipleResourcePropertiesDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyDocument;
+
+import javax.xml.namespace.QName;
+
+/**
+ * TODO
+ *
+ * @author Ian P. Springer (Hewlett-Packard Company)
+ */
+public class AbstractWsrpPortTypeImplTestCase extends AbstractResourcePropertiesTestCase
+{
+
+ protected static final String INITIAL_PROP_VALUE_FUGU = "dangerous!";
+ protected static final QName BOGUS_PROP_NAME = new QName( "http://blah.com/", "Bogus" );
+
+ protected XmlObject createXsdAnyPropElem()
+ throws XmlException
+ {
+ XmlOptions xOpts = new XmlOptions();
+ XmlObject xBean = XmlObject.Factory.parse( "<fu:Fugu xmlns:fu=\"http://ws.apache.org/resource/properties/test/sushi/blowfish\">"
+ + INITIAL_PROP_VALUE_FUGU + "</fu:Fugu>", xOpts );
+ return xBean;
+ }
+
+ protected void insertXsdAnyPropElem()
+ throws XmlException
+ {
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( m_resourceContext );
+ InsertDocument insertDoc = InsertDocument.Factory.newInstance();
+ InsertType insertType = insertDoc.addNewInsert();
+ XmlObject anyXBean = createXsdAnyPropElem();
+ XmlBeanUtils.addChildElement( insertType, anyXBean );
+ set_provider.insertResourceProperty( insertType );
+ }
+
+ protected void assertPropHasOneElemWithGivenValue( QName propName, String expectedValue )
+ {
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty( propName );
+ XmlObject[] propElems = XmlBeanUtils.getChildElements( getResourcePropertyResponse, propName );
+ assertNotNull( propElems );
+ String value = XmlBeanUtils.getValue( propElems[0] );
+ assertEquals( expectedValue, value );
+ }
+
+ protected GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourceProperty( QName propName )
+ {
+ GetResourcePropertyProvider get_provider = new GetResourcePropertyProvider( 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;
+ }
+
+
+
+}
Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java?view=diff&rev=111559&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java&r1=111558&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java&r2=111559
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java Fri Dec 10 16:21:40 2004
@@ -15,9 +15,6 @@
*=============================================================================*/
package org.apache.ws.resource.properties.porttype.impl;
-import org.apache.ws.resource.ResourceContextException;
-import org.apache.ws.resource.ResourceException;
-import org.apache.ws.resource.properties.AbstractResourcePropertiesTestCase;
import org.apache.ws.resource.properties.ResourceProperty;
import org.apache.ws.resource.properties.SushiCallback;
import org.apache.ws.resource.properties.SushiPlate;
@@ -29,92 +26,64 @@
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetMultipleResourcePropertiesDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetMultipleResourcePropertiesResponseDocument;
+import javax.xml.namespace.QName;
+
/**
- * @author Sal Campana
+ * @author Sal Campana, Ian Springer
*/
public class GetMultipleResourcePropertiesProviderTestCase
- extends AbstractResourcePropertiesTestCase
+ extends AbstractWsrpPortTypeImplTestCase
{
- /**
- * DOCUMENT_ME
- */
- public void testGetMultipleResourceProperties( )
- {
- SushiResourceContext context =
- new SushiResourceContext( );
- GetMultipleResourcePropertiesProvider provider =
- new GetMultipleResourcePropertiesProvider( context );
- GetMultipleResourcePropertiesDocument doc =
- GetMultipleResourcePropertiesDocument.Factory.newInstance( );
- GetMultipleResourcePropertiesDocument.GetMultipleResourceProperties getMultipleResourceProperties =
- doc.addNewGetMultipleResourceProperties( );
- getMultipleResourceProperties.addResourceProperty( SushiPropertyQNames.EBI );
- getMultipleResourceProperties.addResourceProperty( SushiPropertyQNames.HAMACHI );
-
- GetMultipleResourcePropertiesResponseDocument resourceProperties =
- provider.getMultipleResourceProperties( doc );
- GetMultipleResourcePropertiesResponseDocument.GetMultipleResourcePropertiesResponse getResourcePropertyResponse =
- resourceProperties.getGetMultipleResourcePropertiesResponse( );
- XmlObject[] childElements =
- XmlBeanUtils.getChildElements( getResourcePropertyResponse, null );
- assertNotNull( childElements );
- assertTrue( childElements.length == 2 );
- String value = XmlBeanUtils.getValue( childElements[0] );
- assertEquals( "ohlala",value );
- }
-
- /**
- * DOCUMENT_ME
- *
- * @throws Exception DOCUMENT_ME
- */
- protected void setUp( )
- throws Exception
- {
- //initResourcePropsDoc( );
- }
-
+
/**
* DOCUMENT_ME
- *
- * @throws ResourceException DOCUMENT_ME
- * @throws ResourceContextException DOCUMENT_ME
*/
- public void testGetMultipleResourcePropertiesCallback( )
- throws ResourceException,
- ResourceContextException
+ public void testGetMultipleResourceProperties()
{
- //build custom "test" context
- SushiResourceContext context = new SushiResourceContext( );
-
- //build callback obj
- SushiPlate plate = new SushiPlate( );
- SushiCallback callback = new SushiCallback( plate );
+ m_resourceContext = new SushiResourceContext();
+ GetMultipleResourcePropertiesResponseDocument.GetMultipleResourcePropertiesResponse response = getMultipleResourceProperties( new QName[]{SushiPropertyQNames.EBI, SushiPropertyQNames.IKA} );
+ XmlObject[] propElems = XmlBeanUtils.getChildElements( response, null );
+ assertNotNull( propElems );
+ assertEquals( 2, propElems.length );
+ assertEquals( SushiPropertyQNames.EBI, XmlBeanUtils.getName( propElems[0] ) );
+ assertEquals( "9", XmlBeanUtils.getValue( propElems[0] ) );
+ assertEquals( SushiPropertyQNames.IKA, XmlBeanUtils.getName( propElems[1] ) );
+ assertEquals( "mamamia", XmlBeanUtils.getValue( propElems[1] ) );
+ }
- //setup callback on resource prop
- SushiResource resource = (SushiResource) context.getResource( );
- ResourceProperty resourceProp = resource.getResourcePropertySet( ).get( SushiPropertyQNames.EBI );
- resourceProp.setCallback( callback );
+ /**
+ * 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 );
+ GetMultipleResourcePropertiesResponseDocument.GetMultipleResourcePropertiesResponse response = getMultipleResourceProperties( new QName[]{SushiPropertyQNames.EBI, SushiPropertyQNames.HAMACHI} );
+ XmlObject[] propElems = XmlBeanUtils.getChildElements( response, null );
+ assertNotNull( propElems );
+ String value = XmlBeanUtils.getValue( propElems[0] );
+ assertEquals( plate.getEbi().getNumberOfPieces(), value );
+ }
- //build provider and invoke
- GetMultipleResourcePropertiesProvider provider = new GetMultipleResourcePropertiesProvider( context );
- GetMultipleResourcePropertiesDocument doc = GetMultipleResourcePropertiesDocument.Factory.newInstance( );
+ private GetMultipleResourcePropertiesResponseDocument.GetMultipleResourcePropertiesResponse getMultipleResourceProperties( QName[] propNames )
+ {
+ GetMultipleResourcePropertiesProvider provider = new GetMultipleResourcePropertiesProvider( m_resourceContext );
+ GetMultipleResourcePropertiesDocument doc = GetMultipleResourcePropertiesDocument.Factory.newInstance();
GetMultipleResourcePropertiesDocument.GetMultipleResourceProperties getMultipleResourceProperties = doc.addNewGetMultipleResourceProperties();
- getMultipleResourceProperties.addResourceProperty(SushiPropertyQNames.EBI);
- getMultipleResourceProperties.addResourceProperty(SushiPropertyQNames.HAMACHI);
-
- GetMultipleResourcePropertiesResponseDocument resourceProperty = provider.getMultipleResourceProperties( doc );
-
- //retrieve the response value
- GetMultipleResourcePropertiesResponseDocument.GetMultipleResourcePropertiesResponse getResourcePropertyResponse =
- resourceProperty.getGetMultipleResourcePropertiesResponse( );
- XmlObject[] childElements =
- XmlBeanUtils.getChildElements( getResourcePropertyResponse, null );
-
- //assert the values
- assertNotNull( childElements );
- String value = XmlBeanUtils.getValue( childElements[0] );
- assertEquals( "10", value );
+ for ( int i = 0; i < propNames.length; i++ )
+ {
+ getMultipleResourceProperties.addResourceProperty( propNames[i] );
+ }
+ GetMultipleResourcePropertiesResponseDocument responseDoc = provider.getMultipleResourceProperties( doc );
+ GetMultipleResourcePropertiesResponseDocument.GetMultipleResourcePropertiesResponse response =
+ responseDoc.getGetMultipleResourcePropertiesResponse();
+ return response;
}
+
}
Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetResourcePropertyProviderTestCase.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetResourcePropertyProviderTestCase.java?view=diff&rev=111559&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetResourcePropertyProviderTestCase.java&r1=111558&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetResourcePropertyProviderTestCase.java&r2=111559
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetResourcePropertyProviderTestCase.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetResourcePropertyProviderTestCase.java Fri Dec 10 16:21:40 2004
@@ -15,95 +15,100 @@
*=============================================================================*/
package org.apache.ws.resource.properties.porttype.impl;
-import org.apache.ws.resource.ResourceContextException;
-import org.apache.ws.resource.ResourceException;
-import org.apache.ws.resource.properties.AbstractResourcePropertiesTestCase;
import org.apache.ws.resource.properties.ResourceProperty;
import org.apache.ws.resource.properties.SushiCallback;
import org.apache.ws.resource.properties.SushiPlate;
import org.apache.ws.resource.properties.SushiPropertyQNames;
import org.apache.ws.resource.properties.SushiResource;
import org.apache.ws.resource.properties.SushiResourceContext;
+import org.apache.ws.resource.properties.faults.InvalidResourcePropertyQNameFaultException;
import org.apache.ws.util.XmlBeanUtils;
import org.apache.xmlbeans.XmlObject;
-import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyResponseDocument;
/**
- * @author Sal Campana
+ * Test case for {@link GetResourcePropertyProvider}.
+ *
+ * @author Sal Campana, Ian Springer
*/
public class GetResourcePropertyProviderTestCase
- extends AbstractResourcePropertiesTestCase
-{
+ extends AbstractWsrpPortTypeImplTestCase
+{
+
+ /**
+ * Test for {@link GetResourcePropertyProvider#getResourceProperty(org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyDocument)}.
+ */
+ public void testGetExistingProperty()
+ {
+ 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] ) );
+ }
+
+ /**
+ * Test for {@link GetResourcePropertyProvider#getResourceProperty(org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyDocument)}.
+ */
+ public void testGetNonexistingOptionalProperty()
+ {
+ m_resourceContext = new SushiResourceContext();
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse response = getResourceProperty( SushiPropertyQNames.UNI );
+ XmlObject[] uniPropElems = XmlBeanUtils.getChildElements( response, SushiPropertyQNames.UNI );
+ assertNotNull( uniPropElems );
+ assertEquals( 0, uniPropElems.length );
+ }
+
+ /**
+ * Test for {@link GetResourcePropertyProvider#getResourceProperty(org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyDocument)}.
+ */
+ public void testGetNonexistingXsdAnyProperty()
+ {
+ m_resourceContext = new SushiResourceContext();
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse response = getResourceProperty( SushiPropertyQNames.EBI );
+ XmlObject[] ebiPropElems = XmlBeanUtils.getChildElements( response, BOGUS_PROP_NAME );
+ assertNotNull( ebiPropElems );
+ assertEquals( 0, ebiPropElems.length );
+ }
+
+ /**
+ * Test for {@link GetResourcePropertyProvider#getResourceProperty(org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyDocument)}.
+ */
+ public void testGetInvalidProperty()
+ {
+ m_resourceContext = new SushiResourceContext( false );
+ try
+ {
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse response = getResourceProperty( BOGUS_PROP_NAME );
+ fail( response != null ? "Expected fault, but received response." : null );
+ }
+ catch ( InvalidResourcePropertyQNameFaultException expectedFault )
+ {
+ return;
+ }
+ }
+
+ /**
+ * Test that {@link GetResourcePropertyProvider#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] ) );
+ }
- /**
- * DOCUMENT_ME
- */
- public void testGetResourceProperty( )
- {
- SushiResourceContext context = new SushiResourceContext( );
- GetResourcePropertyProvider provider = new GetResourcePropertyProvider( context );
- GetResourcePropertyDocument doc = GetResourcePropertyDocument.Factory.newInstance( );
- doc.setGetResourceProperty( SushiPropertyQNames.EBI );
- GetResourcePropertyResponseDocument resourceProperty =
- provider.getResourceProperty( doc );
- GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse =
- resourceProperty.getGetResourcePropertyResponse( );
- XmlObject[] childElements =
- XmlBeanUtils.getChildElements( getResourcePropertyResponse, SushiPropertyQNames.EBI );
- assertNotNull( childElements );
- String value = XmlBeanUtils.getValue( childElements[0] );
- assertEquals( value, "ohlala" );
- }
-
- /**
- * DOCUMENT_ME
- *
- * @throws ResourceException DOCUMENT_ME
- * @throws ResourceContextException DOCUMENT_ME
- */
- public void testGetResourcePropertyCallback( )
- throws ResourceException,
- ResourceContextException
- {
- //build custom "test" context
- SushiResourceContext context = new SushiResourceContext( );
-
- //build callback obj
- SushiPlate plate = new SushiPlate( );
- SushiCallback callback = new SushiCallback( plate );
-
- //setup callback on resource prop
- SushiResource resource = (SushiResource) context.getResource( );
- ResourceProperty resourceProp = resource.getResourcePropertySet( ).get( SushiPropertyQNames.EBI );
- resourceProp.setCallback( callback );
-
- //build provider and invoke
- GetResourcePropertyProvider provider = new GetResourcePropertyProvider( context );
- GetResourcePropertyDocument doc = GetResourcePropertyDocument.Factory.newInstance( );
- doc.setGetResourceProperty( SushiPropertyQNames.EBI );
- GetResourcePropertyResponseDocument resourceProperty = provider.getResourceProperty( doc );
-
- //retrieve the response value
- GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse =
- resourceProperty.getGetResourcePropertyResponse( );
- XmlObject[] childElements =
- XmlBeanUtils.getChildElements( getResourcePropertyResponse, SushiPropertyQNames.EBI );
-
- //assert the values
- assertNotNull( childElements );
- String value = XmlBeanUtils.getValue( childElements[0] );
- assertEquals( "10", value );
- }
-
- /**
- * DOCUMENT_ME
- *
- * @throws Exception DOCUMENT_ME
- */
- protected void setUp( )
- throws Exception
- {
- initResourcePropsDoc( );
- }
}
Deleted: /incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java?view=auto&rev=111558
==============================================================================
Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/QueryResourcePropertiesProviderTestCase.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/QueryResourcePropertiesProviderTestCase.java?view=diff&rev=111559&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/QueryResourcePropertiesProviderTestCase.java&r1=111558&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/QueryResourcePropertiesProviderTestCase.java&r2=111559
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/QueryResourcePropertiesProviderTestCase.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/QueryResourcePropertiesProviderTestCase.java Fri Dec 10 16:21:40 2004
@@ -17,7 +17,6 @@
import org.apache.ws.resource.ResourceContextException;
import org.apache.ws.resource.ResourceException;
-import org.apache.ws.resource.properties.AbstractResourcePropertiesTestCase;
import org.apache.ws.resource.properties.ResourceProperty;
import org.apache.ws.resource.properties.SushiCallback;
import org.apache.ws.resource.properties.SushiPlate;
@@ -26,103 +25,101 @@
import org.apache.ws.resource.properties.SushiResourceContext;
import org.apache.ws.resource.properties.query.QueryConstants;
import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
-import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyDocument;
-import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyResponseDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.QueryExpressionType;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.QueryResourcePropertiesDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.QueryResourcePropertiesResponseDocument;
/**
- * @author Sal Campana
+ * Test case for {@link QueryResourcePropertiesProvider}.
+ *
+ * @author Sal Campana, Ian Springer
*/
public class QueryResourcePropertiesProviderTestCase
- extends AbstractResourcePropertiesTestCase
+ extends AbstractWsrpPortTypeImplTestCase
{
- /**
- * DOCUMENT_ME
- */
- public void testQueryResourceProperties( )
- {
- SushiResourceContext context =
- new SushiResourceContext( );
-
- QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse queryResourcePropertiesResponse =
- queryAll( context );
-
- XmlObject[] childElements =
- XmlBeanUtils.getChildElements( queryResourcePropertiesResponse, null );
- assertNotNull( childElements );
- assertTrue( childElements.length == 8 );
- }
-
- /**
- * DOCUMENT_ME
- */
- public void testQueryResourcePropertiesCallback( )
- throws ResourceException,
- ResourceContextException
- {
- //build custom "test" context
- SushiResourceContext context = new SushiResourceContext( );
-
- //build callback obj
- SushiPlate plate = new SushiPlate( );
- SushiCallback callback = new SushiCallback( plate );
-
- //check whats there
- QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse queryResourcePropertiesResponse =
- queryAll( context );
- XmlObject[] childElements =
- XmlBeanUtils.getChildElements( queryResourcePropertiesResponse, SushiPropertyQNames.EBI );
- String value =
- XmlBeanUtils.getValue( childElements[0] );
- assertEquals( "ohlala", value );
-
- //setup callback to modify resource prop
- SushiResource resource = (SushiResource) context.getResource( );
- ResourceProperty resourceProp = resource.getResourcePropertySet( ).get( SushiPropertyQNames.EBI );
- resourceProp.setCallback( callback );
-
- queryResourcePropertiesResponse = queryAll( context );
-
- childElements = XmlBeanUtils.getChildElements( queryResourcePropertiesResponse, SushiPropertyQNames.EBI );
- assertNotNull( childElements );
- value = XmlBeanUtils.getValue( childElements[0] );
- assertEquals( "10", value );
- }
-
- /**
- * DOCUMENT_ME
- *
- * @throws Exception DOCUMENT_ME
- */
- protected void setUp( )
- throws Exception
- {
- initResourcePropsDoc( );
- }
-
- private QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse queryAll( SushiResourceContext context )
- {
- //build provider and invoke
- QueryResourcePropertiesProvider provider =
- new QueryResourcePropertiesProvider( context );
- QueryResourcePropertiesDocument doc =
- QueryResourcePropertiesDocument.Factory.newInstance( );
-
- QueryResourcePropertiesDocument.QueryResourceProperties queryResourceProperties =
- doc.addNewQueryResourceProperties( );
- QueryExpressionType queryExpressionType =
- queryResourceProperties.addNewQueryExpression( );
- queryExpressionType.setDialect( QueryConstants.DIALECT_URI__XPATH1_0.toString( ) );
-
- //XmlBeanUtils.addChildElement(queryExpressionType, );
- XmlBeanUtils.setValue( queryExpressionType, "*" );
- QueryResourcePropertiesResponseDocument queryResourcePropertiesResponseDocument =
- provider.queryResourceProperties( doc );
- QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse queryResourcePropertiesResponse =
- queryResourcePropertiesResponseDocument.getQueryResourcePropertiesResponse( );
- return queryResourcePropertiesResponse;
- }
+ /**
+ * DOCUMENT_ME
+ */
+ public void testQueryResourceProperties()
+ {
+ m_resourceContext = new SushiResourceContext();
+ QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse queryResourcePropertiesResponse = queryAll();
+ XmlObject[] allPropElems = XmlBeanUtils.getChildElements( queryResourcePropertiesResponse );
+ assertNotNull( allPropElems );
+ assertTrue( allPropElems.length == 8 );
+ }
+
+ public void testQueryOpenContent() throws XmlException
+ {
+ m_resourceContext = new SushiResourceContext();
+ insertXsdAnyPropElem();
+ QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse queryResourcePropertiesResponse = queryAll();
+ XmlObject[] allPropElems = XmlBeanUtils.getChildElements( queryResourcePropertiesResponse );
+ assertNotNull( allPropElems );
+ assertTrue( allPropElems.length == 9 );
+ XmlObject[] fuguPropElems = XmlBeanUtils.getChildElements( queryResourcePropertiesResponse, SushiPropertyQNames.FUGU );
+ assertNotNull( fuguPropElems );
+ assertEquals( 1, fuguPropElems.length );
+ }
+
+ /**
+ * DOCUMENT_ME
+ */
+ public void testQueryResourcePropertiesCallback()
+ throws ResourceException,
+ ResourceContextException
+ {
+ m_resourceContext = new SushiResourceContext();
+
+ //build callback obj
+ SushiPlate plate = new SushiPlate();
+ SushiCallback callback = new SushiCallback( plate );
+
+ //check whats there
+ QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse queryResourcePropertiesResponse =
+ queryAll();
+ 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 = queryAll();
+
+ ebiPropElems = XmlBeanUtils.getChildElements( queryResourcePropertiesResponse, SushiPropertyQNames.EBI );
+ assertNotNull( ebiPropElems );
+ value = XmlBeanUtils.getValue( ebiPropElems[0] );
+ assertEquals( plate.getEbi().getNumberOfPieces(), value );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @throws Exception DOCUMENT_ME
+ */
+ protected void setUp()
+ throws Exception
+ {
+ //initResourcePropsDoc();
+ }
+
+ private QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse queryAll()
+ {
+ QueryResourcePropertiesProvider provider = new QueryResourcePropertiesProvider( m_resourceContext );
+ QueryResourcePropertiesDocument doc = QueryResourcePropertiesDocument.Factory.newInstance();
+ QueryResourcePropertiesDocument.QueryResourceProperties queryResourceProperties = doc.addNewQueryResourceProperties();
+ QueryExpressionType queryExpressionType = queryResourceProperties.addNewQueryExpression();
+ queryExpressionType.setDialect( QueryConstants.DIALECT_URI__XPATH1_0.toString() );
+ XmlBeanUtils.setValue( queryExpressionType, "*" );
+ QueryResourcePropertiesResponseDocument queryResourcePropertiesResponseDocument = provider.queryResourceProperties( doc );
+ QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse queryResourcePropertiesResponse =
+ queryResourcePropertiesResponseDocument.getQueryResourcePropertiesResponse();
+ return queryResourcePropertiesResponse;
+ }
}
Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTestCase.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTestCase.java?view=diff&rev=111559&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTestCase.java&r1=111558&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTestCase.java&r2=111559
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTestCase.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/SetResourcePropertiesProviderTestCase.java Fri Dec 10 16:21:40 2004
@@ -17,217 +17,238 @@
import org.apache.ws.resource.ResourceContextException;
import org.apache.ws.resource.ResourceException;
-import org.apache.ws.resource.properties.AbstractResourcePropertiesTestCase;
import org.apache.ws.resource.properties.ResourceProperty;
import org.apache.ws.resource.properties.SushiCallback;
import org.apache.ws.resource.properties.SushiPlate;
import org.apache.ws.resource.properties.SushiPropertyQNames;
import org.apache.ws.resource.properties.SushiResource;
import org.apache.ws.resource.properties.SushiResourceContext;
+import org.apache.ws.resource.properties.faults.InvalidResourcePropertyQNameFaultException;
import org.apache.ws.util.XmlBeanUtils;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.DeleteDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.DeleteType;
-import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyResponseDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.InsertDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.InsertType;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.UpdateDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.UpdateType;
-import javax.xml.namespace.QName;
+import java.io.IOException;
/**
- * @author Sal Campana
+ * @author Sal Campana, Ian Springer
*/
public class SetResourcePropertiesProviderTestCase
- extends AbstractResourcePropertiesTestCase
+ extends AbstractWsrpPortTypeImplTestCase
{
- /**
- * DOCUMENT_ME
- */
- public void testUpdateResourcePropertiesCallback() throws ResourceException, ResourceContextException, XmlException
- {
- String expectedValue = "thisisatest";
- SushiResourceContext context = new SushiResourceContext();
- SushiPlate plate = new SushiPlate();
- SushiCallback callback = new SushiCallback(plate);
-
- //setup callback on resource prop
- SushiResource resource = (SushiResource) context.getResource();
- ResourceProperty resourceProp = resource.getResourcePropertySet().get(SushiPropertyQNames.EBI);
- resourceProp.setCallback(callback);
- SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider(context);
- UpdateDocument updateDoc = UpdateDocument.Factory.newInstance();
- UpdateType update = updateDoc.addNewUpdate();
-
- XmlObject xmlObject =
- XmlObject.Factory.parse("<foo:Ebi xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
- + expectedValue + "</foo:Ebi>");
- XmlBeanUtils.addChildElement(update, xmlObject);
-
- set_provider.updateResourceProperty(updateDoc.getUpdate());
-
- verifyViaGet(context, expectedValue, SushiPropertyQNames.EBI);
- assertTrue(callback.isUpdateInvoked());
- }
+ /* ===================================== TESTS FOR 'INSERT' ====================================== */
public void testInsertResourcePropertiesCallback() throws XmlException, ResourceException, ResourceContextException
{
- SushiResourceContext context = new SushiResourceContext();
+ m_resourceContext = new SushiResourceContext();
//build callback obj
SushiPlate plate = new SushiPlate();
- SushiCallback callback = new SushiCallback(plate);
+ SushiCallback callback = new SushiCallback( plate );
//setup callback on resource prop
- SushiResource resource = (SushiResource) context.getResource();
- ResourceProperty resourceProp = resource.getResourcePropertySet().get(SushiPropertyQNames.EBI);
- resourceProp.setCallback(callback);
+ SushiResource resource = (SushiResource) m_resourceContext.getResource();
+ ResourceProperty resourceProp = resource.getResourcePropertySet().get( SushiPropertyQNames.EBI );
+ resourceProp.setCallback( callback );
- SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider(context);
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( m_resourceContext );
InsertDocument insertDoc = InsertDocument.Factory.newInstance();
InsertType insertType = insertDoc.addNewInsert();
XmlObject xmlObject =
- XmlObject.Factory.parse("<foo:Ebi xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
- + "my favorite!" + "</foo:Ebi>");
- XmlBeanUtils.addChildElement(insertType, xmlObject);
-
- set_provider.insertResourceProperty(insertType);
- GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(context, SushiPropertyQNames.EBI);
-
- assertNotNull(getResourcePropertyResponse);
- XmlObject[] childElements = XmlBeanUtils.getChildElements(getResourcePropertyResponse, SushiPropertyQNames.EBI);
- assertTrue(childElements.length == 2);
- assertTrue(callback.isInsertInvoked());
+ XmlObject.Factory.parse( "<foo:Ebi xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
+ + "0" + "</foo:Ebi>" );
+ XmlBeanUtils.addChildElement( insertType, xmlObject );
+
+ set_provider.insertResourceProperty( insertType );
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty( SushiPropertyQNames.EBI );
+
+ assertNotNull( getResourcePropertyResponse );
+ XmlObject[] childElements = XmlBeanUtils.getChildElements( getResourcePropertyResponse, SushiPropertyQNames.EBI );
+ assertTrue( childElements.length == 2 );
+ assertTrue( callback.isInsertInvoked() );
}
- public void testDeleteResourcePropertiesCallback() throws ResourceException, ResourceContextException, XmlException
+ public void testInsertResourceProperty()
+ throws XmlException
{
- SushiResourceContext context = new SushiResourceContext();
- //build callback obj
- SushiPlate plate = new SushiPlate();
- SushiCallback callback = new SushiCallback(plate);
-
- //insert a prop
- SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider(context);
+ m_resourceContext = new SushiResourceContext();
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( m_resourceContext );
InsertDocument insertDoc = InsertDocument.Factory.newInstance();
InsertType insertType = insertDoc.addNewInsert();
XmlObject xmlObject =
- XmlObject.Factory.parse("<foo:Ika xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
- + "my favorite!" + "</foo:Ika>");
- XmlBeanUtils.addChildElement(insertType, xmlObject);
+ XmlObject.Factory.parse( "<foo:Ebi xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
+ + "0" + "</foo:Ebi>" );
+ XmlBeanUtils.addChildElement( insertType, xmlObject );
- set_provider.insertResourceProperty(insertType);
+ set_provider.insertResourceProperty( insertType );
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty( SushiPropertyQNames.EBI );
- //setup callback on resource prop
- SushiResource resource = (SushiResource) context.getResource();
- ResourceProperty resourceProp = resource.getResourcePropertySet().get(SushiPropertyQNames.IKA);
- resourceProp.setCallback(callback);
+ assertNotNull( getResourcePropertyResponse );
+ XmlObject[] childElements = XmlBeanUtils.getChildElements( getResourcePropertyResponse, SushiPropertyQNames.EBI );
+ assertTrue( childElements.length == 2 );
+ }
+ public void testInsertAnyIntoOpenContent() throws XmlException
+ {
+ m_resourceContext = new SushiResourceContext();
+ insertXsdAnyPropElem();
+ assertPropHasOneElemWithGivenValue( SushiPropertyQNames.FUGU, INITIAL_PROP_VALUE_FUGU );
+ }
+
+ public void testInsertAnyIntoNonOpenContent() throws Exception
+ {
+ m_resourceContext = new SushiResourceContext( false );
+ try
+ {
+ insertXsdAnyPropElem();
+ fail();
+ }
+ catch ( InvalidResourcePropertyQNameFaultException expectedFault )
+ {
+ return;
+ }
+ }
+
+ /* ===================================== TESTS FOR 'DELETE' ====================================== */
+
+ public void testDeleteResourceProperty()
+ throws XmlException
+ {
+ m_resourceContext = new SushiResourceContext();
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( m_resourceContext );
DeleteDocument deleteDoc = DeleteDocument.Factory.newInstance();
DeleteType deleteType = deleteDoc.addNewDelete();
- deleteType.setResourceProperty(SushiPropertyQNames.IKA);
-
- set_provider.deleteResourceProperty(deleteType);
- GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(context, SushiPropertyQNames.OHTORO);
+ deleteType.setResourceProperty( SushiPropertyQNames.OHTORO );
+ set_provider.deleteResourceProperty( deleteType );
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty( SushiPropertyQNames.OHTORO );
+ assertNotNull( getResourcePropertyResponse );
+ }
- assertNotNull(getResourcePropertyResponse);
- assertTrue(callback.isDeleteInvoked());
+ public void testDeleteOpenContent() throws IOException, XmlException
+ {
+ //initResourcePropsDoc();
+ m_resourceContext = new SushiResourceContext( true );
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( m_resourceContext );
+ DeleteDocument deleteDoc = DeleteDocument.Factory.newInstance();
+ DeleteType deleteType = deleteDoc.addNewDelete();
+ deleteType.setResourceProperty( SushiPropertyQNames.FUGU );
+ set_provider.deleteResourceProperty( deleteType );
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty( SushiPropertyQNames.OHTORO );
+ //todo better way to validate
+ assertNotNull( getResourcePropertyResponse );
}
- public void testInsertResourceProperty()
- throws XmlException
+ public void testDeleteResourcePropertiesCallback() throws ResourceException, ResourceContextException, XmlException
{
- SushiResourceContext context = new SushiResourceContext();
- SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider(context);
+ m_resourceContext = new SushiResourceContext();
+ //build callback obj
+ SushiPlate plate = new SushiPlate();
+ SushiCallback callback = new SushiCallback( plate );
+
+ //insert a prop
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( m_resourceContext );
InsertDocument insertDoc = InsertDocument.Factory.newInstance();
InsertType insertType = insertDoc.addNewInsert();
XmlObject xmlObject =
- XmlObject.Factory.parse("<foo:Ebi xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
- + "my favorite!" + "</foo:Ebi>");
- XmlBeanUtils.addChildElement(insertType, xmlObject);
-
- set_provider.insertResourceProperty(insertType);
- GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(context, SushiPropertyQNames.EBI);
-
- assertNotNull(getResourcePropertyResponse);
- XmlObject[] childElements = XmlBeanUtils.getChildElements(getResourcePropertyResponse, SushiPropertyQNames.EBI);
- assertTrue(childElements.length == 2);
- }
+ XmlObject.Factory.parse( "<foo:Ika xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
+ + "my favorite!" + "</foo:Ika>" );
+ XmlBeanUtils.addChildElement( insertType, xmlObject );
+
+ set_provider.insertResourceProperty( insertType );
+
+ //setup callback on resource prop
+ SushiResource resource = (SushiResource) m_resourceContext.getResource();
+ ResourceProperty resourceProp = resource.getResourcePropertySet().get( SushiPropertyQNames.IKA );
+ resourceProp.setCallback( callback );
- public void testDeleteResourceProperty()
- throws XmlException
- {
- SushiResourceContext context = new SushiResourceContext();
- SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider(context);
DeleteDocument deleteDoc = DeleteDocument.Factory.newInstance();
DeleteType deleteType = deleteDoc.addNewDelete();
- deleteType.setResourceProperty(SushiPropertyQNames.OHTORO);
+ deleteType.setResourceProperty( SushiPropertyQNames.IKA );
- set_provider.deleteResourceProperty(deleteType);
- GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(context, SushiPropertyQNames.OHTORO);
+ set_provider.deleteResourceProperty( deleteType );
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty( SushiPropertyQNames.OHTORO );
- assertNotNull(getResourcePropertyResponse);
+ assertNotNull( getResourcePropertyResponse );
+ assertTrue( callback.isDeleteInvoked() );
}
+ /* ===================================== TESTS FOR 'UPDATE' ====================================== */
+
/**
* DOCUMENT_ME
*/
- public void testUpdateResourceProperty()
- throws XmlException
+ public void testUpdateResourcePropertiesCallback() throws ResourceException, ResourceContextException, XmlException
{
- String expectedValue = "thisisatest";
- SushiResourceContext context = new SushiResourceContext();
- SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider(context);
+ 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 );
+
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( m_resourceContext );
UpdateDocument updateDoc = UpdateDocument.Factory.newInstance();
UpdateType update = updateDoc.addNewUpdate();
XmlObject xmlObject =
- XmlObject.Factory.parse("<foo:Ebi xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
- + expectedValue + "</foo:Ebi>");
- XmlBeanUtils.addChildElement(update, xmlObject);
+ XmlObject.Factory.parse( "<foo:Ebi xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
+ + newValue + "</foo:Ebi>" );
+ XmlBeanUtils.addChildElement( update, xmlObject );
- set_provider.updateResourceProperty(updateDoc.getUpdate());
+ set_provider.updateResourceProperty( updateDoc.getUpdate() );
- verifyViaGet(context, expectedValue, SushiPropertyQNames.EBI);
+ assertPropHasOneElemWithGivenValue( SushiPropertyQNames.EBI, newValue );
+ assertTrue( callback.isUpdateInvoked() );
+ }
+
+ public void testUpdateOpenContent() throws XmlException
+ {
+ m_resourceContext = new SushiResourceContext( true );
+ insertXsdAnyPropElem();
+ assertPropHasOneElemWithGivenValue( SushiPropertyQNames.FUGU, INITIAL_PROP_VALUE_FUGU );
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( m_resourceContext );
+ UpdateDocument updateDoc = UpdateDocument.Factory.newInstance();
+ UpdateType update = updateDoc.addNewUpdate();
+ XmlObject anyXBean = createXsdAnyPropElem();
+ final String newValue = "yummy!";
+ XmlBeanUtils.setValue( anyXBean, newValue );
+ XmlBeanUtils.addChildElement( update, anyXBean );
+ set_provider.updateResourceProperty( updateDoc.getUpdate() );
+ assertPropHasOneElemWithGivenValue( SushiPropertyQNames.FUGU, newValue );
}
/**
* DOCUMENT_ME
- *
- * @throws Exception DOCUMENT_ME
*/
- protected void setUp()
- throws Exception
+ public void testUpdateResourceProperty()
+ throws XmlException
{
- initResourcePropsDoc();
- }
+ String newValue = "99";
+ m_resourceContext = new SushiResourceContext();
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( m_resourceContext );
+ UpdateDocument updateDoc = UpdateDocument.Factory.newInstance();
+ UpdateType update = updateDoc.addNewUpdate();
- private void verifyViaGet(SushiResourceContext context,
- String expectedVariable,
- QName nameToFind)
- {
- GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(context, nameToFind);
- XmlObject[] childElements =
- XmlBeanUtils.getChildElements(getResourcePropertyResponse, nameToFind);
- assertNotNull(childElements);
- String value = XmlBeanUtils.getValue(childElements[0]);
- assertEquals(expectedVariable,value );
- }
-
- private GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourceProperty(SushiResourceContext context, QName nameToFind)
- {
- GetResourcePropertyProvider get_provider = new GetResourcePropertyProvider(context);
- GetResourcePropertyDocument get_document = GetResourcePropertyDocument.Factory.newInstance();
- get_document.setGetResourceProperty(nameToFind);
- GetResourcePropertyResponseDocument resourceProperty =
- get_provider.getResourceProperty(get_document);
- GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse =
- resourceProperty.getGetResourcePropertyResponse();
- return getResourcePropertyResponse;
+ XmlObject xmlObject =
+ XmlObject.Factory.parse( "<foo:Ebi xmlns:foo=\"http://ws.apache.org/resource/properties/test/sushi\">"
+ + newValue + "</foo:Ebi>" );
+ XmlBeanUtils.addChildElement( update, xmlObject );
+
+ set_provider.updateResourceProperty( updateDoc.getUpdate() );
+
+ assertPropHasOneElemWithGivenValue( SushiPropertyQNames.EBI, newValue );
}
+
}
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=111559&p1=incubator/apollo/trunk/src/test/org/apache/ws/util/XmlBeanUtilsTestCase.java&r1=111558&p2=incubator/apollo/trunk/src/test/org/apache/ws/util/XmlBeanUtilsTestCase.java&r2=111559
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/util/XmlBeanUtilsTestCase.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/util/XmlBeanUtilsTestCase.java Fri Dec 10 16:21:40 2004
@@ -21,16 +21,18 @@
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlString;
+import javax.xml.namespace.QName;
+
/**
* Test case for {@link XmlBeanUtils}.
*
- * @author Ian P. Springer (Hewlett-Packard Company)
+ * @author Ian Springer
*/
public class XmlBeanUtilsTestCase
extends AbstractResourcePropertiesTestCase
{
- /** DOCUMENT_ME */
- XmlObject m_propsDoc;
+
+ private XmlObject m_propsDoc;
/**
* DOCUMENT_ME
@@ -52,10 +54,11 @@
public void testAddChildElement( )
throws Exception
{
- final String stringValue = "whatever";
- XmlObject xBean = XmlObject.Factory.parse( "<" + SushiPropertyQNames.EBI.getLocalPart() + " xmlns=\"" + SushiPropertyQNames.EBI.getNamespaceURI() + "\">" + stringValue + "</" + SushiPropertyQNames.EBI.getLocalPart() + ">" );
+ final QName elemName = SushiPropertyQNames.IKA;
+ final String elemValue = "whatever";
+ XmlObject xBean = XmlObject.Factory.parse( "<" + elemName.getLocalPart() + " xmlns=\"" + elemName.getNamespaceURI() + "\">" + elemValue + "</" + elemName.getLocalPart() + ">" );
XmlBeanUtils.addChildElement( m_propsDoc, xBean );
- XmlObject[] childElems = XmlBeanUtils.getChildElements( m_propsDoc, SushiPropertyQNames.EBI );
+ XmlObject[] childElems = XmlBeanUtils.getChildElements( m_propsDoc, elemName );
assertEquals( 2, childElems.length );
assertTrue( childElems[1] instanceof XmlString );
}
@@ -65,7 +68,7 @@
*/
public void testGetChildElements( )
{
- XmlObject[] childElems = XmlBeanUtils.getChildElements( m_propsDoc, SushiPropertyQNames.EBI );
+ XmlObject[] childElems = XmlBeanUtils.getChildElements( m_propsDoc, SushiPropertyQNames.IKA );
assertEquals( 1, childElems.length );
assertTrue( childElems[0] instanceof XmlString );
}
---------------------------------------------------------------------
To unsubscribe, e-mail: apollo-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: apollo-dev-help@ws.apache.org