Skip to content

Commit

Permalink
Ref #872 #873: Remove junit dependency, makes names more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
indrajitr committed Feb 24, 2011
1 parent 395c617 commit 8a66667
Show file tree
Hide file tree
Showing 24 changed files with 149 additions and 122 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2010 WorldWide Conferencing, LLC
* Copyright 2007-2011 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,14 +18,19 @@ package net.liftweb
package json
package ext

import _root_.org.specs._
import _root_.org.specs.runner._
import org.joda.time._

import org.specs.Specification

import common._
import json.Serialization.{read, write => swrite}
import org.joda.time._

class JodaTimeSerializerSpecTest extends JUnit4(JodaTimeSerializerSpec)
object JodaTimeSerializerSpec extends Specification {

/**
* System under specification for JodaTimeSerializer.
*/
object JodaTimeSerializerSpec extends Specification("JodaTimeSerializer Specification") {

implicit val formats = Serialization.formats(NoTypeHints) ++ JodaTimeSerializers.all

"Serialize joda time types" in {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2010 WorldWide Conferencing, LLC
* Copyright 2007-2011 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,13 +18,17 @@ package net.liftweb
package json
package ext

import _root_.org.specs._
import _root_.org.specs.runner._
import org.specs.Specification

import common._
import json.Serialization.{read, write => swrite}

class JsonBoxSerializerSpecTest extends JUnit4(JsonBoxSerializerSpec)
object JsonBoxSerializerSpec extends Specification {

/**
* System under specification for JsonBoxSerializer.
*/
object JsonBoxSerializerSpec extends Specification("JsonBoxSerializer Specification") {

implicit val formats = net.liftweb.json.DefaultFormats + new JsonBoxSerializer

"Extract empty age" in {
Expand Down
4 changes: 2 additions & 2 deletions core/json/README.md
Expand Up @@ -240,7 +240,7 @@ Querying JSON
------------

JSON values can be extracted using for-comprehensions.
Please see more examples in src/test/scala/net/liftweb/json/QueryExamples.scala
Please see more examples in src/test/scala/net/liftweb/json/JsonQueryExamples.scala

scala> import net.liftweb.json._
scala> val json = parse("""
Expand Down Expand Up @@ -386,7 +386,7 @@ Extracting values
Case classes can be used to extract values from parsed JSON. Non-existing values
can be extracted into scala.Option and strings can be automatically converted into
java.util.Dates.
Please see more examples in src/test/scala/net/liftweb/json/ExtractionExamples.scala
Please see more examples in src/test/scala/net/liftweb/json/ExtractionExamplesSpec.scala

scala> import net.liftweb.json._
scala> implicit val formats = DefaultFormats // Brings in default date formats etc.
Expand Down
12 changes: 7 additions & 5 deletions core/json/src/test/scala/net/liftweb/json/DiffExamples.scala
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2010 WorldWide Conferencing, LLC
* Copyright 2009-2011 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,10 +18,12 @@ package net.liftweb
package json

import org.specs.Specification
import org.specs.runner.{Runner, JUnit}

class DiffExamplesTest extends Runner(DiffExamples) with JUnit
object DiffExamples extends Specification {

/**
* System under specification for Diff Examples.
*/
object DiffExamples extends Specification("Diff Examples") {
import MergeExamples.{scala1, scala2, lotto1, lotto2, mergedLottoResult}

"Diff example" in {
Expand Down Expand Up @@ -71,5 +73,5 @@ object DiffExamples extends Specification {
}

private def read(resource: String) =
parse(scala.io.Source.fromInputStream(classOf[DiffExamplesTest].getResourceAsStream(resource)).getLines().mkString)
parse(scala.io.Source.fromInputStream(getClass.getResourceAsStream(resource)).getLines().mkString)
}
5 changes: 2 additions & 3 deletions core/json/src/test/scala/net/liftweb/json/Examples.scala
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2010 WorldWide Conferencing, LLC
* Copyright 2009-2011 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,9 +18,8 @@ package net.liftweb
package json

import org.specs.Specification
import org.specs.runner.{Runner, JUnit}

class ExampleTest extends Runner(Examples) with JUnit

object Examples extends Specification {
import JsonAST.concat
import JsonDSL._
Expand Down
10 changes: 6 additions & 4 deletions core/json/src/test/scala/net/liftweb/json/ExtractionBugs.scala
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2010 WorldWide Conferencing, LLC
* Copyright 2009-2011 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,10 +18,12 @@ package net.liftweb
package json

import org.specs.Specification
import org.specs.runner.{Runner, JUnit}

class ExtractionBugsTest extends Runner(ExtractionBugs) with JUnit
object ExtractionBugs extends Specification {

/**
* System under specification for Extraction bugs.
*/
object ExtractionBugs extends Specification("Extraction bugs Specification") {
implicit val formats = DefaultFormats

"ClassCastException (BigInt) regression 2 must pass" in {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2010 WorldWide Conferencing, LLC
* Copyright 2009-2011 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,10 +19,12 @@ package json

import java.util.Date
import org.specs.Specification
import org.specs.runner.{Runner, JUnit}

class ExtractionExampleTest extends Runner(ExtractionExamples) with JUnit
object ExtractionExamples extends Specification {

/**
* Systems under specification for Extraction Examples.
*/
object ExtractionExamples extends Specification("Extraction Examples Specification") {
implicit val formats = DefaultFormats

"Extraction example" in {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2010 WorldWide Conferencing, LLC
* Copyright 2009-2011 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,14 +17,15 @@
package net.liftweb
package json

import org.specs.{ScalaCheck, Specification}
import org.scalacheck._
import org.scalacheck.Prop.{forAll, forAllNoShrink}
import org.specs.Specification
import org.specs.runner.{Runner, JUnit}
import org.specs.ScalaCheck

class JsonASTTest extends Runner(JsonASTSpec) with JUnit
object JsonASTSpec extends Specification with JValueGen with ScalaCheck {

/**
* System under specification for JSON AST.
*/
object JsonAstSpec extends Specification("JSON AST Specification") with JValueGen with ScalaCheck {
"Functor identity" in {
val identityProp = (json: JValue) => json == (json map identity)
forAll(identityProp) must pass
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2010 WorldWide Conferencing, LLC
* Copyright 2009-2011 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,13 +17,13 @@
package net.liftweb
package json

import java.util.Date
import org.specs.Specification
import org.specs.runner.{Runner, JUnit}

class FormatsExamplesTest extends Runner(FormatsExamples) with JUnit

object FormatsExamples extends Specification with TypeHintExamples {
/**
* System under specification for JSON Formats.
*/
object JsonFormatsSpec extends Specification("JsonFormats Specification") with TypeHintExamples {
implicit val formats = ShortTypeHintExamples.formats + FullTypeHintExamples.formats.typeHints

val hintsForFish = ShortTypeHintExamples.formats.typeHints.hintFor(classOf[Fish])
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2010 WorldWide Conferencing, LLC
* Copyright 2009-2011 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,14 +17,15 @@
package net.liftweb
package json

import org.scalacheck._
import org.specs.{ScalaCheck, Specification}
import org.scalacheck.{Arbitrary, Gen}
import org.scalacheck.Prop._
import org.specs.Specification
import org.specs.runner.{Runner, JUnit}
import org.specs.ScalaCheck

class ParserTest extends Runner(ParserSpec) with JUnit
object ParserSpec extends Specification with JValueGen with ScalaCheck {

/**
* System under specification for JSON Parser.
*/
object JsonParserSpec extends Specification("JSON Parser Specification") with JValueGen with ScalaCheck {
"Any valid json can be parsed" in {
val parsing = (json: JValue) => { parse(Printer.pretty(render(json))); true }
forAll(parsing) must pass
Expand Down
Expand Up @@ -17,14 +17,15 @@
package net.liftweb
package json

import org.scalacheck._
import org.specs.{ScalaCheck, Specification}
import org.scalacheck.Arbitrary
import org.scalacheck.Prop.forAll
import org.specs.Specification
import org.specs.runner.{Runner, JUnit}
import org.specs.ScalaCheck

class PrintingTest extends Runner(PrintingSpec) with JUnit
object PrintingSpec extends Specification with JValueGen with ScalaCheck {

/**
* System under specification for JSON Printing.
*/
object JsonPrintingSpec extends Specification("JSON Printing Specification") with JValueGen with ScalaCheck {
import scala.text.Document

"rendering does not change semantics" in {
Expand Down
Expand Up @@ -18,10 +18,12 @@ package net.liftweb
package json

import org.specs.Specification
import org.specs.runner.{Runner, JUnit}

class QueryExamplesTest extends Runner(QueryExamples) with JUnit
object QueryExamples extends Specification {

/**
* System under specification for JSON Query Examples.
*/
object JsonQueryExamples extends Specification("JSON Query Examples") {
"List of IPs" in {
val ips = for { JString(ip) <- json \\ "ip" } yield ip
ips mustEqual List("192.168.1.125", "192.168.1.126", "192.168.1.127", "192.168.2.125", "192.168.2.126")
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2010 WorldWide Conferencing, LLC
* Copyright 2009-2011 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,14 +17,15 @@
package net.liftweb
package json

import org.scalacheck._
import org.specs.{ScalaCheck, Specification}
import org.scalacheck.Arbitrary
import org.scalacheck.Prop.forAll
import org.specs.Specification
import org.specs.runner.{Runner, JUnit}
import org.specs.ScalaCheck

class XmlTest extends Runner(XmlSpec) with JUnit
object XmlSpec extends Specification with NodeGen with JValueGen with ScalaCheck {

/**
* System under specification for JSON XML.
*/
object JsonXmlSpec extends Specification("JSON XML Specification") with NodeGen with JValueGen with ScalaCheck {
import Xml._
import scala.xml.Node

Expand Down
10 changes: 6 additions & 4 deletions core/json/src/test/scala/net/liftweb/json/LottoExample.scala
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2010 WorldWide Conferencing, LLC
* Copyright 2009-2011 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,10 +18,12 @@ package net.liftweb
package json

import org.specs.Specification
import org.specs.runner.{Runner, JUnit}

class LottoExampleTest extends Runner(LottoExample) with JUnit
object LottoExample extends Specification {

/**
* System under specification for Lotto Examples.
*/
object LottoExample extends Specification("Lotto Examples") {
import JsonDSL._

implicit val formats = DefaultFormats
Expand Down
8 changes: 4 additions & 4 deletions core/json/src/test/scala/net/liftweb/json/MergeExamples.scala
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2010 WorldWide Conferencing, LLC
* Copyright 2009-2011 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,10 +18,10 @@ package net.liftweb
package json

import org.specs.Specification
import org.specs.runner.{Runner, JUnit}

class MergeExamplesTest extends Runner(MergeExamples) with JUnit
object MergeExamples extends Specification {


object MergeExamples extends Specification("Merge Examples") {
"Merge example" in {
(scala1 merge scala2) mustEqual expectedMergeResult
}
Expand Down
8 changes: 4 additions & 4 deletions core/json/src/test/scala/net/liftweb/json/ParserBugs.scala
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2010 WorldWide Conferencing, LLC
* Copyright 2009-2011 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,11 +17,11 @@
package net.liftweb
package json

import util.control.Exception._

import org.specs.Specification
import org.specs.runner.{Runner, JUnit}
import scala.util.control.Exception._

class ParserBugsTest extends Runner(ParserBugs) with JUnit

object ParserBugs extends Specification {
"Unicode ffff is a valid char in string literal" in {
parseOpt(""" {"x":"\uffff"} """).isDefined mustEqual true
Expand Down

0 comments on commit 8a66667

Please sign in to comment.