Permalink
Browse files

#19 fixed empty graph test

  • Loading branch information...
1 parent 661552f commit 576b740fe63c85c48215991c6de7758352aebe0b @jexp jexp committed Sep 18, 2012
@@ -0,0 +1,43 @@
+/**
+ * Copyright (c) 2002-2012 "Neo Technology,"
+ * Network Engine for Objects in Lund AB [http://neotechnology.com]
+ *
+ * This file is part of Neo4j.
+ *
+ * Neo4j is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.neo4j.rest.graphdb;
+
+import org.junit.After;
+import org.junit.Test;
+import org.neo4j.graphdb.NotFoundException;
+import org.neo4j.graphdb.Transaction;
+
+public class EmptyGraphTest extends RestTestBase {
+
+ @Test(expected = NotFoundException.class)
+ public void testGetReferenceNodeOnEmptyDbFails() {
+ Transaction tx = getGraphDatabase().beginTx();
+ getGraphDatabase().getReferenceNode().delete();
+ tx.success();tx.finish();
+ getRestGraphDb().getReferenceNode();
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ super.tearDown();
+ initServer();
+ }
+}
@@ -80,14 +80,6 @@ public void testHasSingleRelationshipShouldReturnFalseIfThereIsNone() throws Exc
assertEquals(false,getRestGraphDb().getReferenceNode().hasRelationship(DynamicRelationshipType.withName("foo"),Direction.OUTGOING));
}
- @Test(expected = NotFoundException.class)
- public void testGetReferenceNodeOnEmptyDbFails() {
- Transaction tx = getGraphDatabase().beginTx();
- getGraphDatabase().getReferenceNode().delete();
- tx.success();tx.finish();
- getRestGraphDb().getReferenceNode();
- }
-
@Test
public void testCreateRelationshipWithParams() {
Node refNode = getRestGraphDb().getReferenceNode();
@@ -41,12 +41,23 @@
private GraphDatabaseService restGraphDb;
private static final String HOSTNAME = "localhost";
private static final int PORT = 7473;
- private static LocalTestServer neoServer = new LocalTestServer(HOSTNAME,PORT).withPropertiesFile("neo4j-server.properties");
+ private static LocalTestServer neoServer;
public static final String SERVER_ROOT = "http://" + HOSTNAME + ":" + PORT;
protected static final String SERVER_ROOT_URI = SERVER_ROOT + "/db/data/";
private static final String SERVER_CLEANDB_URI = SERVER_ROOT + "/cleandb/secret-key";
private static final String CONFIG = RestTestBase.class.getResource("/neo4j-server.properties").getFile();
+ static {
+ initServer();
+ }
+
+ protected static void initServer() {
+ if (neoServer!=null) {
+ neoServer.stop();
+ }
+ neoServer = new LocalTestServer(HOSTNAME,PORT).withPropertiesFile("neo4j-server.properties");
+ }
+
@BeforeClass
public static void startDb() throws Exception {
neoServer.start();

0 comments on commit 576b740

Please sign in to comment.