/samples/scalate-sample/src/test/scala/org/fusesource/scalate/sample/SampleTest.scala

http://github.com/scalate/scalate · Scala · 139 lines · 92 code · 26 blank · 21 comment · 0 complexity · 8ea1a85130d40fee47e2b9f9c1518590 MD5 · raw file

  1. /**
  2. * Copyright (C) 2009-2011 the original author or authors.
  3. * See the notice.md file distributed with this work for additional
  4. * information regarding copyright ownership.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. package org.fusesource.scalate.sample
  19. import _root_.org.junit.runner.RunWith
  20. import _root_.org.scalatest.junit.JUnitRunner
  21. import org.scalatest.{ConfigMap, FunSuite}
  22. import _root_.org.fusesource.scalate.test._
  23. /**
  24. * @version $Revision: 1.1 $
  25. */
  26. @RunWith(classOf[JUnitRunner])
  27. class SampleTest extends FunSuite with WebServerMixin with WebDriverMixin {
  28. override protected def beforeAll(configMap: ConfigMap) = {
  29. System.setProperty("scalate.mode", "development")
  30. super.beforeAll(configMap)
  31. }
  32. testPageContains("ssp/renderObject.ssp", "Strachan")
  33. test("home page") {
  34. webDriver.get(rootUrl)
  35. pageContains("Scalate")
  36. }
  37. testPageContains("jade/captureAttribute.jade", "the captured template", "some javascript goes here", "Hello World")
  38. testPageContains("mustache", "Scala", "Great", "Java", "Crufty")
  39. testPageContains("mustache/errors/templateCompileError.mustache", "Missing", "'{{/items}}'", "near line 8")
  40. testPageContains("sampleServlet", "The foo is: Foo(")
  41. testPageContains("ssp/capture.ssp", "Hello James", "Sample 2", "Hello James")
  42. testPageContains("ssp/customLayout.ssp", "layout header goes here...", "Custom page", "This is some text", "layout footer goes here...")
  43. testPageContains("ssp/defaultAttribute.ssp", "James")
  44. testPageContains("ssp/exampleIncludes.ssp", "included from /includes/something.jsp",
  45. "included from /ssp/child/foo.ssp", "included from /includes/something.jsp", "Finished including!")
  46. testPageContains("ssp/errors/badAttributeType.ssp",
  47. "error: not found: type StringF",
  48. "in /ssp/errors/badAttributeType.ssp near line 22 col 13")
  49. testPageContains("ssp/errors/badExpression.ssp",
  50. "error: not found: value nameX",
  51. "in /ssp/errors/badExpression.ssp near line 24 col 13")
  52. testPageContains("ssp/errors/missingAttribute.ssp", "The value for 'name' was not set")
  53. testPageContains("ssp/errors/missingInclude.ssp", "Could not load resource")
  54. testPageContains("ssp/errors/missingView.ssp", "No 'index' view template could be found for model object")
  55. testPageContains("ssp/ifExpression.ssp", "x = 1", "x is 1", "x = 2", "x is not 1")
  56. testPageContains("ssp/ifExpression2.ssp", "x = 1", "x is 1", "x = 2", "x is not 1")
  57. testPageContains("ssp/includeServlet.ssp", "Scalate Start", "Hello World!", "Scalate End")
  58. testPageContains("ssp/implicitParamTest.ssp", "encoded '/somePath'", "encoded2 '/anotherPath'", "encoded3 '/path3'")
  59. testPageContains("ssp/locale.ssp", "22.0 / 7 = 3.143")
  60. testPageContains("ssp/matchExpression.ssp", "i = 1", "i is 1", "i = 2", "i is 2", "i = 3", "i is something")
  61. testPage("ssp/noLayout.ssp") {
  62. pageContains("No Layout", "This page has no separate layout")
  63. pageNotContains("stylesheet", "text/css", "style.css")
  64. }
  65. // testPageContains("ssp/renderObject.ssp", "Strachan")
  66. testPageContains("ssp/optionTest.ssp", "no bar", "no foo")
  67. testPageContains("ssp/optionTest2.ssp", "no foo")
  68. testPageContains("ssp/renderCaseClass.ssp", "Strachan", "<hr/>", "Chirino")
  69. testPageContains("ssp/renderCollection.ssp", "Strachan", "<hr/>", "Chirino")
  70. testPageContains("ssp/renderCollection2.ssp", "Strachan", "Person 2", "Chirino")
  71. testPageContains("ssp/renderCollection3.ssp", "Strachan", "Dude 2", "Chirino")
  72. testPageContains("ssp/renderTemplate.ssp", "James", "London", "Hiram", "Tampa", "Matt", "No Location", "Paul", "USA")
  73. testPageContains("ssp/sampleTag.ssp", "Wrapped body", "hey James this is some body text!", "End of wrapped body")
  74. testPageContains("ssp/sampleTag2.ssp", "Wrapped body", "hey James this is some body text!", "End of wrapped body")
  75. testPageContains("ssp/sampleTag3.ssp", "Wrapped body", "hey Hiram this is some body text!", "End of wrapped body")
  76. testPageContains("ssp/simple.ssp", "1 + 2 = 3")
  77. testPageContains("ssp/snippet.ssp", "mmm I like beer")
  78. testPageContains("ssp/velocity/sampleTag.ssp", "Wrapped body", "hey James this is some body text!", "End of wrapped body")
  79. testPageContains("bad", "error: not found: value unknown")
  80. testPageContains("foo", "Hello from a FooResource!")
  81. testPageContains("foo/abc", "The item id is", "abc")
  82. testPageContains("foo/def", "The item id is", "def")
  83. testPageContains("scaml/defaultAttribute.scaml", "James")
  84. testPageContains("scaml/errors/badAttributeType.scaml",
  85. "error: not found: type StringT",
  86. "in /scaml/errors/badAttributeType.scaml near line 19 col 13")
  87. testPageContains("scaml/errors/badExpression.scaml",
  88. "error: not found: value nameX",
  89. "in /scaml/errors/badExpression.scaml near line 24 col 11")
  90. testPageContains("scaml/errors/missingAttribute.scaml", "The value for 'name' was not set")
  91. testPageContains("scaml/errors/missingInclude.scaml", "Could not load resource")
  92. testPageContains("scaml/errors/scalaCompileError.scaml",
  93. "error: not found: value unknown",
  94. "in /scaml/errors/scalaCompileError.scaml near line 25 col 17",
  95. "- for (i &lt;-")
  96. testPageContains("scaml/errors/templateCompileError.scaml",
  97. "Inconsistent indent level detected: indented too shallow",
  98. "in /scaml/errors/templateCompileError.scaml near line 23 col 4",
  99. "%h1 Template Compiler Error")
  100. testPageContains("scaml/captureAttribute.scaml", "Captured text", "Hello World")
  101. testPageContains("scaml/locale.scaml", "22.0 / 7 = 3.143")
  102. testPageContains("scaml/optionTest.scaml", "no foo")
  103. testPageContains("scaml/renderObject.scaml", "Strachan")
  104. testPageContains("scaml/renderCaseClass.scaml", "Strachan", "<hr/>", "Chirino")
  105. testPageContains("scaml/renderCollection.scaml", "Strachan", "<hr/>", "Chirino")
  106. testPageContains("scaml/sampleTag.scaml", "Wrapped body", "hey Hiram this is some body text!", "End of wrapped body")
  107. testPageContains("scaml/sampleTag2.scaml", "Wrapped body", "hey Hiram this is some body text!", "End of wrapped body")
  108. testPageContains("scaml/sampleTag3.scaml", "Wrapped body", "hey James this is some body text!", "End of wrapped body")
  109. testPageContains("scaml/simple.scaml", "Scaml is a Scala version of", "Haml")
  110. testPageContains("scaml/snippet.scaml", "mmm I like beer")
  111. testPageContains("scaml/standalone.scaml", "1 + 2 = 3")
  112. testPageContains("filtered.html", "This AWESOME page is rendered by the filter.")
  113. }