am working with docker to run my DAO unit test which hits the SQLServer database which resides in the docker container.
STEP1: i want me to pull the latest BAK file from my remote server(Linux box in which the docker was installed) to my project class path(src/test/resources) so that i can use the MSSQLServerContainer to fetch it before it start the container.
So am doing a SSHJ to fetch the file like below :
final SSHClient ssh = new SSHClient();
establishConnection(ssh);
SFTPClient sftp = ssh.newSFTPClient();
List<RemoteResourceInfo> files = sftp.ls("public");
for (RemoteResourceInfo file : files) {
String remoteServerFileLocation = file.getPath();
//This will download the BAK file to target folder
sftp.get(remoteServerFileLocation, "src/test/resources");
//sftp.get(remoteServerFileLocation, "target");
}
sftp.close();
ssh.disconnect();
and starting the container like below :
xMSSQLServerContainer.withClasspathResourceMapping(BACKUP_FILE_NAME, BACKUP_FILE_PATH, BindMode.READ_ONLY).start();
so now my problem is, it is failing with the below error :
java.lang.IllegalArgumentException: Resource with path CCS_Utility.bak could not be found on any of these classloaders: [sun.misc.Launcher$AppClassLoader@18b4aac2]
seems like it is not flushing the file to classpath until the container is started. is there a way i can flush the file as soon as the below line sftp.get(remoteServerFileLocation, "src/test/resources"); is executed. so that it will be available on classpath by the time container starts.
before the container starts, it has to put the BAK file into src/test/resources folder so that it can start the container and pick the file from the classpath and run the unit test.