Going through Spring Test Data Geode but @EnableGemFireMockObjects annotation is not found

雨燕双飞 提交于 2020-01-16 08:39:50

问题


I spent a long time trying to run the example tests from here and here.

The @EnableGemFireMockObjects annotation cannot be found and neither can

import org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects;

The example tests don't run. Presumably this is missing a Gradle dependency but I can't find a Gradle example in the documentation.


回答1:


Per Javalibs I needed to add

implementation 'org.springframework.data:spring-data-geode-test:0.0.11.RELEASE'

to gradle.build dependencies group.




回答2:


The Spring Test for Apache Geode project (STDG) should build just fine, by running (from the project root directory)...

$ gradlew clean build install

STDG can also be built with Maven, hence the inclusion of a pom.xml file, by running...

$ mvn clean install

NOTE: If you build with Maven first and then later switch to building with Gradle, make sure to remove the target/ directly before building with Gradle.

Additionally, if you setup your IDE (e.g. IJ or STS) with the STDG project, importing from either the Maven or Gradle project models, after building (compiling) the STDG project, you should be able to run the Unit or Integration Tests individually from your IDE as well.

The Maven or Gradle files will ensure that your (test-time) classpath(s) are correct.

As for using STDG outside of the STDG project itself (the tests in STDG are not there for example, but there to test the functionality of STDG itself), see:

  • Spring Boot for Apache Geode (SBDG): https://github.com/spring-projects/spring-boot-data-geode. Specifically see the auto-configuration module test suite where STDG is used quite extensively.

  • Spring Session for Apache Geode (SSDG) also extensively uses the STDG project now to test Spring Session functionality with Apache Geode or Pivotal GemFire as the provider: https://github.com/spring-projects/spring-session-data-geode.

Eventually, I will be retrofitting the SDG test suite to use STDG as well, replacing the old test framework inside SDG on which STDG was founded.

Finally...

I did a presentation on the STDG project at the SpringOne Platform 2017 conference, the code of which is here:

https://github.com/jxblum/simplifying-apache-geode-with-spring-data

Here is 1 such test class from that example project:

https://github.com/jxblum/simplifying-apache-geode-with-spring-data/blob/master/simplifying-apachegeode-testing-springdata-complete/src/test/java/example/app/tests/SpringApacheGeodeConfigurationUnitTests.java

I have not updated the project in quite awhile, but is still mostly applicable. Use SBDG and SSDG test suites as definitive examples for using STDG.

Hope this helps.



来源:https://stackoverflow.com/questions/59651376/going-through-spring-test-data-geode-but-enablegemfiremockobjects-annotation-is

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!