diff --git a/README.md b/README.md index 5527748..a78c36e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,14 @@ # automate-client-java -## For Code formatting -Code style files are there in code_formatters folder (for eclipse and intellij idea) ,to import formatter instructions are as follows : -* For Eclipse : Under Window/Preferences select Java/Code Style/Formatter. Import the settings file by selecting Import. -* For IntelliJ Idea : Settings → Code Style → Java, click Manage, and import that XML file by simply clicking Import. +

+ BrowserStack Logo +

+ +Java Package to seamlessly connect with Automate and App-Automate. + +## Features +1. Operations on Projects, Builds & Sessions +2. Upload App for App-Automate +3. Account Usage +4. Reset Key + diff --git a/pom.xml b/pom.xml index b2f320a..0d28af8 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.browserstack automate-client-java automate-client - 0.6 + 0.7 jar Java bindings for BrowserStack Automate REST API https://www.browserstack.com diff --git a/src/main/java/com/browserstack/client/BrowserStackClient.java b/src/main/java/com/browserstack/client/BrowserStackClient.java index a76ec52..fea9187 100644 --- a/src/main/java/com/browserstack/client/BrowserStackClient.java +++ b/src/main/java/com/browserstack/client/BrowserStackClient.java @@ -157,20 +157,25 @@ static HttpRequest newRequest(final HttpRequestFactory requestFactory, final Met public void setProxy(final String proxyHost, final int proxyPort, final String proxyUsername, final String proxyPassword) { - if (proxyHost == null || proxyUsername == null || proxyPassword == null) { + if (proxyHost == null || proxyPort == 0) { return; } - final BasicCredentialsProvider basicCredentialsProvider = new BasicCredentialsProvider(); - final AuthScope proxyAuthScope = new AuthScope(proxyHost, proxyPort); - UsernamePasswordCredentials proxyAuthentication = - new UsernamePasswordCredentials(proxyUsername, proxyPassword); - basicCredentialsProvider.setCredentials(proxyAuthScope, proxyAuthentication); - final HttpHost proxy = new HttpHost(proxyHost, proxyPort); - final HttpClient client = HttpClientBuilder.create().setProxy(proxy).setDefaultCredentialsProvider(basicCredentialsProvider).build(); - final ApacheHttpTransport transport = new ApacheHttpTransport(client); - this.HTTP_TRANSPORT = transport; + HttpClientBuilder clientBuilder = HttpClientBuilder.create().setProxy(proxy); + + if (proxyUsername != null && proxyUsername.length() != 0 && proxyPassword != null && proxyPassword.length() != 0) { + final BasicCredentialsProvider basicCredentialsProvider = new BasicCredentialsProvider(); + final AuthScope proxyAuthScope = new AuthScope(proxyHost, proxyPort); + UsernamePasswordCredentials proxyAuthentication = + new UsernamePasswordCredentials(proxyUsername, proxyPassword); + basicCredentialsProvider.setCredentials(proxyAuthScope, proxyAuthentication); + + clientBuilder.setDefaultCredentialsProvider(basicCredentialsProvider); + } + + final HttpClient client = clientBuilder.build(); + HTTP_TRANSPORT = new ApacheHttpTransport(client); this.requestFactory = newRequestFactory(); }