Skip to content

Commit

Permalink
Updated tests for non-ASCII characters in page path.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddadlani committed Feb 25, 2015
1 parent f838d74 commit 3bdfa93
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
Expand Up @@ -92,7 +92,6 @@ public String printURL(ImmutableMultimap<String, String> state) {
return url;
}

// TODO: Why is this encoded?
StringBuilder urlBuilder = new StringBuilder(URL.encodePathSegment(url));
urlBuilder.append(';');

Expand Down
Expand Up @@ -410,7 +410,7 @@ public void testURLWithExtraKeyValuePairs() throws Exception {
}

public void testURLWithNonAsciiCharset() throws Exception {
String url = "page/123/%D0%BF%D0%B0%D1%80%D0%B0%D0%BC%D0%B5%D1%82%D1%80%20%E3%83%91%E3%83%A9%E3%83%A1%E3%83%BC%E3%82%BF%E3%83%BC%20%E5%8F%82%E6%95%B0;var3=4";
String url = "page/123/параметр パラメーター 参数;var3=4";
HistoryToken encodedToken = htFactory.parseURL(url);
assertEquals("Unexpected state map contents: " + encodedToken.getState(), "123", encodedToken.getState()
.get("var1").iterator().next());
Expand All @@ -429,7 +429,7 @@ public void testPageStateWithNonAsciiParam() throws Exception {

Multimap<String, String> pageStateMap = builder.build();
String decodedToken = URL.decodePathSegment(htFactory.createHistoryToken(pageName, pageStateMap).toString());
assertEquals("Incorrect HistoryToken URL generated: " + decodedToken, "page/123/%D0%BF%D0%B0%D1%80%D0%B0%D0%BC%D0%B5%D1%82%D1%80%20%E3%83%91%E3%83%A9%E3%83%A1%E3%83%BC%E3%82%BF%E3%83%BC%20%E5%8F%82%E6%95%B0;var3=4", decodedToken);
assertEquals("Incorrect HistoryToken URL generated: " + decodedToken, "page/123/параметр パラメーター 参数;var3=4", decodedToken);
}

public void testPageStateWithOneExtraParam() throws Exception {
Expand Down Expand Up @@ -486,8 +486,8 @@ public void testPageReloadWhenPageStateChangedInURLBar() throws Exception {
assertEquals("Did not hit @PageShowing method", 2, PageBWithState.hitCount);
}

public void testForNonAsciiPageStateParameters() throws Exception {
String pageName = "PageWithComplexPathParameters";
public void testForNonAsciiPagePath() throws Exception {
String pageName = "PageWithNonAsciiPath";
Builder<String, String> builder = ImmutableMultimap.builder();
builder.put("var1", "параметр パラメーター 参数");
builder.put("var2", "123");
Expand Down
Expand Up @@ -7,7 +7,7 @@
* @author Divya Dadlani <ddadlani@redhat.com>
*/
@Page(path = "pagename/path/some:{var1}thing/öther{var2} thing")
public class PageWithComplexPathParameters extends SimplePanel {
public class PageWithNonAsciiPath extends SimplePanel {

// tests for a URL containing spaces and non-ASCII Unicode characters

Expand Down
Expand Up @@ -85,8 +85,7 @@ public void matchesEmptyStringPattern() throws Exception {

@Test
public void matchesNonAsciiChars() throws Exception {
String testURL = "%D0%BF%D1%83%D1%82%D1%8C/%E9%81%93/%E9%81%93%E8%B7%AF/%D0%BF%D0%B5%D1%80%D0%B5%D0%BC%D0%B5%D0%BD"
+ "%D0%BD%D0%B0%D1%8F%3Avalue";
String testURL = "путь/道/道路/переменная:value";
assertEquals("NonAsciiCharsURL", matcher.getPageName(testURL));
}

Expand Down

0 comments on commit 3bdfa93

Please sign in to comment.