Skip to content

Commit dfba014

Browse files
committed
Merge pull request #108 from jakewins/1.0-import-examples
Fix broken example snippets
2 parents b121739 + c2913b8 commit dfba014

File tree

2 files changed

+52
-21
lines changed

2 files changed

+52
-21
lines changed

driver/src/test/java/org/neo4j/driver/v1/integration/ExamplesIT.java

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@
4848
import static org.neo4j.driver.v1.Config.TlsAuthenticationConfig.usingKnownCerts;
4949
import static org.neo4j.driver.v1.Config.TlsAuthenticationConfig.usingTrustedCert;
5050

51-
// NOTE: Be careful about auto-formatting here. The below segment should contain GraphDatabase, Driver and Session imports
52-
// tag::include-driver[]
53-
// end::include-driver[]
54-
5551
/**
5652
* The tests below are examples that get pulled into the Driver Manual using the tags inside the tests.
5753
*
@@ -69,21 +65,7 @@ public void minimumViableSnippet() throws Throwable
6965
StdIOCapture stdIO = new StdIOCapture();
7066
try( AutoCloseable captured = stdIO.capture() )
7167
{
72-
// tag::minimum-snippet[]
73-
Driver driver = GraphDatabase.driver( "bolt://localhost" );
74-
Session session = driver.session();
75-
76-
session.run( "CREATE (neo:Person {name:'Neo', age:23})" );
77-
78-
ResultCursor result = session.run( "MATCH (p:Person) WHERE p.name = 'Neo' RETURN p.age" );
79-
while ( result.next() )
80-
{
81-
System.out.println( "Neo is " + result.value( "p.age" ).asInt() + " years old." );
82-
}
83-
84-
session.close();
85-
driver.close();
86-
// end::minimum-snippet[]
68+
ImportExample.main();
8769
}
8870

8971
// Then
@@ -186,7 +168,7 @@ public void resultCursor() throws Throwable
186168
}
187169

188170
@Test
189-
public void retainResultsForLaterProcessing() throws Throwable
171+
public void retainResultsForNestedQuerying() throws Throwable
190172
{
191173
StdIOCapture stdIO = new StdIOCapture();
192174
try( AutoCloseable captured = stdIO.capture();
@@ -211,7 +193,7 @@ public void retainResultsForLaterProcessing() throws Throwable
211193
}
212194

213195
@Test
214-
public void retainResultsForNestedQuerying() throws Throwable
196+
public void retainResultsForLaterProcessing() throws Throwable
215197
{
216198
StdIOCapture stdIO = new StdIOCapture();
217199
try( AutoCloseable captured = stdIO.capture();
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Copyright (c) 2002-2015 "Neo Technology,"
3+
* Network Engine for Objects in Lund AB [http://neotechnology.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.neo4j.driver.v1.integration;
20+
21+
// NOTE: Be careful about auto-formatting here. The below segment should contain GraphDatabase, Driver and Session imports
22+
// tag::include-driver[]
23+
import org.neo4j.driver.v1.Driver;
24+
import org.neo4j.driver.v1.GraphDatabase;
25+
import org.neo4j.driver.v1.ResultCursor;
26+
import org.neo4j.driver.v1.Session;
27+
// end::include-driver[]
28+
29+
public class ImportExample
30+
{
31+
public static void main(String ... args) throws Exception
32+
{
33+
// tag::minimum-snippet[]
34+
Driver driver = GraphDatabase.driver( "bolt://localhost" );
35+
Session session = driver.session();
36+
37+
session.run( "CREATE (neo:Person {name:'Neo', age:23})" );
38+
39+
ResultCursor result = session.run( "MATCH (p:Person) WHERE p.name = 'Neo' RETURN p.age" );
40+
while ( result.next() )
41+
{
42+
System.out.println( "Neo is " + result.value( "p.age" ).asInt() + " years old." );
43+
}
44+
45+
session.close();
46+
driver.close();
47+
// end::minimum-snippet[]
48+
}
49+
}

0 commit comments

Comments
 (0)