Coder Social home page Coder Social logo

neo4j-tutorial's Introduction

Neo4j Koans

"New Daleks""

This set of Koans provides a hands-on tutorial for learning the Neo4j open source graph database. It's part of a more comprehensive tutorial often presented by the authors and other folks.

What are Koans?

The Koan idea was borrowed from the Ruby Koans which provide a number of broken unit tests, and in fixing those tests increasingly advanced Ruby features are learned. The Koan model provides very rapid feedback and a structured learning path wrapped in a pre-configured environment for effective learning.

These are very desirable characteristics when it comes to learning Neo4j too, and so the Neo4j Koans have adopted the same model: there are a set of (broken) unit tests, and in fixing each of them we learn some aspect of using Neo4j. As we work through the Koans we'll learn increasingly sophisticated APIs, modeling and querying techniques, and become fluent in the Cypher query language. At the Koans we'll feel supremely confident about using Neo4j in production.

Prerequisites

You'll need to be familiar with the Java programming language for some of the early Koans and confident enough in Java to be able to run JUnit tests. If you like a particular IDE like Eclipse or IntelliJ, that's helpful but you can run these Koans from the command line too using an Ant script. All the Neo4j skills you'll need will be developed as part of completing the Koans.

Setting up Koans

The first step in setting up the koans is to clone this repository from github, or to download the latest tarball. To clone from github:

git clone git://github.com/jimwebber/neo4j-tutorial.git

To download the latest version of the koans as a zipfile, click on the following URI:

https://github.com/jimwebber/neo4j-tutorial/zipball/master

Once you have cloned or downloaded and unzipped the koans, you're almost ready. You just need the Neo4j binary dependencies, which you can get by running the default Apache Ant target from the root directory:

ant 

We use Apache Ivy for dependency resolution and for all the many wonderful benefits Ant and Ivy provide, speed isn't one of them so you might want to go fetch a cup of tea while you're waiting for (seemingly) most of the Internet to download.

Once the default Ant target has completed, you'll find it has dropped a set of libraries in the lib directory immediately under your Koan directory. It has also run the Koans and the unit tests that validate that everything's ready and will have left a report under:

target/koan/reports/output/index.html

Since the Koans come complete with the answers, if you're going to benefit from following them, you'll need to delete those answers. Fortunately we've provided a sed script that does this for you. From the root directory of your Koan download, run:

src/main/scripts/remove_snippets.sh

Sorry to Windows users, you'll have to run this with Cygwin for now.

The sed script removes all lines between

//SNIPPET_START
//SNIPPET_END

in the Koans, leaving them compiling but in a failing state.

If you want to run individual Koans (rather than all of them) then just type the specific Koan's target on the command line. For example to run Koan 5:

ant run.koan05

and to run all of Koan 8 (which has many parts):

ant run.koan08

If you'd prefer to use an IDE, you can of course just use your favourite development environment to run the Koans too.

I want my IDE

If you'd like some help in setting up the Koans in your IDE, the Ant script contains a target called generate.eclipse.project. By issuing the command:

ant generate.eclipse.project

an Eclipse project will be created in the Koan directory. This can be opened easily with Eclipse or Intellij where you can run individual koans as JUnit tests as normal.

Where are my Koans?

The Koans themselves are in the root directory under:

src/koan/java

and you'll see that they're numerically increasing in number. Start with Koan01.java and run it. If you're running the Koans in your IDE, then you can run Koan01.java as a unit test and verify that a Neo4j database can be created and populated with Doctor Who data, and that you have your IDE project set up properly.

Now that you're at this point, you're ready to move to Koan02.java and really start hacking on Neo4j.

Live Sessions

This tutorial is presented around the world. If you're interested in participating in a class, then it'll be taught at:

Authors

Ian Robinson, @iansrobinson

Jim Webber, @jimwebber

Contributors

Stefan Armbruster, darthvader42

Glen Ford, @glen_ford

Alistair Jones, @apcj

Tobias Lindaaker, @thobe

Peter Neubauer, @peterneubauer

Michael Peterson, @midpeter444

Andres Taylor, @andres_taylor

Niklas Uhrberg

Aleksa Vukotic, @aleksavukotic

Links

As well as being a contributor, Michael Peterson has written a blog post on setting up the Koans from the point of view of a first-time user. You can find Michael's posting here.

neo4j-tutorial's People

Contributors

cleishm avatar darthdeus avatar fedosov avatar gdubya avatar iansrobinson avatar jimwebber avatar niklasuhrberg avatar quux00 avatar raftim avatar sarmbruster avatar thobe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

neo4j-tutorial's Issues

'<' expected but 'n' found during Cypher query

I am on Koan 8 and am having some weirdness running the @test shouldFindEpisodesWhereTennantAndRoseBattleTheDaleks. I've tried this both in Eclipse as well as running a neo4j-community-1.4.2 shell. I have a Mac OX 10.6:

klauer@klauer-imac ~/Programming/Java
$ ./neo4j-community-1.4.2/bin/neo4j-shell -path /var/folders/J6/J67--MxKGjejtyI966Nft++++TI/-Tmp-/neo4j-koans1097860323379298061dir
NOTE: Local Neo4j graph database service at '/var/folders/J6/J67--MxKGjejtyI966Nft++++TI/-Tmp-/neo4j-koans1097860323379298061dir'
Welcome to the Neo4j Shell! Enter 'help' for a list of commands

Welcome to the Neo4j Shell! Enter 'help' for a list of commands

neo4j-sh (0)$ start daleks = node:Species( species = 'Daleks'), rose = node:Character(character = 'Rose Tyler'), tennant = node:actors(actor = 'David Tennant') match (daleks)-[:APPEARED_IN]->(ep), (rose)-[:APPEARED_IN]->(ep), (tennant)-[:APPEARED_IN]->(ep) return ep 
org.neo4j.cypher.SyntaxException: `<' expected but `n' found

Error in Koan02 shouldRemoveStarTrekInformation

The test shouldRemoveStarTrekInformation seems to be broken:
with the solution, it fails with the following error

java.lang.IllegalStateException: Node[6] has been deleted in this tx

on the line
captainKirk.hasProperty("character");

Add javadocs to the jars

In order to have good docs, we should pull down and mount even the javadocs for the Neo4j libs.

ant build fails with OS X JDK 7 preview

First, I can probably switch this to 1.6 on OS X (10.6) and things work fine, but I wasn't sure if this is supposed to happen or not.

klauer@klauer-imac ~
$ java -version
openjdk version "1.7.0-b215"
OpenJDK Runtime Environment (build 1.7.0-b215-20111028)
OpenJDK 64-Bit Server VM (build 21.0-b17, mixed mode)

klauer@klauer-imac ~
$ cd Programming/Java/neo4j-tutorial/

klauer@klauer-imac ~/Programming/Java/neo4j-tutorial
$ ant
Buildfile: build.xml

clean:
   [delete] Deleting directory /Users/klauer/Programming/Java/neo4j-tutorial/target

-create.ivy.dir:

-lib.dir-available:

download-ivy:

install-ivy:

lib.retrieve:

compile:
    [mkdir] Created dir: /Users/klauer/Programming/Java/neo4j-tutorial/target/main/classes
     [iajc] warning at /Users/klauer/Programming/Java/neo4j-tutorial/lib/spring-aspects.jar!org/springframework/orm/jpa/aspectj/JpaExceptionTranslatorAspect.class:14::0 advice defined in org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect has not been applied [Xlint:adviceDidNotMatch]
     [iajc] warning at /Users/klauer/Programming/Java/neo4j-tutorial/lib/spring-aspects.jar!org/springframework/scheduling/aspectj/AbstractAsyncExecutionAspect.class:52::0 advice defined in org.springframework.scheduling.aspectj.AbstractAsyncExecutionAspect has not been applied [Xlint:adviceDidNotMatch]
     [iajc] warning at /Users/klauer/Programming/Java/neo4j-tutorial/lib/spring-data-neo4j.jar!org/springframework/data/graph/neo4j/support/node/Neo4jNodeBacking.class:105::0 advice defined in org.springframework.data.graph.neo4j.support.node.Neo4jNodeBacking has not been applied [Xlint:adviceDidNotMatch]
     [iajc] warning at /Users/klauer/Programming/Java/neo4j-tutorial/lib/spring-data-neo4j.jar!org/springframework/data/graph/neo4j/support/node/Neo4jNodeBacking.class:253::0 advice defined in org.springframework.data.graph.neo4j.support.node.Neo4jNodeBacking has not been applied [Xlint:adviceDidNotMatch]
     [iajc] warning at /Users/klauer/Programming/Java/neo4j-tutorial/lib/spring-data-neo4j.jar!org/springframework/data/graph/neo4j/support/node/Neo4jNodeBacking.class:263::0 advice defined in org.springframework.data.graph.neo4j.support.node.Neo4jNodeBacking has not been applied [Xlint:adviceDidNotMatch]
     [iajc] warning at org/springframework/mock/staticmock/AnnotationDrivenStaticEntityMockingControl.aj:64::0 advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch]
     [iajc] warning at /Users/klauer/Programming/Java/neo4j-tutorial/lib/spring-aspects.jar!org/springframework/mock/staticmock/AbstractMethodMockingControl.class:160::0 advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
     [iajc] warning at /Users/klauer/Programming/Java/neo4j-tutorial/lib/spring-aspects.jar!org/springframework/mock/staticmock/AbstractMethodMockingControl.class:169::0 advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
     [iajc] warning at /Users/klauer/Programming/Java/neo4j-tutorial/lib/spring-data-neo4j.jar!org/springframework/data/graph/neo4j/support/relationship/Neo4jRelationshipBacking.class:130::0 advice defined in org.springframework.data.graph.neo4j.support.relationship.Neo4jRelationshipBacking has not been applied [Xlint:adviceDidNotMatch]
     [iajc] warning at /Users/klauer/Programming/Java/neo4j-tutorial/lib/spring-data-neo4j.jar!org/springframework/data/graph/neo4j/support/relationship/Neo4jRelationshipBacking.class:137::0 advice defined in org.springframework.data.graph.neo4j.support.relationship.Neo4jRelationshipBacking has not been applied [Xlint:adviceDidNotMatch]
     [copy] Copying 1 file to /Users/klauer/Programming/Java/neo4j-tutorial/target/main/classes

compile.tests:
    [mkdir] Created dir: /Users/klauer/Programming/Java/neo4j-tutorial/target/test/classes
    [javac] Compiling 2 source files to /Users/klauer/Programming/Java/neo4j-tutorial/target/test/classes

Error in log:

    [javac] javac: target release 1.5 conflicts with default source release 1.7

BUILD FAILED
/Users/klauer/Programming/Java/neo4j-tutorial/build.xml:54: Compile failed; see the compiler error output for details.

Total time: 15 seconds

Koan 8 tests fail on initial build

I would love to contribute a fix for this, unfortunately I have not worked through the exercises yet so I don't know enough.

Here is the output of the failing test case (on initial ant build after clone)

ShouldRemoveCaptainKirkFromTheDatabase  Failure expected:<0> but was:<1>

junit.framework.AssertionFailedError: expected:<0> but was:<1>
at org.neo4j.tutorial.Koan8.shouldRemoveCaptainKirkFromTheDatabase(Koan8.java:66)

For what its worth I am on a new mac book pro retina running OSX 10.9.2

For now I will probably just change the assertion to what it received just to get by this.

Thanks,

Test smell: poor code organization

Hi!

We notice that you mix the test code with the production code.
For example, a test case in the ''neo4j-tutorial/blob/master/src/koan/java/org/neo4j/tutorial/Koan11.java'' path.
In your project, ''.../src/...'' is the folder for placing production code and ''.../test/...'' is the folder for test code.
But you lace the test code in the production folder.
It is a bad programming practice.
Thus, we suggest you'd better re-organize your test code. Thanks.

ant fails to extract neo4j-community-2.1.4-unix.tar

โฏ ant
Buildfile: /Users/emris/src/seth/neo4j-tutorial/build.xml

-download.check:

-make.download.dirs:
[mkdir] Created dir: /Users/emris/src/seth/neo4j-tutorial/downloads/neo4j
[mkdir] Created dir: /Users/emris/src/seth/neo4j-tutorial/downloads/jars

-download.and.unzip.neo4j.windows:

-download.and.uncompress.neo4j.unix:
[get] Getting: http://dist.neo4j.org/neo4j-community-2.1.4-unix.tar.gz
[get] To: /Users/emris/src/seth/neo4j-tutorial/downloads/neo4j/neo4j-community-2.1.4-unix.tar.gz
[gunzip] Expanding /Users/emris/src/seth/neo4j-tutorial/downloads/neo4j/neo4j-community-2.1.4-unix.tar.gz to /Users/emris/src/seth/neo4j-tutorial/downloads/neo4j/neo4j-community-2.1.4-unix.tar
[untar] Expanding: /Users/emris/src/seth/neo4j-tutorial/downloads/neo4j/neo4j-community-2.1.4-unix.tar into /Users/emris/src/seth/neo4j-tutorial/downloads/neo4j

BUILD FAILED
/Users/emris/src/seth/neo4j-tutorial/build.xml:57: Error while expanding /Users/emris/src/seth/neo4j-tutorial/downloads/neo4j/neo4j-community-2.1.4-unix.tar
java.io.IOException: Error detected parsing the header
at org.apache.tools.tar.TarInputStream.getNextEntry(TarInputStream.java:292)
at org.apache.tools.ant.taskdefs.Untar.expandStream(Untar.java:165)
at org.apache.tools.ant.taskdefs.Untar.expandFile(Untar.java:114)
at org.apache.tools.ant.taskdefs.Expand.execute(Expand.java:132)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: java.lang.IllegalArgumentException: Invalid byte 32 at offset 7 in ' {NUL}' len=8
at org.apache.tools.tar.TarUtils.parseOctal(TarUtils.java:134)
at org.apache.tools.tar.TarUtils.parseOctalOrBinary(TarUtils.java:172)
at org.apache.tools.tar.TarEntry.parseTarHeader(TarEntry.java:912)
at org.apache.tools.tar.TarEntry.parseTarHeader(TarEntry.java:899)
at org.apache.tools.tar.TarEntry.(TarEntry.java:323)
at org.apache.tools.tar.TarInputStream.getNextEntry(TarInputStream.java:290)
... 19 more

Total time: 1 minute 2 seconds

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.