From 1be49fdd8a795a0636734f5a845cbe74c937f099 Mon Sep 17 00:00:00 2001
From: Robert Scott <code@humanleg.org.uk>
Date: Sun, 7 Jan 2018 22:01:57 +0000
Subject: [PATCH v1 1/4] TestUtils: add setPrivateStaticField method

---
 test/unit/org/openstreetmap/josm/TestUtils.java | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/test/unit/org/openstreetmap/josm/TestUtils.java b/test/unit/org/openstreetmap/josm/TestUtils.java
index 050d7de2b..28282cf49 100644
--- a/test/unit/org/openstreetmap/josm/TestUtils.java
+++ b/test/unit/org/openstreetmap/josm/TestUtils.java
@@ -187,6 +187,22 @@ public final class TestUtils {
     }
 
     /**
+     * Sets a private static field value.
+     * @param cls object class
+     * @param fieldName private field name
+     * @param value replacement value
+     * @throws ReflectiveOperationException if a reflection operation error occurs
+     */
+    public static void setPrivateStaticField(Class<?> cls, String fieldName, final Object value) throws ReflectiveOperationException {
+        Field f = cls.getDeclaredField(fieldName);
+        AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
+            f.setAccessible(true);
+            return null;
+        });
+        f.set(null, value);
+    }
+
+    /**
      * Returns an instance of {@link AbstractProgressMonitor} which keeps track of the monitor state,
      * but does not show the progress.
      * @return a progress monitor
-- 
2.11.0

