This repository has been archived by the owner on Feb 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#59] Run tests against provisioned Neo4j instance
Travis CI now provisions a Neo4j instance for the latest Neo4j versions. All classes that require scenarii to run against remote and embedded instances now extend `GraphIntegrationTestSuite`. Despite the workaround for travis-ci/travis-ci #5227, OpenJDK 7 turns out be still unstable. For now, this JDK has been removed.
- Loading branch information
Florent Biville
committed
Apr 20, 2016
1 parent
67ca9c4
commit 3ceda86
Showing
17 changed files
with
482 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
if [ "$WITH_DOCKER" = true ] ; then | ||
docker pull neo4j:${NEO_VERSION} | ||
docker run --detach --publish=7474:7474 --volume=$HOME/neo4j/data:/data --env=NEO4J_AUTH=neo4j/j4oen neo4j | ||
fi | ||
mvn -T4 clean test -Dneo4j.version=${NEO_VERSION} ${EXTRA_PROFILES} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
liquigraph-core/src/test/java/org/liquigraph/core/GraphDatabaseRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright 2014-2016 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.liquigraph.core; | ||
|
||
import com.google.common.base.Optional; | ||
import org.junit.rules.TestRule; | ||
|
||
import java.sql.Connection; | ||
|
||
public interface GraphDatabaseRule extends TestRule { | ||
|
||
Connection connection(); | ||
String uri(); | ||
Optional<String> username(); | ||
Optional<String> password(); | ||
} |
21 changes: 21 additions & 0 deletions
21
liquigraph-core/src/test/java/org/liquigraph/core/GraphIntegrationTestSuite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright 2014-2016 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.liquigraph.core; | ||
|
||
public interface GraphIntegrationTestSuite { | ||
|
||
GraphDatabaseRule graphDatabase(); | ||
} |
105 changes: 105 additions & 0 deletions
105
liquigraph-core/src/test/java/org/liquigraph/core/RemoteGraphDatabaseRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/** | ||
* Copyright 2014-2016 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.liquigraph.core; | ||
|
||
import com.google.common.base.Optional; | ||
import org.junit.Assume; | ||
import org.junit.rules.ExternalResource; | ||
import org.junit.runner.Description; | ||
import org.junit.runners.model.Statement; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.SQLException; | ||
|
||
import static com.google.common.base.Throwables.propagate; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class RemoteGraphDatabaseRule extends ExternalResource | ||
implements GraphDatabaseRule { | ||
|
||
private final String uri; | ||
private final String username; | ||
private final String password; | ||
private Connection connection; | ||
|
||
public RemoteGraphDatabaseRule() { | ||
uri = "jdbc:neo4j://127.0.0.1:7474"; | ||
username = "neo4j"; | ||
password = "j4oen"; | ||
} | ||
|
||
public static void assumeRemoteGraphDatabaseIsProvisioned() { | ||
Assume.assumeTrue( | ||
"Neo4j remote instance is provisioned with Docker", | ||
"true".equals(System.getenv("WITH_DOCKER")) | ||
); | ||
} | ||
|
||
@Override | ||
public Statement apply(Statement base, Description description) { | ||
assumeRemoteGraphDatabaseIsProvisioned(); | ||
return super.apply(base, description); | ||
} | ||
|
||
@Override | ||
public Connection connection() { | ||
return connection; | ||
} | ||
|
||
@Override | ||
public String uri() { | ||
return uri; | ||
} | ||
|
||
@Override | ||
public Optional<String> username() { | ||
return Optional.of(username); | ||
} | ||
|
||
@Override | ||
public Optional<String> password() { | ||
return Optional.of(password); | ||
} | ||
|
||
protected void before() { | ||
try { | ||
Class.forName("org.neo4j.jdbc.Driver"); | ||
connection = DriverManager.getConnection(uri, username, password); | ||
connection.setAutoCommit(false); | ||
emptyDatabase(connection); | ||
} catch (ClassNotFoundException | SQLException e) { | ||
throw propagate(e); | ||
} | ||
} | ||
|
||
protected void after() { | ||
try { | ||
if (!connection.isClosed()) { | ||
connection.close(); | ||
} | ||
} catch (SQLException e) { | ||
throw propagate(e); | ||
} | ||
} | ||
|
||
private void emptyDatabase(Connection connection) throws SQLException { | ||
try (java.sql.Statement statement = connection.createStatement()) { | ||
assertThat(statement.execute("MATCH (n) OPTIONAL MATCH (n)-[r]->() DELETE n,r")).isTrue(); | ||
} | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
liquigraph-core/src/test/java/org/liquigraph/core/api/LiquigraphEmbeddedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright 2014-2016 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.liquigraph.core.api; | ||
|
||
import org.junit.Rule; | ||
import org.liquigraph.core.EmbeddedGraphDatabaseRule; | ||
import org.liquigraph.core.GraphDatabaseRule; | ||
|
||
public class LiquigraphEmbeddedTest extends LiquigraphTestSuite { | ||
|
||
@Rule | ||
public GraphDatabaseRule graph = new EmbeddedGraphDatabaseRule("neo"); | ||
|
||
@Override | ||
public GraphDatabaseRule graphDatabase() { | ||
return graph; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
liquigraph-core/src/test/java/org/liquigraph/core/api/LiquigraphRemoteTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright 2014-2016 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.liquigraph.core.api; | ||
|
||
import org.junit.Rule; | ||
import org.liquigraph.core.GraphDatabaseRule; | ||
import org.liquigraph.core.RemoteGraphDatabaseRule; | ||
|
||
public class LiquigraphRemoteTest extends LiquigraphTestSuite { | ||
|
||
@Rule | ||
public GraphDatabaseRule graph = new RemoteGraphDatabaseRule(); | ||
|
||
@Override | ||
public GraphDatabaseRule graphDatabase() { | ||
return graph; | ||
} | ||
} |
Oops, something went wrong.