Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,024 changes: 991 additions & 1,033 deletions src/test/AS400JDBC/AS400JDBCConnectionPoolDataSourceBeanInfoTestcase.java

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions src/test/AS400JDBC/AS400JDBCDataSourceBeanInfoTestcase.java
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public void Var007() {
StringBuffer failMessage = new StringBuffer();
boolean passed = true;
try {
int expectedCount = 120;
int expectedCount = 121;
AS400JDBCDataSourceBeanInfo bi = new AS400JDBCDataSourceBeanInfo();
PropertyDescriptor[] pd = bi.getPropertyDescriptors();
if (pd.length != expectedCount) {
Expand Down Expand Up @@ -458,6 +458,7 @@ public void Var007() {
propertyTypes.put("useSock5", "boolean");
propertyTypes.put("virtualThreads", "boolean");
propertyTypes.put("trimCharFields", "boolean");
propertyTypes.put("authenticationVerificationId", "java.lang.String");

for (int i = 0; i < pd.length; i++) {
String value = (String) propertyTypes.get(pd[i].getName());
Expand Down Expand Up @@ -601,6 +602,7 @@ public void Var007() {
getPropertyMethods.put("useSock5", "isUseSock5");
getPropertyMethods.put("virtualThreads", "isVirtualThreads");
getPropertyMethods.put("trimCharFields", "isTrimCharFields");
getPropertyMethods.put("authenticationVerificationId", "getAuthenticationVerificationId");

for (int i = 0; i < pd.length; i++) {
if (pd[i].getName().equals("password")) // password.
Expand Down Expand Up @@ -757,6 +759,8 @@ public void Var007() {
setPropertyMethods.put("tlsTruststore", "setTlsTruststore");
setPropertyMethods.put("tlsTruststorePassword", "setTlsTruststorePassword");
setPropertyMethods.put("useSock5", "setUseSock5");
setPropertyMethods.put("authenticationVerificationId", "setAuthenticationVerificationId");

setPropertyMethods.put("virtualThreads", "setVirtualThreads");
setPropertyMethods.put("trimCharFields", "setTrimCharFields");

Expand Down Expand Up @@ -977,7 +981,8 @@ public void Var007() {
propertyShortDescs.put("useSock5", "Specifies that Socks5 should be used for the proxy support.");
propertyShortDescs.put("virtualThreads", "Specifies that virtual threads should be used when available.");
propertyShortDescs.put("trimCharFields", "Specifies whether to remove trailing spaces from char fields.");

propertyShortDescs.put("authenticationVerificationId",
"Specified the verification id to be passed when authenticating to the system.");

for (int i = 0; i < pd.length; i++) {

Expand Down
8 changes: 0 additions & 8 deletions src/test/DDM/DDMPosition.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@ public static void main(String args[]) throws Exception {
/**
* Constructor. This is called from the DDMTest constructor.
**/
public DDMPosition(AS400 systemObject, Vector<String> variationsToRun, int runMode,
FileOutputStream fileOutputStream, String testLib) {
// Replace the third parameter (3) with the total number of variations
// in this testcase.
super(systemObject, "DDMPosition", 109, // @A1C @A2C
variationsToRun, runMode, fileOutputStream);
setTestLib(testLib);
}

public DDMPosition(AS400 systemObject, Vector<String> variationsToRun, int runMode,
FileOutputStream fileOutputStream, String testLib,
Expand Down
2 changes: 1 addition & 1 deletion src/test/JD/Driver/JDDriverConnect.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static void main(String args[]) throws Exception {

public JDDriverConnect(AS400 systemObject, Hashtable<String,Vector<String>> namesAndVars, int runMode, FileOutputStream fileOutputStream,
String password, String powerUserID, String powerPassword) {
super(systemObject, "JDDriverMisc", namesAndVars, runMode, fileOutputStream, password, powerUserID, powerPassword);
super(systemObject, "JDDriverConnect", namesAndVars, runMode, fileOutputStream, password, powerUserID, powerPassword);

systemObject_ = systemObject;

Expand Down
8 changes: 4 additions & 4 deletions src/test/JD/Statement/JDStatementStressCCSID.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

////////////////////////////////////////////////////////////////////////
//
// File Name: JDStatementStressTest.java
// File Name: JDStatementStressCCSID.java
//
// Classes: JDStatementStressTest
// Classes: JDStatementStressCCSID
//
////////////////////////////////////////////////////////////////////////

Expand All @@ -40,7 +40,7 @@


/**
Testcase JDStatementStressTest. This tests multithreaded
Testcase JDStatementStressCCSID. This tests multithreaded
use of parts of the JDBC driver.

This also stresses the use of different CCSIDs..
Expand Down Expand Up @@ -91,7 +91,7 @@ public JDStatementStressCCSID (AS400 systemObject,
String password,
String miscParm)
{
super (systemObject, "JDStatementStressTest",
super (systemObject, "JDStatementStressCCSID",
namesAndVars, runMode, fileOutputStream,
password);

Expand Down
13 changes: 9 additions & 4 deletions src/test/JDTestDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ private void grantPackagePermissions(String url, String library, String userId)
if (pwrSysUserID_ != null) {
if (!pwrSysUserID_.equals(userId)) {
try {
String password = PasswordVault.decryptPasswordLeak(encryptedPassword_, "JDTestDriver.grantPackagePermissions");
String password = PasswordVault.decryptPasswordLeak(pwrSysEncryptedPassword_, "JDTestDriver.grantPackagePermissions");
Connection changeConnection = DriverManager.getConnection(url,
pwrSysUserID_, password);

Expand All @@ -1156,9 +1156,14 @@ private void grantPackagePermissions(String url, String library, String userId)
/* grant permission for the packages */
while (rs.next()) {
String packageName = rs.getString(1);

grantStatement.executeUpdate("GRANT ALL ON " + library + "."
+ packageName + " TO " + userId);
String sql = "GRANT ALL ON PACKAGE " + library + "."
+ packageName + " TO USER " + userId;
try {
grantStatement.executeUpdate(sql);
} catch (Exception e) {
System.out.println("Failing SQL statement was "+sql);
throw e;
}

}
rs.close();
Expand Down
168 changes: 154 additions & 14 deletions src/test/JTOpenEclipseExport.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@

import java.beans.PropertyVetoException;
import java.io.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
import java.util.Vector;
import com.ibm.as400.access.*;

Expand All @@ -27,11 +34,20 @@
*/
public class JTOpenEclipseExport extends Thread {

private static boolean isWindows;
private static boolean skipSameLen = false;
private static boolean refreshAll = false;
String as400Name_;
String userid_;
String password_;
private String compileError;

static {
String osName= System.getProperty("os.name");
if (osName.indexOf("Win") >= 0) {
isWindows = true;
}
}
public JTOpenEclipseExport(String as400Name, String userid, String password) {
as400Name_ = as400Name;
userid_ = userid;
Expand All @@ -50,9 +66,10 @@ public void run() {
}

public static void usage() {
System.out.println("Usage: java test.JTOpenEclipseExport IBMi[+IBMi]* userid password ");
System.out.println("Usage: java test.JTOpenEclipseExport IBMi[+IBMi]* userid password [REFRESHALL] ");
System.out.println(" Updates IBM i systems with the latest test changes in the Eclipse Environment");
System.out.println(" Uses {user.dir}/lastUpdate.$system as a time marker");
System.out.println(" If REFRESHALL is selected, the size of the files are checked and different sized files are moved to the system");
}

public static String export(String as400Name, String userid, String password) throws Exception {
Expand Down Expand Up @@ -117,9 +134,22 @@ public static void main(String args[]) {
System.out.println("EXPORTING to " + as400Name);
String userid = args[1];
String password = args[2];
if (args.length > 3) {
if ("REFRESHALL".equals(args[3])) {
System.out.println("REFRESHING ALL WITH DIFFERENT SIZE");
refreshAll = true;
skipSameLen = true;
}
}

if (as400Name.indexOf('+') < 0) {
String compileError = export(as400Name, userid, password);
if (compileError != null) { System.out.println("Hit compile erorr "+compileError); }
if (compileError == null) {
System.out.println("Export to "+as400Name+" completed");

} else {
System.out.println("Export to "+as400Name+" FAILED with "+compileError);
}
} else {
String[] systems = as400Name.split("\\+");
JTOpenEclipseExport[] threads = new JTOpenEclipseExport[systems.length];
Expand All @@ -145,7 +175,8 @@ public static void main(String args[]) {
}
systemList += " " + systems[i];
completedCount++;
System.out.println("Export completed for " + (completedCount) + "/" + systems.length + " systems " + systemList);
System.out.println(
"Export completed for " + (completedCount) + "/" + systems.length + " systems " + systemList);
joined[i] = true;
}
}
Expand Down Expand Up @@ -224,14 +255,66 @@ static int bufferCleanup(byte[] buffer, int length, boolean binary) {
}

static void transferFiles(AS400 as400, String testDirectory, Vector<String> fileList)
throws IOException, AS400SecurityException {
throws IOException, AS400SecurityException, SQLException {
String prefix = as400.getSystemName() + ":" + as400.getUserId() + ":";
int totalCount = fileList.size();
int count = 0;
int transferCount = 0;
long totalTransferTime = 0;
long startMillis = System.currentTimeMillis();
System.out.println(prefix + "Transferring " + totalCount + " files");
Hashtable<String,Long> sizeHash = new Hashtable<String,Long>();
Hashtable<String,Timestamp> timeHash = new Hashtable<String,Timestamp>();

AS400JDBCDriver driver = new AS400JDBCDriver();

Properties jdbcProperties = new Properties();
jdbcProperties.put("block size", "512");
Connection connection = driver.connect(as400,jdbcProperties,"QGPL");
Statement s = connection.createStatement();
int changeSize = fileList.size();
if (changeSize < 500) {
System.out.println(prefix + "Gathering some file statistics for changed size of "+changeSize);
String sql = "select PATH_NAME, DATA_SIZE, MAX(CREATE_TIMESTAMP, DATA_CHANGE_TIMESTAMP) AS TS from table(IFS_OBJECT_STATISTICS( ? )) ";
PreparedStatement ps = connection.prepareStatement(sql);

Enumeration<String> enumeration = fileList.elements();
int statCount = 0;
while (enumeration.hasMoreElements()) {
statCount++;
String localFilename = enumeration.nextElement();
String remoteFilename = getRemoteFilename(testDirectory, localFilename);
ps.setString(1, remoteFilename);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
String filename = rs.getString(1);
sizeHash.put(filename, Long.valueOf(rs.getLong(2)));
timeHash.put(filename, rs.getTimestamp(3));
if (statCount % 1000 == 0)
System.out.println(prefix+" statCount="+statCount );
}
rs.close();
}

} else {
System.out.println("Gathering all statistics for changed size of " + changeSize);
String sql = "select PATH_NAME, DATA_SIZE, MAX(CREATE_TIMESTAMP, DATA_CHANGE_TIMESTAMP) AS TS from table(IFS_OBJECT_STATISTICS('/home/jdbctest', OMIT_LIST=>'/home/jdbctest/ct /home/jdbctest/gen /home/jdbctest/build')) ";
ResultSet rs = s.executeQuery(sql);
System.out.println("Gathering query results");
int statCount = 0;
while (rs.next()) {
String filename = rs.getString(1);
statCount++;
sizeHash.put(filename, Long.valueOf(rs.getLong(2)));
timeHash.put(filename, rs.getTimestamp(3));
if (statCount % 1000 == 0)
System.out.println(prefix+" statCount="+statCount );
}
rs.close();
}
s.close();
connection.close();


Enumeration<String> enumeration = fileList.elements();
int skipCount = 0;
while (enumeration.hasMoreElements()) {
Expand All @@ -249,31 +332,60 @@ static void transferFiles(AS400 as400, String testDirectory, Vector<String> file
int left = totalCount - count;
double leftSeconds = left * millisPerFile / 1000;
count++;
IFSFile ifsFile = new IFSFile(as400, remoteFilename);
File localFile = new File(testDirectory + File.separatorChar + localFilename);
if (localFile.lastModified() <= ifsFile.lastModified()) {
long ifsLastModified = 0;
Timestamp ifsTime = timeHash.get(remoteFilename);
if (ifsTime != null) ifsLastModified = ifsTime.getTime();
if (localFile.lastModified() <= ifsLastModified && !refreshAll) {
skipCount++;
if(skipCount % 100 == 1)
System.out.println(count+"/"+totalCount+" ("+leftSeconds+" s) "+prefix+"Skipping "+remoteFilename);
System.out.println(
count + "("+skipCount+")/" + totalCount + " (" + leftSeconds + " s) " + prefix + " " + remoteFilename);

} else {
skipCount = 0;

boolean doTransfer = true;
Long longLen = sizeHash.get(remoteFilename);
if ((longLen != null) && skipSameLen ) {
long localLen = calculateUnixLen(localFile);
long remoteLen = 0;
remoteLen = longLen.longValue();
if (localLen == remoteLen ) {
doTransfer = false;
skipCount++;
if (skipCount % 100 == 1)
System.out.println(prefix+" "+(count-skipCount)+"+"+skipCount+"="+count+"/" + totalCount + " (" + leftSeconds + " s) " + remoteFilename);
if (skipCount % 1000 == 1) {
long endTime = System.currentTimeMillis() + (long)(leftSeconds*1000);
Timestamp endTs = new Timestamp(endTime);
System.out.println(prefix+" Predict completion at "+endTs);
}
}
}
if (doTransfer) {
transferCount++;
System.out.println(count+"/"+totalCount+" ("+leftSeconds+" s) "+prefix+"Transferring to "+remoteFilename);
System.out.println(prefix+" "+(count-skipCount)+"+"+skipCount+"="+count+"/" + totalCount + " (" + leftSeconds + " s) Transferring to " + remoteFilename);

long startTransferTime = System.currentTimeMillis();
IFSFile ifsFile = new IFSFile(as400, remoteFilename);
ifsFile.delete();
verifyParent(ifsFile);
ifsFile.createNewFile();
if (binary) {
ifsFile.setCCSID(65535);
} else {
ifsFile.setCCSID(1208);
}
@SuppressWarnings("resource")
IFSFileOutputStream ifsFileOutputStream = new IFSFileOutputStream(ifsFile);
@SuppressWarnings("resource")
FileInputStream fileInputStream = new FileInputStream(testDirectory + File.separatorChar + localFilename);
FileInputStream fileInputStream = new FileInputStream(
testDirectory + File.separatorChar + localFilename);
byte[] buffer = new byte[65536];
int bytesRead = fileInputStream.read(buffer);
while (bytesRead >= 0) {
int bytesToWrite = bufferCleanup(buffer, bytesRead, binary);
int bytesToWrite;
bytesToWrite = bufferCleanup(buffer, bytesRead, binary);
ifsFileOutputStream.write(buffer, 0, bytesToWrite);
bytesRead = fileInputStream.read(buffer);
}
Expand All @@ -283,11 +395,34 @@ static void transferFiles(AS400 as400, String testDirectory, Vector<String> file
totalTransferTime += endTransferTime - startTransferTime;
}
}
}

}

private static long calculateUnixLen(File localFile) throws IOException {

if (isWindows) {
FileReader reader = new FileReader(localFile);
char[] buffer = new char[16384];
long count = 0;
int readChars = reader.read(buffer);
while (readChars > 0) {
for (int i = 0; i < readChars; i++) {
if (buffer[i] != 0x0d) {
count++;
}
}
readChars = reader.read(buffer);
}
reader.close();
return count;
}
return localFile.length();
}

static boolean isBinaryFile(String localFilename) {
if (localFilename.endsWith(".zip")) return true;
if (localFilename.endsWith(".jar")) return true;
if (localFilename.endsWith(".savf")) return true;
return false;
}
Expand All @@ -311,9 +446,14 @@ private static Vector<String> buildFileList(File testDirectoryFile, String prefi
File f = files[i];
String fName = f.getName();
if ((fName.indexOf(".git") < 0) &&
!(fName.equals("gen"))){
(fName.indexOf(".class") < 0) &&
!(fName.equals("gen")) &&
!(fName.equals("bin")) &&
(fName.indexOf("deleteMe") < 0) &&
(fName.indexOf("runit") < 0) &&
(fName.indexOf(".out") < 0)){
if (f.isFile()) {
if (f.lastModified() > lastModifiedTime) {
if ((f.lastModified() > lastModifiedTime) || refreshAll) {
if (prefix.length() > 0) {
returnList.add(prefix + File.separator + fName);
} else {
Expand Down
Loading
Loading