Search in sources :

Example 6 with ErrorReceiverFilter

use of com.sun.tools.ws.wscompile.ErrorReceiverFilter in project metro-jax-ws by eclipse-ee4j.

the class WSDLParserTest method createErrorReceiver.

private static ErrorReceiverFilter createErrorReceiver() {
    class Listener extends WsimportListener {

        ConsoleErrorReporter cer = new ConsoleErrorReporter(System.err);

        @Override
        public void generatedFile(String fileName) {
            message(fileName);
        }

        @Override
        public void message(String msg) {
            System.out.println(msg);
        }

        @Override
        public void error(SAXParseException exception) {
            cer.error(exception);
        }

        @Override
        public void fatalError(SAXParseException exception) {
            cer.fatalError(exception);
        }

        @Override
        public void warning(SAXParseException exception) {
            cer.warning(exception);
        }

        @Override
        public void debug(SAXParseException exception) {
            cer.debug(exception);
        }

        @Override
        public void info(SAXParseException exception) {
            cer.info(exception);
        }

        public void enableDebugging() {
            cer.enableDebugging();
        }
    }
    final Listener listener = new Listener();
    ErrorReceiverFilter errorReceiver = new ErrorReceiverFilter(listener) {

        public void info(SAXParseException exception) {
            super.info(exception);
        }

        public void warning(SAXParseException exception) {
            super.warning(exception);
        }

        @Override
        public void pollAbort() throws AbortException {
            if (listener.isCanceled()) {
                throw new AbortException();
            }
        }

        @Override
        public void debug(SAXParseException exception) {
            listener.debug(exception);
        }
    };
    return errorReceiver;
}
Also used : WsimportListener(com.sun.tools.ws.wscompile.WsimportListener) WsimportListener(com.sun.tools.ws.wscompile.WsimportListener) ErrorReceiverFilter(com.sun.tools.ws.wscompile.ErrorReceiverFilter) SAXParseException(org.xml.sax.SAXParseException) ConsoleErrorReporter(com.sun.tools.ws.processor.modeler.wsdl.ConsoleErrorReporter) AbortException(com.sun.tools.ws.wscompile.AbortException)

Example 7 with ErrorReceiverFilter

use of com.sun.tools.ws.wscompile.ErrorReceiverFilter in project metro-jax-ws by eclipse-ee4j.

the class WSDLParserTest method testParseSimple.

public void testParseSimple() throws Exception {
    final ErrorReceiverFilter errorReceiver = createErrorReceiver();
    final InputSource source = getResourceSource("simple.wsdl");
    final WsimportOptions options = new WsimportOptions();
    options.addWSDL(source);
    final WSDLParser instance = new WSDLParser(options, errorReceiver, null);
    final WSDLDocument wsdl = instance.parse();
    assertNotNull(wsdl);
    assertFalse(errorReceiver.hadError());
}
Also used : WSDLDocument(com.sun.tools.ws.wsdl.document.WSDLDocument) InputSource(org.xml.sax.InputSource) ErrorReceiverFilter(com.sun.tools.ws.wscompile.ErrorReceiverFilter) WsimportOptions(com.sun.tools.ws.wscompile.WsimportOptions) WSDLParser(com.sun.tools.ws.wsdl.parser.WSDLParser)

Example 8 with ErrorReceiverFilter

use of com.sun.tools.ws.wscompile.ErrorReceiverFilter in project metro-jax-ws by eclipse-ee4j.

the class WSDLParserTest method testParseUsingPolicy.

public void testParseUsingPolicy() throws Exception {
    final ErrorReceiverFilter errorReceiver = createErrorReceiver();
    final InputSource source = getResourceSource("usingpolicy.wsdl");
    final WsimportOptions options = new WsimportOptions();
    options.addWSDL(source);
    final WSDLParser instance = new WSDLParser(options, errorReceiver, null);
    final WSDLDocument wsdl = instance.parse();
    assertNotNull(wsdl);
    assertFalse(errorReceiver.hadError());
}
Also used : WSDLDocument(com.sun.tools.ws.wsdl.document.WSDLDocument) InputSource(org.xml.sax.InputSource) ErrorReceiverFilter(com.sun.tools.ws.wscompile.ErrorReceiverFilter) WsimportOptions(com.sun.tools.ws.wscompile.WsimportOptions) WSDLParser(com.sun.tools.ws.wsdl.parser.WSDLParser)

Aggregations

ErrorReceiverFilter (com.sun.tools.ws.wscompile.ErrorReceiverFilter)8 WsimportOptions (com.sun.tools.ws.wscompile.WsimportOptions)7 WSDLDocument (com.sun.tools.ws.wsdl.document.WSDLDocument)7 WSDLParser (com.sun.tools.ws.wsdl.parser.WSDLParser)7 InputSource (org.xml.sax.InputSource)7 ConsoleErrorReporter (com.sun.tools.ws.processor.modeler.wsdl.ConsoleErrorReporter)1 AbortException (com.sun.tools.ws.wscompile.AbortException)1 WsimportListener (com.sun.tools.ws.wscompile.WsimportListener)1 SAXParseException (org.xml.sax.SAXParseException)1