Java playframework 2.2功能测试

Java playframework 2.2功能测试,java,unit-testing,playframework,playframework-2.2,Java,Unit Testing,Playframework,Playframework 2.2,我将playframework(Java版本)更新为2.2版。Web服务的调用方式发生了一些重大变化。在2.2之前的版本中,它们被称为: @Test public void testInServer() { running(testServer(3333), new Runnable() { public void run() { assertThat( WS.url("http://localhost:3333").get().get().getStatus()

我将playframework(Java版本)更新为2.2版。Web服务的调用方式发生了一些重大变化。在2.2之前的版本中,它们被称为:

@Test
public void testInServer() {
running(testServer(3333), new Runnable() {
  public void run() {
     assertThat(
       WS.url("http://localhost:3333").get().get().getStatus()
     ).isEqualTo(OK);
  }
});
}
新版本中的更改不推荐使用get()方法访问结果。我认为新的函数调用表示超时。这是进入的正确方式吗?是否有其他方法编写功能测试?超时应该是多长时间


谢谢你的回答。

好吧,我在游戏2.2.1中基本上是以同样的方式使用它的

@Test
public void testServerOK() {
  running(testServer(3333), new Runnable() {
      public void run() {
         //Context.current.set(ctx);
         WSRequestHolder wsreqHolder = WS.url("http://localhost:3333");
         F.Promise<WS.Response> promiseOfResult = wsreqHolder.get();
         assertThat(
           promiseOfResult.get().getStatus()
         ).isEqualTo(OK);
      }
   });
}
@测试
public void testServerOK(){
正在运行(testServer(3333),新的Runnable(){
公开募捐{
//Context.current.set(ctx);
WSRequestHolder wsreqHolder=WS.url(“http://localhost:3333");
F.promiseOfResult=wsreqHolder.get();
断言(
promiseOfResult.get().getStatus()
).isEqualTo(OK);
}
});
}

请记住,
wsreqHolder.get()
返回一个
承诺

好吧,我在play 2.2.1中使用它的方式基本相同

@Test
public void testServerOK() {
  running(testServer(3333), new Runnable() {
      public void run() {
         //Context.current.set(ctx);
         WSRequestHolder wsreqHolder = WS.url("http://localhost:3333");
         F.Promise<WS.Response> promiseOfResult = wsreqHolder.get();
         assertThat(
           promiseOfResult.get().getStatus()
         ).isEqualTo(OK);
      }
   });
}
@测试
public void testServerOK(){
正在运行(testServer(3333),新的Runnable(){
公开募捐{
//Context.current.set(ctx);
WSRequestHolder wsreqHolder=WS.url(“http://localhost:3333");
F.promiseOfResult=wsreqHolder.get();
断言(
promiseOfResult.get().getStatus()
).isEqualTo(OK);
}
});
}
请记住,
wsreqHolder.get()
返回一个
Promise

顺便说一句,
F.Promise.get()已弃用。使用
.get(long,TimeUnit)
.get(long)
代替.BTW,
F.Promise.get()已弃用。改用
.get(long,TimeUnit)
.get(long)