public static boolean isNotNullOrEmpty(String s) { return !isNullOrEmpty(s); }
public static boolean isNotNullOrEmpty(String s) { return !isNullOrEmpty(s); }
public static final String getEnvironmentVariable(String property, String defaultValue) { String result = System.getenv(property); //The reason that we also check against empty, is that test use surefire to build a predictable environment //and surefire doesn't let you set an environment variable to `null`. So we treat them the same. if (Strings.isNullOrEmpty(result)) { return defaultValue; } else { return result; } }
public static final String getEnvironmentVariable(String property, String defaultValue) { String result = System.getenv(property); //The reason that we also check against empty, is that test use surefire to build a predictable environment //and surefire doesn't let you set an environment variable to `null`. So we treat them the same. if (Strings.isNullOrEmpty(result)) { return defaultValue; } else { return result; } }
static String trimPackage(String pkg) { if (Strings.isNullOrEmpty(pkg)) { return pkg; } StringBuilder sb = new StringBuilder(); boolean first = true; for (String part : pkg.split("\\.")) { if (first) { first = false; } else { sb.append("."); } sb.append(part.substring(0, 1)); } return sb.toString(); }
public static Map<String, String> parseMap(String s) throws IOException { if (Strings.isNullOrEmpty(s)) { return Collections.EMPTY_MAP; } Properties properties = new Properties(); try (InputStream is = new ByteArrayInputStream(s.getBytes(Charset.defaultCharset()))) { properties.load(is); } Map<String, String> map = new HashMap<>(); for (String key : properties.stringPropertyNames()) { map.put(key, properties.getProperty(key)); } return map; }
public static Map<String, String> parseMap(String s) throws IOException { if (Strings.isNullOrEmpty(s)) { return Collections.EMPTY_MAP; } Properties properties = new Properties(); try (InputStream is = new ByteArrayInputStream(s.getBytes(Charset.defaultCharset()))) { properties.load(is); } Map<String, String> map = new HashMap<>(); for (String key : properties.stringPropertyNames()) { map.put(key, properties.getProperty(key)); } return map; }
static String trimPackage(String pkg) { if (Strings.isNullOrEmpty(pkg)) { return pkg; } StringBuilder sb = new StringBuilder(); boolean first = true; for (String part : pkg.split("\\.")) { if (first) { first = false; } else { sb.append("."); } sb.append(part.substring(0, 1)); } return sb.toString(); }
/** * Returns the URL of a classpath resource. * * @param resourceName * The name of the resource. * * @return The URL. */ public static URL findConfigResource(String resourceName) { if (Strings.isNullOrEmpty(resourceName)) { return null; } final URL url = resourceName.startsWith(ROOT) ? DefaultConfiguration.class.getResource(resourceName) : DefaultConfiguration.class.getResource(ROOT + resourceName); if (url != null) { return url; } // This is useful to get resource under META-INF directory String[] resourceNamePrefix = new String[] {"META-INF/fabric8/", "META-INF/fabric8/"}; for (String resource : resourceNamePrefix) { String fullResourceName = resource + resourceName; URL candidate = KubernetesResourceLocator.class.getResource(fullResourceName.startsWith(ROOT) ? fullResourceName : ROOT + fullResourceName); if (candidate != null) { return candidate; } } return null; }
/** * Convert a string to a URL and fallback to classpath resource, if not convertible. * * @param s * The string to convert. * * @return The URL. */ public static URL asUrlOrResource(String s) { if (Strings.isNullOrEmpty(s)) { return null; } try { return new URL(s); } catch (MalformedURLException e) { //If its not a valid URL try to treat it as a local resource. return findConfigResource(s); } }
/** * Returns the URL of a classpath resource. * * @param resourceName * The name of the resource. * * @return The URL. */ public static URL findConfigResource(String resourceName) { if (Strings.isNullOrEmpty(resourceName)) { return null; } final URL url = resourceName.startsWith(ROOT) ? DefaultConfiguration.class.getResource(resourceName) : DefaultConfiguration.class.getResource(ROOT + resourceName); if (url != null) { return url; } // This is useful to get resource under META-INF directory String[] resourceNamePrefix = new String[] {"META-INF/fabric8/", "META-INF/fabric8/"}; for (String resource : resourceNamePrefix) { String fullResourceName = resource + resourceName; URL candidate = KubernetesResourceLocator.class.getResource(fullResourceName.startsWith(ROOT) ? fullResourceName : ROOT + fullResourceName); if (candidate != null) { return candidate; } } return null; }
/** * Convert a string to a URL and fallback to classpath resource, if not convertible. * * @param s * The string to convert. * * @return The URL. */ public static URL asUrlOrResource(String s) { if (Strings.isNullOrEmpty(s)) { return null; } try { return new URL(s); } catch (MalformedURLException e) { //If its not a valid URL try to treat it as a local resource. return findConfigResource(s); } }
private void setupEventLogWriter() { String className = session.getCurrentClassName(); String methodName = session.getCurrentMethodName(); if (className != null && className.equals(currentClassName) && methodName != null && methodName.equals(currentMethodName)) return; currentClassName = className; currentMethodName = methodName; String fileName = logPath; if (Strings.isNullOrEmpty(className)) className = "NOCLASS"; fileName += String.format("/%s", className); if (Strings.isNotNullOrEmpty(methodName)) fileName += String.format("-%s", methodName); fileName += "-KUBE_EVENTS.log"; try { if (eventLogWriter != null) { eventLogWriter.close(); } eventLogWriter = new FileWriter(fileName, true); } catch (IOException e) { throw new RuntimeException("Error storing kubernetes events", e); } } }
private void setupEventLogWriter() { String className = session.getCurrentClassName(); String methodName = session.getCurrentMethodName(); if (className != null && className.equals(currentClassName) && methodName != null && methodName.equals(currentMethodName)) return; currentClassName = className; currentMethodName = methodName; String fileName = logPath; if (Strings.isNullOrEmpty(className)) className = "NOCLASS"; fileName += String.format("/%s", className); if (Strings.isNotNullOrEmpty(methodName)) fileName += String.format("-%s", methodName); fileName += "-KUBE_EVENTS.log"; try { if (eventLogWriter != null) { eventLogWriter.close(); } eventLogWriter = new FileWriter(fileName, true); } catch (IOException e) { throw new RuntimeException("Error storing kubernetes events", e); } } }
if (Strings.isNullOrEmpty(logPath)) logPath = String.format("%s/target/surefire-reports", System.getProperty("user.dir")); session.getLogger().info(String.format("Storing pods console logs into dir %s", logPath));
if (Strings.isNullOrEmpty(logPath)) logPath = String.format("%s/target/surefire-reports", System.getProperty("user.dir")); session.getLogger().info(String.format("Storing pods console logs into dir %s", logPath));
String fileName = logPath; if (Strings.isNullOrEmpty(className)) className = "NOCLASS"; fileName += String.format("/%s", className);
String fileName = logPath; if (Strings.isNullOrEmpty(className)) className = "NOCLASS"; fileName += String.format("/%s", className);
@Override public Object lookup(ArquillianResource resource, Annotation... qualifiers) { String name = getName(qualifiers); if (Strings.isNullOrEmpty(name)) { ResourceProvider delegate = getNext(); if (delegate != null) {
@Override public Object lookup(ArquillianResource resource, Annotation... qualifiers) { String name = getName(qualifiers); if (Strings.isNullOrEmpty(name)) { ResourceProvider delegate = getNext(); if (delegate != null) {