aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Somov <public.somov@gmail.com>2022-09-12 09:42:32 +0300
committerAndrey Somov <public.somov@gmail.com>2022-09-12 11:17:30 +0300
commit13192431b0899ba61a2c18332ad5b50c0f54ee74 (patch)
treea18e6b34cc7f854b7c9139fc36360771eca0b084
parent9c05d7250e565df10bdf0da92bf89a1c39e5c073 (diff)
downloadsnakeyaml-13192431b0899ba61a2c18332ad5b50c0f54ee74.tar.gz
Fix PropertyTest for Android
-rw-r--r--pom.xml3
-rw-r--r--src/patches/android/PropertyTest.patch32
-rw-r--r--src/patches/android/PropertyUtils.patch126
3 files changed, 84 insertions, 77 deletions
diff --git a/pom.xml b/pom.xml
index e3b983d4..2537e0b4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -744,8 +744,9 @@
<exclude name="org/yaml/snakeyaml/representer/FilterPropertyToDumpTest.java" />
<exclude name="org/yaml/snakeyaml/issues/issue60/CustomOrderTest.java" />
<exclude name="org/yaml/snakeyaml/issues/issue29/FlexibleScalarStylesInJavaBeanTest.java" />
- <!-- uses filtered resources. Addidional tricks needed to be able to run under current build -->
+ <!-- uses filtered resources. Additional tricks needed to be able to run under current build -->
<exclude name="org/yaml/snakeyaml/issues/issue318/ContextClassLoaderTest.java" />
+ <exclude name="org/yaml/snakeyaml/emitter/template/VelocityTest.java" />
</javac>
</target>
diff --git a/src/patches/android/PropertyTest.patch b/src/patches/android/PropertyTest.patch
index a77ba2ce..b01f2df6 100644
--- a/src/patches/android/PropertyTest.patch
+++ b/src/patches/android/PropertyTest.patch
@@ -1,21 +1,21 @@
diff --git a/src/test/java/org/yaml/snakeyaml/introspector/PropertyTest.java b/src/test/java/org/yaml/snakeyaml/introspector/PropertyTest.java
---- a/src/test/java/org/yaml/snakeyaml/introspector/PropertyTest.java
-+++ b/src/test/java/org/yaml/snakeyaml/introspector/PropertyTest.java
-@@ -33,17 +33,6 @@
+--- a/src/test/java/org/yaml/snakeyaml/introspector/PropertyTest.java (revision 9c05d7250e565df10bdf0da92bf89a1c39e5c073)
++++ b/src/test/java/org/yaml/snakeyaml/introspector/PropertyTest.java (date 1662964689659)
+@@ -32,17 +32,6 @@
+
public class PropertyTest {
- @Test
-- public void testMethodPropertyToString() throws IntrospectionException {
-- for (PropertyDescriptor property : Introspector.getBeanInfo(TestBean1.class)
-- .getPropertyDescriptors()) {
-- if (property.getName().equals("text")) {
-- MethodProperty prop = new MethodProperty(property);
-- assertEquals("text of class java.lang.String", prop.toString());
-- }
-- }
+- @Test
+- public void testMethodPropertyToString() throws IntrospectionException {
+- for (PropertyDescriptor property : Introspector.getBeanInfo(TestBean1.class)
+- .getPropertyDescriptors()) {
+- if (property.getName().equals("text")) {
+- MethodProperty prop = new MethodProperty(property);
+- assertEquals("text of class java.lang.String", prop.toString());
+- }
- }
+- }
-
-- @Test
- public void testGetFieldPropertyAnnotation() {
- PropertyUtils propertyUtils = new PropertyUtils();
- propertyUtils.setBeanAccess(BeanAccess.FIELD);
+ @Test
+ public void testGetFieldPropertyAnnotation() {
+ PropertyUtils propertyUtils = new PropertyUtils();
diff --git a/src/patches/android/PropertyUtils.patch b/src/patches/android/PropertyUtils.patch
index ba282b3f..824a4155 100644
--- a/src/patches/android/PropertyUtils.patch
+++ b/src/patches/android/PropertyUtils.patch
@@ -1,10 +1,12 @@
-# HG changeset patch
-# Parent 982acbc28cc84e6734aaf4b495d8be8c78fc26dd
-
+Index: src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
diff --git a/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java b/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java
---- a/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java
-+++ b/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java
-@@ -15,12 +15,7 @@
+--- a/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java (revision 7bce50d0dddaff7d9313189860ed8f372252e3f6)
++++ b/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java (date 1662970435472)
+@@ -13,12 +13,7 @@
*/
package org.yaml.snakeyaml.introspector;
@@ -17,64 +19,68 @@ diff --git a/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java b/
import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.HashMap;
-@@ -64,9 +59,6 @@
- }
+@@ -65,58 +60,19 @@
+ }
- Map<String, Property> properties = new LinkedHashMap<String, Property>();
-- boolean inaccessableFieldsExist = false;
-- switch (bAccess) {
-- case FIELD:
- for (Class<?> c = type; c != null; c = c.getSuperclass()) {
- for (Field field : c.getDeclaredFields()) {
- int modifiers = field.getModifiers();
-@@ -76,50 +68,10 @@
- }
- }
- }
-- break;
-- default:
-- // add JavaBean properties
-- try {
-- for (PropertyDescriptor property : Introspector.getBeanInfo(type)
-- .getPropertyDescriptors()) {
-- Method readMethod = property.getReadMethod();
-- if ((readMethod == null || !readMethod.getName().equals("getClass"))
-- && !isTransient(property)) {
-- properties.put(property.getName(), new MethodProperty(property));
-- }
-- }
-- } catch (IntrospectionException e) {
-- throw new YAMLException(e);
-- }
--
-- // add public fields
-- for (Class<?> c = type; c != null; c = c.getSuperclass()) {
-- for (Field field : c.getDeclaredFields()) {
-- int modifiers = field.getModifiers();
-- if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers)) {
-- if (Modifier.isPublic(modifiers)) {
-- properties.put(field.getName(), new FieldProperty(field));
-- } else {
-- inaccessableFieldsExist = true;
-- }
-- }
-- }
-- }
-- break;
+ Map<String, Property> properties = new LinkedHashMap<String, Property>();
+- boolean inaccessableFieldsExist = false;
+- if (bAccess == BeanAccess.FIELD) {
+- for (Class<?> c = type; c != null; c = c.getSuperclass()) {
+- for (Field field : c.getDeclaredFields()) {
+- int modifiers = field.getModifiers();
+- if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers)
+- && !properties.containsKey(field.getName())) {
+- properties.put(field.getName(), new FieldProperty(field));
+- }
- }
-- if (properties.isEmpty() && inaccessableFieldsExist) {
-- throw new YAMLException("No JavaBean properties found in " + type.getName());
+- }
+- } else {// add JavaBean properties
+- try {
+- for (PropertyDescriptor property : Introspector.getBeanInfo(type)
+- .getPropertyDescriptors()) {
+- Method readMethod = property.getReadMethod();
+- if ((readMethod == null || !readMethod.getName().equals("getClass"))
+- && !isTransient(property)) {
+- properties.put(property.getName(), new MethodProperty(property));
+- }
- }
- propertiesCache.put(type, properties);
- return properties;
+- } catch (IntrospectionException e) {
+- throw new YAMLException(e);
+- }
+-
+- // add public fields
+- for (Class<?> c = type; c != null; c = c.getSuperclass()) {
+- for (Field field : c.getDeclaredFields()) {
+- int modifiers = field.getModifiers();
+- if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers)) {
+- if (Modifier.isPublic(modifiers)) {
+- properties.put(field.getName(), new FieldProperty(field));
+- } else {
+- inaccessableFieldsExist = true;
+- }
+- }
++ for (Class<?> c = type; c != null; c = c.getSuperclass()) {
++ for (Field field : c.getDeclaredFields()) {
++ int modifiers = field.getModifiers();
++ if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers)
++ && !properties.containsKey(field.getName())) {
++ properties.put(field.getName(), new FieldProperty(field));
+ }
+ }
}
+- if (properties.isEmpty() && inaccessableFieldsExist) {
+- throw new YAMLException("No JavaBean properties found in " + type.getName());
+- }
+ propertiesCache.put(type, properties);
+ return properties;
+ }
-- private static final String TRANSIENT = "transient";
+- private static final String TRANSIENT = "transient";
-
-- private boolean isTransient(FeatureDescriptor fd) {
-- return Boolean.TRUE.equals(fd.getValue(TRANSIENT));
-- }
+- private boolean isTransient(FeatureDescriptor fd) {
+- return Boolean.TRUE.equals(fd.getValue(TRANSIENT));
+- }
-
- public Set<Property> getProperties(Class<? extends Object> type) {
- return getProperties(type, beanAccess);
- }
+ public Set<Property> getProperties(Class<? extends Object> type) {
+ return getProperties(type, beanAccess);
+ }