hugoloza / gwt-platform

Automatically exported from code.google.com/p/gwt-platform
0 stars 0 forks source link

Mismatched tokens made by ParameterTokenFormatter #419

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the test:
@Test
public void testUrlConvertion() {
  ParameterTokenFormatter tokenFormatter = new ParameterTokenFormatter();
  PlaceRequest originalRequest = new PlaceRequest("test").with("base", "1").with("n", "2");
  String originalPlaceToken = tokenFormatter.toPlaceToken(originalRequest);
  PlaceRequest generatedRequest = tokenFormatter.toPlaceRequest(originalPlaceToken);
  String generatedToken = tokenFormatter.toPlaceToken(generatedRequest);
  assertTrue(originalPlaceToken.equals(generatedToken));
}

What is the expected output? What do you see instead?
Test should be passed. Test fails.

What version of the product are you using? On what operating system?
GWTP 0.7

Please provide any additional information below.
This is important in a history processing. Let's assume the URL is 
"#test;base=1;n=2". When clicking on this URL the browser gets another URL 
"#test;n=2;base=1". The history contains two entries. Pressing "Back" button in 
the browser skips the last URL, goes to the previous one and coming back to the 
last one again... So "Back" doesn't work.
The reason is that "base" and "n" have such hash codes that they are sitting in 
a HashMap in one position of the inner List of HashMap items. So it's important 
the order of insertion of this items.
Suggestion: change PlaceRequest(PlaceRequest req, String name, String value) 
implementation: first, add new param then add all existing params.

Original issue reported on code.google.com by Vladimir...@gmail.com on 11 May 2012 at 8:55