diff --git a/skaha/src/test/java/org/opencadc/skaha/image/GetActionTest.java b/skaha/src/test/java/org/opencadc/skaha/image/GetActionTest.java index 7a80ff16..5bb8c81e 100644 --- a/skaha/src/test/java/org/opencadc/skaha/image/GetActionTest.java +++ b/skaha/src/test/java/org/opencadc/skaha/image/GetActionTest.java @@ -92,7 +92,7 @@ public class GetActionTest { public static final String REDIS_PORT = "6129"; @Before - public void setUp() { + public void setUp() throws Exception { TestUtils.setEnv("REDIS_HOST", GetActionTest.REDIS_HOST); TestUtils.setEnv("REDIS_PORT", GetActionTest.REDIS_PORT); diff --git a/skaha/src/test/java/org/opencadc/skaha/utils/TestUtils.java b/skaha/src/test/java/org/opencadc/skaha/utils/TestUtils.java index 95aa1177..1b498c44 100644 --- a/skaha/src/test/java/org/opencadc/skaha/utils/TestUtils.java +++ b/skaha/src/test/java/org/opencadc/skaha/utils/TestUtils.java @@ -23,16 +23,12 @@ public static void set(T object, Class className, String propertyName, Ob } } - public static void setEnv(String key, String value) { - try { - Map env = System.getenv(); - Class clazz = env.getClass(); - Field field = clazz.getDeclaredField("m"); - field.setAccessible(true); - Map writableEnv = (Map) field.get(env); - writableEnv.put(key, value); - } catch (Exception e) { - throw new IllegalArgumentException("Failed to set environment variable", e); - } + public static void setEnv(String key, String value) throws Exception { + Map env = System.getenv(); + Class clazz = env.getClass(); + Field field = clazz.getDeclaredField("m"); + field.setAccessible(true); + Map writableEnv = (Map) field.get(env); + writableEnv.put(key, value); } }