This project is no longer publicly maintained. It will receive no more updates and will eventually be removed.
The GS-Test library contains utilities designed to simplify testing of applications implemented using GigaSpaces.
The PuConfigurers
/StandalonePuConfigurers
classes contains factory methods for builders for different types of processing units (partitioned pu, mirror pu).
Those can be used to create an embedded processing unit (RunningPu
).
The RunningPu
is available as a @TestRule
for JUnit4 and as an Extension
for JUnit5.
class FruitTest {
@Rule
public RunningPu fruitPu = PuConfigurers.partitionedPu("classpath:/fruit-pu.xml")
.configure();
// Test cases against fruitPu
}
class FruitTest {
@RegisterExtension
public RunningPu fruitPu = PuConfigurers.partitionedPu("classpath:/fruit-pu.xml")
.configure();
// Test cases against fruitPu
}
class FruitTest {
StandaloneRunningPu fruitPu = StandalonePuConfigurers.partitionedPu("classpath:/fruit-pu.xml")
.configure();
@Before
public void startFruitPu() {
fruitPu.start();
}
@After
public void stopFruitPu() {
fruitPu.stop();
}
// Test cases against fruitPu
}
In case you only need access to gigaspace, you can use the EmbeddedSpace
as a @Rule in Junit 4 or as an @ExtendWith for Junit 5:
public class EmbeddedSpaceAsRuleTest {
@Rule
public final EmbeddedSpace embeddedSpace = new EmbeddedSpace("space-name");
@Test
public void testPersistingAndReading() {
GigaSpace gigaSpace = embeddedSpace.getGigaSpace();
gigaSpace.write(new FruitPojo("orange"));
FruitPojo fruit = gigaSpace.readById(FruitPojo.class, "orange");
assertNotNull(fruit);
}
}
@ExtendWith(EmbeddedSpace.class)
class GigaspaceExtensionTest {
@Test
void testPersistingAndReading(GigaSpace gigaSpace) {
gigaSpace.write(new FruitPojo("orange"));
FruitPojo fruit = gigaSpace.readById(FruitPojo.class, "orange");
assertNotNull(fruit);
}
}
Since version 2.1.0
this library comes bundled with ZooKeeper, and switches to using a ZooKeeper based leader selector for GigaSpaces.
In order to run tests without ZooKeeper, run the tests with system property -Dcom.avanza.gs.test.zookeeper.disable=true
.
In this case, a LUS-based selector will be used.
The core module that contains standalone configuration, without depending on any testing framework.
<dependency>
<groupId>com.avanza.gs</groupId>
<artifactId>gs-test-core</artifactId>
<version>2.1.x</version>
</dependency>
JUnit4 bindings for running as test rules.
<dependency>
<groupId>com.avanza.gs</groupId>
<artifactId>gs-test-junit4</artifactId>
<version>2.1.x</version>
</dependency>
This artifact replaces com.avanza.gs:gs-test
from pre-2.1.0
versions of this library.
JUnit5 extension bindings.
<dependency>
<groupId>com.avanza.gs</groupId>
<artifactId>gs-test-junit5</artifactId>
<version>2.1.x</version>
</dependency>
Branch | Description |
---|---|
v0.1.x | Based on GigaSpaces 10.1.1 and Java 8 |
gs14.5 | Based on GigaSpaces 14.5 and Java 11 |
The GS-Test library is released under version 2.0 of the Apache License.