PageRenderTime 32ms CodeModel.GetById 17ms app.highlight 11ms RepoModel.GetById 2ms app.codeStats 0ms

/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 */
 18package org.fusesource.scalate.sample
 19
 20import _root_.org.junit.runner.RunWith
 21import _root_.org.scalatest.junit.JUnitRunner
 22import org.scalatest.{ConfigMap, FunSuite}
 23
 24import _root_.org.fusesource.scalate.test._
 25
 26/**
 27 * @version $Revision: 1.1 $
 28 */
 29@RunWith(classOf[JUnitRunner])
 30class SampleTest extends FunSuite with WebServerMixin with WebDriverMixin {
 31
 32  override protected def beforeAll(configMap: ConfigMap) = {
 33    System.setProperty("scalate.mode", "development")
 34    super.beforeAll(configMap)
 35  }
 36
 37  testPageContains("ssp/renderObject.ssp", "Strachan")
 38
 39  test("home page") {
 40    webDriver.get(rootUrl)
 41    pageContains("Scalate")
 42  }
 43
 44  testPageContains("jade/captureAttribute.jade", "the captured template", "some javascript goes here", "Hello World")
 45
 46  testPageContains("mustache", "Scala", "Great", "Java", "Crufty")
 47  testPageContains("mustache/errors/templateCompileError.mustache", "Missing", "'{{/items}}'", "near line 8")
 48
 49  testPageContains("sampleServlet", "The foo is: Foo(")
 50
 51  testPageContains("ssp/capture.ssp", "Hello James", "Sample 2", "Hello James")
 52  testPageContains("ssp/customLayout.ssp", "layout header goes here...", "Custom page", "This is some text", "layout footer goes here...")
 53  testPageContains("ssp/defaultAttribute.ssp", "James")
 54  testPageContains("ssp/exampleIncludes.ssp", "included from /includes/something.jsp",
 55    "included from /ssp/child/foo.ssp", "included from /includes/something.jsp", "Finished including!")
 56
 57  testPageContains("ssp/errors/badAttributeType.ssp",
 58    "error: not found: type StringF",
 59    "in /ssp/errors/badAttributeType.ssp near line 22 col 13")
 60  
 61  testPageContains("ssp/errors/badExpression.ssp",
 62    "error: not found: value nameX",
 63    "in /ssp/errors/badExpression.ssp near line 24 col 13")
 64
 65  testPageContains("ssp/errors/missingAttribute.ssp", "The value for 'name' was not set")
 66  testPageContains("ssp/errors/missingInclude.ssp", "Could not load resource")
 67  testPageContains("ssp/errors/missingView.ssp", "No 'index' view template could be found for model object")
 68
 69  testPageContains("ssp/ifExpression.ssp", "x = 1", "x is 1", "x = 2", "x is not 1")
 70  testPageContains("ssp/ifExpression2.ssp", "x = 1", "x is 1", "x = 2", "x is not 1")
 71  testPageContains("ssp/includeServlet.ssp", "Scalate Start", "Hello World!", "Scalate End")
 72  testPageContains("ssp/implicitParamTest.ssp", "encoded '/somePath'", "encoded2 '/anotherPath'", "encoded3 '/path3'")
 73  testPageContains("ssp/locale.ssp", "22.0 / 7 = 3.143")
 74  testPageContains("ssp/matchExpression.ssp", "i = 1", "i is 1", "i = 2", "i is 2", "i = 3", "i is something")
 75
 76  testPage("ssp/noLayout.ssp") {
 77    pageContains("No Layout", "This page has no separate layout")
 78    pageNotContains("stylesheet", "text/css", "style.css")
 79  }
 80
 81//  testPageContains("ssp/renderObject.ssp", "Strachan")
 82  testPageContains("ssp/optionTest.ssp", "no bar", "no foo")
 83  testPageContains("ssp/optionTest2.ssp", "no foo")
 84  testPageContains("ssp/renderCaseClass.ssp", "Strachan", "<hr/>", "Chirino")
 85  testPageContains("ssp/renderCollection.ssp", "Strachan", "<hr/>", "Chirino")
 86  testPageContains("ssp/renderCollection2.ssp", "Strachan", "Person 2", "Chirino")
 87  testPageContains("ssp/renderCollection3.ssp", "Strachan", "Dude 2", "Chirino")
 88  testPageContains("ssp/renderTemplate.ssp", "James", "London", "Hiram", "Tampa", "Matt", "No Location", "Paul", "USA")
 89  testPageContains("ssp/sampleTag.ssp",  "Wrapped body", "hey James this is some body text!", "End of wrapped body")
 90  testPageContains("ssp/sampleTag2.ssp", "Wrapped body", "hey James this is some body text!", "End of wrapped body")
 91  testPageContains("ssp/sampleTag3.ssp", "Wrapped body", "hey Hiram this is some body text!", "End of wrapped body")
 92  testPageContains("ssp/simple.ssp", "1 + 2 = 3")
 93  testPageContains("ssp/snippet.ssp", "mmm I like beer")
 94  testPageContains("ssp/velocity/sampleTag.ssp",  "Wrapped body", "hey James this is some body text!", "End of wrapped body")
 95
 96  testPageContains("bad", "error: not found: value unknown")
 97  testPageContains("foo", "Hello from a FooResource!")
 98  testPageContains("foo/abc", "The item id is", "abc")
 99  testPageContains("foo/def", "The item id is", "def")
100
101  testPageContains("scaml/defaultAttribute.scaml", "James")
102
103  testPageContains("scaml/errors/badAttributeType.scaml",
104    "error: not found: type StringT",
105    "in /scaml/errors/badAttributeType.scaml near line 19 col 13")
106
107  testPageContains("scaml/errors/badExpression.scaml",
108    "error: not found: value nameX",
109    "in /scaml/errors/badExpression.scaml near line 24 col 11")
110
111  testPageContains("scaml/errors/missingAttribute.scaml", "The value for 'name' was not set")
112  testPageContains("scaml/errors/missingInclude.scaml", "Could not load resource")
113
114  testPageContains("scaml/errors/scalaCompileError.scaml",
115    "error: not found: value unknown",
116    "in /scaml/errors/scalaCompileError.scaml near line 25 col 17",
117    "- for (i &lt;-")
118
119  testPageContains("scaml/errors/templateCompileError.scaml",
120    "Inconsistent indent level detected: indented too shallow",
121    "in /scaml/errors/templateCompileError.scaml near line 23 col 4",
122    "%h1 Template Compiler Error")
123
124
125  testPageContains("scaml/captureAttribute.scaml", "Captured text", "Hello World")
126  testPageContains("scaml/locale.scaml", "22.0 / 7 = 3.143")
127  testPageContains("scaml/optionTest.scaml", "no foo")
128  testPageContains("scaml/renderObject.scaml", "Strachan")
129  testPageContains("scaml/renderCaseClass.scaml", "Strachan", "<hr/>", "Chirino")
130  testPageContains("scaml/renderCollection.scaml", "Strachan", "<hr/>", "Chirino")
131  testPageContains("scaml/sampleTag.scaml",  "Wrapped body", "hey Hiram this is some body text!", "End of wrapped body")
132  testPageContains("scaml/sampleTag2.scaml", "Wrapped body", "hey Hiram this is some body text!", "End of wrapped body")
133  testPageContains("scaml/sampleTag3.scaml", "Wrapped body", "hey James this is some body text!", "End of wrapped body")
134  testPageContains("scaml/simple.scaml", "Scaml is a Scala version of", "Haml")
135  testPageContains("scaml/snippet.scaml", "mmm I like beer")
136  testPageContains("scaml/standalone.scaml", "1 + 2 = 3")
137  testPageContains("filtered.html", "This AWESOME page is rendered by the filter.")
138
139}