Examples of XMLContext


Examples of org.teiid.query.processor.xml.XMLContext

    }   
   
       
    public void testGetCurrentRows() throws Exception{
       
        XMLContext parentContext = new XMLContext();
        XMLContext childContext = new XMLContext(parentContext);
       
        List[] rows1 = new List[] {
             Arrays.asList( new Object[] { "Lamp", new Integer(5), null } ),         //$NON-NLS-1$
             Arrays.asList( new Object[] { "Screwdriver", new Integer(100), null } ),         //$NON-NLS-1$
             Arrays.asList( new Object[] { "Goat", new Integer(4), null } )         //$NON-NLS-1$
        };      
       
        List[] rows2 = new List[] {
             Arrays.asList( new Object[] { "Lamp2", new Integer(54), null } ),         //$NON-NLS-1$
             Arrays.asList( new Object[] { "Screwdriver2", new Integer(1000), null } ),         //$NON-NLS-1$
             Arrays.asList( new Object[] { "Goat2", new Integer(43), null } )         //$NON-NLS-1$
        };      
        String results1= "resultsOne"; //$NON-NLS-1$
        String results2= "resultsTwo"; //$NON-NLS-1$
       
        FakePlanExecutor executor = new FakePlanExecutor(results1, rows1);
        parentContext.setResultSet(results1, executor);
        parentContext.getNextRow(results1);

        executor = new FakePlanExecutor(results2, rows2);
        childContext.setResultSet(results2, executor);
        childContext.getNextRow(results2);

        // make sure parent context dos not have access to the child's results
        assertEquals(Arrays.asList( new Object[] { "Lamp", new Integer(5), null } ), parentContext.getCurrentRow(results1)); //$NON-NLS-1$
        try {
            parentContext.getCurrentRow(results2);
            fail("should fail to get child contexts results from parent.."); //$NON-NLS-1$
        } catch (TeiidComponentException e) {
        }
       
        // note that we only using the current context which is the "child"
        // here we should have access to both parent and child's reslt sets.
        assertEquals(Arrays.asList( new Object[] { "Lamp", new Integer(5), null } ), childContext.getCurrentRow(results1)); //$NON-NLS-1$
        assertEquals(Arrays.asList( new Object[] { "Lamp2", new Integer(54), null } ), childContext.getCurrentRow(results2)); //$NON-NLS-1$

        // move the child context result and make sure parent context result stays same
        childContext.getNextRow(results2);
        assertEquals(Arrays.asList( new Object[] { "Lamp", new Integer(5), null } ), childContext.getCurrentRow(results1)); //$NON-NLS-1$       
        assertEquals(Arrays.asList( new Object[] { "Screwdriver2", new Integer(1000), null } ), childContext.getCurrentRow(results2)); //$NON-NLS-1$       
    }    

Examples of org.teiid.query.processor.xml.XMLContext

        assertEquals(Arrays.asList( new Object[] { "Screwdriver2", new Integer(1000), null } ), childContext.getCurrentRow(results2)); //$NON-NLS-1$       
    }    
   
    public void testGetCurrentRowRecursive() throws Exception{
       
        XMLContext parentContext = new XMLContext();
        XMLContext childContext = new XMLContext(parentContext);
       
        List[] rows1 = new List[] {
             Arrays.asList( new Object[] { "Lamp", new Integer(5), null } ),         //$NON-NLS-1$
             Arrays.asList( new Object[] { "Screwdriver", new Integer(100), null } ),         //$NON-NLS-1$
             Arrays.asList( new Object[] { "Goat", new Integer(4), null } )         //$NON-NLS-1$
        };      
       
        List[] rows2 = new List[] {
             Arrays.asList( new Object[] { "Lamp2", new Integer(54), null } ),         //$NON-NLS-1$
             Arrays.asList( new Object[] { "Screwdriver2", new Integer(1000), null } ),         //$NON-NLS-1$
             Arrays.asList( new Object[] { "Goat2", new Integer(43), null } )         //$NON-NLS-1$
        };      
       
        FakePlanExecutor executor = new FakePlanExecutor(resultSetName, rows1);
        parentContext.setResultSet(resultSetName, executor);
        parentContext.getNextRow(resultSetName);

        // know here that 'FakeName' is a different result set for the recursive node
        // and you should be able to retrive rows using both 'FakeName' and realname
        executor = new FakePlanExecutor("FakeName", rows2); //$NON-NLS-1$
        childContext.setResultSet(resultSetName, executor);
        childContext.getNextRow(resultSetName);

        assertEquals(Arrays.asList( new Object[] { "Lamp", new Integer(5), null } ), parentContext.getCurrentRow(resultSetName)); //$NON-NLS-1$
        assertEquals(Arrays.asList( new Object[] { "Lamp2", new Integer(54), null } ), childContext.getCurrentRow(resultSetName)); //$NON-NLS-1$
    }   

Examples of org.teiid.query.processor.xml.XMLContext

        assertEquals(Arrays.asList( new Object[] { "Lamp", new Integer(5), null } ), parentContext.getCurrentRow(resultSetName)); //$NON-NLS-1$
        assertEquals(Arrays.asList( new Object[] { "Lamp2", new Integer(54), null } ), childContext.getCurrentRow(resultSetName)); //$NON-NLS-1$
    }   
   
    public void testGetReferenceValues() throws Exception {
        XMLContext context = new XMLContext();
        String FOO = "Foo"; //$NON-NLS-1$
        String BAR = "Bar"; //$NON-NLS-1$
       
        ElementSymbol X = new ElementSymbol("Foo.X"); //$NON-NLS-1$
        ElementSymbol Y = new ElementSymbol("Foo.Y"); //$NON-NLS-1$

        GroupSymbol Foo = new GroupSymbol(FOO);
        X.setGroupSymbol(Foo);
        Y.setGroupSymbol(Foo);

        ElementSymbol AX = new ElementSymbol("Bar.X"); //$NON-NLS-1$
        ElementSymbol AY = new ElementSymbol("Bar.Y"); //$NON-NLS-1$

        GroupSymbol Bar = new GroupSymbol(BAR);
        AX.setGroupSymbol(Bar);
        AY.setGroupSymbol(Bar);

        List fooSchema = Arrays.asList( new Object[] {X, Y});
        List barSchema = Arrays.asList( new Object[] {AX,AY});
       
        List[] fooRows = new List[] {
             Arrays.asList( new Object[] { "Lamp", new Integer(5)} ),         //$NON-NLS-1$
             Arrays.asList( new Object[] { "Screwdriver", new Integer(100)} ),         //$NON-NLS-1$
             Arrays.asList( new Object[] { "Goat", new Integer(4) } )         //$NON-NLS-1$
        };      
       
        List[] barRows = new List[] {
             Arrays.asList( new Object[] { "Lamp2", new Integer(54)} ),         //$NON-NLS-1$
             Arrays.asList( new Object[] { "Screwdriver2", new Integer(1000)} ),         //$NON-NLS-1$
             Arrays.asList( new Object[] { "Goat2", new Integer(43)} )         //$NON-NLS-1$
        };      
       
        FakePlanExecutor executorFoo = new FakePlanExecutor(FOO, fooSchema, fooRows);
        context.setResultSet(FOO, executorFoo);
        context.setVariableValues(FOO, context.getNextRow(FOO));
       
        XMLContext childContext = new XMLContext(context);
       
        FakePlanExecutor executorBar = new FakePlanExecutor(BAR, barSchema, barRows);
        childContext.setResultSet(FOO, executorBar);
        childContext.setVariableValues(FOO, childContext.getNextRow(FOO));
       
        // THIS is the TEST.. we need the Foo elements with Bar values
        Map referenceValues = childContext.getReferenceValues();
        assertEquals(2, referenceValues.size());
       
        assertEquals("Lamp2", referenceValues.get(X)); //$NON-NLS-1$
        assertEquals(new Integer(54), referenceValues.get(Y));
       
        // advance BAR and get new results for the references.
        childContext.setVariableValues(FOO, childContext.getNextRow(FOO));
        referenceValues = childContext.getReferenceValues();
        assertEquals("Screwdriver2", referenceValues.get(X)); //$NON-NLS-1$
        assertEquals(new Integer(1000), referenceValues.get(Y));
    }

Examples of org.teiid.query.processor.xml.XMLContext

     * Program.  Implicit in this test is that the program counter
     * is separate from the two occurances of the p1 instance.
     * @throws Exception
     */
    public void testGetCurrentInstruction() throws Exception {
        XMLContext context = new XMLContext();
        NoOpInstruction i1 = new NoOpInstruction();
        NoOpInstruction i2 = new NoOpInstruction();
        NoOpInstruction i3 = new NoOpInstruction();
        NoOpInstruction i4 = new NoOpInstruction();
        Program p1 = new Program();

Examples of org.teiid.query.processor.xml.XMLContext

     * Program.  Implicit in this test is that the program counter
     * is separate from the two occurances of the p1 instance.
     * @throws Exception
     */
    public void testGetCurrentInstruction2() throws Exception {
        XMLContext context = new XMLContext();
        NoOpInstruction i1 = new NoOpInstruction();
        NoOpInstruction i2 = new NoOpInstruction();
        NoOpInstruction i3 = new NoOpInstruction();
        NoOpInstruction i4 = new NoOpInstruction();
        Program p1 = new Program();

Examples of org.teiid.query.processor.xml.XMLContext

    /**
     * Test that doc instructions don't do anything while
     * recursion is going on.
     */
    public void testInitializeDocInstruction() throws Exception {
        XMLContext context = new XMLContext();
        Program p0 = new Program();
        InitializeDocumentInstruction i1 = new InitializeDocumentInstruction();
        Program p1 = new Program();
        p1.addInstruction(i1);

Examples of org.teiid.query.processor.xml.XMLContext

    /**
     * Test that doc instructions don't do anything while
     * recursion is going on.
     */
    public void testInitializeDocInstruction2() throws Exception {
        XMLContext context = new XMLContext();
        Program p0 = new Program();
        InitializeDocumentInstruction i1 = new InitializeDocumentInstruction();
        Program p1 = new Program();
        p1.addInstruction(i1);

TOP
Copyright © 2018 www.massapi.com. 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.