PageRenderTime 47ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/src/test/resources/io/mikael/urlbuilder/urlbuilder.feature

http://github.com/mikaelhg/urlbuilder
Gherkin Specification | 98 lines | 81 code | 17 blank | 0 comment | 3 complexity | 045bc92f9434ef31374005e480628ae6 MD5 | raw file
Possible License(s): Apache-2.0
  1. Feature: UrlBuilder url creation
  2. Scenario: Empty URL builder
  3. Given I create an empty builder
  4. Then it should be an empty string
  5. Scenario: Basic Google URL string
  6. Given I create a builder from the string http://www.google.com/?q=test
  7. When I set the schema to https
  8. Then as a string it should be https://www.google.com/?q=test
  9. Scenario: From URL with urlencoded space character
  10. Given I create a builder from the URL http://www.example.com/a%20b/
  11. Then as a string it should be http://www.example.com/a%20b/
  12. Scenario: Do not percent Encode a plus in the path
  13. Given I create a builder from the URL http://www.example.com/a+b%2b/
  14. Then the path should be /a+b+/
  15. And as a string it should be http://www.example.com/a+b+/
  16. Scenario: From URL with allowed special characters in the path
  17. Given I create a builder from the URL http://example.com/a=&b/
  18. Then as a string it should be http://example.com/a=&b/
  19. Scenario: From URL with space character in the query
  20. Given I create a builder from the URL http://example.com/?some+key=some%20value
  21. Then as a string it should be http://example.com/?some%20key=some%20value
  22. Scenario: From URL with special characters in the query
  23. Given I create a builder from the URL http://example.com/?some+%2b%20key=some%20%3d?value
  24. Then the parameter some + key should be some =?value
  25. And as a string it should be http://example.com/?some%20%2B%20key=some%20%3D%3Fvalue
  26. Scenario: From URL with special characters in the fragment
  27. Given I create a builder from the URL http://example.com/#=?%23
  28. Then the fragment should be =?#
  29. And as a string it should be http://example.com/#=?%23
  30. Scenario: Equals character in query parameter value
  31. Given I create a builder from the string /?a=1=2
  32. Then the parameter a should be 1=2
  33. Scenario: From URL with user info
  34. Given I create a builder from the URL https://bob:passwd@example.com/secure
  35. Then as a string it should be https://bob:passwd@example.com/secure
  36. And the user info should be bob:passwd
  37. And the host name should be example.com
  38. Scenario: From URL with encoded characters in the user info
  39. Given I create a builder from the string https://bobby%20droptables:passwd@example.com/secure
  40. Then as a string it should be https://bobby%20droptables:passwd@example.com/secure
  41. And the user info should be bobby droptables:passwd
  42. Scenario: From URI with a null path and query
  43. Given I create a builder from a URI mailto:bob@example.com with a null path and query
  44. Then as a string it should be mailto:
  45. Scenario: Round trip conversion
  46. Given I have these URLs:
  47. | https:// |
  48. | https://www |
  49. | https://www:1234 |
  50. | https://www:1234/ |
  51. | https://www:1234/foo |
  52. | https://www:1234/foo/bar |
  53. | https://www:1234/foo/bar/ |
  54. | https://www:1234/foo/bar// |
  55. | https://www:1234/foo//bar// |
  56. | //google.com/logo.png |
  57. | g:h |
  58. | http://a/b/c/d;p?y |
  59. | http://a/b/c/d;p?q#s |
  60. | http://a/b/c/g?y#s |
  61. | http://a/b/c/g;x?y#s |
  62. | http://a/b/c/g#s/../x |
  63. | http:g |
  64. Then the urls stay the same after a roundtrip conversion
  65. Scenario: Default Google Translate link, a mix of escaped and unescaped characters
  66. Given I create a builder from the string http://translate.google.com/translate?hl=auto&langpair=auto|zh-TW&u=http%3A%2F%2Fus6.campaign-archive1.com%2F%3Fu%3Dcbc96c3d7a%26id%3D17fdad33a4%26e%3D
  67. Then as a string it should be http://translate.google.com/translate?hl=auto&langpair=auto%7Czh-TW&u=http%3A%2F%2Fus6.campaign-archive1.com%2F%3Fu%3Dcbc96c3d7a%26id%3D17fdad33a4%26e%3D
  68. Then as a URI it should be http://translate.google.com/translate?hl=auto&langpair=auto%7Czh-TW&u=http%3A%2F%2Fus6.campaign-archive1.com%2F%3Fu%3Dcbc96c3d7a%26id%3D17fdad33a4%26e%3D
  69. Scenario: Escaped Google Translate link
  70. Given I create a builder from the string http://translate.google.com/translate?hl=auto&langpair=auto%7Czh-TW&u=http%3A%2F%2Fus6.campaign-archive1.com%2F%3Fu%3Dcbc96c3d7a%26id%3D17fdad33a4%26e%3D
  71. Then as a string it should be http://translate.google.com/translate?hl=auto&langpair=auto%7Czh-TW&u=http%3A%2F%2Fus6.campaign-archive1.com%2F%3Fu%3Dcbc96c3d7a%26id%3D17fdad33a4%26e%3D
  72. Then as a URI it should be http://translate.google.com/translate?hl=auto&langpair=auto%7Czh-TW&u=http%3A%2F%2Fus6.campaign-archive1.com%2F%3Fu%3Dcbc96c3d7a%26id%3D17fdad33a4%26e%3D
  73. Scenario: Non-default port string
  74. Given I create a builder from the URL http://www.example.com:8080/
  75. Then the port should be 8080
  76. Scenario: Path must start with a slash
  77. Given I create an empty builder
  78. When I set the schema to https
  79. And I set the host to www.google.com
  80. And I set the path to foo/bar
  81. Then as a string it should be https://www.google.com/foo/bar