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

olli pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hc-core.git

commit cf9534886756af0fe905ac82d255b8284ee08a8a
Author: Oliver Lietz <o...@apache.org>
AuthorDate: Sat Feb 3 00:15:38 2018 +0100

    use FieldUtils to set scriptEngineManager in test
---
 .../org/apache/sling/hc/core/impl/ScriptableHealthCheckTest.java   | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git 
a/src/test/java/org/apache/sling/hc/core/impl/ScriptableHealthCheckTest.java 
b/src/test/java/org/apache/sling/hc/core/impl/ScriptableHealthCheckTest.java
index 3c1464c..af3a142 100644
--- a/src/test/java/org/apache/sling/hc/core/impl/ScriptableHealthCheckTest.java
+++ b/src/test/java/org/apache/sling/hc/core/impl/ScriptableHealthCheckTest.java
@@ -17,11 +17,10 @@
  */
 package org.apache.sling.hc.core.impl;
 
-import java.lang.reflect.Field;
-
 import javax.script.ScriptEngine;
 import javax.script.ScriptEngineManager;
 
+import org.apache.commons.lang3.reflect.FieldUtils;
 import org.apache.sling.hc.api.Result;
 import org.junit.Before;
 import org.junit.Test;
@@ -43,9 +42,7 @@ public class ScriptableHealthCheckTest {
         assertNotNull("With the rhino jar in our classpath, we should get a js 
script engine", rhino);
         final ScriptEngineManager manager = mock(ScriptEngineManager.class);
         
when(manager.getEngineByExtension(Matchers.same("ecma"))).thenReturn(rhino);
-        final Field f = hc.getClass().getDeclaredField("scriptEngineManager");
-        f.setAccessible(true);
-        f.set(hc, manager);
+        FieldUtils.writeDeclaredField(hc, "scriptEngineManager", manager, 
true);
 
         final ScriptableHealthCheckConfiguration configuration = 
mock(ScriptableHealthCheckConfiguration.class);
         when(configuration.expression()).thenReturn(expression);

-- 
To stop receiving notification emails like this one, please contact
o...@apache.org.

Reply via email to