Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) Fix signature issue and upgrade dependencies #52

Merged
merged 6 commits into from
Nov 7, 2020
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
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true

[Makefile]
indent_style = tab

[**/examples/**.java]
# 84 looks like a odd number, however
# it accounts for 4 spaces (class and example method indentation)
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ target
build
.vertx
.DS_Store
.run
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Artifacts are published [here](https://search.maven.org/artifact/io.reactiverse/

| Project | Vert.x | AWS sdk |
| ------- | ------ | ------- |
| 0.7.0 | 3.9.4 | 2.15.23 |
| 0.6.0 | 3.9.2 | 2.14.7 |
| 0.5.1 | 3.9.2 | 2.13.6 |
| 0.5.0 | 3.9.0 | 2.12.0 |
Expand Down
23 changes: 18 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
val vertxVersion = "3.9.2"
val awsSdkVersion = "2.14.7"
val vertxVersion = "3.9.4"
val awsSdkVersion = "2.15.23"
val junit5Version = "5.4.0"
val logbackVersion = "1.2.3"
val integrationOption = "tests.integration"

group = "io.reactiverse"
version = "0.6.0"
version = "0.7.0"

plugins {
`java-library`
`maven-publish`
jacoco
id("com.jfrog.bintray") version "1.8.5"
id("com.jaredsburrows.license") version "0.8.42"
id("org.sonarqube") version "2.6"
id("org.sonarqube") version "3.0"
id("com.github.ben-manes.versions") version "0.34.0"
}

// In order to publish SNAPSHOTs to Sonatype Snapshots repository => the CI should define such `ossrhUsername` and `ossrhPassword` properties
Expand Down Expand Up @@ -54,13 +55,20 @@ repositories {
}
}

fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}

dependencies {
api("io.vertx:vertx-core:$vertxVersion")
api("software.amazon.awssdk:aws-core:$awsSdkVersion")

testImplementation("io.vertx:vertx-junit5:$vertxVersion")
testImplementation("io.vertx:vertx-rx-java2:$vertxVersion")
testImplementation("cloud.localstack:localstack-utils:0.1.22")
testImplementation("cloud.localstack:localstack-utils:0.2.5")
testImplementation("ch.qos.logback:logback-classic:$logbackVersion")
testImplementation("ch.qos.logback:logback-core:$logbackVersion")
testImplementation("software.amazon.awssdk:aws-sdk-java:$awsSdkVersion")
Expand All @@ -78,6 +86,11 @@ jacoco {
}

tasks {
named("dependencyUpdates", com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask::class.java).configure {
rejectVersionIf {
isNonStable(candidate.version)
}
}

jacocoTestReport {
dependsOn(":test")
Expand Down
32 changes: 23 additions & 9 deletions src/main/java/io/reactiverse/awssdk/VertxNioAsyncHttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@
import io.reactiverse.awssdk.reactivestreams.ReadStreamPublisher;
import io.vertx.core.Context;
import io.vertx.core.Vertx;
import io.vertx.core.http.*;
import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpClientRequest;
import io.vertx.core.http.HttpHeaders;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.RequestOptions;
import software.amazon.awssdk.http.SdkHttpFullResponse;
import software.amazon.awssdk.http.SdkHttpRequest;
import software.amazon.awssdk.http.SdkHttpResponse;
import software.amazon.awssdk.http.async.AsyncExecuteRequest;
import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
import software.amazon.awssdk.http.async.SdkAsyncHttpResponseHandler;
import software.amazon.awssdk.http.async.SdkHttpContentPublisher;
import software.amazon.awssdk.utils.StringUtils;

import java.util.Optional;
import java.net.URI;
import java.util.concurrent.CompletableFuture;

import static java.util.Objects.requireNonNull;
Expand Down Expand Up @@ -90,13 +96,21 @@ void executeOnContext(AsyncExecuteRequest asyncExecuteRequest, CompletableFuture
}
}

private static RequestOptions getRequestOptions(SdkHttpRequest request) {
return new RequestOptions()
.setHost(request.host())
.setPort(request.port())
.setURI(request.encodedPath())
.setSsl("https".equals(request.protocol()));
}
private static RequestOptions getRequestOptions(SdkHttpRequest request) {
return new RequestOptions()
.setHost(request.host())
.setPort(request.port())
.setURI(createRelativeUri(request.getUri()))
.setSsl("https".equals(request.protocol()));
}

private static String createRelativeUri(URI uri) {
return (StringUtils.isEmpty(uri.getPath()) ? "/" : uri.getPath()) +
// AWS requires query parameters to be encoded as defined by RFC 3986.
// see https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html
// uri.toASCIIString() returns the URI encoded in this manner
(StringUtils.isEmpty(uri.getQuery()) ? "" : "?" + uri.toASCIIString().split("\\?")[1]);
}

@Override
public void close() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.reactiverse.awssdk.integration;

import cloud.localstack.docker.LocalstackDocker;
import cloud.localstack.Localstack;
import io.reactivex.Single;
import io.reactivex.SingleOnSubscribe;
import io.vertx.core.Context;
Expand Down Expand Up @@ -39,7 +39,7 @@ protected void assertContext(Vertx vertx, Context context, VertxTestContext test
}

protected static URI s3URI() throws Exception {
return new URI(LocalstackDocker.INSTANCE.getEndpointS3());
return new URI(Localstack.INSTANCE.getEndpointS3());
}

protected static S3AsyncClient s3(Context context) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.reactiverse.awssdk.integration.apigateway;

import cloud.localstack.docker.LocalstackDocker;
import cloud.localstack.Localstack;
import cloud.localstack.docker.LocalstackDockerExtension;
import cloud.localstack.docker.annotation.LocalstackDockerProperties;
import io.reactiverse.awssdk.VertxSdkClient;
Expand Down Expand Up @@ -40,13 +40,13 @@
import static org.junit.jupiter.api.Assertions.assertEquals;

@EnabledIfSystemProperty(named = "tests.integration", matches = "localstack")
@LocalstackDockerProperties(services = { "apigateway" }, imageTag = "0.10.2")
@LocalstackDockerProperties(services = { "apigateway" }, imageTag = "0.12.2")
@ExtendWith(VertxExtension.class)
@ExtendWith(LocalstackDockerExtension.class)
public class VertxApiGatewaySpec extends LocalStackBaseSpec {

private final static String API_NAME = "My-API";
private final static String PATH = "/faking";
private final static String API_NAME = "MyAPI";
private final static String PATH = "faking";
private final static HttpMethod METHOD = HttpMethod.GET;
private final static Map<String, String> TEMPLATES = new HashMap<>();
private final static String MOCK_RESPONSE = "{\"message\": \"Hello from a fake backend\"}";
Expand All @@ -60,7 +60,8 @@ public class VertxApiGatewaySpec extends LocalStackBaseSpec {
private String resourceId;

// README: see below for the full test
// But: https://github.com/localstack/localstack/issues/1030
// Since: https://github.com/localstack/localstack/issues/1030 has been fixed, it should work, but there's another issue
// (on the test design this time: No integration defined for method "Service: ApiGateway" => investigate later)
// For now we're just testing creation requests, but not the actual routing one, because localstack doesn't allow it
@Test
@Timeout(value = 10, timeUnit = TimeUnit.SECONDS)
Expand Down Expand Up @@ -174,11 +175,11 @@ private Single<TestInvokeMethodResponse> makeIntegrationTest() {
private static CreateRestApiRequest.Builder restApiDefinition(CreateRestApiRequest.Builder rar) {
return rar.name(API_NAME)
.binaryMediaTypes("text/plain")
.description("Fetches weather");
.description("Fetches_weather");
}

private void createGatewayClient(Context context) throws Exception {
final URI gatewayURI = new URI(LocalstackDocker.INSTANCE.getEndpointAPIGateway());
final URI gatewayURI = new URI(Localstack.INSTANCE.getEndpointAPIGateway());
final ApiGatewayAsyncClientBuilder builder = ApiGatewayAsyncClient.builder()
.region(Region.US_EAST_1)
.credentialsProvider(credentialsProvider)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.reactiverse.awssdk.integration.cloudwatch;

import cloud.localstack.docker.LocalstackDocker;
import cloud.localstack.Localstack;
import cloud.localstack.docker.LocalstackDockerExtension;
import cloud.localstack.docker.annotation.LocalstackDockerProperties;
import io.reactiverse.awssdk.VertxSdkClient;
Expand All @@ -23,11 +23,10 @@
import java.net.URI;
import java.util.concurrent.TimeUnit;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

@EnabledIfSystemProperty(named = "tests.integration", matches = "localstack")
@LocalstackDockerProperties(services = { "cloudwatch" }, imageTag = "0.10.2")
@LocalstackDockerProperties(services = { "cloudwatch" }, imageTag = "0.12.2")
@ExtendWith(VertxExtension.class)
@ExtendWith(LocalstackDockerExtension.class)
public class VertxCloudWatchClientSpec extends LocalStackBaseSpec {
Expand Down Expand Up @@ -85,7 +84,7 @@ private static PutDashboardRequest.Builder createDashboard(PutDashboardRequest.B
}

private static CloudWatchAsyncClient cloudwatchClient(Context ctx) throws Exception {
final URI cloudwatchURI = new URI(LocalstackDocker.INSTANCE.getEndpointCloudWatch());
final URI cloudwatchURI = new URI(Localstack.INSTANCE.getEndpointCloudWatch());
final CloudWatchAsyncClientBuilder builder =
CloudWatchAsyncClient.builder()
.credentialsProvider(credentialsProvider)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.reactiverse.awssdk.integration.dynamodb;

import cloud.localstack.docker.LocalstackDocker;
import cloud.localstack.Localstack;
import cloud.localstack.docker.LocalstackDockerExtension;
import cloud.localstack.docker.annotation.LocalstackDockerProperties;
import io.reactiverse.awssdk.VertxSdkClient;
Expand Down Expand Up @@ -37,7 +37,7 @@
@ExtendWith(VertxExtension.class)
@ExtendWith(LocalstackDockerExtension.class)
@EnabledIfSystemProperty(named = "tests.integration", matches = "localstack")
@LocalstackDockerProperties(services = { "dynamodb" }, imageTag = "0.10.2")
@LocalstackDockerProperties(services = { "dynamodb" }, imageTag = "0.12.2")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class VertxDynamoClientSpec extends LocalStackBaseSpec {

Expand Down Expand Up @@ -136,7 +136,7 @@ private static GetItemRequest.Builder getItem(GetItemRequest.Builder gib) {
}

private DynamoDbAsyncClient dynamo(Context context) throws Exception {
final URI dynamoEndpoint = new URI(LocalstackDocker.INSTANCE.getEndpointDynamoDB());
final URI dynamoEndpoint = new URI(Localstack.INSTANCE.getEndpointDynamoDB());
return VertxSdkClient.withVertx(
DynamoDbAsyncClient.builder()
.region(Region.EU_WEST_1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.reactiverse.awssdk.integration.firehose;

import cloud.localstack.docker.LocalstackDocker;
import cloud.localstack.Localstack;
import cloud.localstack.docker.LocalstackDockerExtension;
import cloud.localstack.docker.annotation.LocalstackDockerProperties;
import io.reactiverse.awssdk.VertxSdkClient;
Expand Down Expand Up @@ -52,7 +52,7 @@
@ExtendWith(VertxExtension.class)
@ExtendWith(LocalstackDockerExtension.class)
@EnabledIfSystemProperty(named = "tests.integration", matches = "localstack")
@LocalstackDockerProperties(services = { "firehose", "s3" }, imageTag = "0.10.2")
@LocalstackDockerProperties(services = { "firehose", "s3" }, imageTag = "0.12.2")
public class VertxFirehoseClientSpec extends LocalStackBaseSpec {

private final static String STREAM = "My-Vertx-Firehose-Stream";
Expand Down Expand Up @@ -173,6 +173,6 @@ private void createFirehoseClient(Context context) throws Exception {
}

private static URI getFirehoseURI() throws Exception {
return new URI(LocalstackDocker.INSTANCE.getEndpointFirehose());
return new URI(Localstack.INSTANCE.getEndpointFirehose());
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.reactiverse.awssdk.integration.kinesis;

import cloud.localstack.docker.LocalstackDocker;
import cloud.localstack.Localstack;
import cloud.localstack.docker.LocalstackDockerExtension;
import cloud.localstack.docker.annotation.LocalstackDockerProperties;
import io.reactiverse.awssdk.VertxSdkClient;
Expand Down Expand Up @@ -41,7 +41,7 @@
@ExtendWith(VertxExtension.class)
@ExtendWith(LocalstackDockerExtension.class)
@EnabledIfSystemProperty(named = "tests.integration", matches = "localstack")
@LocalstackDockerProperties(services = { "kinesis" }, imageTag = "0.10.2")
@LocalstackDockerProperties(services = { "kinesis" }, imageTag = "0.12.2")
public class VertxKinesisClientSpec extends LocalStackBaseSpec {

private final static String STREAM = "my-awesome-stream";
Expand All @@ -61,7 +61,7 @@ public static void createStream() throws Exception {
KinesisClient client = KinesisClient.builder()
.region(Region.EU_WEST_1)
.credentialsProvider(credentialsProvider)
.endpointOverride(new URI(LocalstackDocker.INSTANCE.getEndpointKinesis()))
.endpointOverride(new URI(Localstack.INSTANCE.getEndpointKinesis()))
.build();
CreateStreamResponse resp = client.createStream(cs -> cs.streamName(STREAM).shardCount(1));
assertNotNull(resp);
Expand Down Expand Up @@ -149,7 +149,7 @@ private Consumer<GetShardIteratorRequest.Builder> shardIterator(String shardId)
}

private KinesisAsyncClient kinesis(Context context) throws Exception {
final URI kinesisURI = new URI(LocalstackDocker.INSTANCE.getEndpointKinesis());
final URI kinesisURI = new URI(Localstack.INSTANCE.getEndpointKinesis());
final KinesisAsyncClientBuilder builder = KinesisAsyncClient.builder()
.region(Region.EU_WEST_1)
.endpointOverride(kinesisURI)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.reactiverse.awssdk.integration.lambda;

import cloud.localstack.docker.LocalstackDocker;
import cloud.localstack.Localstack;
import cloud.localstack.docker.LocalstackDockerExtension;
import cloud.localstack.docker.annotation.LocalstackDockerProperties;
import io.reactiverse.awssdk.VertxSdkClient;
Expand Down Expand Up @@ -38,7 +38,7 @@
import static org.junit.jupiter.api.Assertions.assertNull;

@EnabledIfSystemProperty(named = "tests.integration", matches = "localstack")
@LocalstackDockerProperties(services = { "lambda" }, imageTag = "0.10.2")
@LocalstackDockerProperties(services = { "lambda" }, imageTag = "0.12.2")
@ExtendWith(VertxExtension.class)
@ExtendWith(LocalstackDockerExtension.class)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
Expand Down Expand Up @@ -119,7 +119,7 @@ private static InvokeRequest.Builder lambdaInvokation(InvokeRequest.Builder irb)
}

private static LambdaAsyncClient createLambdaClient(Context ctx) throws Exception {
final URI lambdaURI = new URI(LocalstackDocker.INSTANCE.getEndpointLambda());
final URI lambdaURI = new URI(Localstack.INSTANCE.getEndpointLambda());
final LambdaAsyncClientBuilder builder =
LambdaAsyncClient.builder()
.credentialsProvider(credentialsProvider)
Expand Down
Loading