useable outside of play applications?
See original GitHub issueplays WS client can be used as a stand alone client outside of a play app. Can / should this mock also be used in that situation?
I am trying it where the project definition looks like
lazy val `blah` = (project in file("preference-service-client")) .settings( libraryDependencies ++= Seq( "org.scalatest" %% "scalatest" % "3.0.1" % "test", "com.typesafe.play" %% "play-ws" % "2.5.12", "de.leanovate.play-mockws" %% "play-mockws" % "2.5.1" % "test" ), version := "1.0.0", scalaVersion := "2.11.8", scalafmtConfig := Some(file(".scalafmt")), reformatOnCompileSettings ) .dependsOn(root)
and root is a full blown play app
however when execute is called on the ws request I get a class not found exception on this line
the stack trace is as follows:
com.yadda *** ABORTED ***
[info] java.lang.NoClassDefFoundError: play/api/test/FakeRequest$
[info] at mockws.FakeWSRequestHolder.fakeRequest$1(FakeWSRequestHolder.scala:111)
[info] at mockws.FakeWSRequestHolder.executeResult(FakeWSRequestHolder.scala:115)
[info] at mockws.FakeWSRequestHolder.execute(FakeWSRequestHolder.scala:87)
[info] at com.iofficecorp.preferences.PreferenceClient$.get(PreferencesClient.scala:37)
[info] at com.yadda$$anonfun$2.apply(PreferenceClientSpec.scala:92)
[info] at com.yadda$$anonfun$2.apply(PreferenceClientSpec.scala:90)
[info] at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
[info] at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
[info] at org.scalatest.Transformer.apply(Transformer.scala:22)
[info] at org.scalatest.Transformer.apply(Transformer.scala:20)
[info] ...
[info] Cause: java.lang.ClassNotFoundException: play.api.test.FakeRequest$
[info] at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
[info] at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
[info] at java.security.AccessController.doPrivileged(Native Method)
[info] at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
[info] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[info] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[info] at mockws.FakeWSRequestHolder.fakeRequest$1(FakeWSRequestHolder.scala:111)
[info] at mockws.FakeWSRequestHolder.executeResult(FakeWSRequestHolder.scala:115)
[info] at mockws.FakeWSRequestHolder.execute(FakeWSRequestHolder.scala:87)
[info] at com.yada$.get(PreferencesClient.scala:37)
I am guessing this is because wsMock expects an implementation of FakeRequest to be injected by play and therefore this makes wsMock not usable outside of a play app but I Want to make sure I am not missing something
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
The core functionality is using play to resolve requests/responses: https://github.com/leanovate/play-mockws/blob/master/src/main/scala/mockws/FakeWSRequestHolder.scala#L110
Maybe the better way is to add play as test dependency?
And one more annoyance is that
FakeWSRequestHolder
depends onAhcWSResponse
, which makes depending onplay-ws
not enough, I need to add a test dependency toplay-ahc-ws