Skip to content

Commit 0bbc16f

Browse files
authored
Merge pull request #57 from EMCECS/bugfix-truncated-write-tests
adjustments for some refactoring done in other branches
2 parents 02800f3 + 97386e3 commit 0bbc16f

File tree

3 files changed

+23
-31
lines changed

3 files changed

+23
-31
lines changed

src/test/java/com/emc/object/s3/AbstractS3ClientTest.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected void createBucket(String bucketName) throws Exception {
8686
}
8787

8888
@Override
89-
protected void cleanUpBucket(String bucketName) throws Exception {
89+
protected void cleanUpBucket(String bucketName) {
9090
if (client != null && client.bucketExists(bucketName)) {
9191
if (client.getBucketVersioning(bucketName).getStatus() != null) {
9292
for (AbstractVersion version : client.listVersions(new ListVersionsRequest(bucketName).withEncodingType(EncodingType.url)).getVersions()) {
@@ -101,27 +101,23 @@ protected void cleanUpBucket(String bucketName) throws Exception {
101101
}
102102
}
103103

104+
/**
105+
* this should be the only hook method for generating an S3Config instance - if a test class needs any
106+
* customizations to the config, override this method and call super, then make your customizations
107+
*/
104108
protected S3Config createS3Config() throws Exception {
105109
return s3ConfigFromProperties();
106110
}
107111

108-
protected S3Config s3ConfigFromProperties() throws Exception {
112+
static S3Config s3ConfigFromProperties() throws Exception {
109113
Properties props = TestConfig.getProperties();
110114

111-
String accessKey = TestConfig.getPropertyNotEmpty(props, TestProperties.S3_ACCESS_KEY);
112-
String secretKey = TestConfig.getPropertyNotEmpty(props, TestProperties.S3_SECRET_KEY);
113-
114-
S3Config s3Config = s3ConfigNetWorkSetting(props);
115-
s3Config.withIdentity(accessKey).withSecretKey(secretKey);
116-
117-
return s3Config;
118-
}
119-
120-
protected S3Config s3ConfigNetWorkSetting(Properties props) throws Exception {
121115
URI endpoint = new URI(TestConfig.getPropertyNotEmpty(props, TestProperties.S3_ENDPOINT));
122116
boolean enableVhost = Boolean.parseBoolean(props.getProperty(TestProperties.ENABLE_VHOST));
123117
boolean disableSmartClient = Boolean.parseBoolean(props.getProperty(TestProperties.DISABLE_SMART_CLIENT));
124118
String proxyUriStr = props.getProperty(TestProperties.PROXY_URI);
119+
String accessKey = TestConfig.getPropertyNotEmpty(props, TestProperties.S3_ACCESS_KEY);
120+
String secretKey = TestConfig.getPropertyNotEmpty(props, TestProperties.S3_SECRET_KEY);
125121

126122
S3Config s3Config;
127123
if (enableVhost) {
@@ -144,6 +140,8 @@ protected S3Config s3ConfigNetWorkSetting(Properties props) throws Exception {
144140
if (disableSmartClient)
145141
s3Config.setSmartClient(false);
146142

143+
s3Config.withIdentity(accessKey).withSecretKey(secretKey);
144+
147145
return s3Config;
148146
}
149147
}

src/test/java/com/emc/object/s3/S3TempCredentialsTest.java

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import com.sun.jersey.api.client.Client;
99
import com.sun.jersey.api.client.ClientResponse;
1010
import org.junit.*;
11-
import org.slf4j.Logger;
12-
import org.slf4j.LoggerFactory;
1311

1412
import java.net.HttpURLConnection;
1513
import java.net.URI;
@@ -19,18 +17,17 @@
1917
import java.util.Properties;
2018

2119
public class S3TempCredentialsTest extends S3JerseyClientTest {
22-
private static final Logger log = LoggerFactory.getLogger(S3TempCredentialsTest.class);
2320
private static final String SESSION_TOKEN = "Cghuc190ZXN0MRIIaWFtX3VzZXIaFEFST0EzQjFGMDc0OUJFQkIzRDlFIiB1cm46ZWNzOmlhbTo6bnNfdGVzdDE6cm9sZS9yb2xlMSoUQVNJQUI1MTEzMzYwN0FBNzg1QjUyUE1hc3RlcktleVJlY29yZC0zZGE0ZTJlNmMyMGNiMzg2NDVlZTJlYjlkNWUxYzUxODJiYTBhYjQ3NWIxMDg4YWE5NDBmMzIyZTAyNWEzY2Q1OKXTrK2VL1IMZWNzLXN0cy10ZW1waL_l44QG";
2421

25-
protected S3Config s3ConfigFromProperties() throws Exception {
26-
22+
@Override
23+
protected S3Config createS3Config() throws Exception {
2724
Properties props = TestConfig.getProperties();
2825

2926
String accessKey = TestConfig.getPropertyNotEmpty(props, TestProperties.S3_TEMP_ACCESS_KEY);
3027
String secretKey = TestConfig.getPropertyNotEmpty(props, TestProperties.S3_TEMP_SECRET_KEY);
3128
String securityToken = TestConfig.getPropertyNotEmpty(props, TestProperties.S3_SECURITY_TOKEN);
3229

33-
S3Config s3Config = s3ConfigNetWorkSetting(props);
30+
S3Config s3Config = super.createS3Config();
3431
s3Config.withIdentity(accessKey).withSecretKey(secretKey).withSessionToken(securityToken);
3532

3633
return s3Config;
@@ -157,46 +154,42 @@ public void testPreSignedUrlWithHeaders() throws Exception {
157154

158155
@Ignore
159156
@Test
160-
public void testMultipleVdcs() throws Exception {
157+
public void testMultipleVdcs() {
161158
}
162159

163160
@Ignore
164161
@Test
165-
public void testMpuAbortInMiddle() throws Exception {
162+
public void testMpuAbortInMiddle() {
166163
}
167164

168165
@Ignore
169166
@Test
170-
public void testSetObjectAclRequestAcl() throws Exception {
167+
public void testSetObjectAclRequestAcl() {
171168
}
172169

173170
@Ignore
174171
@Test
175-
public void testSetObjectAcl() throws Exception {
172+
public void testSetObjectAcl() {
176173
}
177174

178175
@Ignore
179176
@Test
180177
public void testCreateFilesystemBucket() {
181-
super.testCreateFilesystemBucket();
182178
}
183179

184180
@Ignore
185181
@Test
186-
public void testSetBucketAclCanned() throws Exception {
187-
super.testSetBucketAclCanned();
182+
public void testSetBucketAclCanned() {
188183
}
189184

190185
@Ignore
191186
@Test
192-
public void testSetGetBucketAcl() throws Exception {
193-
super.testSetGetBucketAcl();
187+
public void testSetGetBucketAcl() {
194188
}
195189

196190
@Ignore
197191
@Test
198-
public void testExtendObjectRetentionPeriod() throws Exception {
199-
super.testExtendObjectRetentionPeriod();
192+
public void testExtendObjectRetentionPeriod() {
200193
}
201194

202195
private S3Client getPresignDummyClient() throws URISyntaxException {

src/test/java/com/emc/object/s3/WriteTruncationTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
import com.sun.jersey.api.client.ClientHandlerException;
1111
import com.sun.jersey.client.urlconnection.URLConnectionClientHandler;
1212
import org.apache.commons.codec.digest.DigestUtils;
13-
import org.apache.log4j.Logger;
1413
import org.junit.*;
14+
import org.slf4j.Logger;
15+
import org.slf4j.LoggerFactory;
1516

1617
import javax.xml.bind.DatatypeConverter;
1718
import java.io.ByteArrayInputStream;
@@ -21,7 +22,7 @@
2122
import java.util.Random;
2223

2324
public class WriteTruncationTest {
24-
public static final Logger log = Logger.getLogger(WriteTruncationTest.class);
25+
public static final Logger log = LoggerFactory.getLogger(WriteTruncationTest.class);
2526

2627
static final String BUCKET_NAME = "ecs-object-client-write-truncation-test";
2728
static final int OBJECT_RETENTION_PERIOD = 15; // 15 seconds

0 commit comments

Comments
 (0)