Example usage for org.apache.commons.jxpath JXPathContext newContext

List of usage examples for org.apache.commons.jxpath JXPathContext newContext

Introduction

In this page you can find the example usage for org.apache.commons.jxpath JXPathContext newContext.

Prototype

public static JXPathContext newContext(Object contextBean) 

Source Link

Document

Creates a new JXPathContext with the specified object as the root node.

Usage

From source file:org.xchain.javassist.CommandEngineeringTest.java

@Test
public void testWrappingInnerExecute() throws Exception {
    Command command = getWrappingInnerCommand("org.xchain.javassist.InnerClassCommand");

    // create a context.
    JXPathContext context = JXPathContext.newContext(new Object());

    // execute the command
    command.execute(context);/* www.  j  a  va  2  s. co  m*/

    // assert that the namespace was defined while the command executed.
    assertEquals("The namespace returned was not correct.", (Object) "http://www.xchain.org/test",
            context.getValue("$namespace"));
    assertEquals("The namespace returned was not correct.", (Object) "http://www.xchain.org/test-inner",
            context.getValue("$inner-namespace"));
    assertEquals("The namespace returned was not correct.", (Object) "http://www.xchain.org/test-static-inner",
            context.getValue("$static-inner-namespace"));

    // assert that the namespace is no longer defined on the context.
    assertEquals("The namespace was still defined on the context.", (String) null,
            context.getNamespaceURI("test"));
}

From source file:org.xchain.namespaces.core.TestBrokenXPath.java

@Before
public void setUp() throws Exception {
    context = JXPathContext.newContext(new Object());
}

From source file:org.xchain.namespaces.core.TestChooseCommand.java

@Before
public void setUp() throws Exception {
    context = JXPathContext.newContext(new Object());
    context.getVariables().declareVariable("call-first-when", Boolean.FALSE);
    context.getVariables().declareVariable("call-second-when", Boolean.FALSE);
    context.getVariables().declareVariable("first-when-result", Boolean.FALSE);
    context.getVariables().declareVariable("second-when-result", Boolean.FALSE);
    context.getVariables().declareVariable("otherwise-result", Boolean.FALSE);
    context.registerNamespace(TEST_NAMESPACE, TEST_NAMESPACE_URI);
    context.getVariables().declareVariable(TEST_NAMESPACE + ":call-first-when", Boolean.FALSE);
    context.getVariables().declareVariable(TEST_NAMESPACE + ":call-second-when", Boolean.FALSE);
    context.getVariables().declareVariable(TEST_NAMESPACE + ":first-when-result", Boolean.FALSE);
    context.getVariables().declareVariable(TEST_NAMESPACE + ":second-when-result", Boolean.FALSE);
    context.getVariables().declareVariable(TEST_NAMESPACE + ":otherwise-result", Boolean.FALSE);
    context.registerNamespace(TEST_NAMESPACE, null);
    catalog = CatalogFactory.getInstance().getCatalog(CATALOG_URI);
    /**//from  www.j a v a 2 s . c om
        Map map = catalog.getCommandMap();
        for( Object key : map.keySet() ) {
          System.out.println("IF COMMAND KEY"+key);
        }
    **/
}

From source file:org.xchain.namespaces.core.TestCoreFunctions.java

@Before
public void setUp() throws Exception {
    contextBean = new ContextBean();
    context = JXPathContext.newContext(contextBean);
    catalog = CatalogFactory.getInstance().getCatalog(CATALOG_URI);
}

From source file:org.xchain.namespaces.core.TestEvalCommand.java

@Before
public void setUp() throws Exception {
    context = JXPathContext.newContext(new DataObject());
    ((ScopedQNameVariables) context.getVariables()).declareVariable("data-object", new DataObject());
    catalog = CatalogFactory.getInstance().getCatalog(CATALOG_URI);
}

From source file:org.xchain.namespaces.core.TestExecuteCommand.java

@Before
public void setUp() throws Exception {
    context = JXPathContext.newContext(new Object());

    // Declare the result to the initial value.
    context.getVariables().declareVariable(RESULT, RESULT_VALUE_INITIAL);

    catalog = CatalogFactory.getInstance().getCatalog(CATALOG_URI);
}

From source file:org.xchain.namespaces.core.TestFilter.java

@Before
public void setUp() throws Exception {
    context = JXPathContext.newContext(new Object());

    // Declare the result variables.
    context.getVariables().declareVariable(RESULT_VARIABLE, RESULT_INITIAL_VALUE);
    context.getVariables().declareVariable(FILTER_RESULT, FILTER_INITIAL_VALUE);

    catalog = CatalogFactory.getInstance().getCatalog(CATALOG_URI);
}

From source file:org.xchain.namespaces.core.TestFilterChooseCommand.java

@Before
public void setUp() throws Exception {
    context = JXPathContext.newContext(new Object());
    context.getVariables().declareVariable("call-first-when", Boolean.FALSE);
    context.getVariables().declareVariable("call-second-when", Boolean.FALSE);
    context.getVariables().declareVariable("first-when-result", Boolean.FALSE);
    context.getVariables().declareVariable("second-when-result", Boolean.FALSE);
    context.getVariables().declareVariable("otherwise-result", Boolean.FALSE);
    context.registerNamespace(TEST_NAMESPACE, TEST_NAMESPACE_URI);
    context.getVariables().declareVariable(TEST_NAMESPACE + ":call-first-when", Boolean.FALSE);
    context.getVariables().declareVariable(TEST_NAMESPACE + ":call-second-when", Boolean.FALSE);
    context.getVariables().declareVariable(TEST_NAMESPACE + ":first-when-result", Boolean.FALSE);
    context.getVariables().declareVariable(TEST_NAMESPACE + ":second-when-result", Boolean.FALSE);
    context.getVariables().declareVariable(TEST_NAMESPACE + ":otherwise-result", Boolean.FALSE);
    context.registerNamespace(TEST_NAMESPACE, null);
    catalog = CatalogFactory.getInstance().getCatalog(CATALOG_URI);

    /**/* www  .  j  av  a 2 s. co m*/
        Map map = catalog.getCommandMap();
        for( Object key : map.keySet() ) {
          System.out.println("IF COMMAND KEY"+key);
        }
    **/
}

From source file:org.xchain.namespaces.core.TestForEachCommand.java

@Before
public void setUp() throws Exception {
    Node rootNode = new Node("root");
    Node childNode = new Node("child");
    rootNode.getChildList().add(childNode);

    context = JXPathContext.newContext(rootNode);
    // Initialize the count variable to zero.
    context.getVariables().declareVariable(COUNT_VARIABLE, 0);

    catalog = CatalogFactory.getInstance().getCatalog(CATALOG_URI);
}

From source file:org.xchain.namespaces.core.TestIfCommand.java

@Before
public void setUp() throws Exception {
    context = JXPathContext.newContext(new Object());
    context.getVariables().declareVariable("result", Boolean.FALSE);
    catalog = CatalogFactory.getInstance().getCatalog(CATALOG_URI);

    /**//from w w  w .j  a v a 2  s  .c  om
        Map map = catalog.getCommandMap();
        for( Object key : map.keySet() ) {
          System.out.println("IF COMMAND KEY"+key);
        }
    **/
}