Permalink
Browse files

Merge branch 'master' of github.com:neo4j/neo4j-geoff

  • Loading branch information...
2 parents 5b9b35b + d5480f0 commit 813db17f56ee24b01c6b5d258160c2f74c9b38b0 @nigelsmall nigelsmall committed Jan 13, 2012
@@ -19,6 +19,7 @@
*/
package org.neo4j.geoff.test;
+import org.junit.Before;
import org.junit.Test;
import org.neo4j.geoff.Geoff;
import org.neo4j.geoff.Rule;
@@ -33,8 +34,13 @@
import static org.junit.Assert.*;
import static org.neo4j.geoff.test.TestDatabase.*;
-public class CreateOrUpdateNodeTest {
+public class CreateOrUpdateNodeTest extends TestBase{
+ @Before
+ public void setUp(){
+ db = new TestDatabase();
+
+ }
@Test
public void canParseCreateOrUpdateNodeRule() throws Exception {
String source = "(A) {\"name\": \"Alice\"}";
@@ -52,7 +58,6 @@ public void canParseCreateOrUpdateNodeRule() throws Exception {
@Test
public void canCreateNode() throws Exception {
- TestDatabase db = new TestDatabase();
TestGeoffBuilder geoff = new TestGeoffBuilder();
geoff.appendAlice();
Map<String, PropertyContainer> out = Geoff.loadIntoNeo4j(geoff.getReader(), db, null);
@@ -63,7 +68,6 @@ public void canCreateNode() throws Exception {
@Test
public void canUpdateNodeProperties() throws Exception {
- TestDatabase db = new TestDatabase();
TestGeoffBuilder geoff = new TestGeoffBuilder();
geoff.append("(A) {\"foo\": \"bar\"}");
geoff.appendAlice();
@@ -77,7 +81,6 @@ public void canUpdateNodeProperties() throws Exception {
@Test
public void canUpdateNodeToEraseProperties() throws Exception {
- TestDatabase db = new TestDatabase();
TestGeoffBuilder geoff = new TestGeoffBuilder();
geoff.appendAlice();
geoff.append("(A) {}");
@@ -96,7 +99,6 @@ public void canUpdateNodeToEraseProperties() throws Exception {
@Test
public void canUpdateNodeWithoutErasingProperties() throws Exception {
- TestDatabase db = new TestDatabase();
TestGeoffBuilder geoff = new TestGeoffBuilder();
geoff.appendAlice();
geoff.append("(A)");
@@ -108,7 +110,6 @@ public void canUpdateNodeWithoutErasingProperties() throws Exception {
@Test
public void canCreateMultipleNodes() throws Exception {
- TestDatabase db = new TestDatabase();
TestGeoffBuilder geoff = new TestGeoffBuilder();
geoff.appendAlice();
geoff.appendBob();
@@ -123,7 +124,6 @@ public void canCreateMultipleNodes() throws Exception {
@Test
public void canCreateMultipleAnonymousNodes() throws Exception {
- TestDatabase db = new TestDatabase();
TestGeoffBuilder geoff = new TestGeoffBuilder();
geoff.append("() {\"name\": \"Alice Allison\"}");
geoff.append("() {\"name\": \"Bob Robertson\"}");
@@ -19,31 +19,29 @@
*/
package org.neo4j.geoff.test;
-import org.junit.Before;
+import static junit.framework.Assert.assertFalse;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
import org.junit.Test;
import org.neo4j.geoff.Geoff;
import org.neo4j.geoff.Rule;
import org.neo4j.geoff.tokens.NodeToken;
import org.neo4j.geoff.tokens.RelationshipToken;
import org.neo4j.geoff.tokens.Token;
-import org.neo4j.graphdb.*;
-import org.neo4j.test.ImpermanentGraphDatabase;
+import org.neo4j.graphdb.Direction;
+import org.neo4j.graphdb.DynamicRelationshipType;
+import org.neo4j.graphdb.Node;
+import org.neo4j.graphdb.PropertyContainer;
+import org.neo4j.graphdb.Relationship;
-import java.io.StringReader;
-import java.util.HashMap;
-import java.util.Map;
-
-import static junit.framework.Assert.assertFalse;
-import static org.junit.Assert.*;
-
-public class DeleteRelationshipsTest {
-
- private ImpermanentGraphDatabase db;
-
- @Before
- public void setUp() throws Exception {
- db = new ImpermanentGraphDatabase();
- }
+public class DeleteRelationshipsTest extends TestBase{
@Test
public void testRelationshipExclusionByNameRule() throws Exception {
@@ -19,7 +19,15 @@
*/
package org.neo4j.geoff.test;
-import org.junit.Before;
+import static junit.framework.Assert.assertFalse;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
import org.junit.Test;
import org.neo4j.geoff.Geoff;
import org.neo4j.geoff.Rule;
@@ -31,24 +39,9 @@
import org.neo4j.graphdb.PropertyContainer;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.index.Index;
-import org.neo4j.test.ImpermanentGraphDatabase;
-
-import java.io.StringReader;
-import java.util.HashMap;
-import java.util.Map;
-
-import static junit.framework.Assert.assertFalse;
-import static org.junit.Assert.*;
-
-public class ExcludeIndexEntryTest {
-
- private ImpermanentGraphDatabase db;
-
- @Before
- public void setUp() throws Exception {
- db = new ImpermanentGraphDatabase();
- }
+public class ExcludeIndexEntryTest extends TestBase{
+
@Test
public void testNodeIndexExclusionRule() throws Exception {
String source = "(A)!=|People| {\"name\": \"Alice\"}";
@@ -37,7 +37,7 @@
import static org.junit.Assert.assertTrue;
import static org.neo4j.geoff.test.TestDatabase.assertNodesExist;
-public class IncludeNodeIndexEntryTest {
+public class IncludeNodeIndexEntryTest extends TestBase{
@Test
public void canParseIncludeNodeIndexEntryRule() throws Exception {
@@ -61,7 +61,6 @@ public void canParseIncludeNodeIndexEntryRule() throws Exception {
@Test
public void willCreateNodeAndAddIndexEntryWhenNeitherExist() throws Exception {
- TestDatabase db = new TestDatabase();
TestGeoffBuilder geoff = new TestGeoffBuilder();
geoff.append("(A)<=|People| {\"name\": \"Allison, Alice\"}");
Map<String, PropertyContainer> out = Geoff.loadIntoNeo4j(geoff.getReader(), db, null);
@@ -77,7 +76,6 @@ public void willCreateNodeAndAddIndexEntryWhenNeitherExist() throws Exception {
@Test
public void willAddIndexEntryWhenOnlyNodeExists() throws Exception {
- TestDatabase db = new TestDatabase();
TestGeoffBuilder geoff = new TestGeoffBuilder();
geoff.appendAlice();
geoff.append("(A)<=|People| {\"name\": \"Allison, Alice\"}");
@@ -94,7 +92,6 @@ public void willAddIndexEntryWhenOnlyNodeExists() throws Exception {
@Test
public void willReflectNodeWhenOnlyEntryExists() throws Exception {
- TestDatabase db = new TestDatabase();
Node alice = db.createAlice();
Transaction tx = db.beginTx();
db.index().forNodes("People").add(alice, "name", "Allison, Alice");
@@ -115,7 +112,6 @@ public void willReflectNodeWhenOnlyEntryExists() throws Exception {
@Test
public void willDoNothingWhenBothExist() throws Exception {
- TestDatabase db = new TestDatabase();
Node alice = db.createAlice();
Map<String, PropertyContainer> params = new HashMap<String, PropertyContainer>();
params.put("(A)", alice);
@@ -19,7 +19,15 @@
*/
package org.neo4j.geoff.test;
-import org.junit.Before;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
import org.junit.Test;
import org.neo4j.geoff.Geoff;
import org.neo4j.geoff.Rule;
@@ -31,26 +39,10 @@
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.index.Index;
import org.neo4j.graphdb.index.IndexHits;
-import org.neo4j.test.ImpermanentGraphDatabase;
-import java.io.StringReader;
-import java.util.HashMap;
-import java.util.Map;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-public class IncludeRelationshipIndexEntryTest {
-
- private ImpermanentGraphDatabase db;
-
- @Before
- public void setUp() throws Exception {
- db = new ImpermanentGraphDatabase();
- }
+public class IncludeRelationshipIndexEntryTest extends TestBase{
+
@Test
public void testRelationshipIndexInclusionRule() throws Exception {
String source = "[R]<=|People| {\"name\": \"Alice\"}";
@@ -74,7 +66,6 @@ public void testRelationshipIndexInclusionRule() throws Exception {
@Test
public void testLoadingNodeIndexInclusionRuleWhereNodeExistsButIndexEntryDoesnt() throws Exception {
- db = new ImpermanentGraphDatabase();
// load node and add index entry
String source =
"(A) {\"given-names\": \"Alice\", \"family-name\": \"Allison\"}\n" +
@@ -94,7 +85,6 @@ public void testLoadingNodeIndexInclusionRuleWhereNodeExistsButIndexEntryDoesnt(
@Test
public void testLoadingRelationshipIndexInclusionRule() throws Exception {
- db = new ImpermanentGraphDatabase();
// load relationship and add index entry
String source =
"(A) {\"name\": \"Alice\"}\n" +
@@ -112,7 +102,6 @@ public void testLoadingRelationshipIndexInclusionRule() throws Exception {
@Test
public void testLoadingNodeIndexInclusionRuleWithLoadParameter() throws Exception {
- db = new ImpermanentGraphDatabase();
// perform first call to inject node
String source = "(A) {\"name\": \"Alice\"}";
Map<String, PropertyContainer> out = Geoff.loadIntoNeo4j(new StringReader(source), db, null);
@@ -134,7 +123,6 @@ public void testLoadingNodeIndexInclusionRuleWithLoadParameter() throws Exceptio
@Test
public void testLoadingRelationshipIndexInclusionRuleWithLoadParameter() throws Exception {
- db = new ImpermanentGraphDatabase();
// perform first call to inject relationship
String source =
"(A) {\"name\": \"Alice\"}\n" +
@@ -19,25 +19,33 @@
*/
package org.neo4j.geoff.test;
-import org.junit.Before;
-import org.junit.Test;
-import org.neo4j.geoff.Geoff;
-import org.neo4j.geoff.Rule;
-import org.neo4j.graphdb.*;
-import org.neo4j.test.ImpermanentGraphDatabase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.neo4j.geoff.test.TestDatabase.assertAlice;
+import static org.neo4j.geoff.test.TestDatabase.assertBob;
+import static org.neo4j.geoff.test.TestDatabase.assertNodesExist;
+import static org.neo4j.geoff.test.TestDatabase.assertRelationshipsExist;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.*;
-import static org.neo4j.geoff.test.TestDatabase.*;
+import org.junit.Test;
+import org.neo4j.geoff.Geoff;
+import org.neo4j.geoff.Rule;
+import org.neo4j.graphdb.Direction;
+import org.neo4j.graphdb.DynamicRelationshipType;
+import org.neo4j.graphdb.Node;
+import org.neo4j.graphdb.PropertyContainer;
+import org.neo4j.graphdb.Relationship;
+import org.neo4j.graphdb.Transaction;
-public class MiscellaneousTest {
+public class MiscellaneousTest extends TestBase{
- private ImpermanentGraphDatabase db;
@Test
public void canCreateGraphFromSingleString() throws Exception {
@@ -171,11 +179,6 @@ public void canLoadRulesCreatedFromValues() throws Exception {
assertTrue(db.index().forNodes("People").get("name", "The Doctor").hasNext());
assertEquals("doctor", db.index().forNodes("People").get("name", "The Doctor").getSingle().getProperty("name"));
}
-
- @Before
- public void setUp() throws Exception {
- db = new ImpermanentGraphDatabase();
- }
@Test
public void canCreateNodesBeforeRelationship() throws Exception {
@@ -19,28 +19,26 @@
*/
package org.neo4j.geoff.test;
-import org.junit.Before;
-import org.junit.Test;
-import org.neo4j.geoff.Geoff;
-import org.neo4j.geoff.except.GeoffLoadException;
-import org.neo4j.graphdb.*;
-import org.neo4j.test.ImpermanentGraphDatabase;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Map;
-import static junit.framework.Assert.*;
-
-public class OverlappingFileTest {
+import org.junit.Test;
+import org.neo4j.geoff.Geoff;
+import org.neo4j.geoff.except.GeoffLoadException;
+import org.neo4j.graphdb.Direction;
+import org.neo4j.graphdb.DynamicRelationshipType;
+import org.neo4j.graphdb.Node;
+import org.neo4j.graphdb.PropertyContainer;
+import org.neo4j.graphdb.Relationship;
- private ImpermanentGraphDatabase db;
+public class OverlappingFileTest extends TestBase {
- @Before
- public void setUp() throws Exception {
- db = new ImpermanentGraphDatabase();
- }
private static Reader readerForResource(String name) {
return new InputStreamReader(ClassLoader.getSystemResourceAsStream(name));
@@ -52,7 +50,6 @@ private static Reader readerForResource(String name) {
*/
@Test
public void canLoadOverlappingFiles() throws GeoffLoadException, IOException {
- db = new ImpermanentGraphDatabase();
Geoff.loadIntoNeo4j(readerForResource("music/David Bowie - Space Oddity.geoff"), db, null);
Geoff.loadIntoNeo4j(readerForResource("music/David Bowie - Space Oddity v2.geoff"), db, null);
Geoff.loadIntoNeo4j(readerForResource("music/David Bowie - Life On Mars.geoff"), db, null);
@@ -79,7 +76,6 @@ public void canLoadOverlappingFiles() throws GeoffLoadException, IOException {
@Test
public void canLoadFilesMultipleTimes() throws GeoffLoadException, IOException {
- db = new ImpermanentGraphDatabase();
Geoff.loadIntoNeo4j(readerForResource("music/David Bowie - Space Oddity.geoff"), db, null);
Geoff.loadIntoNeo4j(readerForResource("music/David Bowie - Space Oddity.geoff"), db, null);
Geoff.loadIntoNeo4j(readerForResource("music/David Bowie - Space Oddity v2.geoff"), db, null);
Oops, something went wrong.

0 comments on commit 813db17

Please sign in to comment.