use of com.mercedesbenz.sechub.storage.core.SharedVolumeSetup in project sechub by mercedes-benz.
the class S3RealLiveStorageTestMain method main.
public static void main(String[] args) throws IOException {
/* setup */
SharedVolumeSetup setup = createFakeSharedVolumeNotValid();
S3Setup s3Setup = createS3SetupByEnvironmentVariables();
MultiStorageService service = new MultiStorageService(setup, s3Setup);
UUID jobUUID = UUID.randomUUID();
JobStorage jobStorage = service.getJobStorage("test-only", jobUUID);
/* check preconditions */
boolean existsBefore = jobStorage.isExisting(S3_OBJECT_NAME);
String testDataAsString = "This is some test data as a simple string\nJust another line...";
/* store */
jobStorage.store(S3_OBJECT_NAME, new StringInputStream(testDataAsString));
boolean existsAfterStore = jobStorage.isExisting(S3_OBJECT_NAME);
/* fetch */
InputStream inputStream = jobStorage.fetch(S3_OBJECT_NAME);
InputStreamReader reader = new InputStreamReader(inputStream);
BufferedReader br = new BufferedReader(reader);
String result = br.readLine();
br.close();
/* delete all */
jobStorage.deleteAll();
/* check delete done */
boolean existsAfterDelete = jobStorage.isExisting(S3_OBJECT_NAME);
System.out.println("exists before storage:" + existsBefore);
System.out.println("exists after storage:" + existsAfterStore);
System.out.println("fetched string from object store:" + result);
System.out.println("exists after delete:" + existsAfterDelete);
if (existsBefore) {
System.err.println("existed before!");
System.exit(1);
}
if (!existsAfterStore) {
System.err.println("was not stored!");
System.exit(1);
}
if (!testDataAsString.equals(result)) {
System.err.println("result was not as expected:" + result);
System.exit(1);
}
if (existsAfterDelete) {
System.err.println("data was not as expected:" + result);
System.exit(1);
}
}
use of com.mercedesbenz.sechub.storage.core.SharedVolumeSetup in project sechub by mercedes-benz.
the class S3RealLiveStorageManualTest method manualTestByDeveloper.
@Test
@EnabledIfSystemProperty(named = TestConstants.MANUAL_TEST_BY_DEVELOPER, matches = "true", disabledReason = TestConstants.DESCRIPTION_DISABLED_BECAUSE_A_MANUAL_TEST_FOR_GENERATION)
void manualTestByDeveloper() throws Exception {
/* setup */
SharedVolumeSetup setup = createFakeSharedVolumeNotValid();
S3Setup s3Setup = createS3SetupByEnvironmentVariables();
MultiStorageService service = new MultiStorageService(setup, s3Setup);
UUID jobUUID = UUID.randomUUID();
JobStorage jobStorage = service.getJobStorage("test-only", jobUUID);
/* check preconditions */
boolean existsBefore = jobStorage.isExisting(S3_OBJECT_NAME);
String testDataAsString = "This is some test data as a simple string\nJust another line...";
/* store */
jobStorage.store(S3_OBJECT_NAME, new StringInputStream(testDataAsString));
boolean existsAfterStore = jobStorage.isExisting(S3_OBJECT_NAME);
/* fetch */
InputStream inputStream = jobStorage.fetch(S3_OBJECT_NAME);
InputStreamReader reader = new InputStreamReader(inputStream);
BufferedReader br = new BufferedReader(reader);
String result = br.readLine();
br.close();
/* delete all */
jobStorage.deleteAll();
/* check delete done */
boolean existsAfterDelete = jobStorage.isExisting(S3_OBJECT_NAME);
System.out.println("exists before storage:" + existsBefore);
System.out.println("exists after storage:" + existsAfterStore);
System.out.println("fetched string from object store:" + result);
System.out.println("exists after delete:" + existsAfterDelete);
if (existsBefore) {
System.err.println("existed before!");
System.exit(1);
}
if (!existsAfterStore) {
System.err.println("was not stored!");
System.exit(1);
}
if (!testDataAsString.equals(result)) {
System.err.println("result was not as expected:" + result);
System.exit(1);
}
if (existsAfterDelete) {
System.err.println("data was not as expected:" + result);
System.exit(1);
}
}
Aggregations