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

Source Code of org.apache.ws.resource.properties.v1_2.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.v1_2.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.InsertDocument;
import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.InsertType;

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
    {
        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;
    }



}
TOP

Related Classes of org.apache.ws.resource.properties.v1_2.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.