use of com.formkiq.aws.s3.S3ConnectionBuilder in project formkiq-core by formkiq.
the class StagingS3CreateTest method beforeClass.
/**
* Before Class.
*
* @throws URISyntaxException URISyntaxException
* @throws InterruptedException InterruptedException
* @throws IOException IOException
*/
@BeforeAll
public static void beforeClass() throws URISyntaxException, InterruptedException, IOException {
Region region = Region.US_EAST_1;
AwsCredentialsProvider cred = StaticCredentialsProvider.create(AwsSessionCredentials.create("ACCESSKEY", "SECRETKEY", "TOKENKEY"));
localstack.start();
snsBuilder = new SnsConnectionBuilder().setEndpointOverride(localstack.getEndpointOverride(Service.SNS).toString()).setRegion(region).setCredentials(cred);
sqsBuilder = new SqsConnectionBuilder().setEndpointOverride(localstack.getEndpointOverride(Service.SQS).toString()).setRegion(region).setCredentials(cred);
sqsService = new SqsService(sqsBuilder);
s3Builder = new S3ConnectionBuilder().setEndpointOverride(localstack.getEndpointOverride(Service.S3).toString()).setRegion(region).setCredentials(cred);
dbBuilder = DynamoDbTestServices.getDynamoDbConnection(null);
service = new DocumentServiceImpl(dbBuilder, "Documents");
dbHelper = DynamoDbTestServices.getDynamoDbHelper(null);
s3 = new S3Service(s3Builder);
try (S3Client c = s3.buildClient()) {
s3.createBucket(c, DOCUMENTS_BUCKET);
s3.createBucket(c, STAGING_BUCKET);
}
if (!sqsService.exists(SNS_SQS_DELETE_QUEUE)) {
snsSqsDeleteQueueUrl = sqsService.createQueue(SNS_SQS_DELETE_QUEUE).queueUrl();
}
if (!sqsService.exists(SNS_SQS_CREATE_QUEUE)) {
snsSqsCreateQueueUrl = sqsService.createQueue(SNS_SQS_CREATE_QUEUE).queueUrl();
}
if (!sqsService.exists(ERROR_SQS_QUEUE)) {
sqsErrorUrl = sqsService.createQueue(ERROR_SQS_QUEUE).queueUrl();
}
snsService = new SnsService(snsBuilder);
snsDeleteTopic = snsService.createTopic("deleteDocument").topicArn();
snsService.subscribe(snsDeleteTopic, "sqs", "arn:aws:sqs:us-east-1:000000000000:" + SNS_SQS_DELETE_QUEUE);
snsCreateTopic = snsService.createTopic("createDocument").topicArn();
snsService.subscribe(snsCreateTopic, "sqs", "arn:aws:sqs:us-east-1:000000000000:" + SNS_SQS_CREATE_QUEUE);
if (!dbHelper.isDocumentsTableExists()) {
dbHelper.createDocumentsTable();
dbHelper.createCacheTable();
}
}
use of com.formkiq.aws.s3.S3ConnectionBuilder in project formkiq-core by formkiq.
the class TestServices method getS3Connection.
/**
* Get Singleton {@link S3ConnectionBuilder}.
* @return {@link S3ConnectionBuilder}
* @throws URISyntaxException URISyntaxException
*/
@SuppressWarnings("resource")
public static S3ConnectionBuilder getS3Connection() throws URISyntaxException {
if (s3Connection == null) {
AwsCredentialsProvider cred = StaticCredentialsProvider.create(AwsSessionCredentials.create("ACCESSKEY", "SECRETKEY", "TOKENKEY"));
s3Connection = new S3ConnectionBuilder().setCredentials(cred).setRegion(AWS_REGION).setEndpointOverride(getLocalStack().getEndpointOverride(Service.S3).toString());
}
return s3Connection;
}
use of com.formkiq.aws.s3.S3ConnectionBuilder in project formkiq-core by formkiq.
the class ConsoleInstallHandlerTest method beforeClass.
/**
* Before Class.
*
* @throws IOException IOException
* @throws InterruptedException InterruptedException
* @throws URISyntaxException URISyntaxException
*/
@BeforeClass
public static void beforeClass() throws IOException, URISyntaxException, InterruptedException {
AwsCredentialsProvider cred = StaticCredentialsProvider.create(AwsSessionCredentials.create("ACCESSKEY", "SECRETKEY", "TOKENKEY"));
localstack.start();
s3Connection = new S3ConnectionBuilder().setCredentials(cred).setRegion(Region.US_EAST_1).setEndpointOverride(localstack.getEndpointOverride(Service.S3).toString());
s3 = new S3Service(s3Connection);
try (S3Client s = s3.buildClient()) {
s3.createBucket(s, "distrobucket");
s3.createBucket(s, "destbucket");
try (InputStream is = LambdaContextRecorder.class.getResourceAsStream("/test.zip")) {
s3.putObject(s, "distrobucket", "formkiq-console/0.1/formkiq-console.zip", is, null);
}
}
connection = new HttpUrlConnectionRecorder(new URL("http://localhost"));
}
use of com.formkiq.aws.s3.S3ConnectionBuilder in project formkiq-core by formkiq.
the class AwsResourceTest method beforeClass.
/**
* beforeclass.
*
* @throws IOException IOException
*/
@BeforeClass
public static void beforeClass() throws IOException {
Region region = Region.of(System.getProperty("testregion"));
String awsprofile = System.getProperty("testprofile");
appenvironment = System.getProperty("testappenvironment");
final SsmConnectionBuilder ssmBuilder = new SsmConnectionBuilder().setCredentials(awsprofile).setRegion(region);
ssmService = new SsmServiceImpl(ssmBuilder);
final S3ConnectionBuilder s3Builder = new S3ConnectionBuilder().setCredentials(awsprofile).setRegion(region);
s3 = new S3Service(s3Builder);
}
use of com.formkiq.aws.s3.S3ConnectionBuilder in project formkiq-core by formkiq.
the class DocumentsS3UpdateTest method beforeClass.
/**
* Before Class.
*
* @throws URISyntaxException URISyntaxException
* @throws InterruptedException InterruptedException
* @throws IOException IOException
*/
@BeforeAll
public static void beforeClass() throws URISyntaxException, InterruptedException, IOException {
Region region = Region.US_EAST_1;
AwsCredentialsProvider cred = StaticCredentialsProvider.create(AwsSessionCredentials.create("ACCESSKEY", "SECRETKEY", "TOKENKEY"));
localstack.start();
snsBuilder = new SnsConnectionBuilder().setEndpointOverride(localstack.getEndpointOverride(Service.SNS).toString()).setRegion(region).setCredentials(cred);
sqsBuilder = new SqsConnectionBuilder().setEndpointOverride(localstack.getEndpointOverride(Service.SQS).toString()).setRegion(region).setCredentials(cred);
sqsService = new SqsService(sqsBuilder);
s3Builder = new S3ConnectionBuilder().setEndpointOverride(localstack.getEndpointOverride(Service.S3).toString()).setRegion(region).setCredentials(cred);
dbBuilder = DynamoDbTestServices.getDynamoDbConnection(null);
service = new DocumentServiceImpl(dbBuilder, "Documents");
if (!sqsService.exists(ERROR_SQS_QUEUE)) {
sqsService.createQueue(ERROR_SQS_QUEUE);
}
if (!sqsService.exists(SNS_SQS_CREATE_QUEUE)) {
sqsDocumentEventUrl = sqsService.createQueue(SNS_SQS_CREATE_QUEUE).queueUrl();
}
s3service = new S3Service(s3Builder);
try (S3Client s3 = s3service.buildClient()) {
s3service.createBucket(s3, "example-bucket");
}
snsService = new SnsService(snsBuilder);
snsDocumentEvent = snsService.createTopic("createDocument1").topicArn();
snsService.subscribe(snsDocumentEvent, "sqs", sqsDocumentEventUrl);
dbHelper = new DynamoDbHelper(dbBuilder);
if (!dbHelper.isDocumentsTableExists()) {
dbHelper.createDocumentsTable();
dbHelper.createCacheTable();
}
}
Aggregations