org.apache.derby.impl.drda
Class TestProto

java.lang.Object
  extended byorg.apache.derby.impl.drda.TestProto

public class TestProto
extends java.lang.Object

This class is used to test error conditions in the protocol. The protocol to send to the Net server is contained in a file encoded as calls to routines in ddmreader and ddmwriter. Additional commands have been added for testing purposes. To add tests, modify the file protocol.tests. Tests can also be done as separate files and given as an argument to this class.


Field Summary
private static CcsidManager ccsidManager
           
private static int CHECK_SQLCARD
           
private static int CHECKERROR
           
private static CodePointNameTable codePointNameTable
           
private static java.util.Hashtable codePointValueTable
           
private static java.util.Hashtable commandTable
           
private static int CREATE_DSS_OBJECT
           
private static int CREATE_DSS_REPLY
           
private static int CREATE_DSS_REQUEST
           
private  java.lang.String current_filename
           
private static int DISPLAY
           
private static int END_DDM
           
private static int END_DDM_AND_DSS
           
private static int END_DSS
           
private static int END_TEST
           
private  boolean failed
           
private static int FLUSH
           
private static int GET_CODEPOINT
           
private static int INCLUDE
           
private static int MARK_COLLECTION
           
private  java.io.InputStream monitorIs
           
private  java.io.OutputStream monitorOs
           
private  java.net.Socket monitorSocket
           
private static int MORE_DATA
           
private static java.lang.String MULTIVAL_END
           
private static java.lang.String MULTIVAL_SEP
           
private static java.lang.String MULTIVAL_START
           
private static int READ_BOOLEAN
           
private static int READ_BYTE
           
private static int READ_BYTES
           
private static int READ_CODEPOINT
           
private static int READ_INT
           
private static int READ_LENGTH_AND_CODEPOINT
           
private static int READ_LONG
           
private static int READ_NETWORK_INT
           
private static int READ_NETWORK_SHORT
           
private static int READ_REPLY_DSS
           
private static int READ_SCALAR_1BYTE
           
private static int READ_SCALAR_2BYTES
           
private static int READ_SHORT
           
private static int READ_STRING
           
private  DDMReader reader
           
private static int RESET
           
private static int SKIP_BYTES
           
private static int SKIP_DDM
           
private static int SKIP_DSS
           
private static int START_DDM
           
private  java.io.StreamTokenizer tkn
           
private static int WRITE_BYTE
           
private static int WRITE_BYTES
           
private static int WRITE_CODEPOINT_4BYTES
           
private static int WRITE_DOUBLE
           
private static int WRITE_ENCODED_LDSTRING
           
private static int WRITE_ENCODED_STRING
           
private static int WRITE_FLOAT
           
private static int WRITE_INT
           
private static int WRITE_LONG
           
private static int WRITE_NETWORK_INT
           
private static int WRITE_NETWORK_SHORT
           
private static int WRITE_PADDED_STRING
           
private static int WRITE_SCALAR_1BYTE
           
private static int WRITE_SCALAR_2BYTES
           
private static int WRITE_SCALAR_BYTES
           
private static int WRITE_SCALAR_HEADER
           
private static int WRITE_SCALAR_PADDED_BYTES
           
private static int WRITE_SCALAR_PADDED_STRING
           
private static int WRITE_SCALAR_STRING
           
private static int WRITE_SHORT
           
private static int WRITE_STRING
           
private  DDMWriter writer
           
 
Constructor Summary
TestProto(java.lang.String filename)
           
 
Method Summary
private  void checkError()
          Check error sent back to application requester
private  boolean checkIntOrCP(int val)
          checks if value matches next int or cp.
private  void checkSQLCARD(int sqlCode, java.lang.String sqlState)
          Check the value of SQLCARD
private  void closeConnection()
          Close connection to the network server
private  int convertHex(java.lang.String str)
          Convert a token in hex format to int from the command file
private  void cpError(int cp, int reqCP)
          Codepoint error
private  int decodeCP(java.lang.String strval)
          Translate a string codepoint such as ACCSEC to the equivalent int value
private  void fail(java.lang.String msg)
          Print failure message and skip to the next test
private  byte[] getBytes()
          Read an array of bytes from the command file A byte string can start with 0x in which case the bytes are interpreted in hex format or it can just be a string, in which case each char is interpreted as 2 byte UNICODE
private  void getConnection()
          Set up a connection to the Network server
private  int getCP()
          Read the string version of a CodePoint
private  byte[] getEBCDIC(java.lang.String str)
          Translate a string to EBCDIC for use in the protocol
private  int getInt()
          Read an int from the command file Negative numbers are preceded by "-"
private  int getIntOrCP()
          Read an int or codepoint - codepoint is given as a string
private  java.lang.String getString()
          Read a string from the command file
private static void init()
          Initialize hashtable for commands and set up a table to translate from the codepoint name to the codepoint value
private  void processCommand()
          Process a command
private  void processFile(java.lang.String filename)
          Process a command file
private  void processIncludeFile()
          Process include file
private  void readLengthAndCodePoint()
          Read length and codepoint and check against required values
private  void reset()
          Reset connection for another test
private  void skipDdm()
          Skip the a Ddm communication
private  void skipDss()
          Skip a DSS communication
private  void writeEncodedLDString(java.lang.String str, java.lang.String encoding, int len)
          Write length and encoded string
private  void writeEncodedString(java.lang.String str, java.lang.String encoding)
          Write an encoded string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

codePointNameTable

private static final CodePointNameTable codePointNameTable

codePointValueTable

private static final java.util.Hashtable codePointValueTable

commandTable

private static final java.util.Hashtable commandTable

ccsidManager

private static final CcsidManager ccsidManager

CREATE_DSS_REQUEST

private static final int CREATE_DSS_REQUEST
See Also:
Constant Field Values

CREATE_DSS_OBJECT

private static final int CREATE_DSS_OBJECT
See Also:
Constant Field Values

END_DSS

private static final int END_DSS
See Also:
Constant Field Values

END_DDM_AND_DSS

private static final int END_DDM_AND_DSS
See Also:
Constant Field Values

START_DDM

private static final int START_DDM
See Also:
Constant Field Values

END_DDM

private static final int END_DDM
See Also:
Constant Field Values

WRITE_BYTE

private static final int WRITE_BYTE
See Also:
Constant Field Values

WRITE_NETWORK_SHORT

private static final int WRITE_NETWORK_SHORT
See Also:
Constant Field Values

WRITE_NETWORK_INT

private static final int WRITE_NETWORK_INT
See Also:
Constant Field Values

WRITE_BYTES

private static final int WRITE_BYTES
See Also:
Constant Field Values

WRITE_CODEPOINT_4BYTES

private static final int WRITE_CODEPOINT_4BYTES
See Also:
Constant Field Values

WRITE_SCALAR_1BYTE

private static final int WRITE_SCALAR_1BYTE
See Also:
Constant Field Values

WRITE_SCALAR_2BYTES

private static final int WRITE_SCALAR_2BYTES
See Also:
Constant Field Values

WRITE_SCALAR_BYTES

private static final int WRITE_SCALAR_BYTES
See Also:
Constant Field Values

WRITE_SCALAR_HEADER

private static final int WRITE_SCALAR_HEADER
See Also:
Constant Field Values

WRITE_SCALAR_STRING

private static final int WRITE_SCALAR_STRING
See Also:
Constant Field Values

WRITE_SCALAR_PADDED_STRING

private static final int WRITE_SCALAR_PADDED_STRING
See Also:
Constant Field Values

WRITE_SCALAR_PADDED_BYTES

private static final int WRITE_SCALAR_PADDED_BYTES
See Also:
Constant Field Values

WRITE_SHORT

private static final int WRITE_SHORT
See Also:
Constant Field Values

WRITE_INT

private static final int WRITE_INT
See Also:
Constant Field Values

WRITE_LONG

private static final int WRITE_LONG
See Also:
Constant Field Values

WRITE_FLOAT

private static final int WRITE_FLOAT
See Also:
Constant Field Values

WRITE_DOUBLE

private static final int WRITE_DOUBLE
See Also:
Constant Field Values

READ_REPLY_DSS

private static final int READ_REPLY_DSS
See Also:
Constant Field Values

READ_LENGTH_AND_CODEPOINT

private static final int READ_LENGTH_AND_CODEPOINT
See Also:
Constant Field Values

READ_CODEPOINT

private static final int READ_CODEPOINT
See Also:
Constant Field Values

MARK_COLLECTION

private static final int MARK_COLLECTION
See Also:
Constant Field Values

GET_CODEPOINT

private static final int GET_CODEPOINT
See Also:
Constant Field Values

READ_BYTE

private static final int READ_BYTE
See Also:
Constant Field Values

READ_NETWORK_SHORT

private static final int READ_NETWORK_SHORT
See Also:
Constant Field Values

READ_SHORT

private static final int READ_SHORT
See Also:
Constant Field Values

READ_NETWORK_INT

private static final int READ_NETWORK_INT
See Also:
Constant Field Values

READ_INT

private static final int READ_INT
See Also:
Constant Field Values

READ_LONG

private static final int READ_LONG
See Also:
Constant Field Values

READ_BOOLEAN

private static final int READ_BOOLEAN
See Also:
Constant Field Values

READ_STRING

private static final int READ_STRING
See Also:
Constant Field Values

READ_BYTES

private static final int READ_BYTES
See Also:
Constant Field Values

FLUSH

private static final int FLUSH
See Also:
Constant Field Values

DISPLAY

private static final int DISPLAY
See Also:
Constant Field Values

CHECKERROR

private static final int CHECKERROR
See Also:
Constant Field Values

RESET

private static final int RESET
See Also:
Constant Field Values

CREATE_DSS_REPLY

private static final int CREATE_DSS_REPLY
See Also:
Constant Field Values

SKIP_DSS

private static final int SKIP_DSS
See Also:
Constant Field Values

READ_SCALAR_2BYTES

private static final int READ_SCALAR_2BYTES
See Also:
Constant Field Values

READ_SCALAR_1BYTE

private static final int READ_SCALAR_1BYTE
See Also:
Constant Field Values

END_TEST

private static final int END_TEST
See Also:
Constant Field Values

SKIP_DDM

private static final int SKIP_DDM
See Also:
Constant Field Values

INCLUDE

private static final int INCLUDE
See Also:
Constant Field Values

SKIP_BYTES

private static final int SKIP_BYTES
See Also:
Constant Field Values

WRITE_PADDED_STRING

private static final int WRITE_PADDED_STRING
See Also:
Constant Field Values

WRITE_STRING

private static final int WRITE_STRING
See Also:
Constant Field Values

WRITE_ENCODED_STRING

private static final int WRITE_ENCODED_STRING
See Also:
Constant Field Values

WRITE_ENCODED_LDSTRING

private static final int WRITE_ENCODED_LDSTRING
See Also:
Constant Field Values

CHECK_SQLCARD

private static final int CHECK_SQLCARD
See Also:
Constant Field Values

MORE_DATA

private static final int MORE_DATA
See Also:
Constant Field Values

MULTIVAL_START

private static final java.lang.String MULTIVAL_START
See Also:
Constant Field Values

MULTIVAL_SEP

private static final java.lang.String MULTIVAL_SEP
See Also:
Constant Field Values

MULTIVAL_END

private static final java.lang.String MULTIVAL_END
See Also:
Constant Field Values

monitorSocket

private java.net.Socket monitorSocket

monitorIs

private java.io.InputStream monitorIs

monitorOs

private java.io.OutputStream monitorOs

writer

private DDMWriter writer

reader

private DDMReader reader

failed

private boolean failed

tkn

private java.io.StreamTokenizer tkn

current_filename

private java.lang.String current_filename
Constructor Detail

TestProto

public TestProto(java.lang.String filename)
Method Detail

processIncludeFile

private void processIncludeFile()
                         throws java.io.IOException,
                                DRDAProtocolException
Process include file

Throws:
IOException, - DRDAProtocolException error reading file or protocol
java.io.IOException
DRDAProtocolException

processFile

private void processFile(java.lang.String filename)
                  throws java.io.IOException,
                         DRDAProtocolException
Process a command file

Parameters:
filename -
Throws:
IOException, - DRDAProtocolException error reading file or protocol
java.io.IOException
DRDAProtocolException

getConnection

private void getConnection()
Set up a connection to the Network server


closeConnection

private void closeConnection()
Close connection to the network server


reset

private void reset()
Reset connection for another test


init

private static void init()
Initialize hashtable for commands and set up a table to translate from the codepoint name to the codepoint value


processCommand

private void processCommand()
                     throws java.io.IOException,
                            DRDAProtocolException
Process a command

Throws:
java.io.IOException
DRDAProtocolException

skipDss

private void skipDss()
              throws DRDAProtocolException
Skip a DSS communication

Throws:
DRDAProtocolException

skipDdm

private void skipDdm()
              throws DRDAProtocolException
Skip the a Ddm communication

Throws:
DRDAProtocolException

getInt

private int getInt()
            throws java.io.IOException
Read an int from the command file Negative numbers are preceded by "-"

Throws:
java.io.IOException

convertHex

private int convertHex(java.lang.String str)
                throws java.io.IOException
Convert a token in hex format to int from the command file

Throws:
java.io.IOException

checkIntOrCP

private boolean checkIntOrCP(int val)
                      throws java.io.IOException
checks if value matches next int or cp. Handles multiple legal values in protocol test file FORMAT for Multiple Values MULTIVALSTART 10 SEP 32 SEP 40 MULTIVALEND

Throws:
java.io.IOException

getIntOrCP

private int getIntOrCP()
                throws java.io.IOException
Read an int or codepoint - codepoint is given as a string

Throws:
java.io.IOException

getBytes

private byte[] getBytes()
                 throws java.io.IOException
Read an array of bytes from the command file A byte string can start with 0x in which case the bytes are interpreted in hex format or it can just be a string, in which case each char is interpreted as 2 byte UNICODE

Returns:
byte array
Throws:
java.io.IOException

getString

private java.lang.String getString()
                            throws java.io.IOException
Read a string from the command file

Returns:
string found in file
Throws:
java.io.IOException - error reading file

getCP

private int getCP()
           throws java.io.IOException
Read the string version of a CodePoint

Throws:
java.io.IOException - error reading file

decodeCP

private int decodeCP(java.lang.String strval)
Translate a string codepoint such as ACCSEC to the equivalent int value

Parameters:
strval - string codepoint
Returns:
integer value of codepoint

fail

private void fail(java.lang.String msg)
           throws java.io.IOException
Print failure message and skip to the next test

Throws:
java.io.IOException - error reading file

checkError

private void checkError()
                 throws java.io.IOException,
                        DRDAProtocolException
Check error sent back to application requester

Throws:
IOException, - DRDAProtocolException error reading file or protocol
java.io.IOException
DRDAProtocolException

readLengthAndCodePoint

private void readLengthAndCodePoint()
                             throws java.io.IOException,
                                    DRDAProtocolException
Read length and codepoint and check against required values

Throws:
IOException, - DRDAProtocolException error reading file or protocol
java.io.IOException
DRDAProtocolException

cpError

private void cpError(int cp,
                     int reqCP)
              throws java.io.IOException
Codepoint error

Throws:
java.io.IOException - error reading command file

getEBCDIC

private byte[] getEBCDIC(java.lang.String str)
Translate a string to EBCDIC for use in the protocol

Parameters:
str - string to transform
Returns:
EBCDIC string

writeEncodedString

private void writeEncodedString(java.lang.String str,
                                java.lang.String encoding)
                         throws java.io.IOException
Write an encoded string

Parameters:
str - string to write
encoding - Java encoding to use
Throws:
java.io.IOException

writeEncodedLDString

private void writeEncodedLDString(java.lang.String str,
                                  java.lang.String encoding,
                                  int len)
                           throws java.io.IOException
Write length and encoded string

Parameters:
str - string to write
encoding - Java encoding to use
len - Size of length value (2 or 4 bytes)
Throws:
java.io.IOException

checkSQLCARD

private void checkSQLCARD(int sqlCode,
                          java.lang.String sqlState)
                   throws java.io.IOException,
                          DRDAProtocolException
Check the value of SQLCARD

Parameters:
sqlCode - SQLCODE value
sqlState - SQLSTATE value
Throws:
IOException, - DRDAProtocolException
java.io.IOException
DRDAProtocolException

Built on Mon 2007-06-04 09:58:47+0400, from revision ???

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.