Permalink
Browse files

merge Fixes reflection for value types in generic classes and fixes v…

…alidation error serializer
  • Loading branch information...
2 parents 9a1d5cf + 5ee31b2 commit 2da04ca1c602d6b6f0d995a8a0f07ea35374619b @casualjim casualjim committed Mar 22, 2013
@@ -0,0 +1,19 @@
+package org.scalatra
+package validation
+
+import org.specs2.mutable.Specification
+import org.json4s._
+
+
+class ValidationSerializerSpec extends Specification {
+
+ implicit val formats: Formats =
+ DefaultFormats + new ErrorCodeSerializer(org.scalatra.validation.NotFound) + new ValidationErrorSerializer()
+
+ "A validation error serializer" should {
+ "serialize a validation error" in {
+ val err = ValidationError("the error message", FieldName("a_field"), org.scalatra.validation.NotFound)
+ Extraction.decompose(err) must_== JObject(JField("message", JString("the error message")) :: "field" -> JString("a_field") :: "code" -> JString("NotFound") :: Nil)
+ }
+ }
+}
View
@@ -8,7 +8,6 @@ import org.scalatra.sbt.ScalatraPlugin.scalatraWithWarOverlays
object ScalatraBuild extends Build {
import Dependencies._
- import Resolvers._
lazy val scalatraSettings = Defaults.defaultSettings ++ ls.Plugin.lsSettings ++ Seq(
organization := "org.scalatra",
@@ -19,7 +18,7 @@ object ScalatraBuild extends Build {
javacOptions ++= Seq("-target", "1.6", "-source", "1.6", "-Xlint:deprecation"),
manifestSetting,
publishSetting,
- resolvers ++= Seq(sonatypeNexusSnapshots),
+ resolvers ++= Seq(Opts.resolver.sonatypeSnapshots, Opts.resolver.sonatypeReleases),
(LsKeys.tags in LsKeys.lsync) := Seq("web", "sinatra", "scalatra", "akka"),
(LsKeys.docsUrl in LsKeys.lsync) := Some(new URL("http://www.scalatra.org/guides/"))
) ++ mavenCentralFrouFrou
@@ -108,7 +107,6 @@ object ScalatraBuild extends Build {
base = file("scalate"),
settings = scalatraSettings ++ Seq(
libraryDependencies <+= scalaVersion(scalate),
- resolvers ++= Seq(sonatypeNexusSnapshots),
description := "Scalate integration with Scalatra",
LsKeys.tags in LsKeys.lsync ++= Seq("templating", "scalate", "ssp", "jade", "mustache", "scaml", "haml")
)
@@ -233,7 +231,6 @@ object ScalatraBuild extends Build {
id = "scalatra-example",
base = file("example"),
settings = scalatraSettings ++ doNotPublish ++ scalatraWithWarOverlays ++ Seq(
- resolvers ++= Seq(sonatypeNexusSnapshots),
libraryDependencies += servletApi % "container;test",
libraryDependencies += jettyWebsocket % "container;test",
libraryDependencies ++= Seq(jettyWebapp % "container;test", slf4jSimple),
@@ -310,7 +307,7 @@ object ScalatraBuild extends Build {
private val jettyVersion = "8.1.10.v20130312"
- private val json4sVersion = "3.2.0"
+ private val json4sVersion = "3.2.1"
private val scalateArtifact: String => String = {
case sv if sv startsWith "2.8." => "scalate-core"
@@ -347,7 +344,7 @@ object ScalatraBuild extends Build {
private val specs2Version: String => String = {
case sv if sv startsWith "2.8." => "1.5"
case "2.9.0-1" => "1.8.2"
- case sv if sv startsWith "2.9." => "1.12.3"
+ case sv if sv startsWith "2.9." => "1.12.4.1"
case _ => "1.14"
}
@@ -358,13 +355,6 @@ object ScalatraBuild extends Build {
private val swaggerVersion = "1.2.0"
}
- object Resolvers {
- val sonatypeNexusSnapshots = "Sonatype Nexus Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
- val sonatypeNexusReleases = "Sonatype Nexus Releases" at "https://oss.sonatype.org/content/repositories/releases"
- val sonatypeNexusStaging = "Sonatype Nexus Staging" at "https://oss.sonatype.org/service/local/staging/deploy/maven2"
- val fuseSourceSnapshots = "FuseSource Snapshots" at "http://repo.fusesource.com/nexus/content/repositories/snapshots"
- }
-
lazy val manifestSetting = packageOptions <+= (name, version, organization) map {
(title, version, vendor) =>
Package.ManifestAttributes(
@@ -383,9 +373,9 @@ object ScalatraBuild extends Build {
lazy val publishSetting = publishTo <<= (version) { version: String =>
if (version.trim.endsWith("SNAPSHOT"))
- Some(sonatypeNexusSnapshots)
+ Some(Opts.resolver.sonatypeSnapshots)
else
- Some(sonatypeNexusStaging)
+ Some(Opts.resolver.sonatypeStaging)
}
// Things we care about primarily because Maven Central demands them
@@ -6,10 +6,10 @@ import org.specs2.specification.{SpecificationStructure, BaseSpecification, Step
import org.specs2.mutable.FragmentsBuilder
/**
-* A base specification structure that starts the tester before the
-* specification and stops it afterward. Clients probably want to extend
-* ScalatraSpec or MutableScalatraSpec.
-*/
+ * A base specification structure that starts the tester before the
+ * specification and stops it afterward. Clients probably want to extend
+ * ScalatraSpec or MutableScalatraSpec.
+ */
trait BaseScalatraSpec extends SpecificationStructure with FragmentsBuilder with ScalatraTests {
override def map(fs: =>Fragments) = Step(start()) ^ super.map(fs) ^ Step(stop())
}
@@ -4,12 +4,11 @@ package specs2
import org.specs2.SpecificationLike
-
/**
* A Specification that starts the tester before the specification and stops it
* afterward.
*
* This is a spec of the immutable variation of the specs2 framework.
* All documentation for specs2 still applies.
*/
-trait ScalatraSpec extends SpecificationLike with BaseScalatraSpec
+trait ScalatraSpec extends SpecificationLike with BaseScalatraSpec
@@ -5,7 +5,6 @@ import java.lang.reflect.{ TypeVariable, WildcardType, ParameterizedType, Type,
private[swagger] object ManifestFactory {
def manifestOf(t: Type): Manifest[_] = t match {
- case c: Class[_] => fromClass(c)
case pt: ParameterizedType =>
val clazz = manifestOf(pt.getRawType).erasure
@@ -31,6 +30,9 @@ private[swagger] object ManifestFactory {
val upper = wt.getBounds
if (upper != null && upper.size > 0) manifestOf(upper(0))
else manifestOf(classOf[AnyRef])
+
+ case c: Class[_] => fromClass(c)
+
}
def manifestOf(erasure: Class[_], typeArgs: Seq[Manifest[_]]): Manifest[_] = {
Oops, something went wrong.

0 comments on commit 2da04ca

Please sign in to comment.