Package org.apache.pig.piggybank.evaluation.xml

Examples of org.apache.pig.piggybank.evaluation.xml.XPath


   
   
    //@Test --optional test
    public void testCacheBenefit() throws Exception{

        final XPath xpath = new XPath();
       
        //should be a live instance this time
        final Tuple tuple = TupleFactory.getInstance().newTuple(3);
       
        //cache on
View Full Code Here


public class XPathTest {

    @Test
    public void testExecTuple() throws Exception {

        final XPath xpath = new XPath();

        final Tuple tuple = mock(Tuple.class);

        when(tuple.get(0))
                .thenReturn(
                        "<book id=\"bk101\">"
                                + "<author>Gambardella, Matthew</author>"
                                + "<title>XML Developer's Guide</title>"
                                + "<genre>Computer</genre>"
                                + "<price>44.95</price>"
                                + "<publish_date>2000-10-01</publish_date>"
                                + "<description>An in-depth look at creating applications with XML.</description>"
                                + "</book>");

        when(tuple.size()).thenReturn(2);

        when(tuple.get(1)).thenReturn("book/author");
        assertEquals("Gambardella, Matthew", xpath.exec(tuple));

    }
View Full Code Here

    }

    @Test
    public void testRepeatingCallWithSameXml() throws Exception {

        final XPath xpath = new XPath();

        final Tuple tuple = mock(Tuple.class);

        when(tuple.get(0)).thenReturn(
                        "<book id=\"bk101\">"
                                + "<author>Gambardella, Matthew</author>"
                                + "<title>XML Developer's Guide</title>"
                                + "<genre>Computer</genre>"
                                + "<price>44.95</price>"
                                + "<publish_date>2000-10-01</publish_date>"
                                + "<description>An in-depth look at creating applications with XML.</description>"
                                + "</book>");

        when(tuple.size()).thenReturn(2);

        when(tuple.get(1)).thenReturn("book/author");
        assertEquals("Gambardella, Matthew", xpath.exec(tuple));
        assertNotEquals("Someone else", xpath.exec(tuple));

        when(tuple.get(1)).thenReturn("book/price");
        assertEquals("44.95", xpath.exec(tuple));
        assertNotEquals("00.00", xpath.exec(tuple));
    }
View Full Code Here

    }

    @Test
    public void testCacheFlag() throws Exception {
       
        final XPath xpath = new XPath();
       
        final Tuple tuple = mock(Tuple.class);
       
        when(tuple.get(0)).thenReturn(
                         "<book id=\"bk101\">" +
                          "<author>Gambardella, Matthew</author>" +
                      "<title>XML Developer's Guide</title>" +
                      "<genre>Computer</genre>" +
                      "<price>44.95</price>" +
                      "<publish_date>2000-10-01</publish_date>" +
                      "<description>An in-depth look at creating applications with XML.</description>" +
                        "</book>");

        when(tuple.size()).thenReturn(3);
       
        //cache on
        when(tuple.get(2)).thenReturn(true);
       
        when(tuple.get(1)).thenReturn("book/author");
        assertEquals("Gambardella, Matthew", xpath.exec(tuple));
        assertNotEquals("Someone else", xpath.exec(tuple));
       
        when(tuple.get(1)).thenReturn("book/price");
        assertEquals("44.95", xpath.exec(tuple));
        assertNotEquals("00.00", xpath.exec(tuple));
       
        //cache off
        when(tuple.get(2)).thenReturn(false);
       
        when(tuple.get(1)).thenReturn("book/author");
        assertEquals("Gambardella, Matthew", xpath.exec(tuple));
        assertNotEquals("Someone else", xpath.exec(tuple));
       
        when(tuple.get(1)).thenReturn("book/price");
        assertEquals("44.95", xpath.exec(tuple));
        assertNotEquals("00.00", xpath.exec(tuple));
               
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.piggybank.evaluation.xml.XPath

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.