Skip to content

Commit 70b45ad

Browse files
authored
Merge pull request #1 from kaiyaok2/fixed_all_flaky_tests
Fixed All Flaky Tests
2 parents 14dd202 + 2c45d1f commit 70b45ad

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

sdk1/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DynamoDBEncryptorTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import java.util.Collection;
4747
import java.util.Collections;
4848
import java.util.HashMap;
49+
import java.util.TreeMap;
4950
import java.util.HashSet;
5051
import java.util.Map;
5152
import java.util.Set;
@@ -198,15 +199,15 @@ public void ensureEncryptedAttributesUnmodified() throws GeneralSecurityExceptio
198199
Map<String, AttributeValue> encryptedAttributes =
199200
encryptor.encryptAllFieldsExcept(
200201
Collections.unmodifiableMap(attribs), context, "hashKey", "rangeKey", "version");
201-
String encryptedString = encryptedAttributes.toString();
202+
String encryptedString = new TreeMap<>(encryptedAttributes).toString();
202203
encryptor.decryptAllFieldsExcept(
203204
Collections.unmodifiableMap(encryptedAttributes),
204205
context,
205206
"hashKey",
206207
"rangeKey",
207208
"version");
208209

209-
assertEquals(encryptedString, encryptedAttributes.toString());
210+
assertEquals(encryptedString, new TreeMap<>(encryptedAttributes).toString());
210211
}
211212

212213
@Test(expectedExceptions = SignatureException.class)

sdk1/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/internal/AttributeValueMarshallerTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,12 @@ public void testSimpleMapWithNull() {
266266
marshall(av);
267267
Assert.fail("Unexpected success");
268268
} catch (final NullPointerException npe) {
269-
Assert.assertEquals(
270-
"Encountered null map value for key NullKeyValue while marshalling attribute value {M: {KeyValue={S: ValueValue,}, NullKeyValue=null},}",
271-
npe.getMessage());
269+
// Map entries may permute under nondeterministic Java API
270+
String npeMessage = npe.getMessage();
271+
String common = "Encountered null map value for key NullKeyValue while marshalling attribute value ";
272+
String case1 = common + "{M: {KeyValue={S: ValueValue,}, NullKeyValue=null},}";
273+
String case2 = common + "{M: {NullKeyValue=null, KeyValue={S: ValueValue,}},}";
274+
Assert.assertTrue(case1.equals(npeMessage) || case2.equals(npeMessage));
272275
}
273276
}
274277

0 commit comments

Comments
 (0)