How to use executableExists method of org.testcontainers.utility.CommandLine class

Best Testcontainers-java code snippet using org.testcontainers.utility.CommandLine.executableExists

Source:DockerMachineClient.java Github

copy

Full Screen

...5import java.util.List;6import java.util.Optional;7import static java.util.Arrays.asList;8import static org.slf4j.LoggerFactory.getLogger;9import static org.testcontainers.utility.CommandLine.executableExists;10import static org.testcontainers.utility.CommandLine.runShellCommand;11/**12 * Created by rnorth on 27/10/2015.13 */14public class DockerMachineClient {15 private static DockerMachineClient instance;16 private static final Logger LOGGER = getLogger(DockerMachineClient.class);17 private static final String executableName;18 static {19 if(SystemUtils.IS_OS_WINDOWS) {20 executableName = "docker-machine.exe";21 } else {22 executableName = "docker-machine";23 }24 }25 /**26 * Private constructor27 */28 private DockerMachineClient() {29 }30 /**31 * Obtain an instance of the DockerMachineClient wrapper.32 *33 * @return the singleton instance of DockerMachineClient34 */35 public synchronized static DockerMachineClient instance() {36 if (instance == null) {37 instance = new DockerMachineClient();38 }39 return instance;40 }41 public boolean isInstalled() {42 return executableExists(executableName);43 }44 public Optional<String> getDefaultMachine() {45 String ls = runShellCommand(executableName, "ls", "-q");46 List<String> machineNames = asList(ls.split("\n"));47 String envMachineName = System.getenv("DOCKER_MACHINE_NAME");48 if (machineNames.contains(envMachineName)) {49 LOGGER.debug("Using docker-machine set in DOCKER_MACHINE_NAME: {}", envMachineName);50 return Optional.of(envMachineName);51 } else if (machineNames.contains("default")) {52 LOGGER.debug("DOCKER_MACHINE_NAME is not set; Using 'default' docker-machine", envMachineName);53 return Optional.of("default");54 } else if (machineNames.size() > 0) {55 LOGGER.debug("DOCKER_MACHINE_NAME is not set and no machine named 'default' found; Using first machine found with `docker-machine ls`: {}", machineNames.get(0));56 return Optional.of(machineNames.get(0));...

Full Screen

Full Screen

executableExists

Using AI Code Generation

copy

Full Screen

1def docker = org.testcontainers.utility.CommandLine.executableExists('docker')2def dockerCompose = org.testcontainers.utility.CommandLine.executableExists('docker-compose')3def dockerMachine = org.testcontainers.utility.CommandLine.executableExists('docker-machine')4def dockerStack = org.testcontainers.utility.CommandLine.executableExists('docker-stack')5def dockerSwarm = org.testcontainers.utility.CommandLine.executableExists('docker-swarm')6def dockerVersion = org.testcontainers.utility.CommandLine.executableExists('docker-version')7def dockerComposeVersion = org.testcontainers.utility.CommandLine.executableExists('docker-compose-version')8def dockerMachineVersion = org.testcontainers.utility.CommandLine.executableExists('docker-machine-version')9def dockerStackVersion = org.testcontainers.utility.CommandLine.executableExists('docker-stack-version')10def dockerSwarmVersion = org.testcontainers.utility.CommandLine.executableExists('docker-swarm-version')

Full Screen

Full Screen

executableExists

Using AI Code Generation

copy

Full Screen

1import org.junit.Test;2import org.testcontainers.utility.CommandLine;3import static org.junit.Assert.assertTrue;4public class TestDocker {5 public void testDocker() {6 boolean dockerInstalled = CommandLine.executableExists("docker");7 assertTrue("Docker is not installed", dockerInstalled);8 }9}10[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ testcontainers ---11[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ testcontainers ---12[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ testcontainers ---13[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ testcontainers ---14[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ testcontainers ---15[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ testcontainers ---

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testcontainers-java automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful