Skip to content

Commit

Permalink
Merge pull request #15 from EMCECS/feature-update-object-client
Browse files Browse the repository at this point in the history
updated all dependencies and plugins
  • Loading branch information
twincitiesguy authored Oct 25, 2022
2 parents d74effa + d7c4b12 commit 0dbdf15
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 47 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id 'net.saliman.cobertura' version '4.0.0'
id 'distribution'
id 'com.github.johnrengelman.shadow' version '6.1.0'
id 'com.github.jk1.dependency-license-report' version '1.17'
id 'com.github.jk1.dependency-license-report' version '1.19'
id 'signing'
id 'maven'
id 'org.ajoberstar.git-publish' version '3.0.1'
Expand Down Expand Up @@ -37,9 +37,9 @@ repositories {
}

dependencies {
implementation 'com.emc.ecs:object-client:3.4.2'
implementation 'com.emc.ecs:smart-client-ecs:3.0.0'
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.18.0'
implementation 'com.emc.ecs:object-client:3.4.4'
implementation 'com.emc.ecs:smart-client-ecs:3.0.1'
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.19.0'
implementation 'commons-cli:commons-cli:1.5.0'
testImplementation 'junit:junit:4.13.2'
}
Expand Down
11 changes: 4 additions & 7 deletions src/main/resources/log4j.xml → src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@
<Console name="mainAppender" target="SYSTEM_OUT">
<PatternLayout pattern="%-10r %-5p [%-15t] %c{1}: %m%n"/>
</Console>
<Console name="infoAppender" target="SYSTEM_OUT" threshold="INFO">
<PatternLayout pattern="%-10r %-5p [%-15t] %c{1}: %m%n"/>
</Console>
</Appenders>
<Loggers>
<!-- Don't go above INFO for REST classes (takes up too much log space)
comment these out if you want full debug logs (will be huge)
WARNING: at debug level, if the following lines are not active,
object *data* will be logged in byte-hex ([0x9a]...) -->
<Logger name="org.apache.http" additivity="false">
<AppenderRef ref="infoAppender"/>
<Logger name="org.apache.http.wire" additivity="false">
<AppenderRef ref="mainAppender" level="info"/>
</Logger>
<Logger name="com.sun.jersey.api.client" additivity="false">
<AppenderRef ref="infoAppender"/>
<AppenderRef ref="mainAppender" level="info"/>
</Logger>
<Logger name="com.amazonaws.request" additivity="false">
<AppenderRef ref="infoAppender"/>
<AppenderRef ref="mainAppender" level="info"/>
</Logger>

<Root level="warn">
Expand Down
73 changes: 67 additions & 6 deletions src/test/java/com/emc/ecs/tool/TestBucketWipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.io.File;
import java.io.FileWriter;
import java.net.URI;
import java.util.Arrays;

public class TestBucketWipe {
private static final Logger log = LoggerFactory.getLogger(TestBucketWipe.class);
Expand Down Expand Up @@ -122,12 +123,13 @@ void deleteBucket(S3Client client, String bucketName) {
@Test
public void testUrlEncoding() {
S3Client client = new S3JerseyClient(getS3Config());
String bucketName = "test-bucket-wipe";
String bucketName = "test-bucket-wipe-encoding";
String[] keys = {
"foo!@#$%^&*()-_=+",
"bar\\u00a1\\u00bfbar",
"bar\u00a1\u00bfbar",
"查找的unicode",
"baz\\u0007bim"
"baz\u0007bim",
"spaces test"
};

// create bucket and keys
Expand Down Expand Up @@ -161,10 +163,69 @@ public void testUrlEncoding() {
}
}

@Test
public void testVersions() {
S3Client client = new S3JerseyClient(getS3Config());
String bucketName = "test-bucket-wipe-versions";
String[] keys = {
"foo!@#$%^&*()-_=+",
"bar\u00a1\u00bfbar",
"查找的unicode",
"baz\u0007bim",
"spaces test"
};

// create bucket and keys
createBucketAndKeys(client, bucketName, keys);

// enable versioning
client.setBucketVersioning(bucketName, new VersioningConfiguration().withStatus(VersioningConfiguration.Status.Enabled));

// delete some keys (even indexes)
int counter = 0;
for (String key : keys) {
if (counter++ % 2 == 0) client.deleteObject(bucketName, key);
}
// overwrite all keys
Arrays.stream(keys).forEach(key -> client.putObject(bucketName, key, "foo", "text/plain"));
// delete some other keys (odd indexes)
counter = 0;
for (String key : keys) {
if (counter++ % 2 == 1) client.deleteObject(bucketName, key);
}

try {
// delete the bucket with bucket-wipe
BucketWipe bucketWipe = new BucketWipe().withEndpoint(endpoint).withSmartClient(false)
.withAccessKey(accessKey).withSecretKey(secretKey);
bucketWipe.withBucket(bucketName).run();

if (bucketWipe.getResult().getErrors().size() > 0) {
for (String error : bucketWipe.getResult().getErrors()) {
System.err.println(error);
}
}

Assert.assertEquals(keys.length * 3, bucketWipe.getResult().getDeletedObjects());
Assert.assertEquals(0, bucketWipe.getResult().getErrors().size());

try {
client.listObjects(bucketName);
Assert.fail("bucket still exists");
} catch (S3Exception e) {
if (e.getHttpCode() != 404) log.error("unexpected error listing bucket", e);
Assert.assertEquals(e.getHttpCode(), 404);
}
} finally {
// clean up bucket and keys if necessary
deleteBucket(client, bucketName);
}
}

@Test
public void testWithSourceList() throws Exception {
S3Client client = new S3JerseyClient(getS3Config());
String bucketName = "test-bucket-wipe";
String bucketName = "test-bucket-wipe-list";
String[] keys = {
"key-1",
"key-2",
Expand Down Expand Up @@ -220,7 +281,7 @@ public void testWithSourceList() throws Exception {
public void testKeepBucket() {
// create bucket
S3Client client = new S3JerseyClient(getS3Config());
String bucketName = "test-bucket-wipe";
String bucketName = "test-bucket-wipe-keep";
String[] keys = {
"key-1",
"key-2",
Expand Down Expand Up @@ -263,7 +324,7 @@ public void testKeepBucket() {
@Test
public void testDeleteMpu() {
S3Client client = new S3JerseyClient(getS3Config());
String bucketName = "test-bucket-wipe";
String bucketName = "test-bucket-wipe-mpu";
String[] keys = {
"key-1",
"key-2",
Expand Down
30 changes: 0 additions & 30 deletions src/test/resources/log4j.xml

This file was deleted.

32 changes: 32 additions & 0 deletions src/test/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="mainAppender" target="SYSTEM_OUT">
<PatternLayout pattern="%-10r %-5p [%-15t] %c{1}: %m%n"/>
</Console>
</Appenders>
<Loggers>
<!-- Don't go above INFO for REST classes (takes up too much log space)
comment these out if you want full debug logs (will be huge)
WARNING: at debug level, if the following lines are not active,
object *data* will be logged in byte-hex ([0x9a]...) -->
<Logger name="org.apache.http.wire" additivity="false">
<AppenderRef ref="mainAppender" level="info"/>
</Logger>
<Logger name="com.sun.jersey.api.client" additivity="false">
<AppenderRef ref="mainAppender" level="info"/>
</Logger>
<Logger name="com.amazonaws.request" additivity="false">
<AppenderRef ref="mainAppender" level="info"/>
</Logger>

<!--
For request debugging
-->
<!-- <Logger name="org.apache.http.headers" level="debug"/>-->

<Root level="info">
<AppenderRef ref="mainAppender"/>
</Root>
</Loggers>
</Configuration>

0 comments on commit 0dbdf15

Please sign in to comment.