question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useable outside of play applications?

See original GitHub issue

plays 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

https://github.com/leanovate/play-mockws/blob/master/src/main/scala/mockws/FakeWSRequestHolder.scala#L111

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:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
yannscommented, Feb 7, 2017

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?

0reactions
francisdbcommented, Jul 17, 2017

And one more annoyance is that FakeWSRequestHolder depends on AhcWSResponse, which makes depending on play-ws not enough, I need to add a test dependency to play-ahc-ws

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use of All files access (MANAGE_EXTERNAL_STORAGE ...
Google Play restricts the use of high risk or sensitive permissions, including a special app access called All files access. This is only...
Read more >
The Best Android Apps for 2022 - PCMag
The Google Play store has millions of apps. Some are great, many are duds. Our guide, which covers 13 key categories and 104...
Read more >
How to Download Apps on Android WITHOUT Google Play
Although Google works hard to make sure Android users stay secure, you have the option to download apps on Android without using the...
Read more >
How to install apps outside of Google Play - CNET
From your smartphone or tablet running Android 4.0 or higher, go to Settings, scroll down to Security, and select Unknown sources. Selecting ...
Read more >
App Stores List - Business of Apps
The Google Play Store for Android and the Apple App Store for iOS are ... largest alternative app stores out there at the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found