Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* Worked on lift_blank

* Added logback-test.xml file (which has a different name schema than the default xml file).
* Updated specs tests to use specs2
  • Loading branch information...
commit f57f5ca1722423cb8d1a16d8b99c237f97505485 1 parent 9a1822e
@fmpwizard fmpwizard authored
View
4 scala_29/lift_basic/project/plugins.sbt
@@ -6,7 +6,7 @@ libraryDependencies <+= sbtVersion(v => v match {
})
//Uncoment this line to enable the sbt idea plugin
-//addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.0.0")
+addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.0.0")
//Uncoment this line to enable the sbt eclipse plugin
-//addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0-RC1")
+addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0-RC1")
View
23 scala_29/lift_basic/src/test/resources/logback-test.xml
@@ -0,0 +1,23 @@
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>console.devmode.log</file>
+ <append>true</append>
+ <encoder>
+ <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+
+
+ <logger name="code.snippet" level="info" />
+ <logger name="net.liftweb" level="warn" />
+ <logger name="bootstrap.liftweb" level="info" />
+ <root level="warn">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
View
11 scala_29/lift_basic/src/test/scala/code/snippet/HelloWorldTest.scala
@@ -1,17 +1,18 @@
package code
package snippet
-import org.specs._
import net.liftweb._
import http._
import net.liftweb.util._
import net.liftweb.common._
-import org.specs.specification._
import Helpers._
import lib._
+import org.specs2.mutable.Specification
+import org.specs2.specification.AroundExample
+import org.specs2.execute.Result
-object HelloWorldTestSpecs extends Specification {
+object HelloWorldTestSpecs extends Specification with AroundExample{
val session = new LiftSession("", randomString(20), Empty)
val stableTime = now
@@ -19,10 +20,10 @@ object HelloWorldTestSpecs extends Specification {
* For additional ways of writing tests,
* please see http://www.assembla.com/spaces/liftweb/wiki/Mocking_HTTP_Requests
*/
- override def executeExpectations(ex: Examples, t: =>Any): Any = {
+ def around[T <% Result](body: => T) = {
S.initIfUninitted(session) {
DependencyFactory.time.doWith(stableTime) {
- super.executeExpectations(ex, t)
+ body
}
}
}
View
27 scala_29/lift_blank/build.sbt
@@ -0,0 +1,27 @@
+name := "Lift 2.5 starter template"
+
+version := "0.0.1"
+
+organization := "net.liftweb"
+
+scalaVersion := "2.9.1"
+
+resolvers ++= Seq("snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
+ "releases" at "http://oss.sonatype.org/content/repositories/releases"
+ )
+
+seq(com.github.siasia.WebPlugin.webSettings :_*)
+
+scalacOptions ++= Seq("-deprecation", "-unchecked")
+
+libraryDependencies ++= {
+ val liftVersion = "2.5-SNAPSHOT"
+ Seq(
+ "net.liftweb" %% "lift-webkit" % liftVersion % "compile",
+ "net.liftmodules" %% "lift-jquery-module" % (liftVersion + "-1.0-SNAPSHOT"),
+ "org.eclipse.jetty" % "jetty-webapp" % "7.5.4.v20111024" % "container; test",
+ "ch.qos.logback" % "logback-classic" % "1.0.6",
+ "org.specs2" %% "specs2" % "1.11" % "test"
+ )
+}
+
View
9 scala_29/lift_blank/project/build.properties
@@ -1,9 +0,0 @@
-#Project properties
-project.organization=Lift
-project.name=Lift SBT Template
-sbt.version=0.7.7
-project.version=0.1
-def.scala.version=2.7.7
-build.scala.versions=2.9.0-1
-project.initialize=false
-lift.version=2.4
View
24 scala_29/lift_blank/project/build/LiftProject.scala
@@ -1,24 +0,0 @@
-import sbt._
-
-class LiftProject(info: ProjectInfo) extends DefaultWebProject(info) {
- val liftVersion = property[Version]
-
- // uncomment the following if you want to use the snapshot repo
- // val scalatoolsSnapshot = ScalaToolsSnapshots
-
- // If you're using JRebel for Lift development, uncomment
- // this line
- // override def scanDirectories = Nil
-
- lazy val JavaNet = "Java.net Maven2 Repository" at "http://download.java.net/maven/2/"
-
- val SonatypeRep = "Sonatype scala-tools repo" at "https://oss.sonatype.org/content/groups/scala-tools/"
-
- override def libraryDependencies = Set(
- "net.liftweb" %% "lift-webkit" % liftVersion.value.toString % "compile",
- "org.mortbay.jetty" % "jetty" % "6.1.26" % "test",
- "junit" % "junit" % "4.7" % "test",
- "ch.qos.logback" % "logback-classic" % "0.9.26",
- "org.scala-tools.testing" %% "specs" % "1.6.8" % "test"
- ) ++ super.libraryDependencies
-}
View
12 scala_29/lift_blank/project/plugins.sbt
@@ -0,0 +1,12 @@
+libraryDependencies <+= sbtVersion(v => v match {
+ case "0.11.0" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.0-0.2.8"
+ case "0.11.1" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.1-0.2.10"
+ case "0.11.2" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.2-0.2.11"
+ case "0.11.3" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.3-0.2.11.1"
+})
+
+//Uncoment this line to enable the sbt idea plugin
+addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.0.0")
+
+//Uncoment this line to enable the sbt eclipse plugin
+//addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0-RC1")
View
2  scala_29/lift_blank/sbt
@@ -1 +1 @@
-java -Xmx1024M -Xss2M -XX:+CMSClassUnloadingEnabled -jar `dirname $0`/sbt-launcher.jar "$@"
+java -Xmx1024M -Xss2M -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -jar `dirname $0`/sbt-launcher.jar "$@"
View
BIN  scala_29/lift_blank/sbt-launcher.jar
Binary file not shown
View
23 scala_29/lift_blank/src/main/resources/props/default.logback.xml
@@ -0,0 +1,23 @@
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>console.devmode.log</file>
+ <append>true</append>
+ <encoder>
+ <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+
+
+ <logger name="code.snippet" level="info" />
+ <logger name="net.liftweb" level="warn" />
+ <logger name="bootstrap.liftweb" level="info" />
+ <root level="warn">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
View
14 scala_29/lift_blank/src/main/scala/bootstrap/liftweb/Boot.scala
@@ -8,6 +8,8 @@ import common._
import http._
import sitemap._
import Loc._
+import net.liftmodules.JQueryModule
+import net.liftweb.http.js.jquery._
/**
@@ -32,9 +34,6 @@ class Boot {
// each page, just comment this line out.
LiftRules.setSiteMap(SiteMap(entries:_*))
- // Use jQuery 1.4
- LiftRules.jsArtifacts = net.liftweb.http.js.jquery.JQuery14Artifacts
-
//Show the spinny image when an Ajax call starts
LiftRules.ajaxStart =
Full(() => LiftRules.jsArtifacts.show("ajax-loader").cmd)
@@ -46,5 +45,14 @@ class Boot {
// Force the request to be UTF-8
LiftRules.early.append(_.setCharacterEncoding("UTF-8"))
+ // Use HTML5 for rendering
+ LiftRules.htmlProperties.default.set((r: Req) =>
+ new Html5Properties(r.userAgent))
+
+ //Init the jQuery module, see http://liftweb.net/jquery for more information.
+ LiftRules.jsArtifacts = JQueryArtifacts
+ JQueryModule.InitParam.JQuery=JQueryModule.JQuery172
+ JQueryModule.init()
+
}
}
View
85 scala_29/lift_blank/src/main/webapp/templates-hidden/default.html
@@ -3,20 +3,83 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
- <title><span class="lift:Menu.title">code:app:0.1-SNAPSHOT</span></title>
- <script id="jquery" src="/classpath/jquery.js" type="text/javascript"/>
+ <title class="lift:Menu.title">App: </title>
+ <style class="lift:CSS.blueprint"></style>
+ <style class="lift:CSS.fancyType"></style>
+ <script id="jquery" src="/classpath/jquery.js" type="text/javascript"></script>
+ <script id="json" src="/classpath/json.js" type="text/javascript"></script>
+ <style type="text/css">
+/* <![CDATA[ */
+.edit_error_class {
+ display: block;
+ color: red;
+}
+
+.sidebar ul {
+ margin:0;
+ padding:0;
+ border-bottom:1px solid #ccc;
+}
+
+
+.sidebar ul li {
+ margin:0;
+ padding:0;
+ list-style:none;
+ border:1px solid #ccc;
+ border-bottom:none;
+}
+
+.sidebar ul li a {
+ display:block;
+ padding:3px;
+ text-indent:30px;
+ text-decoration:none;
+}
+
+.sidebar ul li span {
+ display:block;
+ padding:3px;
+ text-indent:30px;
+ text-decoration:none;
+}
+
+.sidebar ul li a:hover {
+ background-color: #eee;
+}
+
+
+ /* ]]> */
+ </style>
</head>
<body>
- <div class="lift:Menu.builder"/>
- <div class="lift:Msgs?showAll=true"/>
+ <div class="container">
+ <div class="column span-12 last" style="text-align: right">
+ <h1 class="alt">app<img alt="" id="ajax-loader" style="display:none; margin-bottom: 0px; margin-left: 5px" src="/images/ajax-loader.gif"></h1>
+ </div>
+
+ <hr>
+
+ <div class="column span-6 colborder sidebar">
+ <hr class="space" >
+
+ <span class="lift:Menu.builder"></span>
+
+ <div class="lift:Msgs?showAll=true"></div>
+ <hr class="space" />
+ </div>
- <lift:bind name="content" />
+ <div class="column span-17 last">
+ <div id="content">The main content will get bound here</div>
+ </div>
- <hr />
- <h4>
- <a href="http://www.liftweb.net"><i>Lift</i></a>
- is Copyright 2007-2011 WorldWide Conferencing, LLC.
- Distributed under an Apache 2.0 License.
- </h4>
+ <hr />
+ <div class="column span-23 last" style="text-align: center">
+ <h4 class="alt">
+ <a href="http://www.liftweb.net"><i>Lift</i></a>
+ is Copyright 2007-2012 WorldWide Conferencing, LLC.
+ Distributed under an Apache 2.0 License.</h4>
+ </div>
+ </div>
</body>
</html>
View
23 scala_29/lift_blank/src/test/resources/logback-test.xml
@@ -0,0 +1,23 @@
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>console.devmode.log</file>
+ <append>true</append>
+ <encoder>
+ <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+
+
+ <logger name="code.snippet" level="info" />
+ <logger name="net.liftweb" level="warn" />
+ <logger name="bootstrap.liftweb" level="info" />
+ <root level="warn">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
View
15 scala_29/lift_blank/src/test/scala/LiftConsole.scala
@@ -1,15 +0,0 @@
-import bootstrap.liftweb.Boot
-import scala.tools.nsc.MainGenericRunner
-
-object LiftConsole {
- def main(args : Array[String]) {
- // Instantiate your project's Boot file
- val b = new Boot()
- // Boot your project
- b.boot
- // Now run the MainGenericRunner to get your repl
- MainGenericRunner.main(args)
- // After the repl exits, then exit the scala script
- sys.exit(0)
- }
-}
View
15 scala_29/lift_blank/src/test/scala/RunWebApp.scala
@@ -1,7 +1,7 @@
-import org.mortbay.jetty.Connector
-import org.mortbay.jetty.Server
-import org.mortbay.jetty.webapp.WebAppContext
-import org.mortbay.jetty.nio._
+import org.eclipse.jetty.server.handler.ContextHandler
+import org.eclipse.jetty.server.nio.SelectChannelConnector
+import org.eclipse.jetty.server.{Handler, Server}
+import org.eclipse.jetty.webapp.WebAppContext
object RunWebApp extends App {
val server = new Server
@@ -11,10 +11,11 @@ object RunWebApp extends App {
val context = new WebAppContext()
context.setServer(server)
- context.setContextPath("/")
context.setWar("src/main/webapp")
- server.addHandler(context)
+ val context0: ContextHandler = new ContextHandler();
+ context0.setHandler(context)
+ server.setHandler(context0)
try {
println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP")
@@ -25,7 +26,7 @@ object RunWebApp extends App {
server.stop()
server.join()
} catch {
- case exc : Exception => {
+ case exc: Exception => {
exc.printStackTrace()
System.exit(100)
}
View
76 scala_29/lift_blank/src/test/scala/code/AppTest.scala
@@ -1,76 +0,0 @@
-package code
-
-import java.io.File
-import junit.framework._
-import Assert._
-import scala.xml.XML
-import net.liftweb.util._
-import net.liftweb.common._
-
-object AppTest {
- def suite: Test = {
- val suite = new TestSuite(classOf[AppTest])
- suite
- }
-
- def main(args : Array[String]) {
- junit.textui.TestRunner.run(suite)
- }
-}
-
-/**
- * Unit test for simple App.
- */
-class AppTest extends TestCase("app") {
-
- /**
- * Rigourous Tests :-)
- */
- def testOK() = assertTrue(true)
- // def testKO() = assertTrue(false);
-
- /**
- * Tests to make sure the project's XML files are well-formed.
- *
- * Finds every *.html and *.xml file in src/main/webapp (and its
- * subdirectories) and tests to make sure they are well-formed.
- */
- def testXml() = {
- var failed: List[File] = Nil
-
- def handledXml(file: String) =
- file.endsWith(".xml")
-
- def handledXHtml(file: String) =
- file.endsWith(".html") || file.endsWith(".htm") || file.endsWith(".xhtml")
-
- def wellFormed(file: File) {
- if (file.isDirectory)
- for (f <- file.listFiles) wellFormed(f)
-
- if (file.isFile && handledXml(file.getName)) {
- try {
- XML.loadFile(file)
- } catch {
- case e: org.xml.sax.SAXParseException => failed = file :: failed
- }
- }
- if (file.isFile && handledXHtml(file.getName)) {
- PCDataXmlParser(new java.io.FileInputStream(file.getAbsolutePath)) match {
- case Full(_) => // file is ok
- case _ => failed = file :: failed
- }
- }
- }
-
- wellFormed(new File("src/main/webapp"))
-
- val numFails = failed.size
- if (numFails > 0) {
- val fileStr = if (numFails == 1) "file" else "files"
- val msg = "Malformed XML in " + numFails + " " + fileStr + ": " + failed.mkString(", ")
- println(msg)
- fail(msg)
- }
- }
-}
View
23 scala_29/lift_blank/src/test/scala/code/snippet/HelloWorldTest.scala
@@ -1,30 +1,29 @@
package code
package snippet
-import org.specs._
-import org.specs.runner.JUnit4
-import org.specs.runner.ConsoleRunner
import net.liftweb._
import http._
import net.liftweb.util._
import net.liftweb.common._
-import org.specs.matcher._
-import org.specs.specification._
import Helpers._
import lib._
+import org.specs2.mutable.Specification
+import org.specs2.specification.AroundExample
+import org.specs2.execute.Result
-class HelloWorldTestSpecsAsTest extends JUnit4(HelloWorldTestSpecs)
-object HelloWorldTestSpecsRunner extends ConsoleRunner(HelloWorldTestSpecs)
-
-object HelloWorldTestSpecs extends Specification {
+object HelloWorldTestSpecs extends Specification with AroundExample{
val session = new LiftSession("", randomString(20), Empty)
val stableTime = now
- override def executeExpectations(ex: Examples, t: =>Any): Any = {
+ /**
+ * For additional ways of writing tests,
+ * please see http://www.assembla.com/spaces/liftweb/wiki/Mocking_HTTP_Requests
+ */
+ def around[T <% Result](body: => T) = {
S.initIfUninitted(session) {
DependencyFactory.time.doWith(stableTime) {
- super.executeExpectations(ex, t)
+ body
}
}
}
@@ -37,7 +36,7 @@ object HelloWorldTestSpecs extends Specification {
val str = hello.howdy(<span>Welcome to your Lift app at <span id="time">Time goes here</span></span>).toString
str.indexOf(stableTime.toString) must be >= 0
- str.indexOf("Welcome to") must be >= 0
+ str must startWith("<span>Welcome to")
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.