Reputation: 1
I have a maven/Java 8 project using JUnit4. The code under test creates and manipulates a Cache using the Java thin client. In order to run my unit tests from the command line (mvn test) or from an IDE like Eclipse, I'd like to be able to programatically start an Ignite server.
If I start the server like:
Runnable runnable = () -> {
Ignite ignite = Ignition.getOrStart(cfg);
};
Thread t = new Thread(runnable);
t.start();
in a @BeforeClass (using Runnable to avoid blocking on getOrStart()), the server dies gracefully after a few Seconds.
[15:34:16] Ignite node started OK (id=33cb95c5)
[15:34:22] Ignite node stopped OK [uptime=00:00:05.378]
Sadly too soon for my unit tests to run. So is there a best practice for unit testing application code with the ad hoc start of Ignite? Seems to be not an uncommon question but I've yet to find a good answer ("use this framework", "extend this class" etc).
Thanks!
Upvotes: 0
Views: 2413
Reputation: 19313
Why not just use
// Non-blocking
Ignite ignite = Ignition.getOrStart(cfg);
... go on with your test cases?
You can stop it with Ignition.stopAll()
later.
Upvotes: 1