Created
August 19, 2013 22:28
-
-
Save ncolomer/6274959 to your computer and use it in GitHub Desktop.
MapDB - This test fail (MapDB throws an ArrayStoreException)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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