Package org.apache.ws.resource.properties.v2004_06.porttype.impl

Source Code of org.apache.ws.resource.properties.v2004_06.porttype.impl.AbstractWsrpPortTypeImplTestCase

/*=============================================================================*
*  Copyright 2004 The Apache Software Foundation
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*=============================================================================*/
package org.apache.ws.resource.properties.v2004_06.porttype.impl;

import org.apache.ws.resource.properties.AbstractResourcePropertiesTestCase;
import org.apache.ws.util.XmlBeanUtils;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyResponseDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.InsertType;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.SetResourcePropertiesDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.UpdateType;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.DeleteType;

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 static final QName ANOTHER_BOGUS_PROP_NAME = new QName( "http://blah.com/", "EvenMoreBogus" );

    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
    {
        XmlObject anyXBean = createXsdAnyPropElem();
        insertResourceProperty( new XmlObject[] {anyXBean} );
    }

    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 )
    {
        GetResourcePropertyPortTypeImpl get_provider = new GetResourcePropertyPortTypeImpl( m_resourceContext );
        GetResourcePropertyDocument get_document = GetResourcePropertyDocument.Factory.newInstance();
        get_document.setGetResourceProperty( propName );
        GetResourcePropertyResponseDocument resourceProperty = get_provider.getResourceProperty( get_document );
        GetResourcePropertyResponseDocument.GetResourcePropertyResponse getResourcePropertyResponse =
                resourceProperty.getGetResourcePropertyResponse();
        return getResourcePropertyResponse;
    }

    protected void insertResourceProperty( XmlObject[] propElems )
    {
        SetResourcePropertiesPortTypeImpl setProvider = new SetResourcePropertiesPortTypeImpl( m_resourceContext );
        SetResourcePropertiesDocument setDocument = SetResourcePropertiesDocument.Factory.newInstance();
        SetResourcePropertiesDocument.SetResourceProperties setType = setDocument.addNewSetResourceProperties();
        InsertType insertType = setType.addNewInsert();
        for ( int i = 0; i < propElems.length; i++ )
        {
            XmlBeanUtils.addChildElement( insertType, propElems[i] );
        }

        setProvider.setResourceProperties( setDocument ).getSetResourcePropertiesResponse();

    }

    protected void updateResourceProperty( XmlObject[] propElems )
    {
        SetResourcePropertiesPortTypeImpl setProvider = new SetResourcePropertiesPortTypeImpl( m_resourceContext );
        SetResourcePropertiesDocument setDocument = SetResourcePropertiesDocument.Factory.newInstance();
        SetResourcePropertiesDocument.SetResourceProperties setType = setDocument.addNewSetResourceProperties();
        UpdateType updateType = setType.addNewUpdate();
        for ( int i = 0; i < propElems.length; i++ )
        {
            XmlBeanUtils.addChildElement( updateType, propElems[i] );
        }
        setProvider.setResourceProperties( setDocument ).getSetResourcePropertiesResponse();
    }

    protected void deleteResourceProperty( QName propName )
    {
        SetResourcePropertiesPortTypeImpl setProvider = new SetResourcePropertiesPortTypeImpl( m_resourceContext );
        SetResourcePropertiesDocument setDocument = SetResourcePropertiesDocument.Factory.newInstance();
        SetResourcePropertiesDocument.SetResourceProperties setType = setDocument.addNewSetResourceProperties();
        DeleteType deleteType = setType.addNewDelete();
        deleteType.setResourceProperty( propName );       
        setProvider.setResourceProperties( setDocument ).getSetResourcePropertiesResponse();
    }

}
TOP

Related Classes of org.apache.ws.resource.properties.v2004_06.porttype.impl.AbstractWsrpPortTypeImplTestCase

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.