From a397d736a082459340aaf45ff26166db9bd5885a Mon Sep 17 00:00:00 2001 From: Dima Kaigorodov Date: Wed, 15 Jul 2026 12:23:46 +0200 Subject: [PATCH] Upgrade snakeyaml to 2.4 and raise Java baseline to 1.8 - Bump org.yaml:snakeyaml from 1.26 to 2.4 (latest) - Drop the android classifier (no longer published in snakeyaml 2.x) - Raise maven-compiler-plugin source/target from 1.6 to 1.8 (snakeyaml 2.x requires Java 8+, and modern JDKs no longer compile for 1.6) - Add FakeValuesTest coverage for YAML sequence/mapping deserialization and value caching under snakeyaml's 2.x safe loader - Update README.md and CONTRIBUTING.md to reflect the Java 1.8 baseline and current Android support story (desugaring, no android artifact needed) Co-authored-by: Cursor --- CONTRIBUTING.md | 3 +- README.md | 5 ++++ pom.xml | 7 ++--- .../javafaker/service/FakeValuesTest.java | 28 +++++++++++++++++++ 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 74e642288..1560c5bd9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ First and foremost thanks to anyone who contributes, very much appreciated. ## Guidelines -- Need to maintain compatibility with Java 1.6 (and Android). Therefore any attempt to migrate to 1.6 JDKs and above will not be merged back in. +- The minimum supported Java version is **1.8**. Please keep source/target compatibility at Java 1.8 and avoid APIs introduced in later JDKs. This baseline was raised from 1.6 so the project can stay on maintained dependency versions (for example `snakeyaml` 2.x, which requires Java 8+). Android is still supported on API levels that provide Java 8 language features (via desugaring), so no Android-specific artifact/classifier is required anymore. - If you add new faker classes like `Address`, `Country`, and `Number` they should be accompanied by a unit test. Where relevant please add more assertions to the `com.github.javafaker.integration.FakerIT` class. - If you add a new faker class, update the `README.md`. @@ -13,3 +13,4 @@ First and foremost thanks to anyone who contributes, very much appreciated. ## Building - Should be as easy as running `mvn clean install` on the root directory +- Requires a JDK 8 or newer to build diff --git a/README.md b/README.md index d1385324e..1d211c9fd 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,11 @@ Java Faker This library is a port of Ruby's [faker](https://github.com/stympy/faker) gem (as well as Perl's Data::Faker library) that generates fake data. It's useful when you're developing a new project and need some pretty data for showcase. +Requirements +----- +* Java 1.8 or newer. +* Android is supported on API levels that enable Java 8 language features (via [desugaring](https://developer.android.com/studio/write/java8-support)). + Usage ----- In pom.xml, add the following xml stanza between ` ... ` diff --git a/pom.xml b/pom.xml index f936524bc..d9aa49f23 100644 --- a/pom.xml +++ b/pom.xml @@ -53,8 +53,7 @@ org.yaml snakeyaml - 1.26 - android + 2.4 com.github.mifmif @@ -112,8 +111,8 @@ maven-compiler-plugin 3.7.0 - 1.6 - 1.6 + 1.8 + 1.8 diff --git a/src/test/java/com/github/javafaker/service/FakeValuesTest.java b/src/test/java/com/github/javafaker/service/FakeValuesTest.java index 1710efe6e..7f8948f3e 100644 --- a/src/test/java/com/github/javafaker/service/FakeValuesTest.java +++ b/src/test/java/com/github/javafaker/service/FakeValuesTest.java @@ -3,7 +3,9 @@ import org.junit.Before; import org.junit.Test; +import java.util.List; import java.util.Locale; +import java.util.Map; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.Matchers.*; @@ -58,4 +60,30 @@ public void getAValueFromALocaleThatCantBeLoaded() { assertThat(fakeValues.get(PATH), is(nullValue())); } + @Test + public void getReturnsAMapForALoadedPath() { + assertThat(fakeValues.get(PATH), is(instanceOf(Map.class))); + } + + @Test + public void yamlSequencesAreLoadedAsLists() { + Map address = (Map) fakeValues.get(PATH); + Object cityPrefix = address.get("city_prefix"); + assertThat(cityPrefix, is(instanceOf(List.class))); + assertThat((List) cityPrefix, hasItem("North")); + } + + @Test + public void nestedYamlMappingsAreLoadedAsMaps() { + Map address = (Map) fakeValues.get(PATH); + Object countryByCode = address.get("country_by_code"); + assertThat(countryByCode, is(instanceOf(Map.class))); + assertThat((Map) countryByCode, hasEntry("AF", "Afghanistan")); + } + + @Test + public void getIsCachedAcrossInvocations() { + assertThat(fakeValues.get(PATH), is(sameInstance(fakeValues.get(PATH)))); + } + }