diff options
author | Artur Signell <artur@vaadin.com> | 2012-08-29 11:21:56 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2012-08-29 11:21:56 +0300 |
commit | bfbfdd51a0563d212d1e811a3eb534122847d206 (patch) | |
tree | 8fe2f3f9feda9fe3a1c22ba261c7b498718ddbfd /tests/client-side/com/vaadin/client/ApplicationConnectionTestURLGeneration.java | |
parent | ed8a1d154436a635b29a35093cc349e4a4aa2897 (diff) | |
download | vaadin-framework-bfbfdd51a0563d212d1e811a3eb534122847d206.tar.gz vaadin-framework-bfbfdd51a0563d212d1e811a3eb534122847d206.zip |
Renamed com.vaadin.terminal.gwt.client to com.vaadin.client (#9432)
Diffstat (limited to 'tests/client-side/com/vaadin/client/ApplicationConnectionTestURLGeneration.java')
-rw-r--r-- | tests/client-side/com/vaadin/client/ApplicationConnectionTestURLGeneration.java | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/client-side/com/vaadin/client/ApplicationConnectionTestURLGeneration.java b/tests/client-side/com/vaadin/client/ApplicationConnectionTestURLGeneration.java new file mode 100644 index 0000000000..da5970d64d --- /dev/null +++ b/tests/client-side/com/vaadin/client/ApplicationConnectionTestURLGeneration.java @@ -0,0 +1,77 @@ +package com.vaadin.client; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import com.vaadin.client.ApplicationConnection; + +public class ApplicationConnectionTestURLGeneration { + + private static final String[] URIS = new String[] { + "http://demo.vaadin.com/", // + "https://demo.vaadin.com/", + "http://demo.vaadin.com/foo", + "http://demo.vaadin.com/foo?f", + "http://demo.vaadin.com/foo?f=1", + "http://demo.vaadin.com:1234/foo?a", + "http://demo.vaadin.com:1234/foo#frag?fakeparam", + // Jetspeed + "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__", + // Liferay generated url + "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1", + + }; + private static final String[] URIS_WITH_ABCD_PARAM = new String[] { + "http://demo.vaadin.com/?a=b&c=d", + "https://demo.vaadin.com/?a=b&c=d", + "http://demo.vaadin.com/foo?a=b&c=d", + "http://demo.vaadin.com/foo?f&a=b&c=d", + "http://demo.vaadin.com/foo?f=1&a=b&c=d", + "http://demo.vaadin.com:1234/foo?a&a=b&c=d", + "http://demo.vaadin.com:1234/foo?a=b&c=d#frag?fakeparam", + "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__?a=b&c=d", + "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1&a=b&c=d", + + }; + + private static final String[] URIS_WITH_ABCD_PARAM_AND_FRAGMENT = new String[] { + "http://demo.vaadin.com/?a=b&c=d#fragment", + "https://demo.vaadin.com/?a=b&c=d#fragment", + "http://demo.vaadin.com/foo?a=b&c=d#fragment", + "http://demo.vaadin.com/foo?f&a=b&c=d#fragment", + "http://demo.vaadin.com/foo?f=1&a=b&c=d#fragment", + "http://demo.vaadin.com:1234/foo?a&a=b&c=d#fragment", + "", + "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__?a=b&c=d#fragment", + "http://vaadin.com/directory?p_p_id=Directory_WAR_Directory&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=UIDL&p_p_cacheability=cacheLevelPage&p_p_col_id=row-1&p_p_col_count=1&a=b&c=d#fragment", + + }; + + @Test + public void testParameterAdding() { + for (int i = 0; i < URIS.length; i++) { + // Adding nothing + assertEquals(URIS[i], + ApplicationConnection.addGetParameters(URIS[i], "")); + + // Adding a=b&c=d + assertEquals(URIS_WITH_ABCD_PARAM[i], + ApplicationConnection.addGetParameters(URIS[i], "a=b&c=d")); + + // Fragments + if (URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].length() > 0) { + assertEquals( + URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i], + ApplicationConnection.addGetParameters(URIS[i] + + "#fragment", "a=b&c=d")); + + // Empty fragment + assertEquals(URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].replace( + "#fragment", "#"), + ApplicationConnection.addGetParameters(URIS[i] + "#", + "a=b&c=d")); + } + } + } +} |