MongoDB单元测试(MongoDB unit tests)
我有一个基于Spring的webapp,我正在使用Fongo进行一些Junit测试。 这样做到目前为止,但现在我想在执行它们之前将我的数据库设置为具体的上下文(例如,事先将.json文件加载到具体集合中)并且事实证明使用Fongo是不可能的。 你通常用什么? 它真的可能吗? 还有其他可能的选择吗? 我也听说过EmbedMongo,但我不确定它是否适用于Spring Data存储库,这是我在持久层中使用的。
提前致谢!
I have a Spring-based webapp and I am using Fongo for some of my Junit tests. This did the trick so far but now I would like to set my database into a concrete context before executing them (by loading, for instance, a .json file beforehand into a concrete collection) and it turns out not to be possible using Fongo. What do you use normally? Is it actually possible? Are there out other possible options? I also heard of EmbedMongo but I am not sure this works with Spring Data repositories, which is what I am using in the persistence layer.
Thanks in advance!
原文:https://stackoverflow.com/questions/17337968
最满意答案
在查看了一些其他相关问题并浏览Eclipse的设置(与GAE相关的设置)后,我得出的结论是,可能没有简单的方法直接指定类路径。
我能够想出的最简单和最优雅的方法是禁用自动Datanucleus增强,并引入Ant任务来完成此任务。
对Scan类添加到DataNucleus增强器CLASSPATH的问题的批准答案结果特别有帮助。
我写了一个Ant构建文件几乎与链接问题中提供的文件相同,它解决了我的问题。
After reviewing some other related questions and browsing through Eclipse's settings (the GAE-related ones) I've come to the conclusion that there probably is no easy way to specify classpath directly.
The simplest and most elegant way I was able to come up with was to disable automatic Datanucleus enhancement, and introduce an Ant task to do this.
The approved answer to the question Add scala class to DataNucleus enhancer CLASSPATH turned out to be particularly helpful.
I wrote an Ant build file nearly identical to the one presented in the linked question and it solved my problem.
相关问答
更多-
我没有使用Maven所以我需要手动将所有需要的jar包含到WEB-INF / lib中。 即使我复制了google-api-services-storage-v1-rev104-java-1.22.0.zip包中的所有库,我忘了包含主库(不在该包中的libs目录下)。 简而言之,将google-api-services-storage-v1-rev104-1.22.0.jar放入Eclipse中的WEB-INF / lib目录就完成了这项工作。 非常感谢。 I'm not using Maven so I ...
-
我搜索并没有发现从Gradle运行DataNucleus Enhancer的插件。 但是通过使用DataNucleus Enhancer Ant任务可以实现这一点。 我在build.gradle添加了以下build.gradle 。 task datanucleusEnhance { description "Enhance JPA model classes using DataNucleus Enhancer" dependsOn compileJava doLast { ...
-
DataNucleus增强失败 - Android Studio中的GAE(DataNucleus enhancing failed - GAE in Android Studio)[2022-10-29]
好的,事实证明这是与最新版本的App Engine Java SDK相关的问题 。 降级线 appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.42' 以下 appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.38' 解决了所有错误,增强工作正常。 Alright, turns out this is an issue related to the latest version ... -
我从spring依赖项中排除了log4j,我不再收到错误。 在我的常春藤文件中:
-
DataNucleus Maven增强器插件错误 - 找不到类(DataNucleus Maven enhancer plugin error - class not found)[2023-10-25]
问题是@AssociationOverride注释带有错误的@JoinColumn名称。 我想错误信息应该更清楚。 The problem was an @AssociationOverride annotation with a wrong @JoinColumn name. I guess the error message should have been more clearer. -
建议你整理出使用的罐子的版本。 此页面说明了谷歌“datanucleus-appengine”与DataNucleus项目罐的兼容性 Suggest you sort out the versions of jars being used. This page states the compatibility of Googles "datanucleus-appengine" with DataNucleus project jars
-
appengine数据核增强器问题与类没有得到增强(appengine data nucleus enhancer issue with classes not getting enhanced)[2022-03-29]
有时在更改应用程序引擎sdk时,jars并没有完全从以前的版本中删除,因此请检查您的webapps / lib是否具有相同的多个版本的jar,然后从webapps / lib中删除所有jar,然后更改appengine版本。 清理并刷新项目,确保lib只有默认jar Sometimes while changing app engine sdk, jars are not completely removed from previous version, so check if your webapps/l ... -
datanucleus enhancer&javaw:“参数不正确”(datanucleus enhancer & javaw: “the parameter is incorrect”)[2021-12-06]
啊哈! 在项目属性> Google> App Engine> ORM下,我发现我的所有类都得到了增强,导致命令行太长 - 显然与类路径无关。 我只是将该属性页面配置为仅增强我的类的子集(仅5%需要增强),现在,它不仅可以再次工作,而且构建过程更快! Aha! Under Project properties > Google > App Engine > ORM I found that all of my classes were being enhanced, which was leading to ... -
在查看了一些其他相关问题并浏览Eclipse的设置(与GAE相关的设置)后,我得出的结论是,可能没有简单的方法直接指定类路径。 我能够想出的最简单和最优雅的方法是禁用自动Datanucleus增强,并引入Ant任务来完成此任务。 对Scan类添加到DataNucleus增强器CLASSPATH的问题的批准答案结果特别有帮助。 我写了一个Ant构建文件几乎与链接问题中提供的文件相同,它解决了我的问题。 After reviewing some other related questions and brows ...
-
使用JDO的Maven GAE插件(Maven GAE Plugin using JDO)[2023-07-09]
我的映射包括错误。 现在,如果实体位于具有姓氏实体的包中(例如com.my.app.entity),则它可以正常工作:**/entity/*.class I had something wrong with my mappings includes. Now it works if entities are in package that has last name entity (example com.my.app.entity) ...