|
25 | 25 | import static org.junit.Assert.assertThat;
|
26 | 26 | import static org.junit.Assert.assertTrue;
|
27 | 27 | import static org.junit.Assert.fail;
|
| 28 | +import static org.openqa.selenium.json.Json.MAP_TYPE; |
28 | 29 |
|
29 | 30 | import com.google.common.collect.ImmutableMap;
|
30 | 31 | import com.google.common.collect.ImmutableSortedSet;
|
|
59 | 60 | import org.openqa.selenium.remote.SessionId;
|
60 | 61 |
|
61 | 62 | import java.awt.*;
|
| 63 | +import java.beans.FeatureDescriptor; |
| 64 | +import java.beans.IntrospectionException; |
| 65 | +import java.beans.Introspector; |
| 66 | +import java.beans.PropertyDescriptor; |
62 | 67 | import java.io.StringReader;
|
63 | 68 | import java.net.MalformedURLException;
|
64 | 69 | import java.net.URL;
|
|
70 | 75 | import java.util.Set;
|
71 | 76 | import java.util.concurrent.TimeUnit;
|
72 | 77 | import java.util.logging.Level;
|
| 78 | +import java.util.stream.Stream; |
73 | 79 |
|
74 | 80 |
|
75 | 81 | @RunWith(JUnit4.class)
|
@@ -534,6 +540,20 @@ public void shouldConvertAUrlToAString() throws MalformedURLException {
|
534 | 540 | assertEquals(url.toExternalForm(), converted.get("url").getAsString());
|
535 | 541 | }
|
536 | 542 |
|
| 543 | + @Test |
| 544 | + public void shouldNotIncludePropertiesFromJavaLangObjectOtherThanClass() |
| 545 | + throws IntrospectionException { |
| 546 | + String json = new BeanToJsonConverter().convert(new SimpleBean()); |
| 547 | + |
| 548 | + JsonObject converted = new JsonParser().parse(json).getAsJsonObject(); |
| 549 | + |
| 550 | + Stream.of(SimplePropertyDescriptor.getPropertyDescriptors(Object.class)) |
| 551 | + .filter(pd -> !"class".equals(pd.getName())) |
| 552 | + .map(SimplePropertyDescriptor::getName) |
| 553 | + .peek(System.out::println) |
| 554 | + .forEach(name -> assertFalse(name, converted.keySet().contains(name))); |
| 555 | + } |
| 556 | + |
537 | 557 | @SuppressWarnings("unused")
|
538 | 558 | private static class SimpleBean {
|
539 | 559 |
|
|
0 commit comments