mosche commented on a change in pull request #16607:
URL: https://github.com/apache/beam/pull/16607#discussion_r793412422



##########
File path: 
sdks/java/io/amazon-web-services2/src/test/java/org/apache/beam/sdk/io/aws2/s3/S3ResourceIdTest.java
##########
@@ -75,6 +81,62 @@
           new TestCase(
               "s3://bucket/path/to/dir/", "..", RESOLVE_DIRECTORY, 
"s3://bucket/path/to/"));
 
+  private S3ResourceId deserializeFromB64(String base64) throws Exception {
+    ByteArrayInputStream b = new 
ByteArrayInputStream(Base64.getDecoder().decode(base64));
+    try (ObjectInputStream s = new ObjectInputStream(b)) {
+      return (S3ResourceId) s.readObject();
+    }
+  }
+
+  private String serializeToB64(S3ResourceId r) throws Exception {
+    ByteArrayOutputStream b = new ByteArrayOutputStream();
+    try (ObjectOutputStream s = new ObjectOutputStream(b)) {
+      s.writeObject(r);
+    }
+    return Base64.getEncoder().encodeToString(b.toByteArray());
+  }
+
+  @Test
+  public void testSerialization() throws Exception {
+    String r1Serialized =
+        
"rO0ABXNyACtvcmcuYXBhY2hlLmJlYW0uc2RrLmlvLmF3czIuczMuUzNSZXNvdXJjZUlkC+xJufQ6MnwCAAVMAAZidWNrZXR0ABJMamF2YS9sYW5nL1N0cmluZztMAANrZXlxAH4AAUwADGxhc3RNb2RpZmllZHQAEExqYXZhL3V0aWwvRGF0ZTtMAAZzY2hlbWVxAH4AAUwABHNpemV0ABBMamF2YS9sYW5nL0xvbmc7eHB0AAZidWNrZXR0AAYvYS9iL2NwdAACczNw";
+    String r2Serialized =
+        
"rO0ABXNyACtvcmcuYXBhY2hlLmJlYW0uc2RrLmlvLmF3czIuczMuUzNSZXNvdXJjZUlkC+xJufQ6MnwCAAVMAAZidWNrZXR0ABJMamF2YS9sYW5nL1N0cmluZztMAANrZXlxAH4AAUwADGxhc3RNb2RpZmllZHQAEExqYXZhL3V0aWwvRGF0ZTtMAAZzY2hlbWVxAH4AAUwABHNpemV0ABBMamF2YS9sYW5nL0xvbmc7eHB0AAxvdGhlci1idWNrZXR0AAYveC95L3pwdAACczNw";
+    String r3Serialized =
+        
"rO0ABXNyACtvcmcuYXBhY2hlLmJlYW0uc2RrLmlvLmF3czIuczMuUzNSZXNvdXJjZUlkC+xJufQ6MnwCAAVMAAZidWNrZXR0ABJMamF2YS9sYW5nL1N0cmluZztMAANrZXlxAH4AAUwADGxhc3RNb2RpZmllZHQAEExqYXZhL3V0aWwvRGF0ZTtMAAZzY2hlbWVxAH4AAUwABHNpemV0ABBMamF2YS9sYW5nL0xvbmc7eHB0AAx0aGlyZC1idWNrZXR0AAkvZm9vL2Jhci9wdAACczNw";
+    String r4Serialized =
+        
"rO0ABXNyACtvcmcuYXBhY2hlLmJlYW0uc2RrLmlvLmF3czIuczMuUzNSZXNvdXJjZUlkC+xJufQ6MnwCAAVMAAZidWNrZXR0ABJMamF2YS9sYW5nL1N0cmluZztMAANrZXlxAH4AAUwADGxhc3RNb2RpZmllZHQAEExqYXZhL3V0aWwvRGF0ZTtMAAZzY2hlbWVxAH4AAUwABHNpemV0ABBMamF2YS9sYW5nL0xvbmc7eHB0AApiYXotYnVja2V0dAAGL2EvYi9jcHQAAnMzcA==";
+
+    S3ResourceId r1 = S3ResourceId.fromComponents("s3", "bucket", "a/b/c");
+    S3ResourceId r2 = S3ResourceId.fromComponents("s3", "other-bucket", 
"x/y/z").withSize(123);
+    S3ResourceId r3 =
+        S3ResourceId.fromComponents("s3", "third-bucket", "foo/bar/")
+            .withLastModified(new Date(2021, 6, 3));

Review comment:
       `ErrorProne` complains about these dates, please use `new 
Date("06/03/2021")`or `SimpleDateFormat` or similar ...
   
   
   > This Date usage looks suspect for the following reason(s): The 1900-based 
year value (2021) is out of bounds [1..150]. Use Calendar.JULY instead of 6 to 
represent the month.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to