Skip to content

Instantly share code, notes, and snippets.

@ncolomer
Created August 19, 2013 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ncolomer/6274959 to your computer and use it in GitHub Desktop.
Save ncolomer/6274959 to your computer and use it in GitHub Desktop.
MapDB - This test fail (MapDB throws an ArrayStoreException)
package me.nco.test;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.mapdb.MapDBGraph;
import org.junit.Before;
import org.junit.Test;
import org.mapdb.DBMaker;
import java.io.File;
import java.util.UUID;
import static org.junit.Assert.assertFalse;
public class DummyTest {
private Graph graph;
@Before
public void setUp() {
File dbFile = new File("./dummy.db");
DBMaker dbMaker = DBMaker.newFileDB(dbFile)
.asyncWriteDisable()
.transactionDisable()
.compressionEnable() // This causes troubles
.deleteFilesAfterClose()
.closeOnJvmShutdown();
graph = new MapDBGraph(dbMaker, true);
}
@Test
public void testArrayStoreException() {
// Action
boolean exceptionThrown = false;
try {
long i = 0;
Vertex tail, head;
while (i < 10E5) {
tail = addOrGetVertex(i);
head = addOrGetVertex(i++);
Edge edge = graph.addEdge(UUID.randomUUID().toString(), tail, head, "precedes");
edge.setProperty("myId", new Long(i));
}
} catch (ArrayStoreException e) {
e.printStackTrace();
exceptionThrown = true;
}
// Assert
assertFalse("ArrayStoreException was thrown", exceptionThrown);
}
public Vertex addOrGetVertex(Object id) {
Vertex v = graph.getVertex(id);
if (v != null) return v;
v = graph.addVertex(id);
v.setProperty("myId", id);
return v;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment