Skip to content

Commit

Permalink
Remove dependency on global Play object playframework#147
Browse files Browse the repository at this point in the history
- must be initialized manually
  • Loading branch information
lavrov committed Jun 8, 2016
1 parent 10b99da commit 0c4d8e5
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 387 deletions.
29 changes: 12 additions & 17 deletions statsd/build.sbt
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
import play.core.PlayVersion

name := "play-statsd"

organization := "com.typesafe.play.plugins"

version := "2.3.0"

scalaVersion := "2.11.1"
version := "2.4.0"

crossScalaVersions := Seq("2.11.1", "2.10.4")
scalaVersion in ThisBuild := "2.11.8"

resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

libraryDependencies ++= Seq(
"com.typesafe.play" %% "play" % "2.3.0" % "provided",
"com.typesafe.play" %% "play-test" % "2.3.0" % "test"
"com.typesafe.play" %% "play" % PlayVersion.current % "provided",
"com.typesafe.play" %% "play-test" % PlayVersion.current % "test",
specs2 % "test"
)

resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"

parallelExecution in Test := false

testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v")

publishTo <<= (version) { version: String =>
publishTo <<= version { version: String =>
val nexus = "https://private-repo.typesafe.com/typesafe/"
if (version.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "maven-snapshots/")
else Some("releases" at nexus + "maven-releases/")
}

javacOptions ++= Seq("-source", "1.6", "-target", "1.6", "-Xlint:unchecked", "-encoding", "UTF-8")

scalacOptions += "-deprecation"

lazy val root = project in file(".")
lazy val root: Project = project in file(".") aggregate sample

lazy val sample = (project in file("sample/sample-statsd"))
.enablePlugins(PlayScala)
.settings(
Keys.fork in Test := false
).dependsOn(root).aggregate(root)
lazy val sample = project in file("sample/sample-statsd") dependsOn (LocalRootProject % "test->test;compile->compile")
2 changes: 1 addition & 1 deletion statsd/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.5
sbt.version=0.13.11
2 changes: 1 addition & 1 deletion statsd/project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.0")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.3")
10 changes: 8 additions & 2 deletions statsd/sample/sample-statsd/app/Global.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import play.api.Application
import play.api.mvc.WithFilters
import play.modules.statsd.api.StatsdFilter
import play.modules.statsd.api.{Statsd, StatsdFilter}

object Global extends WithFilters(new StatsdFilter)
object Global extends WithFilters(new StatsdFilter) {
override def onStart(app: Application) = {
Statsd.init(app.configuration)
super.onStart(app)
}
}
5 changes: 5 additions & 0 deletions statsd/sample/sample-statsd/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
enablePlugins(PlayScala)

libraryDependencies += ws

Keys.fork in Test := false
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package test

import java.net.{SocketTimeoutException, DatagramPacket, DatagramSocket}
import java.net.{DatagramPacket, DatagramSocket, SocketTimeoutException}

import org.specs2.execute.AsResult
import org.specs2.mutable._
import play.api.libs.ws.ning.NingWSClient
import play.api.test.Helpers._
import play.api.test._
import org.specs2.execute.{AsResult, Result}
import collection.mutable.ListBuffer
import play.api.libs.ws.WS
import concurrent.Await
import concurrent.duration.Duration

object IntegrationTestSpec extends Specification {
import scala.collection.mutable.ListBuffer
import scala.concurrent.Await
import scala.concurrent.duration.Duration

object IntegrationSpec extends Specification {
def WS = NingWSClient()

"statsd filters" should {

"report stats on /" in new Setup {
Expand Down Expand Up @@ -53,16 +57,6 @@ object IntegrationTestSpec extends Specification {
receive(count("sample.routes.async.get"), timing("sample.routes.async.get"), combinedTime, combinedSuccess, combined200)
}

"report stats on failure" in new Setup {
makeWsRequest("/sync/failure")
receive(count("sample.routes.sync.failure.get"), timing("sample.routes.sync.failure.get"), combinedTime, combinedError, combined500)
}

"report stats on failure thrown in async" in new Setup {
makeWsRequest("/async/failure")
receive(count("sample.routes.async.failure.get"), timing("sample.routes.async.failure.get"), combinedTime, combinedError, combined500)
}

"report stats on action returning 503" in new Setup {
makeRequest("/error", 503)
receive(count("sample.routes.error.get"), timing("sample.routes.error.get"), combinedTime, combinedError, combined503)
Expand Down
128 changes: 0 additions & 128 deletions statsd/src/main/java/play/modules/statsd/Statsd.java

This file was deleted.

29 changes: 0 additions & 29 deletions statsd/src/main/java/play/modules/statsd/StatsdFilter.java

This file was deleted.

Loading

0 comments on commit 0c4d8e5

Please sign in to comment.