-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from eroshenkoam/master
Fix command encoding problem
- Loading branch information
Showing
4 changed files
with
95 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
proxy/src/test/java/ru/qatools/gridrouter/CommandDecodingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package ru.qatools.gridrouter; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
import java.net.URLEncoder; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
import static org.hamcrest.Matchers.endsWith; | ||
import static org.junit.Assert.assertThat; | ||
|
||
/** | ||
* @author Artem Eroshenko [email protected] | ||
*/ | ||
@RunWith(Parameterized.class) | ||
public class CommandDecodingTest { | ||
|
||
public static final String SUFFIX = "http://host.com/wd/hub/session/8dec71ede39ad9ff3"; | ||
|
||
public static final String POSTFIX = "b3fbc03311bdc45282358f1-f09c-4c44-8057-4b82f4a53002/element/id/"; | ||
|
||
public String requestUri; | ||
|
||
public String elementId; | ||
|
||
public CommandDecodingTest(String elementId) throws Exception { | ||
this.requestUri = String.format("%s%s%s", SUFFIX, POSTFIX, URLEncoder.encode(elementId, UTF_8.name())); | ||
this.elementId = elementId; | ||
} | ||
|
||
@Parameterized.Parameters | ||
public static Collection<Object[]> getData() { | ||
return Arrays.asList( | ||
new Object[]{"text_???"}, | ||
new Object[]{"text_&_not_text"} | ||
); | ||
} | ||
|
||
@Test | ||
public void testOutput() throws Exception { | ||
ProxyServlet proxyServlet = new ProxyServlet(); | ||
String command = proxyServlet.getCommand(requestUri); | ||
assertThat(command, endsWith(elementId)); | ||
} | ||
|
||
|
||
} |