FileDocCategorySizeDatePackage
WsdlDocumentFilterTest.javaAPI DocExample12332Tue May 29 16:57:38 BST 2007com.sun.xml.ws.policy.jaxws.xmlstreamwriter.documentfilter

WsdlDocumentFilterTest

public class WsdlDocumentFilterTest extends AbstractFilteringTest
author
Marek Potociar (marek.potociar at sun.com)

Fields Summary
private static final String[]
testPolicyResources
private static final String[]
testWsdlResources
private static final com.sun.xml.ws.api.server.SDDocumentFilter
filter
Constructors Summary
public WsdlDocumentFilterTest(String testName)

    
       
        super(testName);
    
Methods Summary
private voidreadAndWriteWsdl(java.lang.String wsdlName, java.io.StringWriter buffer, boolean filter)

        XMLStreamReader reader = null;
        XMLStreamWriter writer = null;
        try {
            reader = XMLInputFactory.newInstance().createXMLStreamReader(PolicyResourceLoader.getResourceStream("wsdl_filter/" + wsdlName + ".wsdl"));
            writer = XMLOutputFactory.newInstance().createXMLStreamWriter(buffer /*, "UTF-8"*/);
            //generate the WSDL with utf-8 encoding and XML version 1.0
            writer.writeStartDocument("UTF-8", "1.0");
            if (filter) {
                writer = new WsdlDocumentFilter().filter(null, writer);
            }
            
            new XMLStreamReaderToXMLStreamWriter().bridge(reader, writer);
            
            writer.writeEndDocument();
        } finally {
            if (writer != null) try {writer.close();} finally {
                if (reader != null) reader.close();
            }
        }
        
    
public voidtestCreateProxy()
Test of createProxy method, of class com.sun.xml.ws.policy.jaxws.documentfilter.FilteringXmlStreamWriterProxy.

        XMLStreamWriter result = openFilteredWriter(new StringWriter(), filter);
        
        assertNotNull(result);
    
public voidtestFilterPolicyExpression()

        performResourceBasedTest(testPolicyResources, "wsdl_filter/", ".xml", filter);
    
public voidtestFilterWSDL()

        for (String wsdlResource : testWsdlResources) {
            StringWriter filteredBuffer = new StringWriter();
            StringWriter unfilteredBuffer = new StringWriter();
            
            readAndWriteWsdl(wsdlResource, filteredBuffer, true);
            readAndWriteWsdl(wsdlResource + "_expected", unfilteredBuffer, false);
            
            System.out.println(filteredBuffer.toString());
            assertEquals(unfilteredBuffer.toString(), filteredBuffer.toString());
        }