You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrf-dev@ws.apache.org by sc...@apache.org on 2004/12/09 23:29:29 UTC
svn commit: r111440 - in incubator/apollo/trunk/src/test/org/apache/ws/resource/properties: . porttype/impl
Author: scamp
Date: Thu Dec 9 14:29:27 2004
New Revision: 111440
URL: http://svn.apache.org/viewcvs?view=rev&rev=111440
Log:
added tests
Added:
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties-NonOpen.xsd
Modified:
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/SushiPropertyQNames.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiResourceContext.java
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java
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=111440&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java&r1=111439&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java&r2=111440
==============================================================================
--- 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 14:29:27 2004
@@ -39,7 +39,9 @@
public class AbstractResourcePropertiesTestCase extends TestCase
{
- protected static final String RESOURCE_PATH_SUSHI_PROPS_XSD = "org/apache/ws/resource/properties/SushiProperties.xsd";
+
+
+ protected static 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" ) );
@@ -108,4 +110,8 @@
CLASSES_DIR.mkdirs(); // necessary?
return SchemaCompiler.compile( scompParams );
}
+ public static void setResourcePathPropsXsd(String xsd)
+ {
+ RESOURCE_PATH_SUSHI_PROPS_XSD = xsd;
+ }
}
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=111440&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiHome.java&r1=111439&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiHome.java&r2=111440
==============================================================================
--- 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 14:29:27 2004
@@ -38,8 +38,10 @@
implements ResourceFactory,
Serializable
{
- /** DOCUMENT_ME */
- protected static final String RESOURCE_PROPS_RESOURCE_PATH =
+
+
+ /** DOCUMENT_ME */
+ protected static String RESOURCE_PROPS_RESOURCE_PATH =
"org/apache/ws/resource/properties/SushiProperties.xml";
public SushiHome()
@@ -108,4 +110,9 @@
add( key, resource );
return resource;
}
+
+ public void setResourcePropsDocPath(String propsDoc)
+ {
+ SushiHome.RESOURCE_PROPS_RESOURCE_PATH = propsDoc;
+ }
}
Added: 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=111440
==============================================================================
--- (empty file)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiProperties-NonOpen.xsd Thu Dec 9 14:29:27 2004
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+
+<schema elementFormDefault="qualified"
+ targetNamespace="http://ws.apache.org/resource/properties/test/sushi2"
+ xmlns:wsrl="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd"
+ xmlns:tns="http://ws.apache.org/resource/properties/test/sushi"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ 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"/>
+
+ <element name="Akagi" type="xsd:int"/>
+ <element name="Anago" type="xsd:integer"/>
+ <element name="Ebi" type="xsd:string"/>
+ <element name="Ika" type="xsd:string"/>
+ <element name="Uni" type="xsd:anyURI"/>
+ <element name="Hamachi">
+ <complexType>
+ <sequence>
+ <element name="Flavor" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="Ohtoro">
+ <complexType>
+ <sequence>
+ <element name="Flavor" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Resource properties document schema -->
+ <element name="SushiProperties">
+ <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" />
+
+ </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>
+
+</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=111440&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiPropertyQNames.java&r1=111439&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiPropertyQNames.java&r2=111440
==============================================================================
--- 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 14:29:27 2004
@@ -39,4 +39,7 @@
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=111440&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiResourceContext.java&r1=111439&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/SushiResourceContext.java&r2=111440
==============================================================================
--- 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 14:29:27 2004
@@ -58,6 +58,31 @@
}
+ /**
+ * Creates a new {@link AbstractResourceContext} object.
+ *
+ * @param soapMsgContext DOCUMENT_ME
+ */
+ public SushiResourceContext(String pathToPropsXsd)
+ {
+
+ try
+ {
+ ((SushiHome)m_home).setResourcePropsDocPath(pathToPropsXsd);
+ ((SushiHome)m_home).getInstance(this);
+ m_resource = m_home.find(this.m_key);
+ }
+ catch (ResourceException e)
+ {
+ e.printStackTrace();
+ }
+ catch (ResourceContextException e)
+ {
+ e.printStackTrace();
+ }
+
+ }
+
public synchronized ResourceHome getResourceHome() throws ResourceContextException
{
return m_home;
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=111440&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java&r1=111439&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java&r2=111440
==============================================================================
--- 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 14:29:27 2004
@@ -1,12 +1,27 @@
package org.apache.ws.resource.properties.porttype.impl;
-import org.apache.ws.resource.properties.SushiResourceContext;
import org.apache.ws.resource.properties.AbstractResourcePropertiesTestCase;
+import org.apache.ws.resource.properties.SushiPropertyQNames;
+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.apache.xmlbeans.XmlOptions;
+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.QueryExpressionType;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.QueryResourcePropertiesDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.QueryResourcePropertiesResponseDocument;
+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;
/**
@@ -14,32 +29,131 @@
*/
public class OpenContentHandlingTestCase extends AbstractResourcePropertiesTestCase
{
- public void testInsertAnyIntoOpenContent()
+ 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);
+
+
}
- public void testInsertAnyIntoNonOpenContent()
+ private void insertFugu(SushiResourceContext context)
+ throws XmlException
{
+ 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);
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(context, SushiPropertyQNames.FUGU);
+
+ assertNotNull(getResourcePropertyResponse);
+ XmlObject[] childElements = XmlBeanUtils.getChildElements(getResourcePropertyResponse, SushiPropertyQNames.FUGU);
+ assertTrue(childElements.length == 1);
+ }
+
+ private XmlObject getFuguAnyType()
+ 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;
}
- public void testQueryOpenContent()
+ 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);
+ InsertDocument insertDoc = InsertDocument.Factory.newInstance();
+ InsertType insertType = insertDoc.addNewInsert();
+
+ XmlObject xmlObject = getFuguAnyType();
+ XmlBeanUtils.addChildElement(insertType, xmlObject);
+
+ set_provider.insertResourceProperty(insertType);
+ //todo expect fault!
+
}
- public void testUpdateOpenContent()
+ public void testQueryOpenContent() throws XmlException
{
+ //insert to be able to query
+
+ SushiResourceContext context =
+ new SushiResourceContext();
+ insertFugu(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();
+ XmlObject[] childElements =
+ XmlBeanUtils.getChildElements(queryResourcePropertiesResponse, SushiPropertyQNames.FUGU);
+ assertNotNull(childElements);
+ assertTrue(childElements.length == 1);
}
- public void testDeleteOpenContent()
+ public void testUpdateOpenContent() throws XmlException
{
+ //add field
+ SushiResourceContext context = new SushiResourceContext();
+ 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);
}
- private void verifyViaGet(SushiResourceContext context,
+ public void testDeleteOpenContent() throws IOException, XmlException
+ {
+ initResourcePropsDoc();
+ SushiResourceContext context = new SushiResourceContext();
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider(context);
+ DeleteDocument deleteDoc = DeleteDocument.Factory.newInstance();
+ DeleteType deleteType = deleteDoc.addNewDelete();
+ deleteType.setResourceProperty(SushiPropertyQNames.FUGU);
+
+ set_provider.deleteResourceProperty(deleteType);
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty(context, SushiPropertyQNames.OHTORO);
+ //todo better way to validate
+ assertNotNull(getResourcePropertyResponse);
+ }
+
+ private void verifyViaGet(SushiResourceContext context,
String expectedVariable,
QName nameToFind)
{
@@ -48,6 +162,18 @@
XmlBeanUtils.getChildElements(getResourcePropertyResponse, nameToFind);
assertNotNull(childElements);
String value = XmlBeanUtils.getValue(childElements[0]);
- assertEquals(expectedVariable,value );
+ 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;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: apollo-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: apollo-dev-help@ws.apache.org