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

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

Introduction

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

Prototype

public abstract Object getValue(String xpath);

Source Link

Document

Evaluates the xpath and returns the resulting object.

Usage

From source file:org.chiba.xml.xforms.ui.OutputTest.java

/**
 * Tests output with an ui binding and a value expression.
 *
 * @throws Exception if any error occurred during the test.
 *//*  w  w  w.j a  va2s  .  c  o m*/
public void testUIBindingPrecedence() throws Exception {
    Output output = (Output) this.chibaBean.getContainer().lookup("output-ui-binding-precedence");
    JXPathContext context = this.chibaBean.getContainer().getRootContext();
    assertEquals("1", context.getValue("//xf:output[@id='output-ui-binding-precedence']/chiba:data"));
    assertEquals("string",
            context.getValue("//xf:output[@id='output-ui-binding-precedence']/chiba:data/@chiba:type"));
    assertEquals("1", output.getValue());

    assertEquals(null, this.stateChangedListener.getId());
    assertEquals(null, this.stateChangedListener.getPropertyNames());
}

From source file:org.chiba.xml.xforms.ui.OutputTest.java

/**
 * Tests output with a model binding and a value expression.
 *
 * @throws Exception if any error occurred during the test.
 *//*from w ww .j  av a2 s  .c  om*/
public void testModelBindingPrecedence() throws Exception {
    Output output = (Output) this.chibaBean.getContainer().lookup("output-model-binding-precedence");
    JXPathContext context = this.chibaBean.getContainer().getRootContext();
    assertEquals("2", context.getValue("//xf:output[@id='output-model-binding-precedence']/chiba:data"));
    assertEquals("string",
            context.getValue("//xf:output[@id='output-model-binding-precedence']/chiba:data/@chiba:type"));
    assertEquals("2", output.getValue());

    assertEquals(null, this.stateChangedListener.getId());
    assertEquals(null, this.stateChangedListener.getPropertyNames());
}

From source file:org.chiba.xml.xforms.ui.OutputTest.java

/**
 * Tests output with neither a binding nor a value expression.
 *
 * @throws Exception if any error occurred during the test.
 *//*ww  w. ja  v  a  2 s.  com*/
public void testUnspecified() throws Exception {
    Output output = (Output) this.chibaBean.getContainer().lookup("output-unspecified");
    JXPathContext context = this.chibaBean.getContainer().getRootContext();
    assertEquals(new Double(0), context.getValue("count(//xf:output[@id='output-unspecified']/chiba:data)"));
    assertEquals(null, output.getValue());

    assertEquals(null, this.stateChangedListener.getId());
    assertEquals(null, this.stateChangedListener.getPropertyNames());
}

From source file:org.chiba.xml.xforms.ui.RangeTest.java

/**
 * Tests range bound to integer./*from  w  w  w .  j  ava 2  s. co  m*/
 *
 * @throws Exception if any error occurred during the test.
 */
public void testInteger() throws Exception {
    JXPathContext context = this.chibaBean.getContainer().getRootContext();

    assertEquals("-2", context.getValue("//xf:range[@id='range-1']/@start"));
    assertEquals("2", context.getValue("//xf:range[@id='range-1']/@end"));
    assertEquals("1", context.getValue("//xf:range[@id='range-1']/@step"));
}

From source file:org.chiba.xml.xforms.ui.RangeTest.java

/**
 * Tests range bound to integer./*from w  w  w  .j  a v  a  2s. c om*/
 *
 * @throws Exception if any error occurred during the test.
 */
public void testIntegerDefaults() throws Exception {
    JXPathContext context = this.chibaBean.getContainer().getRootContext();

    assertEquals("-2", context.getValue("//xf:range[@id='range-2']/@start"));
    assertEquals("2", context.getValue("//xf:range[@id='range-2']/@end"));
    assertEquals("1", context.getValue("//xf:range[@id='range-2']/@step"));
}

From source file:org.chiba.xml.xforms.ui.RangeTest.java

/**
 * Tests range bound to float./*from  w w  w  .j av  a 2s.  c  o m*/
 *
 * @throws Exception if any error occurred during the test.
 */
public void testFloat() throws Exception {
    JXPathContext context = this.chibaBean.getContainer().getRootContext();

    assertEquals("-2", context.getValue("//xf:range[@id='range-3']/@start"));
    assertEquals("2", context.getValue("//xf:range[@id='range-3']/@end"));
    assertEquals("1", context.getValue("//xf:range[@id='range-3']/@step"));
}

From source file:org.chiba.xml.xforms.ui.RangeTest.java

/**
 * Tests range bound to float.//from   ww  w. j  a v  a 2  s .  com
 *
 * @throws Exception if any error occurred during the test.
 */
public void testFloatDefaults() throws Exception {
    JXPathContext context = this.chibaBean.getContainer().getRootContext();

    assertEquals("-2", context.getValue("//xf:range[@id='range-4']/@start"));
    assertEquals("2", context.getValue("//xf:range[@id='range-4']/@end"));
    assertEquals("1", context.getValue("//xf:range[@id='range-4']/@step"));
}

From source file:org.chiba.xml.xforms.ui.RangeTest.java

/**
 * Tests range bound to double.//from   w ww .  jav  a2  s. c o m
 *
 * @throws Exception if any error occurred during the test.
 */
public void testDouble() throws Exception {
    JXPathContext context = this.chibaBean.getContainer().getRootContext();

    assertEquals("-2", context.getValue("//xf:range[@id='range-5']/@start"));
    assertEquals("2", context.getValue("//xf:range[@id='range-5']/@end"));
    assertEquals("1", context.getValue("//xf:range[@id='range-5']/@step"));
}

From source file:org.chiba.xml.xforms.ui.RangeTest.java

/**
 * Tests range bound to double./* w  ww  .  j  a v a 2s  .  c o  m*/
 *
 * @throws Exception if any error occurred during the test.
 */
public void testDoubleDefaults() throws Exception {
    JXPathContext context = this.chibaBean.getContainer().getRootContext();

    assertEquals("-2", context.getValue("//xf:range[@id='range-6']/@start"));
    assertEquals("2", context.getValue("//xf:range[@id='range-6']/@end"));
    assertEquals("1", context.getValue("//xf:range[@id='range-6']/@step"));
}

From source file:org.chiba.xml.xforms.ui.RepeatTest.java

/**
 * Tests index updating./*from   w  ww . j a va2 s . com*/
 *
 * @throws Exception if any error occurred during the test.
 */
public void testSetIndex() throws Exception {
    Repeat repeat = (Repeat) this.chibaBean.getContainer().lookup("repeat");
    register(repeat.getTarget());

    Output output = (Output) this.chibaBean.getContainer().lookup("selection");
    assertEquals("first", output.getValue());

    JXPathContext context = JXPathContext.newContext(repeat.getElement());
    assertEquals("1", context.getValue("chiba:data/@chiba:index"));

    this.chibaBean.dispatch("trigger-setindex", DOMEventNames.ACTIVATE);
    deregister(repeat.getTarget());

    assertEquals(3, repeat.getIndex());
    assertEquals(3, repeat.getContextSize());
    assertEquals("last", output.getValue());
    assertEquals("3", context.getValue("chiba:data/@chiba:index"));

    assertItemInserted(null, null, null);
    assertItemDeleted(null, null, null);
    assertIndexChanged("repeat", "repeat", "3");
    assertStateChanged(null, null);
}