Package org.mule.module.xml.transformer

Examples of org.mule.module.xml.transformer.JXPathExtractor


        getAndTestTransformer("domToXml", DomDocumentToXml.class);
    }

    public void testJXPathExtractor()
    {
        JXPathExtractor extractor = (JXPathExtractor) getAndTestTransformer("jxpathExtractor",
            JXPathExtractor.class);
        assertEquals("/expression", extractor.getExpression());
        assertFalse(extractor.isSingleResult());
        assertEquals(JXPathExtractor.OUTPUT_TYPE_VALUE, extractor.getOutputType());
       
        Map ns = extractor.getNamespaces();
        assertNotNull(ns);
       
        assertEquals("http://foo.com", ns.get("foo1"));
        assertEquals("http://foo.com", ns.get("foo2"));
    }
View Full Code Here


        getAndTestEndpointTransformer("ep1", DomDocumentToXml.class);
    }

    public void testJXPathExtractorOnEndpoint() throws MuleException
    {
        JXPathExtractor extractor = (JXPathExtractor) getAndTestEndpointTransformer("ep2",
            JXPathExtractor.class);
        assertEquals("/expression", extractor.getExpression());
        assertFalse(extractor.isSingleResult());
    }
View Full Code Here

        assertEquals("http://car.com", filter.getNamespaces().get("car"));
    }

    public void testJXPathExtractor() throws Exception
    {
        JXPathExtractor transformer = (JXPathExtractor) lookupTransformer("jxpath-extractor");
        assertNotNull(transformer.getNamespaces());
        assertEquals(6, transformer.getNamespaces().size());
        assertNotNull(transformer.getNamespaces().get("foo"));
        assertNotNull(transformer.getNamespaces().get("bar"));
    }
View Full Code Here

    protected static final String TEST_XML_SINGLE_RESULT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                                                           + "<root>" + "<node>value1</node>" + "</root>";

    public void testSingeResult() throws Exception
    {
        final JXPathExtractor extractor = createObject(JXPathExtractor.class);
        final String expression = "/root/node";
        extractor.setExpression(expression);
        // just make code coverage tools happy
        assertEquals("Wrong expression returned.", expression, extractor.getExpression());
        final Object objResult = extractor.transform(TEST_XML_SINGLE_RESULT);
        assertNotNull(objResult);
        String result = (String)objResult;
        assertEquals("Wrong value extracted.", "value1", result);
    }
View Full Code Here

        assertEquals("Wrong value extracted.", "value1", result);
    }

    public void testMultipleResults() throws Exception
    {
        JXPathExtractor extractor = createObject(JXPathExtractor.class);
        extractor.setExpression("/root/node");
        extractor.setSingleResult(false);
        final Object objResult = extractor.transform(TEST_XML_MULTI_RESULTS);
        assertNotNull(objResult);
        List results = (List)objResult;
        assertEquals("Wrong number of results returned.", 3, results.size());
        assertEquals("Wrong value returned.", "value1", results.get(0));
        assertEquals("Wrong value returned.", "value2", results.get(1));
View Full Code Here

        assertEquals("Wrong value returned.", "value3", results.get(2));
    }

    public void testMultipleResultsAsNode() throws Exception
    {
        JXPathExtractor extractor = createObject(JXPathExtractor.class);
        extractor.setExpression("/root/node");
        extractor.setSingleResult(false);
        extractor.setOutputType(JXPathExtractor.OUTPUT_TYPE_NODE);
       
        final Object objResult = extractor.transform(TEST_XML_MULTI_RESULTS);
        assertNotNull(objResult);
        List results = (List)objResult;
        assertEquals("Wrong number of results returned.", 3, results.size());
        assertTrue(results.get(0) instanceof Node);
    }
View Full Code Here

     * This xpath expression will internally have DefaultText returned, test there
     * are no ClassCastExceptions.
     */
    public void testMultipleResultsNested() throws Exception
    {
        JXPathExtractor extractor = createObject(JXPathExtractor.class);
        extractor.setExpression("/root/node[*]/*/text()");
        extractor.setSingleResult(false);
        final Object objResult = extractor.transform(TEST_XML_MULTI_NESTED_RESULTS);
        assertNotNull(objResult);
        List results = (List)objResult;
        assertEquals("Wrong number of results returned.", 4, results.size());
        assertEquals("Wrong value returned.", "val1", results.get(0));
        assertEquals("Wrong value returned.", "val2", results.get(1));
View Full Code Here

                                                           + "<root>" + "<node>value1</node>" + "</root>";

    @Test
    public void testSingeResult() throws Exception
    {
        final JXPathExtractor extractor = createObject(JXPathExtractor.class);
        final String expression = "/root/node";
        extractor.setExpression(expression);
        // just make code coverage tools happy
        assertEquals("Wrong expression returned.", expression, extractor.getExpression());
        final Object objResult = extractor.transform(TEST_XML_SINGLE_RESULT);
        assertNotNull(objResult);
        String result = (String)objResult;
        assertEquals("Wrong value extracted.", "value1", result);
    }
View Full Code Here

    }

    @Test
    public void testMultipleResults() throws Exception
    {
        JXPathExtractor extractor = createObject(JXPathExtractor.class);
        extractor.setExpression("/root/node");
        extractor.setSingleResult(false);
        final Object objResult = extractor.transform(TEST_XML_MULTI_RESULTS);
        assertNotNull(objResult);
        List results = (List)objResult;
        assertEquals("Wrong number of results returned.", 3, results.size());
        assertEquals("Wrong value returned.", "value1", results.get(0));
        assertEquals("Wrong value returned.", "value2", results.get(1));
View Full Code Here

    }

    @Test
    public void testMultipleResultsAsNode() throws Exception
    {
        JXPathExtractor extractor = createObject(JXPathExtractor.class);
        extractor.setExpression("/root/node");
        extractor.setSingleResult(false);
        extractor.setOutputType(JXPathExtractor.OUTPUT_TYPE_NODE);
       
        final Object objResult = extractor.transform(TEST_XML_MULTI_RESULTS);
        assertNotNull(objResult);
        List results = (List)objResult;
        assertEquals("Wrong number of results returned.", 3, results.size());
        assertTrue(results.get(0) instanceof Node);
    }
View Full Code Here

TOP

Related Classes of org.mule.module.xml.transformer.JXPathExtractor

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.