Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derbyTesting.functionTests.tests.lang
Class xmlBinding  view xmlBinding download xmlBinding.java

java.lang.Object
  extended byorg.apache.derbyTesting.functionTests.tests.lang.xmlBinding

public class xmlBinding
extends java.lang.Object

This class checks to make sure that the XML data type and the corresponding XML operations all work as expected from the JDBC side of things. In particular, this test verifies that 1) it is NOT possible to bind to/from an XML datatype (because the JDBC specification doesn't indicate how that should be done), and 2) the correct behavior occurs when null values (both Java and SQL) are bound into the bindable parameters for the XML operators. This file also checks that insertion from XML files via a character stream works, which is important since XML files can be arbitrarily long and thus stream-based processing is a must.


Constructor Summary
xmlBinding()
           
 
Method Summary
private  void bindAndExecute(java.sql.PreparedStatement pSt, int paramNum, int paramType, java.lang.Object bindValue, java.lang.String sqlState, boolean bindSqlNull)
          Helper method.
private  void checkException(java.sql.SQLException se, java.lang.String targetState)
          Helper method.
private  void doBindTests(java.sql.Connection conn)
          Performs a series of binding checks to make sure binding to an XML value never works.
private  void doXMLExistsTests(java.sql.Connection conn)
          Run some simple XPath queries against the documents inserted in doXMLParseTests() above, and then test binding of null values in the XMLEXISTS operator.
private  void doXMLParseTests(java.sql.Connection conn)
          Test insertion of documents larger than 32K (this will test stream processing of XML data), and test binding of null values in the XMLPARSE operator.
private  void doXMLSerializeTests(java.sql.Connection conn)
          Test serialization of the XML values inserted by the doXMLParseTests() method above.
private  int existsQuery(java.sql.Connection conn, java.lang.String tableName, java.lang.String xPath)
          Helper method.
 void go(java.lang.String[] args)
          Create a JDBC connection using the arguments passed in from the harness, and then run the binding tests.
private  void insertDocWithDTD(java.sql.Connection conn, java.lang.String tableName, java.lang.String fName, java.lang.String dtdName, int numRows)
          Helper method.
private  void insertFiles(java.sql.Connection conn, java.lang.String tableName, java.lang.String fName, int numRows)
          Helper method.
static void main(java.lang.String[] args)
          Create an instance of this class and do the test.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

xmlBinding

public xmlBinding()
Method Detail

main

public static void main(java.lang.String[] args)
Create an instance of this class and do the test.


go

public void go(java.lang.String[] args)
Create a JDBC connection using the arguments passed in from the harness, and then run the binding tests.


doBindTests

private void doBindTests(java.sql.Connection conn)
Performs a series of binding checks to make sure binding to an XML value never works.


doXMLParseTests

private void doXMLParseTests(java.sql.Connection conn)
Test insertion of documents larger than 32K (this will test stream processing of XML data), and test binding of null values in the XMLPARSE operator.


doXMLSerializeTests

private void doXMLSerializeTests(java.sql.Connection conn)
Test serialization of the XML values inserted by the doXMLParseTests() method above. For the documents that are larger than 32K, this tests that they can be correctly read from disk as a stream (instead of just as as string).


doXMLExistsTests

private void doXMLExistsTests(java.sql.Connection conn)
Run some simple XPath queries against the documents inserted in doXMLParseTests() above, and then test binding of null values in the XMLEXISTS operator.


insertFiles

private void insertFiles(java.sql.Connection conn,
                         java.lang.String tableName,
                         java.lang.String fName,
                         int numRows)
                  throws java.lang.Exception
Helper method. Inserts the contents of a file into the received table using "setCharacterStream".


insertDocWithDTD

private void insertDocWithDTD(java.sql.Connection conn,
                              java.lang.String tableName,
                              java.lang.String fName,
                              java.lang.String dtdName,
                              int numRows)
                       throws java.lang.Exception
Helper method. Inserts an XML document into the received table using setString. This method parallels "insertFiles" above, except that it should be used for documents that require a DTD in order to be complete. In that case, the location of the DTD has to modified _in_ the document so that it can be found regardless of whether we're running in embedded mode or in server/client mode.


existsQuery

private int existsQuery(java.sql.Connection conn,
                        java.lang.String tableName,
                        java.lang.String xPath)
                 throws java.lang.Exception
Helper method. Selects all rows from the received table name that have at least one node matching the received XPath expression. Does this query using the XMLEXISTS operator.


bindAndExecute

private void bindAndExecute(java.sql.PreparedStatement pSt,
                            int paramNum,
                            int paramType,
                            java.lang.Object bindValue,
                            java.lang.String sqlState,
                            boolean bindSqlNull)
Helper method. Attempts to bind a parameter to a given value using the given type, and then prints the result of that attempt (PASS/FAIL).


checkException

private void checkException(java.sql.SQLException se,
                            java.lang.String targetState)
Helper method. Checks to see if the received SQLException has a SQLState that matches the target/expected SQLState. Prints out a message saying the result of this check, and in the case where the actual error is NOT the expected error, prints a full stack trace to System.out.