Permalink
Browse files

first working import of Geoff JSON

  • Loading branch information...
1 parent 1e7c991 commit efa03840729f5b6f337883ab2647a51e7351bdad @peterneubauer peterneubauer committed Dec 19, 2011
View
@@ -10,20 +10,17 @@
<groupId>org.neo4j.server.plugin</groupId>
<artifactId>neo4j-geoff-plugin</artifactId>
<packaging>jar</packaging>
- <version>1.5-SNAPSHOT</version>
+ <version>1.6-SNAPSHOT</version>
<name>neo4j-geoff-plugin</name>
<properties>
<!-- Jar Versions -->
<junit.version>4.8.2</junit.version>
- <spring.version>3.0.4.RELEASE</spring.version>
<jackson.version>1.5.2</jackson.version>
- <cxf.version>2.3.1</cxf.version>
<servlet-api.version>2.5</servlet-api.version>
- <neo4j.version>1.5-SNAPSHOT</neo4j.version>
+ <neo4j.version>1.6-SNAPSHOT</neo4j.version>
<jersey.server.version>1.6</jersey.server.version>
<license-text.header>GPL-3-header.txt</license-text.header>
- <bundle.namespace>org.neo4j.server.plugin.cypher</bundle.namespace>
</properties>
<licenses>
<license>
@@ -19,14 +19,10 @@
*/
package org.neo4j.server.plugin.geoff;
-import java.io.IOException;
import java.util.Map;
import org.neo4j.cypher.SyntaxException;
-import org.neo4j.geoff.BadDescriptorException;
-import org.neo4j.geoff.GEOFFLoader;
-import org.neo4j.geoff.UnknownNodeException;
-import org.neo4j.geoff.UnknownRelationshipException;
+import org.neo4j.geoff.GEOFF;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.server.plugins.Description;
import org.neo4j.server.plugins.Name;
@@ -63,24 +59,9 @@ public Representation executeScript(
{
try
{
- GEOFFLoader.loadIntoNeo4j(geoff, neo4j);
+ GEOFF.loadIntoNeo4j(geoff, neo4j, null);
}
- catch ( BadDescriptorException e )
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- catch ( IOException e )
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- catch ( UnknownNodeException e )
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- catch ( UnknownRelationshipException e )
+ catch ( Exception e )
{
// TODO Auto-generated catch block
e.printStackTrace();
@@ -1 +1 @@
-org.neo4j.server.plugin.geoff.GeoffPlugin
+org.neo4j.server.plugin.geoff.GeoffPlugin
@@ -19,33 +19,40 @@
*/
package org.neo4j.server.plugin.geoff;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.UnsupportedEncodingException;
import javax.ws.rs.core.Response.Status;
import org.junit.Test;
+import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.kernel.impl.annotations.Documented;
import org.neo4j.server.rest.AbstractRestFunctionalTestBase;
public class GeoffPluginFunctionalTest extends AbstractRestFunctionalTestBase
{
private static final String ENDPOINT = "http://localhost:7474/db/data/ext/GeoffPlugin/graphdb/insert";
- /**
- * A simple query returning all nodes connected to node 1, returning the
- * node and the name property, if it exists, otherwise `null`:
- */
@Test
@Documented
- public void sen_a_GEOFF_map() throws UnsupportedEncodingException
+ public void send_a_GEOFF_map() throws UnsupportedEncodingException
{
- String geoff = "{\"(Joe)\":{\"name\":\"Joe\"}}";
+ GraphDatabaseService db = graphdb();
+ String geoff = "{" +
+ "\"(doc)\": {\"name\": \"doctor\"}," +
+ "\"(dal)\": {\"name\": \"dalek\"}," +
+ "\"(doc)-[:ENEMY_OF]->(dal)\": {\"since\":\"forever\"}," +
+ "\"(doc)<=|People|\": {\"name\": \"The Doctor\"}" +
+ "}";
gen.get().expectedStatus( Status.OK.getStatusCode() ).payload(
"{\"geoff\":" + geoff + "}" );
String response = gen.get().post( ENDPOINT ).entity();
assertTrue( response.contains( "OK" ) );
+ assertTrue(db.index().existsForNodes("People"));
+ assertTrue(db.index().forNodes("People").get("name", "The Doctor").hasNext());
+ assertEquals("doctor", db.index().forNodes("People").get("name", "The Doctor").getSingle().getProperty("name"));
}
}
@@ -97,8 +97,7 @@ public GraphDatabaseService graphdb()
@BeforeClass
public static void startDatabase()
{
- db = new ImpermanentGraphDatabase( "target/db"
- + System.currentTimeMillis() );
+ db = new ImpermanentGraphDatabase( );
db.cleanContent(false);
}

0 comments on commit efa0384

Please sign in to comment.