0

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.

John Blum
  • 7,381
  • 1
  • 20
  • 30
rupweb
  • 3,052
  • 1
  • 30
  • 57
  • Can you elaborate on "tests don't run"? When I check out the project I'm able to do both `./{mvnw,gradlew} test` – Jens D Jan 08 '20 at 21:46
  • @Jens D thanks for comment I was copying and pasting various test class into my own `src/test/java` unit & integration tests – rupweb Jan 09 '20 at 10:43

2 Answers2

1

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:

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.

John Blum
  • 7,381
  • 1
  • 20
  • 30
0

Per Javalibs I needed to add

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

to gradle.build dependencies group.

rupweb
  • 3,052
  • 1
  • 30
  • 57