Skip to content

Fix command mapping #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ buildNumber.properties
local.log
settings.xml

/target/
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<source>6</source>
<target>6</target>
</configuration>
</plugin>
<plugin>
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/browserstack/local/Local.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ public class Local {
public Local() {
avoidValueParameters = new HashMap<String, String>();
avoidValueParameters.put("v", "-vvv");
avoidValueParameters.put("force", "-force");
avoidValueParameters.put("forcelocal", "-forcelocal");
avoidValueParameters.put("onlyAutomate", "-onlyAutomate");
avoidValueParameters.put("forceproxy", "-forceproxy");
avoidValueParameters.put("force", "--force");
avoidValueParameters.put("forcelocal", "--force-local");
avoidValueParameters.put("onlyAutomate", "--only-automate");
avoidValueParameters.put("forceproxy", "--force-proxy");

parameters = new HashMap<String, String>();
parameters.put("f", "-f");
parameters.put("only", "-only");
parameters.put("localIdentifier", "-localIdentifier");
parameters.put("proxyHost", "-proxyHost");
parameters.put("proxyPort", "-proxyPort");
parameters.put("proxyUser", "-proxyUser");
parameters.put("proxyPass", "-proxyPass");
parameters.put("only", "--only");
parameters.put("localIdentifier", "--local-identifier");
parameters.put("proxyHost", "--proxy-host");
parameters.put("proxyPort", "--proxy-port");
parameters.put("proxyUser", "--proxy-user");
parameters.put("proxyPass", "--proxy-pass");
}

/**
Expand Down
26 changes: 16 additions & 10 deletions src/test/java/com/browserstack/local/BrowserStackLocalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ public void setUp() throws Exception {

@Test
public void testIsRunning() throws Exception {
preconditionKeyExists();
assertFalse(l.isRunning());
l.start(options);
assertTrue(l.isRunning());
}

@Test
public void testMultipleBinary() throws Exception {
preconditionKeyExists();
l.start(options);
assertTrue(l.isRunning());
Local l2 = new Local();
Expand Down Expand Up @@ -62,47 +64,47 @@ public void testEnableForce() throws Exception {
options.put("force", "true");
options.put("onlyCommand", "true");
l.start(options);
assertTrue(l.command.contains("-force"));
assertTrue(l.command.contains("--force"));
}

@Test
public void testEnableOnly() throws Exception {
options.put("only", "true");
options.put("onlyCommand", "true");
l.start(options);
assertTrue(l.command.contains("-only"));
assertTrue(l.command.contains("--only"));
}

@Test
public void testEnableOnlyAutomate() throws Exception {
options.put("onlyAutomate", "true");
options.put("onlyCommand", "true");
l.start(options);
assertTrue(l.command.contains("-onlyAutomate"));
assertTrue(l.command.contains("--only-automate"));
}

@Test
public void testEnableForceLocal() throws Exception {
options.put("forcelocal", "true");
options.put("onlyCommand", "true");
l.start(options);
assertTrue(l.command.contains("-forcelocal"));
assertTrue(l.command.contains("--force-local"));
}

@Test
public void testEnableForceProxy() throws Exception {
options.put("forceproxy", "true");
options.put("onlyCommand", "true");
l.start(options);
assertTrue(l.command.contains("-forceproxy"));
assertTrue(l.command.contains("--force-proxy"));
}

@Test
public void testSetLocalIdentifier() throws Exception {
options.put("localIdentifier", "abcdef");
options.put("onlyCommand", "true");
l.start(options);
assertTrue(l.command.contains("-localIdentifier"));
assertTrue(l.command.contains("--local-identifier"));
assertTrue(l.command.contains("abcdef"));
}

Expand All @@ -114,13 +116,13 @@ public void testSetProxy() throws Exception {
options.put("proxyPass", "pass");
options.put("onlyCommand", "true");
l.start(options);
assertTrue(l.command.contains("-proxyHost"));
assertTrue(l.command.contains("--proxy-host"));
assertTrue(l.command.contains("localhost"));
assertTrue(l.command.contains("-proxyPort"));
assertTrue(l.command.contains("--proxy-port"));
assertTrue(l.command.contains("8080"));
assertTrue(l.command.contains("-proxyUser"));
assertTrue(l.command.contains("--proxy-user"));
assertTrue(l.command.contains("user"));
assertTrue(l.command.contains("-proxyPass"));
assertTrue(l.command.contains("--proxy-pass"));
assertTrue(l.command.contains("pass"));
}

Expand Down Expand Up @@ -159,4 +161,8 @@ public void testCustomBoolArguments() throws Exception {
public void tearDown() throws Exception {
l.stop();
}

private void preconditionKeyExists() {
assertTrue("The environment variable BROWSERSTACK_ACCESS_KEY must be set to run the tests.", System.getenv("BROWSERSTACK_ACCESS_KEY") != null );
}
}