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 06:57:33 UTC
svn commit: r111468 - in incubator/apollo/trunk/src/test/org/apache/ws/resource/properties: . porttype/impl
Author: ips
Date: Thu Dec 9 21:57:32 2004
New Revision: 111468
URL: http://svn.apache.org/viewcvs?view=rev&rev=111468
Log:
refactored
Modified:
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.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/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=111468&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java&r1=111467&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java&r2=111468
==============================================================================
--- 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 21:57:32 2004
@@ -20,6 +20,7 @@
import org.apache.ws.util.IoUtils;
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;
@@ -109,5 +110,14 @@
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/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=111468&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java&r1=111467&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/GetMultipleResourcePropertiesProviderTestCase.java&r2=111468
==============================================================================
--- 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 Thu Dec 9 21:57:32 2004
@@ -71,7 +71,7 @@
protected void setUp( )
throws Exception
{
- initResourcePropsDoc( );
+ //initResourcePropsDoc( );
}
/**
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=111468&p1=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java&r1=111467&p2=incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/porttype/impl/OpenContentHandlingTestCase.java&r2=111468
==============================================================================
--- 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 21:57:32 2004
@@ -1,3 +1,18 @@
+/*=============================================================================*
+ * 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;
@@ -8,7 +23,6 @@
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;
@@ -26,56 +40,26 @@
/**
* @author Sal Campana
+ * @author Ian Springer
*/
public class OpenContentHandlingTestCase extends AbstractResourcePropertiesTestCase
{
+ SushiResourceContext m_resourceContext;
public void testInsertAnyIntoOpenContent() throws XmlException
{
- SushiResourceContext context = new SushiResourceContext( true );
- insertFugu( context );
- }
-
- private void insertFugu( SushiResourceContext context )
- throws XmlException
- {
- SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( context );
- InsertDocument insertDoc = InsertDocument.Factory.newInstance();
- InsertType insertType = insertDoc.addNewInsert();
-
- XmlObject anyXBean = createFuguAnyXBean();
- XmlBeanUtils.addChildElement( insertType, anyXBean );
-
- 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 createFuguAnyXBean()
- 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;
+ m_resourceContext = new SushiResourceContext( true );
+ insertFuguPropElem();
+ assertContainsOneFuguPropElem();
}
public void testInsertAnyIntoNonOpenContent() throws Exception
{
- AbstractResourcePropertiesTestCase.compileSushiPropsXsd();
- SushiResourceContext context = new SushiResourceContext( false );
- SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( context );
- InsertDocument insertDoc = InsertDocument.Factory.newInstance();
- InsertType insertType = insertDoc.addNewInsert();
- XmlObject anyXBean = createFuguAnyXBean();
- XmlBeanUtils.addChildElement( insertType, anyXBean );
+ m_resourceContext = new SushiResourceContext( false );
try
{
- set_provider.insertResourceProperty( insertType );
+ insertFuguPropElem();
fail();
}
catch ( InvalidResourcePropertyQNameFaultException expectedFault )
@@ -86,13 +70,11 @@
public void testQueryOpenContent() throws XmlException
{
- //insert to be able to query
-
- SushiResourceContext context = new SushiResourceContext( true );
- insertFugu( context );
- //build provider and invoke
+ m_resourceContext = new SushiResourceContext( true );
+ insertFuguPropElem();
+ assertContainsOneFuguPropElem();
QueryResourcePropertiesProvider provider =
- new QueryResourcePropertiesProvider( context );
+ new QueryResourcePropertiesProvider( m_resourceContext );
QueryResourcePropertiesDocument doc =
QueryResourcePropertiesDocument.Factory.newInstance();
@@ -108,41 +90,60 @@
provider.queryResourceProperties( doc );
QueryResourcePropertiesResponseDocument.QueryResourcePropertiesResponse queryResourcePropertiesResponse =
queryResourcePropertiesResponseDocument.getQueryResourcePropertiesResponse();
-
- XmlObject[] childElements =
+ XmlObject[] fuguPropElems =
XmlBeanUtils.getChildElements( queryResourcePropertiesResponse, SushiPropertyQNames.FUGU );
- assertNotNull( childElements );
- assertTrue( childElements.length == 1 );
+ assertNotNull( fuguPropElems );
+ assertEquals( 1, fuguPropElems.length );
}
public void testUpdateOpenContent() throws XmlException
{
- SushiResourceContext context = new SushiResourceContext( true );
- insertFugu( context );
- SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( context );
+ m_resourceContext = new SushiResourceContext( true );
+ insertFuguPropElem();
+ assertContainsOneFuguPropElem();
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( m_resourceContext );
UpdateDocument updateDoc = UpdateDocument.Factory.newInstance();
UpdateType update = updateDoc.addNewUpdate();
- XmlObject anyXBean = createFuguAnyXBean();
+ XmlObject anyXBean = createAnyXBean();
final String newValue = "yummy!";
XmlBeanUtils.setValue( anyXBean, newValue );
XmlBeanUtils.addChildElement( update, anyXBean );
set_provider.updateResourceProperty( updateDoc.getUpdate() );
- verifyViaGet( context, newValue, SushiPropertyQNames.FUGU );
+ verifyViaGet( m_resourceContext, newValue, SushiPropertyQNames.FUGU );
}
public void testDeleteOpenContent() throws IOException, XmlException
{
initResourcePropsDoc();
- SushiResourceContext context = new SushiResourceContext( true );
- SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( context );
+ 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( context, SushiPropertyQNames.OHTORO );
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty( m_resourceContext, SushiPropertyQNames.OHTORO );
//todo better way to validate
assertNotNull( getResourcePropertyResponse );
+ }
+
+ private void insertFuguPropElem()
+ throws XmlException
+ {
+ SetResourcePropertiesProvider set_provider = new SetResourcePropertiesProvider( m_resourceContext );
+ InsertDocument insertDoc = InsertDocument.Factory.newInstance();
+ InsertType insertType = insertDoc.addNewInsert();
+ XmlObject anyXBean = createAnyXBean();
+ XmlBeanUtils.addChildElement( insertType, anyXBean );
+ set_provider.insertResourceProperty( insertType );
+ }
+
+ private void assertContainsOneFuguPropElem()
+ {
+ GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse = getResourceProperty( m_resourceContext, SushiPropertyQNames.FUGU );
+ assertNotNull( getResourcePropertyResponse );
+ XmlObject[] fuguPropElems = XmlBeanUtils.getChildElements( getResourcePropertyResponse, SushiPropertyQNames.FUGU );
+ assertNotNull( fuguPropElems );
+ assertEquals( 1, fuguPropElems.length );
}
private void verifyViaGet( SushiResourceContext context,
---------------------------------------------------------------------
To unsubscribe, e-mail: apollo-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: apollo-dev-help@ws.apache.org