测试Neo4j托管扩展 [英] Testing Neo4j managed extensions

查看:65
本文介绍了测试Neo4j托管扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已按照 http://上的指南为Neo4j编写了服务器扩展. neo4j.com/docs/stable/server-plugins.html .我为一些内部方法编写了单元测试,但是如果可能的话,我也想测试REST接口.

I've written a server extension for Neo4j, following the guidelines at http://neo4j.com/docs/stable/server-plugins.html . I wrote unit tests for some of the internal methods, but I would also like to test the REST interface if possible.

http://neo4j.com/docs/stable/_testing_your_extension.html 似乎仅显示如何测试非托管扩展,但我正在寻找与托管扩展非常相似的内容.有指针吗?

http://neo4j.com/docs/stable/_testing_your_extension.html seems to only show how to test unmanaged extensions, but I'm looking for something closely analogous to that for managed extensions. Any pointers?

我确实知道如何将扩展加载到服务器中并使用curl进行查询(如下所示),但是当出现问题时,这并不是一个有趣的调试周期.

I do know how to load the extension into a server and query it with curl (as follows), but when things go wrong it's not a fun debug cycle.

curl -X POST -v http://localhost:7474/db/data/ext/NeoPlugin/graphdb/myExt \
  -H "Content-Type: application/json" \
  -d '{"argFoo": "ACTED_IN", "argBar": ["0", "10"]}'

更新: 我要坚持的主要(或者只是第一步?)是旋转一个包含我的托管扩展的轻量级测试REST服务器.我认为一旦有了服务器,我就可以使用各种策略对其进行查询并检查结果.

UPDATE: The main (or just first?) part I'm getting stuck at is spinning up a lightweight test REST server that contains my managed extension. I think once there's a server, I can query it using various strategies and check the results.

推荐答案

如果我错了,请纠正我,但这听起来像是关于测试RESTful API的更普遍的问题.

Correct me if I'm wrong but this sounds like a more general question about testing RESTful APIs.

自从标记了junit之后,您可能需要考虑类似 restfuse 这样的RESTful JUnit的API测试扩展.如果您已经在使用neo4j提供的工具来测试非托管扩展,那么这可能是最合适的选择.

Since you've tagged junit, you might want to consider something like restfuse which is a RESTful API testing extension for JUnit. If you're already testing your unmanaged extension using the harnesses provided by neo4j, this might be the best fit.

RESTful测试可能看起来像这样:

RESTful tests might look something like this:

@RunWith( HttpJUnitRunner.class )
public class RestfuseTest {
  @Rule
  public Destination destination = new Destination( "http://localhost:7474/db/data/ext/NeoPlugin/graphdb/myExt" ); 

  @Context
  private Response response; // will be injected after every request

  @HttpTest( method = Method.GET, path = "/" )
  public void checkRestfuseOnlineStatus() {
    assertOk( response );
  }  
}

要进行更多的零售"测试而不是批发"程序化测试,我倾向于在Chrome上使用Postman扩展程序,该扩展程序使得制作请求和检查结果确实非常容易(想想一个更容易卷曲的界面,现在使用).

For more "retail" testing instead of "wholesale" programmatic testing, I would tend to use the Postman extension on Chrome, which makes crafting requests and inspecting the results really easy (think an easier interface to curl, which you're using now).

最后,FWIW提供了数不胜数的选择来测试RESTful API的其他方法.选择您喜欢的技术或堆栈,无论是使用JavaScript的frisby 还是 vREST .

Finally FWIW there's a gajillion options for other approaches to testing RESTful APIs. Pick your favorite tech or stack, whether frisby on javascript or vREST.

这篇关于测试Neo4j托管扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆