@Test public void testResolveEnvVarsException() { String testString = "${MADE_UP_ENV_VAR}/extended/path/to/file.ext"; try { resolveEnvVars(testString); } catch (Exception e) { assertTrue(e instanceof EnvironmentVariableNotFoundException); assertEquals("Environment variable not found: MADE_UP_ENV_VAR", e.getMessage()); } }
public static String resolveEnvVars(String input) throws EtiqetException { String res = null; if (!StringUtils.isNullOrEmpty(input)) { Pattern p = Pattern.compile("\\$\\{([\\w\\.]+)\\}|\\$([\\w\\.]+)"); Matcher m = p.matcher(input); StringBuffer sb = new StringBuffer(); resolveEnvVars(m, sb); res = sb.toString().replace("/", File.separator).trim(); } return res; }
Environment { public static String resolveEnvVars(String input) throws EtiqetException { String res = null; if (!StringUtils.isNullOrEmpty(input)) { Pattern p = Pattern.compile("\\$\\{([\\w\\.]+)\\}|\\$([\\w\\.]+)"); Matcher m = p.matcher(input); StringBuffer sb = new StringBuffer(); resolveEnvVars(m, sb); res = sb.toString().replace("/", File.separator).trim(); } return res; } }
Environment { public static String resolveEnvVars(String input) throws EtiqetException { String res = null; if (!StringUtils.isNullOrEmpty(input)) { Pattern p = Pattern.compile("\\$\\{([\\w\\.]+)\\}|\\$([\\w\\.]+)"); Matcher m = p.matcher(input); StringBuffer sb = new StringBuffer(); resolveEnvVars(m, sb); res = sb.toString().replace("/", File.separator).trim(); } return res; } private  Environment(); }
Environment { public static String resolveEnvVars(String input) throws EtiqetException { String res = null; if (!StringUtils.isNullOrEmpty(input)) { Pattern p = Pattern.compile("\\$\\{([\\w\\.]+)\\}|\\$([\\w\\.]+)"); Matcher m = p.matcher(input); StringBuffer sb = new StringBuffer(); resolveEnvVars(m, sb); res = sb.toString().replace("/", File.separator).trim(); } return res; } private  Environment(); static Boolean isEnvVarSet(String key); static String resolveEnvVars(String input); static InputStream fileResolveEnvVars(String path); }
Environment { public static String resolveEnvVars(String input) throws EtiqetException { String res = null; if (!StringUtils.isNullOrEmpty(input)) { Pattern p = Pattern.compile("\\$\\{([\\w\\.]+)\\}|\\$([\\w\\.]+)"); Matcher m = p.matcher(input); StringBuffer sb = new StringBuffer(); resolveEnvVars(m, sb); res = sb.toString().replace("/", File.separator).trim(); } return res; } private  Environment(); static Boolean isEnvVarSet(String key); static String resolveEnvVars(String input); static InputStream fileResolveEnvVars(String path);  }