Skip to content

Commit

Permalink
Move logic relating to setting of custom/automatic webdriver image na…
Browse files Browse the repository at this point in the history
…me, and clarify name of field
  • Loading branch information
rnorth committed Dec 17, 2016
1 parent 16fb9ad commit 8efdaa8
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

import static com.google.common.base.Preconditions.checkState;

/**
* A chrome/firefox/custom container based on SeleniumHQ's standalone container sets.
* <p>
Expand All @@ -36,7 +40,7 @@ public class BrowserWebDriverContainer<SELF extends BrowserWebDriverContainer<SE

@Nullable
private DesiredCapabilities desiredCapabilities;
private boolean imageNameIsSet = false;
private boolean customImageNameIsSet = false;

@Nullable
private RemoteWebDriver driver;
Expand All @@ -60,16 +64,11 @@ public BrowserWebDriverContainer() {
*/
public BrowserWebDriverContainer(String dockerImageName) {
super.setDockerImageName(dockerImageName);
this.imageNameIsSet = true;
this.customImageNameIsSet = true;
}


public SELF withDesiredCapabilities(DesiredCapabilities desiredCapabilities) {

if (! imageNameIsSet) {
super.setDockerImageName(getImageForCapabilities(desiredCapabilities));
}

this.desiredCapabilities = desiredCapabilities;
return self();
}
Expand All @@ -81,6 +80,12 @@ protected Integer getLivenessCheckPort() {

@Override
protected void configure() {

checkState(desiredCapabilities != null);
if (! customImageNameIsSet) {
super.setDockerImageName(getImageForCapabilities(desiredCapabilities));
}

String timeZone = System.getProperty("user.timezone");

if (timeZone == null || timeZone.isEmpty()) {
Expand Down

0 comments on commit 8efdaa8

Please sign in to comment.