Skip to content

Commit

Permalink
Updates for native JDBC driver (#108)
Browse files Browse the repository at this point in the history
* Test updates for AAF

* Fix AS400NewInstance.

Signed-off-by: John Eberhard <[email protected]>

* Native JDBC Test changes

Signed-off-by: John Eberhard <[email protected]>

* Test cleanup and Native JDBC updates

Signed-off-by: John Eberhard <[email protected]>

---------

Signed-off-by: John Eberhard <[email protected]>
  • Loading branch information
jeber-ibm authored Oct 31, 2024
1 parent 8e505d7 commit 7fd1c22
Show file tree
Hide file tree
Showing 38 changed files with 13,427 additions and 14,516 deletions.
2 changes: 2 additions & 0 deletions src/test/DDM/DDMPosition.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public DDMPosition(AS400 systemObject, Vector variationsToRun, int runMode,
pwrSys_ = pwrsys; // Added for @A1A
}


/**
* Runs the variations requested.
**/
Expand Down Expand Up @@ -344,6 +345,7 @@ public void run() {
**/
protected void setup() throws Exception {
try {

// Delete and recreate library DDMTEST
CommandCall c = new CommandCall(pwrSys_);
deleteLibrary(c, testLib_);
Expand Down
27 changes: 26 additions & 1 deletion src/test/DDM/DDMPositionExtended.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,29 @@ public static void main(String args[]) throws Exception {
public DDMPositionExtended(AS400 systemObject,
Vector variationsToRun,
int runMode,
FileOutputStream fileOutputStream)
FileOutputStream fileOutputStream,
String testLib,
int blockingFactor, AS400 pwrsys)
{
// Replace the third parameter (3) with the total number of variations
// in this testcase.
super(systemObject, "DDMPositionExtended", 18,
variationsToRun, runMode, fileOutputStream);
testLib_ = testLib;
pwrSys_ = pwrsys; // Added for @A1A

}

protected void setup() throws Exception {
try {
// Make sure ther user has access to the QIWS/QCUSTCDT file
CommandCall c = new CommandCall(pwrSys_);
c.run(" GRTOBJAUT OBJ(QIWS/QCUSTCDT) OBJTYPE(*FILE) USER("+systemObject_.getUserId()+") AUT(*USE) ");

} catch (Exception e) {
e.printStackTrace(output_);
throw e;
}
}

/**
Expand All @@ -71,6 +88,14 @@ public DDMPositionExtended(AS400 systemObject,
public void run()
{
boolean allVariations = (variationsToRun_.size() == 0);
// Do any necessary setup work for the variations
try {
setup();
} catch (Exception e) {
// Testcase setup did not complete successfully
System.out.println("Unable to complete setup; variations not run");
return;
}

if (runMode_ != ATTENDED)
{
Expand Down
2 changes: 1 addition & 1 deletion src/test/DDMTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ public void createTestcases()
DDMPositionExtended tc =
new DDMPositionExtended(systemObject_,
namesAndVars_.get("DDMPositionExtended"), runMode_,
fileOutputStream_);
fileOutputStream_, testLib_, 0, PwrSys);
testcases_.addElement(tc);
namesAndVars_.remove("DDMPositionExtended");
}
Expand Down
41 changes: 19 additions & 22 deletions src/test/IFS/IFSMiscTestcase.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public void Var002()
file.read(data2);
file.seek(9);
int i = file.read();
assertCondition(isEqual(data1, data2) && i == dataIn[9]);
assertCondition(areEqual(data1, data2) && i == dataIn[9]);
file.close();
}
catch(Exception e)
Expand All @@ -185,7 +185,7 @@ public void Var003()
try
{
file = new IFSRandomAccessFile(systemObject_, ifsPathName_, "rw");
file.skipBytes(-1);
file.skipBytes(-1L);
failed("Exception didn't occur.");
}
catch(Exception e)
Expand All @@ -208,9 +208,9 @@ public void Var004()
IFSRandomAccessFile file =
new IFSRandomAccessFile(systemObject_, ifsPathName_, "r");
file.read();
assertCondition(file.skipBytes(1) == 1 && file.read() == 2 &&
file.skipBytes(2) == 2 && file.read() == 5 &&
file.skipBytes(3) == 3 && file.read() == 9);
assertCondition(file.skipBytes(1L) == 1 && file.read() == 2 &&
file.skipBytes(2L) == 2 && file.read() == 5 &&
file.skipBytes(3L) == 3 && file.read() == 9);
file.close();
}
catch(Exception e)
Expand Down Expand Up @@ -624,12 +624,7 @@ public void Var023()
**/
public void Var024()
{
if (false /*isApplet_*/)
{
notApplicable();
return;
}


try
{
IFSFile file1 = new IFSFile(systemObject_, ifsDirName_);
Expand Down Expand Up @@ -1259,7 +1254,7 @@ public void Var043()
{
if (DEBUG) System.out.println("Directory: /QIBM/ProdData/HTTP/Public/jt400");
IFSFile dir = new IFSFile(systemObject_, "/QIBM/ProdData/HTTP/Public/jt400");
java.util.Enumeration enumeration = dir.enumerateFiles();
Enumeration<IFSFile> enumeration = dir.enumerateFiles();
while (enumeration.hasMoreElements())
{
IFSFile file = (IFSFile)enumeration.nextElement();
Expand All @@ -1280,7 +1275,7 @@ else if (DEBUG && subtype != null &&
{
if (DEBUG) System.out.println("Directory: /QSYS.LIB");
IFSFile dir = new IFSFile(systemObject_, "/QSYS.LIB");
java.util.Enumeration enumeration = dir.enumerateFiles();
Enumeration<IFSFile> enumeration = dir.enumerateFiles();
while (enumeration.hasMoreElements())
{
IFSFile file = (IFSFile)enumeration.nextElement();
Expand All @@ -1301,7 +1296,7 @@ else if (DEBUG && subtype != null &&
{
if (DEBUG) System.out.println("Directory: /QSYS.LIB/QGPL.LIB");
IFSFile dir = new IFSFile(systemObject_, "/QSYS.LIB/QGPL.LIB");
java.util.Enumeration enumeration = dir.enumerateFiles();
Enumeration<IFSFile> enumeration = dir.enumerateFiles();
while (enumeration.hasMoreElements())
{
try
Expand Down Expand Up @@ -1403,7 +1398,7 @@ public void Var045()
raFile.close();

if (file.length() != data.length ||
!isEqual(data1, data)) {
!areEqual(data1, data)) {
failed("File data is not correct");
}
else
Expand Down Expand Up @@ -1441,6 +1436,7 @@ public void Var046()
data[i] = (byte) i;
}
os.write(data);
os.close();
IFSFile file = new IFSFile(systemObject_, ifsPathName_);
IFSRandomAccessFile raFile = new IFSRandomAccessFile(systemObject_, ifsPathName_, "r");

Expand Down Expand Up @@ -1524,18 +1520,19 @@ public void Var049()
data[i] = (byte) i;
}
os.write(data);
os.close();
IFSFile file = new IFSFile(systemObject_, ifsPathName_);
IFSRandomAccessFile raFile = new IFSRandomAccessFile(systemObject_, ifsPathName_, "r");

long lengthInit = file.length();

//raFile.setLength(MAX_FILE_LENGTH); // This takes a *long* time!
//long lengthMax = file.length();
raFile.setLength(500);
raFile.setLength(500L);
long length500 = file.length();
raFile.setLength(0);
raFile.setLength(0L);
long length0 = file.length();
raFile.setLength(100);
raFile.setLength(100L);
long length100 = file.length();

assertCondition(lengthInit == 256 &&
Expand All @@ -1561,7 +1558,7 @@ public void Var050()
try
{
file = new IFSRandomAccessFile(systemObject_, ifsPathName_, "rw");
file.setLength(-1);
file.setLength(-1L);
failed("Exception didn't occur.");
}
catch(Exception e)
Expand All @@ -1581,7 +1578,7 @@ public void Var051()
try
{
file = new IFSRandomAccessFile(systemObject_, ifsPathName_, "rw");
file.setLength(MAX_FILE_LENGTH+1);
file.setLength((long) MAX_FILE_LENGTH+1);
failed("Exception didn't occur.");
}
catch(Exception e)
Expand All @@ -1594,7 +1591,7 @@ public void Var051()
static final boolean verifyFileCount(IFSFile dir, int expectedCount) throws IOException
{
boolean result = true;
Enumeration enumeration = dir.enumerateFiles("*");
Enumeration<?> enumeration = dir.enumerateFiles("*");
int counter = 0;
if (DEBUG) System.out.println("Enumerating files");
while (enumeration.hasMoreElements())
Expand Down Expand Up @@ -1897,7 +1894,7 @@ public void Var055()
}
else
{
Enumeration enumeration = dir.enumerateFiles();
Enumeration<?> enumeration = dir.enumerateFiles();
int num = 0;
while (enumeration.hasMoreElements())
{
Expand Down
72 changes: 0 additions & 72 deletions src/test/JD/CPDS/JDCPDSConnectionNativeSQL.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public static void main(String args[]) throws Exception {
private Connection connection_;
private int vrm_;
private boolean nativeDriver_ = false;
private boolean v5r2nativeFunctions_ = false;


/**
Expand Down Expand Up @@ -98,7 +97,6 @@ protected void setup ()
JDReflectionUtil.callMethod_V(dataSource,"setPassword",clearPassword_);
connection_ = dataSource.getConnection ();

v5r2nativeFunctions_ = (getDriver() == JDTestDriver.DRIVER_NATIVE);
nativeDriver_ = getDriver() == JDTestDriver.DRIVER_NATIVE;
if (nativeDriver_) {
// @H1A native driver uses different notion of VRM
Expand Down Expand Up @@ -1599,24 +1597,6 @@ public void Var068()
public void Var069()
{
if (checkJdbc20StdExt()) {
if (v5r2nativeFunctions_) {
try {
String sql = "SELECT {fn difference(CHARCOL1,CHARCOL2)} FROM MYTABLE";
String expected = "SELECT DIFFERENCE(CHARCOL1, CHARCOL2) FROM MYTABLE";
String translated = connection_.nativeSQL (sql);

boolean condition = translated.equals (expected);
if (!condition) {
System.out.println("expected = '"+expected+"'");
System.out.println("translated = '"+translated+"'");
}
assertCondition (condition);

}
catch (Exception e) {
failed(e , "Unexpected Exception");
}
} else {

try {
String sql = "SELECT {fn difference(INTEGERCOL)} FROM MYTABLE";
Expand All @@ -1634,7 +1614,6 @@ public void Var069()
catch (Exception e) {
failed(e , "Unexpected Exception");
}
}
}
}

Expand Down Expand Up @@ -1744,9 +1723,6 @@ public void Var074()
try {
String sql = "SELECT {fn locate(CHARCOL1,CHARCOL2,5)} FROM MYTABLE";
String expected = "SELECT LOCATE(CHARCOL1,CHARCOL2,5) FROM MYTABLE";
if ( nativeDriver_) {
expected = "SELECT LOCATE(CHARCOL1, CHARCOL2, 5) FROM MYTABLE";
}
String translated = connection_.nativeSQL (sql);
assertCondition (translated.equalsIgnoreCase (expected), "actual("+translated+")!=expected("+expected+")");
}
Expand All @@ -1769,9 +1745,6 @@ public void Var075()
try {
String sql = "SELECT {fn ltrim(CHARCOL)} FROM MYTABLE";
String expected = "SELECT LTRIM(CHARCOL) FROM MYTABLE";
if ( nativeDriver_) {
expected = "SELECT STRIP(CHARCOL,L,' ') FROM MYTABLE";
}
String translated = connection_.nativeSQL (sql);
assertCondition (translated.equalsIgnoreCase (expected), "actual("+translated+")!=expected("+expected+")");
}
Expand All @@ -1791,16 +1764,6 @@ public void Var075()
public void Var076()
{
if (checkJdbc20StdExt()) {
if (v5r2nativeFunctions_) {
try {
String sql = "SELECT {fn repeat(CHARCOL,6)} FROM MYTABLE";
String translated = connection_.nativeSQL (sql);
failed("Didn't throw SQLException but got "+translated);
}
catch (Exception e) {
assertExceptionIsInstanceOf (e, "java.sql.SQLException");
}
} else {
try {
String sql = "SELECT {fn repeat(CHARCOL,6)} FROM MYTABLE";
String expected = "SELECT REPEAT(CHARCOL,6) FROM MYTABLE";
Expand All @@ -1810,7 +1773,6 @@ public void Var076()
catch (Exception e) {
failed(e, "Unexpected Exception");
}
}
}
}

Expand All @@ -1824,17 +1786,6 @@ public void Var076()
public void Var077()
{
if (checkJdbc20StdExt()) {
if (v5r2nativeFunctions_) {
try {
String sql = "SELECT {fn replace(CHARCOL,'HELLO','GOODBYE')} FROM MYTABLE";
String translated = connection_.nativeSQL (sql);
failed("Didn't throw SQLException but got "+translated);
}
catch (Exception e) {
assertExceptionIsInstanceOf (e, "java.sql.SQLException");
}

} else {

try {
String sql = "SELECT {fn replace(CHARCOL,'HELLO','GOODBYE')} FROM MYTABLE";
Expand All @@ -1846,7 +1797,6 @@ public void Var077()
failed(e, "Unexpected Exception");
}
}
}
}


Expand Down Expand Up @@ -2035,16 +1985,6 @@ public void Var085()
public void Var086()
{
if (checkJdbc20StdExt()) {
if (v5r2nativeFunctions_) {
try {
String sql = "SELECT {fn dayname(DATECOL)} FROM MYTABLE";
String translated = connection_.nativeSQL (sql);
failed("Didn't throw SQLException but got "+translated);
}
catch (Exception e) {
assertExceptionIsInstanceOf (e, "java.sql.SQLException");
}
} else {

try {
String sql = "SELECT {fn dayname(DATECOL)} FROM MYTABLE";
Expand All @@ -2055,7 +1995,6 @@ public void Var086()
catch (Exception e) {
failed(e, "Unexpected Exception");
}
}
}

}
Expand Down Expand Up @@ -2200,16 +2139,6 @@ public void Var092()
public void Var093()
{
if (checkJdbc20StdExt()) {
if (v5r2nativeFunctions_) {
try {
String sql = "SELECT {fn monthname(DATECOL)} FROM MYTABLE";
String translated = connection_.nativeSQL (sql);
failed("Didn't throw SQLException but got "+translated);
}
catch (Exception e) {
assertExceptionIsInstanceOf (e, "java.sql.SQLException");
}
} else {

try {
String sql = "SELECT {fn monthname(DATECOL)} FROM MYTABLE";
Expand All @@ -2221,7 +2150,6 @@ public void Var093()
failed(e, "Unexpected Exception");
}
}
}

}

Expand Down
Loading

0 comments on commit 7fd1c22

Please sign in to comment.