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

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

Introduction

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

Prototype

public JXPathContext getParentContext() 

Source Link

Document

Returns the parent context of this context or null.

Usage

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

@Test
public void testModify() throws Exception {
    // Declare the variable at the 'request' level.
    JXPathContext requestContext = context;
    // Dig up to the 'request' context.
    while (requestContext.getParentContext() != null)
        requestContext = requestContext.getParentContext();

    // Declare the variable.
    requestContext.getVariables().declareVariable(RESULT, "string1");

    // Get the command.
    Command command = catalog.getCommand(MODIFY_COMMAND);

    // execute the command.
    command.execute(context);// ww w . ja  va 2  s . co m

    // Get the result.
    String resultString = (String) context.getValue("$" + RESULT, String.class);

    assertEquals("The modification of a declared variable failed.", "string2", resultString);
}

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

@Test
public void testRequestModify() throws Exception {
    // Declare the variable at the 'request' level.
    JXPathContext requestContext = context;
    // Dig up to the 'request' context.
    while (requestContext.getParentContext() != null)
        requestContext = requestContext.getParentContext();

    // Declare the variable.
    requestContext.getVariables().declareVariable(RESULT, "string1");

    // Get the command.
    Command command = catalog.getCommand(REQUEST_MODIFY_COMMAND);

    // execute the command.
    command.execute(context);//from w w w  .  j  av a 2 s.c om

    // Get the result.
    String resultString = (String) context.getValue("$" + RESULT, String.class);

    assertEquals("The modification of a declared variable failed.", "string2", resultString);
}