Skip to content

Commit

Permalink
Apply sbt-java-formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
mdedetrich authored and pjfanning committed May 28, 2023
1 parent 6426743 commit e9c8f97
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/java-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
- name: Cache Coursier cache
uses: coursier/cache-action@v6.4.0

- name: Check headers
- name: Check java code is formatted
run: |-
sbt \
+javafmtCheck
sbt javafmtCheckAll
51 changes: 34 additions & 17 deletions src/test/java/com/github/pjfanning/pekkohttpspi/s3/S3Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public class S3Test extends JUnitSuite {
private static SecureRandom rnd = new SecureRandom();

@Rule
public GenericContainer s3mock = new GenericContainer<>("adobe/s3mock:2.1.24").withExposedPorts(9090);
public GenericContainer s3mock =
new GenericContainer<>("adobe/s3mock:2.1.24").withExposedPorts(9090);

@Test
public void testS3() throws Exception {
Expand All @@ -58,9 +59,10 @@ public void testS3() throws Exception {
try {
pekkoClient = new PekkoHttpAsyncHttpService().createAsyncHttpClientFactory().build();

client = S3AsyncClient
.builder()
.serviceConfiguration(S3Configuration.builder().checksumValidationEnabled(false).build())
client =
S3AsyncClient.builder()
.serviceConfiguration(
S3Configuration.builder().checksumValidationEnabled(false).build())
.credentialsProvider(AnonymousCredentialsProvider.create())
.endpointOverride(new URI("http://localhost:" + s3mock.getMappedPort(9090)))
.region(Region.of("s3"))
Expand All @@ -81,11 +83,16 @@ public void testS3WithExistingActorSystem() throws Exception {
S3AsyncClient client = null;

try {
pekkoClient = new PekkoHttpAsyncHttpService().createAsyncHttpClientFactory().withActorSystem(system).build();
pekkoClient =
new PekkoHttpAsyncHttpService()
.createAsyncHttpClientFactory()
.withActorSystem(system)
.build();

client = S3AsyncClient
.builder()
.serviceConfiguration(S3Configuration.builder().checksumValidationEnabled(false).build())
client =
S3AsyncClient.builder()
.serviceConfiguration(
S3Configuration.builder().checksumValidationEnabled(false).build())
.credentialsProvider(AnonymousCredentialsProvider.create())
.endpointOverride(new URI("http://localhost:" + s3mock.getMappedPort(9090)))
.region(Region.of("s3"))
Expand All @@ -108,19 +115,29 @@ private void createBucketAndAssert(S3AsyncClient client) throws IOException {
FileWriter fileWriter = new FileWriter(randomFile);
fileWriter.write(fileContent);
fileWriter.flush();
client.putObject(PutObjectRequest.builder().bucket("foo").key("my-file").contentType("text/plain").build(), randomFile.toPath()).join();

ResponseBytes result = client.getObject(GetObjectRequest.builder().bucket("foo").key("my-file").build(),
AsyncResponseTransformer.toBytes()).join();
client
.putObject(
PutObjectRequest.builder()
.bucket("foo")
.key("my-file")
.contentType("text/plain")
.build(),
randomFile.toPath())
.join();

ResponseBytes result =
client
.getObject(
GetObjectRequest.builder().bucket("foo").key("my-file").build(),
AsyncResponseTransformer.toBytes())
.join();

assertEquals(fileContent, result.asUtf8String());
}

String randomString(int len) {
StringBuilder sb = new StringBuilder( len );
for( int i = 0; i < len; i++ )
sb.append( AB.charAt( rnd.nextInt(AB.length()) ) );
return sb.toString();
StringBuilder sb = new StringBuilder(len);
for (int i = 0; i < len; i++) sb.append(AB.charAt(rnd.nextInt(AB.length())));
return sb.toString();
}

}

0 comments on commit e9c8f97

Please sign in to comment.