Skip to content
This repository has been archived by the owner on Mar 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #81 from DanielaSfregola/#54_scala_212
Browse files Browse the repository at this point in the history
#54 Added Scala 2.12 support
  • Loading branch information
DanielaSfregola committed Jan 5, 2017
2 parents 8d0a149 + 97237af commit bd555ad
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 25 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ after_script:
- sbt coverageReport coveralls

scala:
- 2.12.1
- 2.11.8

jdk:
- oraclejdk8

env:
- SBT_OPTS="-XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:PermSize=256M -XX:MaxPermSize=512M"

# whitelist
branches:
only:
Expand Down
30 changes: 19 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import com.typesafe.sbt.SbtGit.{GitKeys => git}
import scoverage.ScoverageSbtPlugin.ScoverageKeys._

name := "twitter4s"
version := "3.1-SNAPSHOT"

scalaVersion := "2.11.8"
scalaVersion := "2.12.1"

resolvers ++= Seq(
"Sonatype Releases" at "https://oss.sonatype.org/content/repositories/releases/",
Expand All @@ -13,17 +12,17 @@ resolvers ++= Seq(

libraryDependencies ++= {

val Typesafe = "1.3.0"
val Akka = "2.4.11"
val Typesafe = "1.3.1"
val Akka = "2.4.16"
val AkkaHttp = "10.0.1"
val AkkaHttpJson4s = "1.11.0"
val Json4s = "3.5.0"
val Spec2Version = "2.3.13"
val ScalaLogging = "3.4.0"
val Spec2Version = "3.8.6"
val ScalaLogging = "3.5.0"

Seq(
"com.typesafe" % "config" % Typesafe,
"com.typesafe.akka" %% "akka-actor" % Akka,
"com.typesafe.akka" %% "akka-http-experimental" % Akka,
"com.typesafe.akka" %% "akka-http" % AkkaHttp,
"de.heikoseeberger" %% "akka-http-json4s" % AkkaHttpJson4s,
"org.json4s" %% "json4s-native" % Json4s,
"org.json4s" %% "json4s-ext" % Json4s,
Expand All @@ -33,8 +32,11 @@ libraryDependencies ++= {
)
}

coverageExcludedPackages := "com.danielasfregola.twitter4s.processors.*;com.danielasfregola.twitter4s.Twitter*Client"
coverageMinimum := 85
scalacOptions in ThisBuild ++= Seq("-language:postfixOps",
"-language:implicitConversions",
"-language:existentials",
"-feature",
"-deprecation")

lazy val standardSettings = Seq(
organization := "com.danielasfregola",
Expand All @@ -44,6 +46,7 @@ lazy val standardSettings = Seq(
ScmInfo(url("https://github.com/DanielaSfregola/twitter4s"),
"scm:git:git@github.com:DanielaSfregola/twitter4s.git")),
apiURL := Some(url("http://DanielaSfregola.github.io/twitter4s/latest/api/")),
crossScalaVersions := Seq("2.12.1", "2.11.8"),
pomExtra := (
<developers>
<developer>
Expand Down Expand Up @@ -77,8 +80,13 @@ lazy val standardSettings = Seq(
}
)

lazy val coverageSettings = Seq(
coverageExcludedPackages := "com.danielasfregola.twitter4s.processors.*;com.danielasfregola.twitter4s.Twitter*Client",
coverageMinimum := 85
)

lazy val root = Project(
id = "twitter4s",
base = file("."),
settings = standardSettings ++ site.settings ++ site.includeScaladoc(version + "/api")
settings = standardSettings ++ coverageSettings ++ site.settings ++ site.includeScaladoc(version + "/api")
++ site.includeScaladoc("latest/api") ++ ghpages.settings)
4 changes: 3 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.3.3")

resolvers += Classpaths.sbtPluginReleases

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.0.4")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.0")

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.0.0")

Expand All @@ -17,3 +17,5 @@ addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.0")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")

parallelExecution in Test := false
4 changes: 4 additions & 0 deletions src/test/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
akka.test {
single-expect-default = 60s
default-timeout = 60s
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class RestClientSpec extends ClientSpec {
val result = when(exampleRequest).expectRequest(identity(_)).respondWith(response)
val expectedTwitterException = TwitterException(code = StatusCodes.NotFound,
errors = Errors(TwitterError("Sorry, that page does not exist", 34)))
result should throwAn(expectedTwitterException).await
result.await should throwAn(expectedTwitterException)
}

"throw twitter exception to generic failure http response" in new RestClientSpecContext {
Expand All @@ -34,7 +34,7 @@ class RestClientSpec extends ClientSpec {
val result = when(exampleRequest).expectRequest(identity(_)).respondWith(response)
val expectedTwitterException = TwitterException(code = StatusCodes.RequestTimeout, errors = Errors(body))

result should throwAn(expectedTwitterException).await
result.await should throwAn(expectedTwitterException)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package com.danielasfregola.twitter4s.http.oauth
import akka.http.scaladsl.model.headers.RawHeader
import akka.http.scaladsl.model.{HttpCharsets, _}
import com.danielasfregola.twitter4s.entities.{AccessToken, ConsumerToken}
import com.danielasfregola.twitter4s.util.{AwaitableFuture, TestActorSystem}
import com.danielasfregola.twitter4s.util.{AwaitableFuture, TestActorSystem, TestExecutionContext}
import org.specs2.mutable.SpecificationLike


class OAuthProviderSpec extends TestActorSystem with SpecificationLike with AwaitableFuture {
class OAuth2ProviderSpec extends TestActorSystem with SpecificationLike with AwaitableFuture with TestExecutionContext {

implicit val consumerToken = ConsumerToken("xvz1evFS4wEEPTGEFPHBog", "kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw")
implicit val accessToken = AccessToken("370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb", "LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE")
Expand Down
6 changes: 3 additions & 3 deletions src/test/scala/com/danielasfregola/twitter4s/util/Spec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package com.danielasfregola.twitter4s.util

import akka.http.scaladsl.model.{HttpCharsets, MediaTypes}
import com.danielasfregola.twitter4s.entities.{AccessToken, ConsumerToken}
import org.specs2.matcher.{NoConcurrentExecutionContext, Scope, ThrownExpectations}
import org.specs2.matcher.Scope
import org.specs2.mutable.SpecificationLike

trait Spec extends ThrownExpectations with SpecificationLike {
trait Spec extends SpecificationLike {

val `application/x-www-form-urlencoded` = MediaTypes.`application/x-www-form-urlencoded` withCharset HttpCharsets.`UTF-8`

trait SpecContext extends FixturesSupport with AwaitableFuture with NoConcurrentExecutionContext with Scope {
trait SpecContext extends FixturesSupport with AwaitableFuture with Scope {

val consumerToken = ConsumerToken("consumer-key", "consumer-secret")
val accessToken = AccessToken("access-key", "access-secret")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.danielasfregola.twitter4s.util

trait TestExecutionContext {
implicit val executionContext = scala.concurrent.ExecutionContext.Implicits.global
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.danielasfregola.twitter4s.util.{RequestDSL, Spec}
import scala.concurrent.Future
import scala.concurrent.duration.DurationInt

class ClientSpec extends Spec {
abstract class ClientSpec extends Spec {

abstract class ClientSpecContext extends RequestDSL with RestClient with SpecContext {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.danielasfregola.twitter4s.util.{RequestDSL, Spec}
import scala.concurrent.Future
import scala.concurrent.duration.DurationInt

class ClientSpec extends Spec {
abstract class ClientSpec extends Spec {

def dummyProcessing: PartialFunction[StreamingMessage, Unit] = { case _ => }

Expand Down

0 comments on commit bd555ad

Please sign in to comment.