This is an automated email from the ASF dual-hosted git repository.

gaul pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jclouds.git


The following commit(s) were added to refs/heads/master by this push:
     new e7894e5a77 Use a class with a File member
e7894e5a77 is described below

commit e7894e5a775c44aca860840a6a57c3c80beee51d
Author: Andrew Gaul <and...@gaul.org>
AuthorDate: Sun Jun 11 23:04:38 2023 -0700

    Use a class with a File member
    
    Using gson on a File directly breaks Java strong encapsulation.
---
 .../org/jclouds/rest/binders/BindToJsonPayloadTest.java     | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git 
a/core/src/test/java/org/jclouds/rest/binders/BindToJsonPayloadTest.java 
b/core/src/test/java/org/jclouds/rest/binders/BindToJsonPayloadTest.java
index 6954c361d7..6eefc2b3d0 100644
--- a/core/src/test/java/org/jclouds/rest/binders/BindToJsonPayloadTest.java
+++ b/core/src/test/java/org/jclouds/rest/binders/BindToJsonPayloadTest.java
@@ -23,7 +23,6 @@ import java.io.File;
 import org.jclouds.http.HttpRequest;
 import org.jclouds.json.Json;
 import org.jclouds.json.config.GsonModule;
-import org.testng.annotations.Ignore;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableMap;
@@ -48,15 +47,19 @@ public class BindToJsonPayloadTest {
 
    }
 
-   // TODO: fails with Failed making field 'java.io.File#path' accessible; 
either increase its visibility or write a custom TypeAdapter for its declaring 
type.
-   // This is serializing a File which we don't actually care about.  Just 
pick a different type instead?
-   @Ignore
+   private static class MyFile {
+      private MyFile(File path) {
+         this.path = path;
+      }
+      private final File path;
+   }
+
    @Test
    public void testSomethingNotAMap() throws SecurityException, 
NoSuchMethodException {
       BindToJsonPayload binder = new BindToJsonPayload(json);
 
       HttpRequest request = 
HttpRequest.builder().method("GET").endpoint("http://momma";).build();
-      request = binder.bindToRequest(request, new File("foo"));
+      request = binder.bindToRequest(request, new MyFile(new File("foo")));
       assertEquals(request.getPayload().getRawContent(), "{\"path\":\"foo\"}");
       assertEquals(request.getPayload().getContentMetadata().getContentType(), 
"application/json");
 

Reply via email to