Skip to content

Commit 497e92e

Browse files
authored
Cleanup test warnings, update gitignore (#28)
Address test warnings, update gitignore Co-authored-by: Simon Marty <[email protected]>
1 parent 4af0926 commit 497e92e

File tree

4 files changed

+44
-8
lines changed

4 files changed

+44
-8
lines changed

.gitignore

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
1-
.idea/
21
build
32
target/
3+
pom.xml.tag
4+
pom.xml.releaseBackup
5+
pom.xml.versionsBackup
6+
pom.xml.next
7+
release.properties
8+
dependency-reduced-pom.xml
9+
buildNumber.properties
10+
.mvn/timing.properties
11+
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
12+
.mvn/wrapper/maven-wrapper.jar
13+
14+
# Eclipse m2e generated files
15+
# Eclipse Core
16+
.project
17+
# JDT-specific (Eclipse Java Development Tools)
18+
.classpath
19+
20+
# IntelliJ
21+
.idea/
422
*.iml
23+
24+
# VS Code
25+
.vscode
26+
27+
# macOS
28+
.DS_Store

pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<dependency>
4747
<groupId>com.amazonaws</groupId>
4848
<artifactId>aws-java-sdk-secretsmanager</artifactId>
49-
<version>1.12.262</version>
49+
<version>1.12.264</version>
5050
</dependency>
5151
<dependency>
5252
<groupId>org.testng</groupId>
@@ -114,6 +114,7 @@
114114
</configuration>
115115
<executions>
116116
<execution>
117+
<?m2e execute onConfiguration,onIncremental?>
117118
<id>validate</id>
118119
<phase>validate</phase>
119120
<goals>
@@ -133,6 +134,7 @@
133134
</configuration>
134135
<executions>
135136
<execution>
137+
<?m2e execute onConfiguration,onIncremental?>
136138
<id>analyze-compile</id>
137139
<phase>compile</phase>
138140
<goals>

src/main/java/com/amazonaws/secretsmanager/caching/cache/SecretCacheObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public SecretCacheObject(final String secretId,
125125
public abstract int hashCode();
126126
public abstract String toString();
127127

128-
protected <T extends AmazonWebServiceRequest> T updateUserAgent(T request) {
128+
protected <U extends AmazonWebServiceRequest> U updateUserAgent(U request) {
129129
request.getRequestClientOptions().appendUserAgent(VersionInfo.USER_AGENT);
130130
return request;
131131
}

src/test/java/com/amazonaws/secretsmanager/caching/SecretCacheTest.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ private static void repeat(int number, IntConsumer c) {
6868
public void exceptionSecretCacheTest() {
6969
SecretCache sc = new SecretCache();
7070
sc.getSecretString("");
71+
sc.close();
7172
}
7273

7374
@Test(expectedExceptions = {SdkClientException.class})
@@ -87,9 +88,11 @@ public void secretCacheConstructorTest() {
8788
SecretCache sc2 = null;
8889
try {
8990
sc1 = new SecretCache((SecretCacheConfiguration)null);
91+
sc1.close();
9092
} catch (Exception e) {}
9193
try {
9294
sc2 = new SecretCache((AWSSecretsManagerClientBuilder)null);
95+
sc2.close();
9396
} catch (Exception e) {}
9497
}
9598

@@ -150,6 +153,7 @@ public Object get(final Object o) {
150153
repeat(10, n -> Assert.assertEquals(sc.getSecretBinary(""),
151154
ByteBuffer.wrap(secret.getBytes())));
152155
Assert.assertEquals(hook.getCount(), 2);
156+
sc.close();
153157
}
154158

155159
@Test
@@ -172,6 +176,7 @@ public void secretCacheNullStagesTest() {
172176

173177
repeat(10, n -> Assert.assertEquals(sc.getSecretBinary(""),
174178
ByteBuffer.wrap(secret.getBytes())));
179+
sc.close();
175180
}
176181

177182
@Test
@@ -198,6 +203,7 @@ public void basicSecretCacheRefreshNowTest() throws Throwable {
198203
repeat(10, n -> Assert.assertEquals(sc.getSecretString(""), secret));
199204
Mockito.verify(asm, Mockito.times(2)).describeSecret(Mockito.any());
200205
Mockito.verify(asm, Mockito.times(1)).getSecretValue(Mockito.any());
206+
sc.close();
201207
}
202208

203209
@Test
@@ -221,6 +227,7 @@ public void basicSecretCacheByteBufferTest() {
221227

222228
repeat(10, n -> Assert.assertEquals(sc.getSecretBinary(""),
223229
ByteBuffer.wrap(secret.getBytes())));
230+
sc.close();
224231
}
225232

226233
@Test
@@ -242,6 +249,7 @@ public void basicSecretCacheMultipleTest() {
242249
// Verify that multiple requests did not call the API
243250
Mockito.verify(asm, Mockito.times(2)).describeSecret(Mockito.any());
244251
Mockito.verify(asm, Mockito.times(2)).getSecretValue(Mockito.any());
252+
sc.close();
245253
}
246254

247255
@Test
@@ -312,30 +320,30 @@ public void basicSecretCacheTestNoVersions() {
312320
// Verify that multiple requests did not call the API
313321
Mockito.verify(asm, Mockito.times(1)).describeSecret(Mockito.any());
314322
Mockito.verify(asm, Mockito.times(0)).getSecretValue(Mockito.any());
323+
sc.close();
315324
}
316325

317326
@Test(expectedExceptions = {RuntimeException.class})
318327
public void basicSecretCacheExceptionTest() {
319-
final String secret = "basicSecretCacheExceptionTest";
320328
Mockito.when(asm.describeSecret(Mockito.any())).thenThrow(new RuntimeException());
321329
SecretCache sc = new SecretCache(asm);
322330
sc.getSecretString("");
331+
sc.close();
323332
}
324333

325334
@Test
326335
public void basicSecretCacheExceptionRefreshNowTest() throws Throwable {
327-
final String secret = "basicSecretCacheExceptionTest";
328336
Mockito.when(asm.describeSecret(Mockito.any())).thenThrow(new RuntimeException());
329337
SecretCache sc = new SecretCache(asm);
330338
Assert.assertFalse(sc.refreshNow(""));
331339
Mockito.verify(asm, Mockito.times(1)).describeSecret(Mockito.any());
332340
Assert.assertFalse(sc.refreshNow(""));
333341
Mockito.verify(asm, Mockito.times(2)).describeSecret(Mockito.any());
342+
sc.close();
334343
}
335344

336345
@Test
337346
public void basicSecretCacheExceptionRetryTest() throws Throwable {
338-
final String secret = "basicSecretCacheExceptionTest";
339347
final int retryCount = 10;
340348
Mockito.when(asm.describeSecret(Mockito.any())).thenThrow(new RuntimeException());
341349
SecretCache sc = new SecretCache(asm);
@@ -357,22 +365,23 @@ public void basicSecretCacheExceptionRetryTest() throws Throwable {
357365
} catch (RuntimeException ex) {}
358366
// The api call should have been retried after the delay.
359367
Mockito.verify(asm, Mockito.times(2)).describeSecret(Mockito.any());
368+
sc.close();
360369
}
361370

362371
@Test
363372
public void basicSecretCacheNullTest() {
364-
final String secret = "basicSecretCacheNullTest";
365373
Mockito.when(asm.describeSecret(Mockito.any())).thenReturn(null);
366374
SecretCache sc = new SecretCache(asm);
367375
Assert.assertNull(sc.getSecretString(""));
376+
sc.close();
368377
}
369378

370379
@Test
371380
public void basicSecretCacheNullStagesTest() {
372-
final String secret = "basicSecretCacheNullStagesTest";
373381
Mockito.when(describeSecretResult.getVersionIdsToStages()).thenReturn(null);
374382
SecretCache sc = new SecretCache(asm);
375383
Assert.assertNull(sc.getSecretString(""));
384+
sc.close();
376385
}
377386

378387
@Test
@@ -390,6 +399,7 @@ public void basicSecretCacheVersionWithNullStageTest() {
390399
// Verify that multiple requests did not call the API
391400
Mockito.verify(asm, Mockito.times(1)).describeSecret(Mockito.any());
392401
Mockito.verify(asm, Mockito.times(0)).getSecretValue(Mockito.any());
402+
sc.close();
393403
}
394404

395405
}

0 commit comments

Comments
 (0)