@@ -0,0 +1,1771 @@
+package org.computelab.config;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNull;%0A%0Aimport java.lang.reflect.Field;%0Aimport java.util.Collections;%0Aimport java.util.Map;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Apublic class SystemEnvConfigReaderTest %7B%0A%0A    @Before%0A    public void before() throws Exception %7B%0A        setEnv(getKey(), %22123abc%22);%0A    %7D%0A%0A    @Test%0A    public void test() %7B%0A        SystemEnvConfigReader reader = new SystemEnvConfigReader();%0A        assertEquals(%22123abc%22, reader.getVal(getKey()));%0A    %7D%0A%0A    @Test%0A    public void testKeyIsProperlyConverted() %7B%0A        SystemEnvConfigReader reader = new SystemEnvConfigReader();%0A        String val = reader.getVal(getClass().getSimpleName() + %22.key%22);%0A        assertEquals(%22123abc%22, val);%0A    %7D%0A%0A    @Test%0A    public void testMissingKey() %7B%0A        SystemEnvConfigReader reader = new SystemEnvConfigReader();%0A        assertNull(reader.getVal(%22some.random.key.not.exist%22));%0A    %7D%0A%0A    // http://stackoverflow.com/questions/318239%0A    @SuppressWarnings(%7B %22rawtypes%22, %22unchecked%22 %7D)%0A    private void setEnv(String key, String val) throws Exception %7B%0A        Class%5B%5D classes = Collections.class.getDeclaredClasses();%0A        Map%3CString, String%3E env = System.getenv();%0A        for (Class cl : classes) %7B%0A            if (%22java.util.Collections$UnmodifiableMap%22.equals(cl.getName())) %7B%0A                Field field = cl.getDeclaredField(%22m%22);%0A                field.setAccessible(true);%0A                Object obj = field.get(env);%0A                Map%3CString, String%3E map = (Map%3CString, String%3E) obj;%0A                map.put(key, val);%0A            %7D%0A        %7D%0A    %7D%0A%0A    private String getKey() %7B%0A        return getClass().getSimpleName().toUpperCase() + %22_KEY%22;%0A    %7D%0A%7D%0A

Test SystemEnvConfigReader