Example usage for org.dom4j Node getStringValue

List of usage examples for org.dom4j Node getStringValue

Introduction

In this page you can find the example usage for org.dom4j Node getStringValue.

Prototype

String getStringValue();

Source Link

Document

Returns the XPath string-value of this node.

Usage

From source file:org.mule.tooling.jubula.xmlparser.JubulaDocumentParser.java

License:Open Source License

public long getTestSuitDuration() {
    Node node = document.selectSingleNode("//test-length");
    SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");
    sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date date;//from  ww  w. j  av a2  s.  c  o m
    try {
        date = sdf.parse(node.getStringValue());
        return date.getTime();
    } catch (ParseException e) {
        e.printStackTrace();
        return 0;
    }
}

From source file:org.mule.tooling.jubula.xmlparser.JubulaDocumentParser.java

License:Open Source License

public String getTestResultById(int secuencialID) {
    Node node = document.selectSingleNode("//testsuite/test-run/testcase[" + secuencialID + "]/status");

    if (node != null) {
        return node.getStringValue();
    }/*from w  ww .  j a  v a  2s . co m*/
    return "2";
}

From source file:org.mule.tooling.jubula.xmlparser.JubulaDocumentParser.java

License:Open Source License

public long getTestTestDurationById(int secuencialID) {
    Node node = document.selectSingleNode("//testsuite/test-run/testcase[" + secuencialID + "]/@duration");
    SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");
    sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date date;//from w w  w  . j ava 2 s  . com
    try {
        if (node != null) {
            date = sdf.parse(node.getStringValue());
            return date.getTime();
        }

        return 0;

    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return 0;
    }

}

From source file:org.openadaptor.auxil.connector.jdbc.writer.xml.AbstractXMLWriter.java

License:Open Source License

private void populateStatementFromOutputColumns(Element root) throws SQLException {
    for (int i = 0; i < outputColumns.length; i++) {
        Node node = root.selectSingleNode(outputColumns[i]);
        populateParameter(i + 1, node != null ? node.getStringValue() : null);
    }/*  w  ww . ja v  a 2  s.co m*/
}

From source file:org.openadaptor.auxil.connector.jdbc.writer.xml.AbstractXMLWriter.java

License:Open Source License

private void populateStatementFromElements(Element root) throws SQLException {
    for (int i = 0; i < root.nodeCount(); i++) {
        Node node = root.node(i);
        populateParameter(i + 1, node.getStringValue());
    }//from  w ww  .j  a v a2s  .  com
}

From source file:org.openadaptor.auxil.connector.jdbc.writer.XMLCallableStatementWriterTestCase.java

License:Open Source License

protected Object[] setUpSingletonDataAndDataExpections() {
    Object[] data = new Object[] { SampleXMLOne };
    preparedStatementMock.expects(once()).method("clearParameters");
    for (int i = 0; i < SampleXMLOne.getRootElement().nodeCount(); i++) {
        Node node = SampleXMLOne.getRootElement().node(i);
        preparedStatementMock.expects(once()).method("setObject").with(eq(i + 1), eq(node.getStringValue()),
                eq(Types.NUMERIC));
    }/*ww  w.j  a  v a  2  s .com*/
    preparedStatementMock.expects(once()).method("executeUpdate").will(returnValue(1));
    return data;
}

From source file:org.openadaptor.auxil.connector.jdbc.writer.XMLCallableStatementWriterTestCase.java

License:Open Source License

/**
 * This method must be overrriden to generate test data consisting of a batch.
 * Associated mock expectations relating to this component must also be set. Note
 * that these expectations are to be set assuming the underlying jdbc layer is configured
 * to enable batch uploads.//from w  ww  .  j a v  a2s  .  co m
 *
 * @return Object[]
 */
protected Object[] setupWriteBatchDataAndExpectationsBatchingEnabled() {
    Object[] data = new Object[] { SampleXMLOne, SampleXMLTwo, SampleXMLThree };
    preparedStatementMock.expects(atLeastOnce()).method("clearParameters");
    for (int dataIndex = 0; dataIndex < data.length; dataIndex++) {
        Document dataElement = (Document) data[dataIndex];
        for (int i = 0; i < dataElement.getRootElement().nodeCount(); i++) {
            Node node = dataElement.getRootElement().node(i);
            preparedStatementMock.expects(once()).method("setObject").with(eq(i + 1), eq(node.getStringValue()),
                    eq(Types.NUMERIC));
        }
    }
    preparedStatementMock.expects(exactly(3)).method("addBatch");
    preparedStatementMock.expects(once()).method("executeBatch").will(returnValue(new int[] { 1, 1, 1 }));
    return data;
}

From source file:org.openadaptor.auxil.connector.jdbc.writer.XMLCallableStatementWriterTestCase.java

License:Open Source License

/**
 * This method must be overriden to generate test data consisting of a  batch.
 * Associated mock expectations relating to this component must also be set. Note
 * that these expectations are to be set assuming the underlying jdbc layer is configured
 * to disable batch uploads.//from   w ww  .  j a  va 2  s .  co m
 *
 * @return Object[]
 */
protected Object[] setupWriteBatchDataAndExpectationsBatchingDisabled() {
    Object[] data = new Object[] { SampleXMLOne, SampleXMLTwo, SampleXMLThree };
    preparedStatementMock.expects(atLeastOnce()).method("clearParameters");
    for (int dataIndex = 0; dataIndex < data.length; dataIndex++) {
        Document dataElement = (Document) data[dataIndex];
        for (int i = 0; i < dataElement.getRootElement().nodeCount(); i++) {
            Node node = dataElement.getRootElement().node(i);
            preparedStatementMock.expects(once()).method("setObject").with(eq(i + 1), eq(node.getStringValue()),
                    eq(Types.NUMERIC));
        }
    }
    preparedStatementMock.expects(never()).method("addBatch");
    preparedStatementMock.expects(never()).method("executeBatch");
    preparedStatementMock.expects(exactly(3)).method("executeUpdate").will(returnValue(1));
    return data;
}

From source file:org.openadaptor.auxil.connector.jdbc.writer.XMLTableWriterTestCase.java

License:Open Source License

protected Object[] setUpSingletonDataAndDataExpections() {
    Object[] data = new Object[] { SampleXMLOne };
    preparedStatementMock.expects(once()).method("clearParameters");
    for (int i = 0; i < ColumnNames.length; i++) {
        Node node = SampleXMLOne.getRootElement().selectSingleNode(ColumnNames[i]);
        preparedStatementMock.expects(once()).method("setObject").with(eq(i + 1), eq(node.getStringValue()),
                eq(Types.NUMERIC));
    }/*from  www. ja v a2  s . c o m*/
    preparedStatementMock.expects(once()).method("executeUpdate").will(returnValue(1));
    return data;
}

From source file:org.openadaptor.auxil.connector.jdbc.writer.XMLTableWriterTestCase.java

License:Open Source License

protected Object[] setupWriteBatchDataAndExpectationsBatchingEnabled() {
    Object[] data = new Object[] { SampleXMLOne, SampleXMLTwo, SampleXMLThree };
    preparedStatementMock.expects(atLeastOnce()).method("clearParameters");
    for (int dataIndex = 0; dataIndex < data.length; dataIndex++) {
        Document dataElement = (Document) data[dataIndex];
        for (int i = 0; i < ColumnNames.length; i++) {
            Node node = dataElement.getRootElement().selectSingleNode(ColumnNames[i]);
            if (node != null) {
                preparedStatementMock.expects(once()).method("setObject").with(eq(i + 1),
                        eq(node.getStringValue()), eq(Types.NUMERIC));
            } else {
                preparedStatementMock.expects(once()).method("setNull").with(eq(i + 1), eq(Types.NUMERIC));
            }//  w ww .j a  v  a 2  s.co  m
        }
    }
    preparedStatementMock.expects(atLeastOnce()).method("addBatch");
    preparedStatementMock.expects(once()).method("executeBatch").will(returnValue(new int[] { 1, 1, 1 }));
    return data;
}