Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ApplicationConnectionURLGenerationTest.java 3.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package com.vaadin.client;
  2. import static org.junit.Assert.assertEquals;
  3. import org.junit.Test;
  4. import com.vaadin.shared.util.SharedUtil;
  5. public class ApplicationConnectionURLGenerationTest {
  6. private static final String[] URIS = {
  7. "http://demo.vaadin.com/", //
  8. "https://demo.vaadin.com/", "http://demo.vaadin.com/foo",
  9. "http://demo.vaadin.com/foo?f", "http://demo.vaadin.com/foo?f=1",
  10. "http://demo.vaadin.com:1234/foo?a",
  11. "http://demo.vaadin.com:1234/foo#frag?fakeparam",
  12. // Jetspeed
  13. "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__",
  14. // Liferay generated url
  15. "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",
  16. };
  17. private static final String[] URIS_WITH_ABCD_PARAM = {
  18. "http://demo.vaadin.com/?a=b&c=d",
  19. "https://demo.vaadin.com/?a=b&c=d",
  20. "http://demo.vaadin.com/foo?a=b&c=d",
  21. "http://demo.vaadin.com/foo?f&a=b&c=d",
  22. "http://demo.vaadin.com/foo?f=1&a=b&c=d",
  23. "http://demo.vaadin.com:1234/foo?a&a=b&c=d",
  24. "http://demo.vaadin.com:1234/foo?a=b&c=d#frag?fakeparam",
  25. "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__?a=b&c=d",
  26. "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",
  27. };
  28. private static final String[] URIS_WITH_ABCD_PARAM_AND_FRAGMENT = {
  29. "http://demo.vaadin.com/?a=b&c=d#fragment",
  30. "https://demo.vaadin.com/?a=b&c=d#fragment",
  31. "http://demo.vaadin.com/foo?a=b&c=d#fragment",
  32. "http://demo.vaadin.com/foo?f&a=b&c=d#fragment",
  33. "http://demo.vaadin.com/foo?f=1&a=b&c=d#fragment",
  34. "http://demo.vaadin.com:1234/foo?a&a=b&c=d#fragment", "",
  35. "http://localhost:8080/jetspeed/portal/_ns:Z3RlbXBsYXRlLXRvcDJfX3BhZ2UtdGVtcGxhdGVfX2RwLTFfX1AtMTJjNTRkYjdlYjUtMTAwMDJ8YzB8ZDF8aVVJREx8Zg__?a=b&c=d#fragment",
  36. "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",
  37. };
  38. @Test
  39. public void testParameterAdding() {
  40. for (int i = 0; i < URIS.length; i++) {
  41. // Adding nothing
  42. assertEquals(URIS[i], SharedUtil.addGetParameters(URIS[i], ""));
  43. // Adding a=b&c=d
  44. assertEquals(URIS_WITH_ABCD_PARAM[i],
  45. SharedUtil.addGetParameters(URIS[i], "a=b&c=d"));
  46. // Fragments
  47. if (!URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].isEmpty()) {
  48. assertEquals(URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i], SharedUtil
  49. .addGetParameters(URIS[i] + "#fragment", "a=b&c=d"));
  50. // Empty fragment
  51. assertEquals(
  52. URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i]
  53. .replace("#fragment", "#"),
  54. SharedUtil.addGetParameters(URIS[i] + "#", "a=b&c=d"));
  55. }
  56. }
  57. }
  58. }