Example usage for java.lang System getenv

List of usage examples for java.lang System getenv

Introduction

In this page you can find the example usage for java.lang System getenv.

Prototype

public static String getenv(String name) 

Source Link

Document

Gets the value of the specified environment variable.

Usage

From source file:com.thoughtworks.gauge.refactor.JavaRefactoring.java

public RefactoringResult performRefactoring() {
    String oldStepText = oldStepValue.getStepText();
    String fileName;/*from   w  ww. j ava 2  s .  co m*/
    Boolean hasAlias;

    if (System.getenv(GaugeConstant.GAUGE_LSP_GRPC) != null) {
        fileName = registry.get(oldStepText).getFileName();
        hasAlias = registry.get(oldStepText).getHasAlias();
    } else {
        fileName = registry.getFileName(oldStepText);
        hasAlias = registry.getAllAliasAnnotationTextsFor(oldStepText).size() > 1;
    }

    if (fileName == null || fileName.isEmpty()) {
        return new RefactoringResult(false,
                "Step Implementation Not Found: Unable to find a file Name to refactor");
    }
    if (hasAlias) {
        return new RefactoringResult(false, "Refactoring for steps having aliases are not supported.");
    }
    if (registry.hasMultipleImplementations(oldStepText)) {
        return new RefactoringResult(false, "Duplicate step implementation found.");
    }

    JavaRefactoringElement element;
    try {
        element = createJavaRefactoringElement(fileName);
        if (saveChanges) {
            new FileModifier(element).refactor();
        }
    } catch (IOException e) {
        return new RefactoringResult(false, "Unable to read/write file while refactoring. " + e.getMessage());
    } catch (RefactoringException e) {
        return new RefactoringResult(false, "Step Implementation Not Found: " + e.getMessage());
    } catch (Exception e) {
        return new RefactoringResult(false, "Refactoring failed: " + e.getMessage());
    }
    return new RefactoringResult(true, element);
}

From source file:com.headissue.pigeon.PigeonBootstrapListener.java

static String getParam(ServletContext _context, String _name) {
    String s = _context.getInitParameter(_name);
    if (StringUtils.isNotEmpty(s)) {
        LogUtils.debug(log, "found in servlet:   '%s'=%s", _name, s);
        return s;
    }/*from w w w .ja  v  a2  s.c o m*/
    String _envName = _name.replaceAll("\\.", "_");
    s = System.getenv(_envName);
    if (StringUtils.isNotEmpty(s)) {
        LogUtils.debug(log, "found in env param: '%s'=%s", _envName, s);
        return s;
    }
    s = System.getProperty(_name);
    if (StringUtils.isNotEmpty(s)) {
        LogUtils.debug(log, "found in sys prop:  '%s'=%s", _name, s);
    }
    return s;
}

From source file:com.seleniumtests.ut.connectors.extools.TestSoapUi.java

@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testNoSoapUiInstall() throws IOException {
    File tmp = Files.createTempDir();
    File runner = Paths.get(tmp.getAbsolutePath(), "ban", "testrunner.bat").toFile();
    FileUtils.write(runner, "rem");

    PowerMockito.mockStatic(System.class);
    when(System.getenv("SOAPUI_HOME")).thenReturn(tmp.getAbsolutePath());
    new SoapUi();
}

From source file:com.vilt.minium.prefs.WebConsolePreferences.java

public File getChromeBin() {
    if (chromeBin == null) {
        // Based on expected Chrome default locations:
        // https://code.google.com/p/selenium/wiki/ChromeDriver
        if (SystemUtils.IS_OS_WINDOWS_XP) {
            return oneOf(
                    new File(System.getenv("HOMEPATH"),
                            "Local Settings\\Application Data\\Google\\Chrome\\Application\\chrome.exe"),
                    new File(System.getenv("PROGRAMFILES"), "Google\\Chrome\\Application\\chrome.exe"));
        } else if (SystemUtils.IS_OS_WINDOWS) {
            return oneOf(
                    new File(format("C:\\Users\\%s\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe",
                            System.getenv("USERNAME"))),
                    new File(System.getenv("PROGRAMFILES"), "Google\\Chrome\\Application\\chrome.exe"),
                    new File(System.getenv("ProgramFiles(x86)"), "Google\\Chrome\\Application\\chrome.exe"));
        } else if (SystemUtils.IS_OS_LINUX) {
            return new File("/usr/bin/google-chrome");
        } else if (SystemUtils.IS_OS_MAC_OSX) {
            return new File("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome");
        }/*from  ww w .j  av  a 2 s. co m*/
    }
    return chromeBin;
}

From source file:io.apiman.common.es.util.ApimanEmbeddedElastic.java

private ApimanEmbeddedElastic(EmbeddedElastic embeddedElastic, long port) {
    this.elastic = embeddedElastic;
    this.pidPath = Paths.get(System.getenv("HOME"), "/.cache/apiman/embedded-es-pid-" + port);
}

From source file:org.greencheek.utils.environment.propertyplaceholder.spring.TestEnvironmentalPropertySourcesPlaceholderConfigurerWithSpringValueResolution.java

@Test
public void testPropertyResolvedFromEnvironmentalFile() {
    System.setProperty("ENVIRONMENT", "dev");
    System.setProperty("ENV", "dev");
    ctx = new ClassPathXmlApplicationContext(new String[] { "classpath:SpringValueResolution-config.xml" });

    String value = (String) ctx.getBean("string");
    String valueSys = (String) ctx.getBean("string-sys");
    String valueEnv = (String) ctx.getBean("string-env");

    assertEquals("devproperties", value);

    assertEquals("dev", valueSys);
    assertEquals(System.getenv("PATH"), valueEnv);

}

From source file:org.wso2.carbon.customer_portal.tag.cloud.sample.CustomerService.java

public List<Customer> getCustomerList() throws Exception {
    String customerDataServiceEndpoint = System.getenv("CUSTOMER_DATA_SERVICE_ENDPOINT");

    try {//w  ww  .j a v a 2s.co  m
        HttpClient client = getHttpClient();
        HttpGet apiMethod = new HttpGet(customerDataServiceEndpoint);
        apiMethod.addHeader("Accept", "application/json");

        HttpResponse response = client.execute(apiMethod);
        if (HttpStatus.SC_OK == response.getStatusLine().getStatusCode()) {

            logger.info("Get customer" + response.getStatusLine().getStatusCode());
            return formatDataToCustomers(getStringFromInputStream(response.getEntity().getContent()));
        } else {
            logger.log(Level.SEVERE, "Error occurred invoking the api endpoint. Http Status : "
                    + response.getStatusLine().getStatusCode());
            throw new Exception("Failed to get Buzzwords from backend API:" + customerDataServiceEndpoint);
        }

    } catch (HttpException e) {
        logger.log(Level.SEVERE, "Error occurred while invoking API endpoint.", e);
        throw new Exception("Failed to get Buzzwords from backend API:" + customerDataServiceEndpoint);
    } catch (IOException e) {
        logger.log(Level.SEVERE, "Error occurred while invoking API endpoint.", e);
        throw new Exception("Failed to get Buzzwords from backend API:" + customerDataServiceEndpoint);
    }

}

From source file:org.cleverbus.core.common.spring.SystemIncludeRegexPatternTypeFilter.java

public SystemIncludeRegexPatternTypeFilter() {
    String regex = System.getenv(PATTERN_PROP_NAME);

    if (System.getProperty(PATTERN_PROP_NAME) != null) {
        regex = System.getProperty(PATTERN_PROP_NAME);
    }// ww  w .  ja  v  a 2s.  c o m

    // compile pattern
    if (regex != null) {
        this.pattern = Pattern.compile(regex);
    }
}

From source file:com.microsoft.azure.keyvault.extensions.test.KeyVaultExtensionsIntegrationTestBase.java

private static String getenvOrDefault(String varName, String defValue) {
    String value = System.getenv(varName);
    return value != null ? value : defValue;
}

From source file:eu.modaclouds.sla.notification.RestNotifierTest.java

@Before
public void setUp() throws Exception {
    String url = System.getenv(ACCOUNTING_URL);

    notifier = new RestNotifier(url, "application/xml");
}