.withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).withTrustSelfSignedCertificate(true) .withDisableHostnameVerification(true).build();
@Test public void testPerformUploadInvalidLocalDir() throws Exception { // Create uploader input manifest file in LOCAL_TEMP_PATH_INPUT directory File manifestFile = createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), getTestUploaderInputManifestDto()); Assert.assertTrue(manifestFile.isFile()); // Try to run upload by specifying a non-existing local directory. S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = getTestS3FileTransferRequestParamsDto(); s3FileTransferRequestParamsDto.setLocalPath(Paths.get(LOCAL_TEMP_PATH_INPUT.toString(), "I_DO_NOT_EXIST").toString()); RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(WEB_SERVICE_HOSTNAME).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true) .withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).build(); try { uploaderController.performUpload(regServerAccessParamsDto, manifestFile, s3FileTransferRequestParamsDto, false, false, TEST_RETRY_ATTEMPTS, TEST_RETRY_DELAY_SECS); fail("Should throw an IllegalArgumentException when local directory does not exist."); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().startsWith("Invalid local base directory")); } }
@Test(expected = IllegalArgumentException.class) public void testPerformUploadManifestContainsDuplicateFileNames() throws Exception { List<ManifestFile> duplicateTestDataFiles = new ArrayList<>(); duplicateTestDataFiles.addAll(testManifestFiles); duplicateTestDataFiles.add(testManifestFiles.get(0)); // Create local data files in LOCAL_TEMP_PATH_INPUT directory for (ManifestFile manifestFile : testManifestFiles) { createLocalFile(LOCAL_TEMP_PATH_INPUT.toString(), manifestFile.getFileName(), FILE_SIZE_1_KB); } // Create uploader input manifest file in LOCAL_TEMP_PATH_INPUT directory UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto(); uploaderInputManifestDto.setManifestFiles(duplicateTestDataFiles); File manifestFile = createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto); Assert.assertTrue(manifestFile.isFile()); // Try to upload business object data having duplicate file names. RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(WEB_SERVICE_HOSTNAME).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true) .withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).build(); uploaderController.performUpload(regServerAccessParamsDto, manifestFile, getTestS3FileTransferRequestParamsDto(), false, false, TEST_RETRY_ATTEMPTS, TEST_RETRY_DELAY_SECS); }
RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(regServerHost).withRegServerPort(regServerPort).withUseSsl(useSsl) .withUsername(argParser.getStringValue(usernameOpt)).withPassword(argParser.getStringValue(passwordOpt)) .withTrustSelfSignedCertificate(trustSelfSignedCertificate).withDisableHostnameVerification(disableHostnameVerification).build(); controller.performUpload(regServerAccessParamsDto, argParser.getFileValue(manifestPathOpt), params, argParser.getBooleanValue(createNewVersionOpt),
RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(hostnameToUse).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true) .withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).withTrustSelfSignedCertificate(true) .withDisableHostnameVerification(true).build(); uploaderController.performUpload(regServerAccessParamsDto, manifestFile, s3FileTransferRequestParamsDto, createNewVersion, force, TEST_RETRY_ATTEMPTS,
RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(regServerHost).withRegServerPort(regServerPort).withUseSsl(useSsl) .withUsername(argParser.getStringValue(usernameOpt)).withPassword(argParser.getStringValue(passwordOpt)) .withTrustSelfSignedCertificate(trustSelfSignedCertificate).withDisableHostnameVerification(disableHostnameVerification).build(); controller.performDownload(regServerAccessParamsDto, argParser.getFileValue(manifestPathOpt), params);
/** * Runs the application by parsing the command line arguments and calling the controller to export business object data that passed its relative retention * expiration. This is the main entry into the application class itself and is typically called from a main method. * * @param args the command line arguments passed to the program * * @return the return value of the application * @throws Exception if any problems were encountered */ protected ToolsCommonConstants.ReturnValue go(String[] args) throws Exception { // Create the Spring application context. ApplicationContext applicationContext = createApplicationContext(); // Parse the command line arguments and return a return value if we shouldn't continue processing (e.g. we displayed usage information, etc.). ToolsCommonConstants.ReturnValue returnValue = parseCommandLineArguments(args, applicationContext); if (returnValue != null) { return returnValue; } // Create a DTO to communicate with herd registration server. RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(argParser.getStringValue(regServerHostOpt)).withRegServerPort(regServerPort).withUseSsl(useSsl) .withUsername(argParser.getStringValue(usernameOpt)).withPassword(argParser.getStringValue(passwordOpt)) .withTrustSelfSignedCertificate(trustSelfSignedCertificate).withDisableHostnameVerification(disableHostnameVerification).build(); // Call the controller with the user specified parameters to perform the upload. RetentionExpirationDestroyerController controller = applicationContext.getBean(RetentionExpirationDestroyerController.class); controller.performRetentionExpirationDestruction(argParser.getFileValue(localInputFileOpt), regServerAccessParamsDto); // No exceptions were returned so return success. return ToolsCommonConstants.ReturnValue.SUCCESS; }
.withUsername(argParser.getStringValue(usernameOpt)).withPassword(argParser.getStringValue(passwordOpt)) .withTrustSelfSignedCertificate(trustSelfSignedCertificate).withDisableHostnameVerification(disableHostnameVerification).build();
/** * Prepares test data and runs a normal download scenario. * * @param downloaderInputManifestDto the downloader input manifest object instance * @param localPath the local target directory * @param numOfThreads the maximum number of threads to use for file transfer to S3 * @param hostname optional override of the default web service hostname. */ protected void runDownload(DownloaderInputManifestDto downloaderInputManifestDto, String localPath, Integer numOfThreads, String hostname) throws Exception { String hostnameToUse = hostname == null ? WEB_SERVICE_HOSTNAME : hostname; // Upload and register business object data parents. uploadAndRegisterTestDataParents(downloaderWebClient); // Upload and register the initial version if of the test business object data. uploadAndRegisterTestData(S3_TEST_PATH_V0); // Create a downloader input manifest file in LOCAL_TEMP_PATH_INPUT directory File downloaderInputManifestFile = createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), downloaderInputManifestDto); // Perform the download. S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = getTestS3FileTransferRequestParamsDto(); s3FileTransferRequestParamsDto.setS3KeyPrefix(S3_TEST_PATH_V0); s3FileTransferRequestParamsDto.setLocalPath(localPath); s3FileTransferRequestParamsDto.setMaxThreads(numOfThreads); RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(hostnameToUse).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true) .withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).withTrustSelfSignedCertificate(true) .withDisableHostnameVerification(true).build(); downloaderController.performDownload(regServerAccessParamsDto, downloaderInputManifestFile, s3FileTransferRequestParamsDto); }
@Test(expected = IllegalArgumentException.class) public void testPerformUploadManifestFileNameDoesNotMatchActualFileName() throws Exception { List<ManifestFile> declaredManifestFiles = getManifestFilesFromFileNames(Arrays.asList("test-data-1.txt", "test-data-2.txt"), FILE_SIZE_1_KB); List<ManifestFile> actualManifestFiles = getManifestFilesFromFileNames(Arrays.asList("test-data-1.txt", "TEST-DATA-2.TXT"), FILE_SIZE_1_KB); // Create local data files in LOCAL_TEMP_PATH_INPUT directory for (ManifestFile manifestFile : actualManifestFiles) { createLocalFile(LOCAL_TEMP_PATH_INPUT.toString(), manifestFile.getFileName(), FILE_SIZE_1_KB); } // Create uploader input manifest file in LOCAL_TEMP_PATH_INPUT directory. UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto(); uploaderInputManifestDto.setManifestFiles(declaredManifestFiles); File manifestFile = createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto); Assert.assertTrue(manifestFile.isFile()); // Try to upload business object data with one of the file having name that does not match to incorrect name specified. RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(WEB_SERVICE_HOSTNAME).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true) .withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).build(); uploaderController.performUpload(regServerAccessParamsDto, manifestFile, getTestS3FileTransferRequestParamsDto(), false, false, TEST_RETRY_ATTEMPTS, TEST_RETRY_DELAY_SECS); }
@Test public void testPerformDownloadZeroByteDirectoryMarkersPresent() throws Exception { // Upload and register business object data parents. uploadAndRegisterTestDataParents(downloaderWebClient); // Upload and register the initial version if of the test business object data. uploadAndRegisterTestData(S3_TEST_PATH_V0, testManifestFiles, S3_DIRECTORY_MARKERS); // Create a downloader input manifest file in LOCAL_TEMP_PATH_INPUT directory File downloaderInputManifestFile = createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), getTestDownloaderInputManifestDto()); // Adjust the S3 file transfer parameters to be passed to the downloader controller. S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = getTestS3FileTransferRequestParamsDto(); s3FileTransferRequestParamsDto.setLocalPath(LOCAL_TEMP_PATH_OUTPUT.toString()); s3FileTransferRequestParamsDto.setMaxThreads(DownloaderController.MIN_THREADS); // Perform the download. RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(WEB_SERVICE_HOSTNAME).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true) .withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).withTrustSelfSignedCertificate(true) .withDisableHostnameVerification(true).build(); downloaderController.performDownload(regServerAccessParamsDto, downloaderInputManifestFile, s3FileTransferRequestParamsDto); }
/** * Sets up the test environment. */ @Before public void setupEnv() throws IOException { super.setupEnv(); // Initialize the uploader web client instance. RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(WEB_SERVICE_HOSTNAME).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true) .withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).build(); uploaderWebClient.setRegServerAccessParamsDto(regServerAccessParamsDto); } }
@Test public void testPerformRetentionExpirationDestruction() throws Exception { // Create a local input CSV file. File inputCsvFile = createLocalInputCsvFile(); // Create and initialize the registration server DTO. RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(WEB_SERVICE_HOSTNAME).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true) .withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).withTrustSelfSignedCertificate(true) .withDisableHostnameVerification(true).build(); // Perform the retention expiration destruction. retentionExpirationDestroyerController.performRetentionExpirationDestruction(inputCsvFile, regServerAccessParamsDto); }
/** * Sets up the test environment. */ @Before public void setupEnv() throws IOException { super.setupEnv(); // Initialize the uploader web client instance. RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(WEB_SERVICE_HOSTNAME).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true) .withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).build(); retentionExpirationDestroyerWebClient.setRegServerAccessParamsDto(regServerAccessParamsDto); }
/** * Sets up the test environment. */ @Before public void setupEnv() throws IOException { super.setupEnv(); // Create and initialize a downloader web client instance. RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(WEB_SERVICE_HOSTNAME).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true) .withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).build(); downloaderWebClient.setRegServerAccessParamsDto(regServerAccessParamsDto); }
/** * Sets up the test environment. */ @Before public void setupEnv() throws IOException { super.setupEnv(); // Initialize the uploader web client instance. RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(WEB_SERVICE_HOSTNAME).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true) .withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).build(); retentionExpirationExporterWebClient.setRegServerAccessParamsDto(regServerAccessParamsDto); }