Guest User

Untitled

a guest
Dec 13th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. package itss;
  2. import java.util.concurrent.CompletionStage;
  3. import javax.inject.Inject;
  4. import org.junit.Test;
  5. import play.libs.Json;
  6. import play.libs.ws.WSBodyReadables;
  7. import play.libs.ws.WSBodyWritables;
  8. import play.libs.ws.WSClient;
  9. import play.libs.ws.WSResponse;
  10. import com.fasterxml.jackson.databind.JsonNode;
  11. public class IntegrationTest implements WSBodyReadables, WSBodyWritables {
  12. private final WSClient ws;
  13. @Inject
  14. public IntegrationTest(WSClient ws) {
  15. this.ws = ws;
  16. }
  17.  
  18. @Test
  19. public void sendSmsMessage() {
  20. try
  21. {
  22. JsonNode json = Json.newObject().put("calledfrom", "dsddsds");
  23. String url = "http://xx.xxx.xxx.xxx:8081/FS/fsqa/cd";
  24. CompletionStage<WSResponse> responseCompletionStage = ws.url(url).setContentType("application/json").post(json);
  25. responseCompletionStage.handle((result, error) -> {
  26. try
  27. {
  28. System.out.println("I am called");
  29. System.out.println("Body results is "+result.getBody().toString());
  30. System.out.println("into error"+error.getMessage());
  31. }
  32. catch(Exception e)
  33. {
  34. e.printStackTrace();
  35. }
  36. return responseCompletionStage;
  37.  
  38. });
  39.  
  40. }
  41. catch(Exception e)
  42. {
  43. e.printStackTrace();
  44.  
  45. }
  46. }
  47. }
  48.  
  49. [info] Test itss.IntegrationTest.initializationError started
  50. [error] Test itss.IntegrationTest.initializationError failed: java.lang.Exception: Test class should have exactly one public constructor, took 0.005 sec
  51. [error] at com.novocode.junit.JUnitRunner$1.execute(JUnitRunner.java:124)
  52. [error] at sbt.ForkMain$Run$2.call(ForkMain.java:296)
  53. [error] at sbt.ForkMain$Run$2.call(ForkMain.java:286)
  54. [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  55. [error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  56. [error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  57. [error] at java.lang.Thread.run(Thread.java:745)
  58. [info] Test run finished: 1 failed, 0 ignored, 1 total, 0.022s
  59. [error] Failed: Total 1, Failed 1, Errors 0, Passed 0
  60. [error] Failed tests:
  61. [error] itss.IntegrationTest
  62. [error] (test:test) sbt.TestsFailedException: Tests unsuccessful
  63. [error] Total time: 4 s, completed 13 Dec, 2017 8:26:52 PM
  64. [play-java-rest-api-example] $ [info]
Add Comment
Please, Sign In to add comment