Package com.volantis.xml.pipeline.sax

Examples of com.volantis.xml.pipeline.sax.XMLProcessTestable


     * @param saxHandler The SAX handler to incorporate into the XMLProcess.
     * @return An XMLProcess that forwards events to a SAXHandler.
     */
    public static XMLProcess
            createSAXHandlerProcess(final SAXHandler saxHandler) {
        XMLProcessTestable process = new XMLProcessTestable() {
            public void startElement(String namespaceURI, String localName,
                                     String qName, Attributes attrs)
                    throws SAXException {
                saxHandler.startElement(namespaceURI, localName,
                                        qName, attrs);
View Full Code Here


                          "xml:base",
                          "String",
                          baseURI.toExternalForm());
       
        // set the next process
        XMLProcessTestable next = new XMLProcessTestable();
        process.setNextProcess(next);
       
        // invoke the method that is being tested
        process.startElement(namespaceURI, localName, qName, atts);
       
        // get hold of the current base uri from the pipeline context
        URL currentBase =
                process.getPipeline().getPipelineContext().getCurrentBaseURI();
       
        // ensure that the XMLPipelineContext is updated with the new base
        assertEquals(
                "XMLPipelineContext should have had its base uri updated",
                baseURI,
                currentBase);

        AttributesImpl cloneAttrs = new AttributesImpl(atts);
                int index = cloneAttrs.
                        getIndex(NamespaceSupport.XMLNS, "base");
                cloneAttrs.removeAttribute(index);

        // ensure that the event is forwarded to the next process
        next.assertStartElementInvoked(namespaceURI, localName, qName, cloneAttrs);
    }
View Full Code Here

        String localName = "localName";
        String namespaceURI = "";
        String qName = localName;               
       
        // set the next process
        XMLProcessTestable next = new XMLProcessTestable();
        process.setNextProcess(next);
       
        // invoke the method that is being tested
        process.endElement(namespaceURI, localName, qName);
       
        // retrieve the current base
        URL base =
                process.getPipeline().getPipelineContext().getCurrentBaseURI();
        // ensure that the base uri is null
        assertNull("XMLPipelineContext should have had its base uri popped",
                   base);
       
        // ensure that the event is forwarded to the next process
        next.assertEndElementInvoked(namespaceURI, localName, qName);
    }
View Full Code Here

       
        // update the locator with the location
        locator.setSystemId(baseURI.toExternalForm());
       
        // set the next process
        XMLProcessTestable next = new XMLProcessTestable();
        process.setNextProcess(next);
       
        // invoke the method that is being tested
        process.setDocumentLocator(locator);       
        process.startDocument();
       
        // get hold of the current base uri from the pipeline context
        URL currentBase =
                process.getPipeline().getPipelineContext().getCurrentBaseURI();
       
        // ensure that the XMLPipelineContext is updated with the new base
        assertEquals(
                "XMLPipelineContext should have had its base uri updated",
                baseURI,
                currentBase);
       
        // get hold of the current locator from the pipeline context
        Locator currentLocator =
                process.getPipeline().getPipelineContext().getCurrentLocator();
       
        // ensure that the XMLPipelineContexts stack of locators is updated
        assertSame(
                "XMLPipelineContext should have the current locator updated",
                locator,
                currentLocator);
       
        // ensure that the event is forwarded to the next process
        next.assertSetDocumentLocatorNotInvoked();
    }
View Full Code Here

       
        // update the locator with the location
        locator.setSystemId(baseURI.toExternalForm());
       
        // set the next process
        XMLProcessTestable next = new XMLProcessTestable();
        process.setNextProcess(next);
               
        // call setDocumentLocator()
        process.setDocumentLocator(locator);
        process.startDocument();
       
        // get hold of the pipeline context
        XMLPipelineContext context
                = process.getPipeline().getPipelineContext();
       
        // ensure that the XMLPipelineContext has a current locator and
        // base uri
        assertNotNull(
                "XMLPipelineContext should have a non null current locator",
                context.getCurrentLocator());

        assertNotNull(
                "XMLPipelineContext should have a non null current base URI",
                context.getCurrentBaseURI());
       
        // invoke the method that is being tested
        process.endDocument();
       
        // ensure that the pipeline context has had both the current locator
        // and base uri popped off.
        assertNull("endDocument should pop the current locator",
                   context.getCurrentLocator());

        assertNull("endDocument should pop the current base uri",
                   context.getCurrentBaseURI());
       
        // ensure that the event is not forwarded to the next process
        next.assertEndDocumentNotInvoked();
    }
View Full Code Here

        String prefix = "prefix";
        String namespace = "namespace";

        // set the next process
        XMLProcessTestable next = new XMLProcessTestable();
        process.setNextProcess(next);
       
        // invoke the method that is being tested
        process.startPrefixMapping(prefix, namespace);

        // get hold of the pipeline context
        XMLPipelineContext context
                = process.getPipeline().getPipelineContext();
       
        // ensure that the pipeline contexts NamespacePrefixTracker has
        // been updated       
        NamespacePrefixTracker tracker = context.getNamespacePrefixTracker();

        assertEquals("NamespacePrefixTracker was not updated with the " +
                     "startPrefixMapping event",
                     namespace,
                     tracker.getNamespaceURI(prefix));      
               
        // ensure the event was forwarded to the next process
        next.assertStartPrefixMappingInvoked(prefix, namespace);
    }
View Full Code Here

        String prefix = "prefix";
        String namespace = "namespace";

        // set the next process
        XMLProcessTestable next = new XMLProcessTestable();
        process.setNextProcess(next);

        // get hold of the pipeline context
        XMLPipelineContext context
                = process.getPipeline().getPipelineContext();
       
        // Update pipeline contexts NamespacePrefixTracker with a prefix
        // and namespace pair
        NamespacePrefixTracker tracker = context.getNamespacePrefixTracker();
        tracker.startPrefixMapping(prefix, namespace);

        assertEquals("NamespacePrefixTracker was not updated with the " +
                     "startPrefixMapping event",
                     namespace,
                     tracker.getNamespaceURI(prefix));      
                     
        // invoke the method that is being tested
        process.endPrefixMapping(prefix);
       
        // ensure that the NamespacePrefixTracker has been updated
        assertNull("NamespacePrefixTracker was not updated with the " +
                   "endPrefixMapping event",                   
                     tracker.getNamespaceURI(prefix));
       
        // ensure the event was forwarded to the next process
        next.assertEndPrefixMappingInvoked(prefix);
    }
View Full Code Here

     */
    public void testEndElementWithWrongProcess() throws Exception {
        // retrieve the pipeline
        XMLPipeline pipeline = dynamicProcess.getPipeline();
        // add the process to the head of the pipeline       
        pipeline.addHeadProcess(new XMLProcessTestable());
       
        // create an expanded name       
        ExpandedName eName = new ImmutableExpandedName("testNamespace",
                                                       "testLocalName");

        try {
            // call end element on the rule
            rule.endElement(dynamicProcess, eName, new XMLProcessTestable());
            fail("endElement did not throw an exception when attempting to " +
                 "remove a process that was not at the head of the pipeline");
        } catch (XMLPipelineException e) {
        }
    }
View Full Code Here

        // invoke the method being tested
        testable.characters(CH, START, LENGTH);
       
        // as in flow control mode ensure event was not forwarded to 
        // the next process
        XMLProcessTestable next =
                (XMLProcessTestable) testable.getNextProcess();
        next.assertCharactersNotInvoked();
    }
View Full Code Here

        // invoke the method being tested
        testable.endDocument();
       
        // as in flow control mode ensure event was not forwarded to 
        // the next process
        XMLProcessTestable next =
                (XMLProcessTestable) testable.getNextProcess();
        next.assertEndDocumentNotInvoked();
    }
View Full Code Here

TOP

Related Classes of com.volantis.xml.pipeline.sax.XMLProcessTestable

Copyright © 2018 www.massapicom. 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.