Permalink
Browse files

initial github push

  • Loading branch information...
0 parents commit 6da3f76bf635983a0c571532a0c7f53055a12ba5 @espeed espeed committed Dec 26, 2011
Showing with 3,413 additions and 0 deletions.
  1. +18 −0 .gitignore
  2. +695 −0 LICENSE.txt
  3. +29 −0 NOTICE.txt
  4. +50 −0 README.markdown
  5. +6 −0 Rakefile
  6. +26 −0 features/download-and-unpack.feature
  7. +19 −0 features/start-and-stop.feature
  8. +109 −0 features/step_definitions/download_steps.rb
  9. +35 −0 features/step_definitions/examples_step.rb
  10. +95 −0 features/step_definitions/shell_steps.rb
  11. +95 −0 features/step_definitions/startstop_steps.rb
  12. +9 −0 features/support/env.rb
  13. +21 −0 features/support/hooks.rb
  14. +19 −0 features/support/neo4j_helpers.rb
  15. +92 −0 features/support/network_helpers.rb
  16. +41 −0 features/support/platform_helpers.rb
  17. +92 −0 features/support/shell_helpers.rb
  18. +3 −0 features/support/unzip.vbs
  19. +231 −0 pom.xml
  20. +5 −0 set_env.sh
  21. +48 −0 src/data/graphml1.xml
  22. BIN src/docs/dev/rest-api/images/gremlin-logo.png
  23. +51 −0 src/docs/dev/rest-api/index.txt
  24. +38 −0 src/main/assembly/docs-assembly.xml
  25. +38 −0 src/main/assembly/server-plugin.xml
  26. +43 −0 src/main/java/org/neo4j/server/plugin/gremlin/CountingEngineReplacementDecision.java
  27. +26 −0 src/main/java/org/neo4j/server/plugin/gremlin/EngineReplacementDecision.java
  28. +141 −0 src/main/java/org/neo4j/server/plugin/gremlin/GremlinPlugin.java
  29. +189 −0 src/main/java/org/neo4j/server/plugin/gremlin/GremlinToRepresentationConverter.java
  30. +44 −0 src/main/java/org/neo4j/server/plugin/gremlin/ScriptCountingEngineReplacementDecision.java
  31. +70 −0 src/main/java/org/neo4j/server/rest/repr/GremlinTableRepresentation.java
  32. +1 −0 src/main/resources/META-INF/services/org.neo4j.server.plugins.ServerPlugin
  33. +703 −0 src/test/java/org/neo4j/server/plugin/gremlin/GremlinPluginFunctionalTest.java
  34. +331 −0 src/test/java/org/neo4j/server/plugin/gremlin/GremlinPluginTest.java
@@ -0,0 +1,18 @@
+*.log
+*~
+\#*
+target
+*.swp
+.project
+.classpath
+.settings
+.scala_dependencies
+.factorypath
+*.iws
+*.ipr
+*.iml
+.idea
+.DS_Store
+artifacts
+*.class
+

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,29 @@
+Neo4j
+Copyright © 2002-2011 Network Engine for Objects in Lund AB (referred to
+in this notice as “Neo Technology”)
+ [http://neotechnology.com]
+
+This product includes software ("Software") developed by Neo Technology.
+
+The copyright in the bundled Neo4j graph database (including the
+Software) is owned by Neo Technology. The Software developed and owned
+by Neo Technology is licensed under the GNU GENERAL PUBLIC LICENSE
+Version 3 (http://www.fsf.org/licensing/licenses/gpl-3.0.html) ("GPL")
+to all third parties and that license, as required by the GPL, is
+included in the LICENSE.txt file.
+
+However, if you have executed an End User Software License and Services
+Agreement or an OEM Software License and Support Services Agreement, or
+another commercial license agreement with Neo Technology or one of its
+affiliates (each, a "Commercial Agreement"), the terms of the license in
+such Commercial Agreement will supersede the GPL and you may use the
+software solely pursuant to the terms of the relevant Commercial
+Agreement.
+
+
+Third party libraries
+---------------------
+
+Third party libraries are only used to build the plugin,
+but the plugin itself doesn't re-distribute any libraries.
+
@@ -0,0 +1,50 @@
+This is a beginning of providing [Gremlin](http://gremlin.tinkerpop.com) backend scripting to the [Neo4j Server](http://neo4j.org). to deploy, please do the following
+
+ mvn clean package
+ cp target/gremlin-translator-plugin-0.1-SNAPSHOT.jar $NEO4J_HOME/plugins
+ cd $NEO4J_HOME
+ bin/neo4j restart
+
+Integration testing:
+
+ mvn clean package
+ source set_env.sh
+ rake
+
+access the plugin
+
+ curl localhost:7474/db/data/
+ {
+ "relationship_index" : "http://localhost:7474/db/data/index/relationship",
+ "node" : "http://localhost:7474/db/data/node",
+ "relationship_types" : "http://localhost:7474/db/data/relationship/types",
+ "extensions_info" : "http://localhost:7474/db/data/ext",
+ "node_index" : "http://localhost:7474/db/data/index/node",
+ "reference_node" : "http://localhost:7474/db/data/node/0",
+ "extensions" : {
+ "GremlinPlugin" : {
+ "execute_script" : "http://localhost:7474/db/data/ext/GremlinPlugin/graphdb/execute_script"
+ }
+ }
+
+
+submit (HTTP POST) a Gremlin script `i=g.V(2);i.outE.inV` returning a list of nodes, URL encoded:
+
+ curl -d "script=i+%3D+g.v%282%29%3Bi.outE.inV" http://localhost:7474/db/data/ext/GremlinPlugin/graphdb/execute_script
+ [ {
+ "outgoing_relationships" : "http://localhost:7474/db/data/node/0/relationships/out",
+ "data" : {
+ },
+ "traverse" : "http://localhost:7474/db/data/node/0/traverse/{returnType}",
+ "all_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/all/{-list|&|types}",
+ "property" : "http://localhost:7474/db/data/node/0/properties/{key}",
+ "self" : "http://localhost:7474/db/data/node/0",
+ "properties" : "http://localhost:7474/db/data/node/0/properties",
+ "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/out/{-list|&|types}",
+ "incoming_relationships" : "http://localhost:7474/db/data/node/0/relationships/in",
+ "extensions" : {
+ },
+ "create_relationship" : "http://localhost:7474/db/data/node/0/relationships",
+ "all_relationships" : "http://localhost:7474/db/data/node/0/relationships/all",
+ "incoming_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/in/{-list|&|types}"
+ } ]
@@ -0,0 +1,6 @@
+# $:.unshift(File.dirname(__FILE__) + '/../../lib')
+require 'cucumber/rake/task'
+
+Cucumber::Rake::Task.new
+
+task :default => 'cucumber'
@@ -0,0 +1,26 @@
+Feature: Download and unpack Neo4j Server
+ In order to get Neo4j Server
+ A user
+ Should be able to download and unpack a platform appropriate archive from the web
+
+ Background:
+ Given a platform supported by Neo4j
+ And a working directory at relative path "target"
+ And set Neo4j Home to "neo4j_home"
+ And Neo4j version based on system property "NEO4J_VERSION"
+ And Neo4j product based on system property "NEO4J_PRODUCT"
+ And a web site at host "dist.neo4j.org" or system property "DOWNLOAD_LOCATION"
+ And plugin based on system property "DOWNLOAD_PLUGIN_LOCATION"
+
+ Scenario: Download Neo4j
+ When I download Neo4j (if I haven't already)
+ Then the working directory should contain a Neo4j archive
+ And I download the plugin (if I haven't already)
+ Then the "plugin.zip" should exists
+
+ Scenario: Unpack downloaded archive
+ When I unpack the archive into Neo4j Home
+ Then Neo4j Home should contain a Neo4j Server installation
+ And the Neo4j version of the installation should be correct
+ And in Windows I will patch the "neo4j_home/conf/neo4j-wrapper.conf" adding "wrapper.java.command" to "#{ENV['JAVA_HOME']}\\bin\\java.exe"
+ Then I unzip the "plugin.zip" into "neo4j_home/plugins"
@@ -0,0 +1,19 @@
+Feature: Start and stop Neo4j Server
+ The Neo4j server should start and stop using a command line script
+
+ Background:
+ Given a platform supported by Neo4j
+ And a working directory at relative path "target"
+ And set Neo4j Home to "neo4j_home"
+ And Neo4j Home should contain a Neo4j Server installation
+
+ Scenario: Start Neo4j Server
+ When I start Neo4j Server
+ And wait for Server started at "http://localhost:7474"
+ Then "http://localhost:7474" should provide the Neo4j REST interface
+ Then requesting "http://localhost:7474/db/data/ext/" should contain "GremlinPlugin"
+ Then sending "script=g.V" to "http://localhost:7474/db/data/ext/GremlinPlugin/graphdb/execute_script" should contain "node"
+ Then sending "script=for (i in 1..2){g.v(0);1};1" to "http://localhost:7474/db/data/ext/GremlinPlugin/graphdb/execute_script" should contain "1"
+ Then sending "script=GraphMLReader.inputGraph(g, new URL('https://github.com/tinkerpop/gremlin/raw/master/data/graph-example-1.xml').openStream());g.v(1).outE.inV.name.paths" to "http://localhost:7474/db/data/ext/GremlinPlugin/graphdb/execute_script" should contain "1"
+
+
@@ -0,0 +1,109 @@
+require 'net/http'
+require 'time'
+
+Given /^a platform supported by Neo4j$/ do
+ fail "unsupported platform #{current_platform}" unless current_platform.supported?
+end
+
+Given /^Neo4j version based on system property "([^"]*)"$/ do |version_name|
+ neo4j.version = ENV[version_name]
+ fail "missing property #{version_name}" if neo4j.version == nil
+end
+
+Given /^Neo4j product based on system property "([^"]*)"$/ do |product_name|
+ neo4j.product = ENV[product_name]
+ fail "missing property #{product_name}" if neo4j.product == nil
+end
+
+When /^dependencies\-zip based on system property "([^\"]*)"$/ do |arg1|
+ neo4j.dependencies_location = URI.parse(ENV[arg1])
+ fail "missing property #{arg1}" if neo4j.dependencies_location == nil
+end
+
+When /^plugin based on system property "([^\"]*)"$/ do |arg1|
+ neo4j.plugin_location = URI.parse(ENV[arg1])
+ fail "missing property #{arg1}" if neo4j.plugin_location == nil
+end
+
+Then /^the "([^\"]*)" should exists$/ do |arg1|
+ fail "#{arg1} does not exists" unless File.exists?(arg1)
+end
+
+Given /^set Neo4j Home to "([^"]*)"$/ do |home|
+ neo4j.home = File.expand_path(home)
+ neo4j.home = neo4j.home.tr('/', '\\') if (current_platform.windows?)
+ puts "using neo4j.home "+neo4j.home
+ ENV["NEO4J_HOME"] = neo4j.home
+ Dir.mkdir(neo4j.home) unless File.exists?(neo4j.home)
+end
+
+Given /^a web site at host "([^"]*)" or system property "([^"]*)"$/ do |host, env_location|
+ puts "host = #{host}"
+ puts "env_location = #{env_location}"
+ puts "env = #{ENV[env_location]}"
+ if ENV[env_location]
+ neo4j.download_location = URI.parse(ENV[env_location])
+ puts "downloading from " + neo4j.download_location.to_s
+ else
+ Net::HTTP.get(URI.parse("http://#{host}"))
+ neo4j.download_location = URI.parse("http://#{host}/#{archive_name}")
+ puts "downloading from " + neo4j.download_location.to_s
+ end
+end
+
+When /^I download Neo4j \(if I haven't already\)$/ do
+ transfer_if_newer(neo4j.download_location, archive_name)
+end
+
+Then /^the working directory should contain a Neo4j archive$/ do
+ fail "#{archive_name} does not exists" unless File.exists?(archive_name)
+end
+
+
+When /^I download the plugin \(if I haven't already\)$/ do
+ transfer_if_newer(neo4j.plugin_location, "plugin.zip");
+end
+
+When /^I unpack the archive into Neo4j Home$/ do
+ if (current_platform.unix?)
+ untar(File.expand_path(archive_name), neo4j.home)
+ elsif current_platform.windows?
+ unzip(File.expand_path(archive_name), neo4j.home)
+ else
+ fail 'platform not supported'
+ end
+end
+
+Then /^Neo4j Home should contain a Neo4j Server installation$/ do
+ if (current_platform.unix?)
+ fail "file "+neo4j.home+"/bin/neo4j not found" unless File.exists?(neo4j.home+"/bin/neo4j")
+ elsif (current_platform.windows?)
+ fail "file "+neo4j.home+"\\bin\\neo4j.bat not found" unless File.exists?(neo4j.home+"\\bin\\neo4j.bat")
+ else
+ fail 'platform not supported'
+ end
+end
+
+Then /^the Neo4j version of the installation should be correct$/ do
+ (Dir.entries(neo4j.home+"/lib") + Dir.entries(neo4j.home+"/system/lib")).each do |lib|
+ if lib =~ /^neo4j.*\.jar$/
+ fail lib+" does not contain the Neo4j-version" unless lib =~ /#{neo4j.version}/;
+ end
+ end
+end
+
+When /^in (Windows|Unix) I will patch the "([^\"]*)" adding "([^\"]*)" to ("[^\"]*")$/ do |platform, config, param, value|
+ if (platform == "Windows" && current_platform.windows?) || (platform == "Unix" && current_platform.unix?)
+ File.open(config, "a") do |config_file|
+ config_file.puts "#{param}=" + eval(value)
+ end
+ end
+end
+
+Then /^I unzip the "([^\"]*)" into "([^\"]*)"$/ do |archive, target|
+ unzip(File.expand_path(archive), File.expand_path(target))
+end
+
+Then /^copy the "([^\"]*)" to "([^\"]*)"$/ do |source, target|
+ copy_file(File.expand_path(source), File.expand_path(target))
+end
@@ -0,0 +1,35 @@
+#Given /^environment variable "([^"]*)" pointing to a Neo(\d+)j Server installation$/ do |arg1, arg2|
+# pending # express the regexp above with the code you wish you had
+#end
+
+When /^I look in the "([^"]*)" directory under "([^"]*)"$/ do |arg1, arg2|
+ pending # express the regexp above with the code you wish you had
+end
+
+Then /^it should have at least (\d+) java file that contains \/extends ServerPlugin\/$/ do |arg1|
+ pending # express the regexp above with the code you wish you had
+end
+
+Then /^it should have at least (\d+) java file that contains \/import javax\.ws\.rs\.Path\/$/ do |arg1|
+ pending # express the regexp above with the code you wish you had
+end
+
+Then /^it should contain a "([^"]*)" jar$/ do |arg1|
+ pending # express the regexp above with the code you wish you had
+end
+
+When /^I install the "([^"]*)" jar from examples\/java\/server\/lib into "([^"]*)"$/ do |arg1, arg2|
+ pending # express the regexp above with the code you wish you had
+end
+
+When /^I start the server$/ do
+ pending # express the regexp above with the code you wish you had
+end
+
+When /^I browse the REST API to the database extensions$/ do
+ pending # express the regexp above with the code you wish you had
+end
+
+Then /^they should be non\-empty$/ do
+ pending # express the regexp above with the code you wish you had
+end
@@ -0,0 +1,95 @@
+Given /^a bash compatible shell$/ do
+ bash_compatible.should be_true
+end
+
+Given /^Java (\d+\.\d+)$/ do |java_version|
+ bash("java -version 2>&1")
+ last_stdout.any?{|line| /#{java_version}/ =~ line}.should be_true,
+ "Java #{java_version} required but not found. Please check your installed Java."
+end
+
+
+Given /^a working directory at relative path "([^"]*)"$/ do |dir_path|
+ popd
+ mkdir (dir_path)
+ pushd(dir_path)
+end
+
+
+Given /^these command\-line tools:$/ do |table|
+ table.hashes.each do |hash|
+ bash("#{hash[:command]} #{hash[:version_switch]}")
+ last_stdout.any?{|line| /#{hash[:version]}/ =~ line}.should be_true,
+ "#{hash[:command]} version #{hash[:expected_version]} not found"
+ end
+end
+
+Given /^environment variable "([^"]*)" set to "([^"]*)"$/ do |env_var, env_value|
+ setenv(env_var, env_value)
+ getenv(env_var).should match(/#{env_value}/)
+end
+
+When /^I run these shell commands:$/ do |script|
+ script.each {|line|
+ bash(line, :verbose => true)
+ }
+end
+
+When /^I fork this shell command and wait (\d+) seconds:$/ do |seconds, script|
+ forked_job = fork do
+ system(script)
+ end
+ Process.detach(forked_job)
+ sleep(seconds.to_i)
+end
+
+When /^I run these shell commands in "([^"]*)":$/ do |working_dir, script|
+ Dir.chdir(working_dir) do
+ script.each {|line|
+ bash(line, :verbose => true)
+ }
+ end
+end
+
+Then /^"([^"]*)" should be an executable$/ do |expected_executable|
+ test_executable(expected_executable).should be_true,
+ "neo4j executable not found, or not executable"
+end
+
+Then /^"([^"]*)" should exist as a directory$/ do |expected_directory|
+ test_directory(expected_directory).should be_true,
+ "missing directory #{expected_directory}"
+end
+
+Then /^"([^"]*)" should( not)? exist as a file$/ do |expected_file, negation|
+ if negation then
+ test_file(expected_file).should be_false
+ else
+ test_file(expected_file).should be_true
+ end
+end
+
+Then /^these commands should succeed:$/ do |script|
+ script.each {|line|
+ bash(line, :verbose => true)
+ last_exit_code.should eql(0),
+ "Exit code #{last_exit_code}. Check the transcript"
+ }
+end
+
+Given /^"([^"]*)" exists as a directory$/ do |expected_directory|
+ test_directory(expected_directory).should be_true,
+ "missing directory #{expected_directory}"
+end
+
+Given /^a file named "([^"]*)" with:$/ do |filename, content|
+ create_file(filename, content)
+end
+
+Then /^"([^"]*)" should contain "([^"]*)"$/ do |filename, pattern|
+ file_contains(filename, Regexp.escape(pattern)).should be_true
+end
+
+
+
+
Oops, something went wrong.

0 comments on commit 6da3f76

Please sign in to comment.