简体   繁体   English

您如何自定义配置RESTeasy以与Mockito一起使用?

[英]How do you custom configure RESTeasy for use with Mockito?

I'm trying to figure out how to configure RESTeasy for use with Mockito. 我试图弄清楚如何配置RESTeasy与Mockito一起使用。 I had to create custom Serializers and Deserializers. 我必须创建自定义的序列化器和反序列化器。 I found this article that talked about creating custom serializers and deserializers and turning them into a module. 我发现这篇文章讨论了如何创建自定义序列化器和反序列化器并将它们转换为模块。

I also found this article and this article about configuring Jackson to use the new custom module that I wrote. 我也发现这个文章, 文章有关配置杰克逊使用,我写了新的自定义模块。

The problem that I'm having is that I don't know how to test it. 我遇到的问题是我不知道如何测试。 One of the articles says 其中一篇文章说

The answer is to have Jackson(Jaxb)JsonProvider in the resteasy.providers section of resteasy-jaxrs.war/WEB-INF/web.xml 答案是在resteasy-jaxrs.war / WEB-INF / web.xml的resteasy.providers部分中具有Jackson(Jaxb)JsonProvider

I'm using Mockito to test everything. 我正在使用Mockito测试所有内容。 As far as I know, there isn't a resteasy-jaxrs.war file that is made. 据我所知,没有创建一个resteasy-jaxrs.war文件。 Is there anyway that I can fake this? 无论如何,我可以伪造吗?

I should probably also add that I'm using spring and I have an applicationContext.xml file that I use just for creating fake beans etc. for testing. 我可能还应该补充一点,我正在使用spring,并且有一个applicationContext.xml文件,该文件仅用于创建假豆等进行测试。

If you want unit tests REST application go with REST-assured. 如果要单元测试REST应用程序,请使用REST保证。 It is very simple and powerful library - you don't need to mock everything. 这是一个非常简单且功能强大的库-您无需模拟所有内容。 For other options see Ways to test RESTful services? 有关其他选项,请参见测试RESTful服务的方法? .

Remember that even if you manage to mock everything, such test might be hardly useful - you'll test your mocks, not a true application. 请记住,即使您设法模拟所有内容,这种测试也可能几乎没有用-您将测试模拟,而不是真正的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何配置wildfly在重新安装时使用https和ClientBuilder? - How to configure wildfly to use https with ClientBuilder in resteasy? 如何配置Spring-Boot应用程序继续使用RestEasy? - How configure Spring-Boot app to continue to use RestEasy? 您如何配置JBOSS在Web应用程序中使用xml库? - How do you configure JBOSS to use the xml lib in the web app? 如何在Horizo​​ntalScrollView中使用自定义视图? - How do you use a custom view in a HorizontalScrollView? 如何使用独立的 Jetty 服务器配置 Resteasy? - How to Configure Resteasy With A Standalone Jetty Server? 如何配置和运行Mockito测试 - How to configure and run a Mockito test 您如何使用 Mockito 从扩展 class 测试方法? - How do you test method from extended class using Mockito? 在 Spring Boot 你如何配置一些监听器使用自动确认和其他使用手动确认 - In Spring Boot How do you configure some listeners to use automatic Acknowledgment and others to use manual acknowledgment 将RestEasy与Windows Live Service结合使用时,如何解组返回的联系人列表? - Using RestEasy with Windows Live Service, how do you unmarshall the list of Contacts returned? JaxRS + RestEasy - 如何创建自己的 @Context 注入字段? - JaxRS + RestEasy - How do you create your own @Context injected field?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM