Skip to content

Commit 4fb3bb8

Browse files
committed
Merge branch '1.0' into 1.0-tck-tests
2 parents 7600a90 + 6efc096 commit 4fb3bb8

File tree

7 files changed

+45
-34
lines changed

7 files changed

+45
-34
lines changed

driver/src/main/java/org/neo4j/driver/internal/InternalSession.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public StatementResult run( String statementText, Value statementParameters )
8989
@Override
9090
public StatementResult run( Statement statement )
9191
{
92-
ensureConnectionIsValid();
92+
ensureConnectionIsValidBeforeRunningSession();
9393
InternalStatementResult cursor = new InternalStatementResult( connection, statement );
9494
connection.run( statement.text(), statement.parameters().asMap( Values.ofValue() ), cursor.runResponseCollector() );
9595
connection.pullAll( cursor.pullAllResponseCollector() );
@@ -132,7 +132,7 @@ public void close()
132132
@Override
133133
public Transaction beginTransaction()
134134
{
135-
ensureConnectionIsValid();
135+
ensureConnectionIsValidBeforeOpeningTransaction();
136136
currentTransaction = new InternalTransaction( connection, txCleanup );
137137
connection.onError( new Runnable() {
138138
@Override
@@ -156,9 +156,15 @@ public TypeSystem typeSystem()
156156
return InternalTypeSystem.TYPE_SYSTEM;
157157
}
158158

159-
private void ensureConnectionIsValid()
159+
private void ensureConnectionIsValidBeforeRunningSession()
160160
{
161-
ensureNoOpenTransaction();
161+
ensureNoOpenTransactionBeforeRunningSession();
162+
ensureConnectionIsOpen();
163+
}
164+
165+
private void ensureConnectionIsValidBeforeOpeningTransaction()
166+
{
167+
ensureNoOpenTransactionBeforeOpeningTransaction();
162168
ensureConnectionIsOpen();
163169
}
164170

@@ -174,12 +180,21 @@ protected void finalize() throws Throwable
174180
super.finalize();
175181
}
176182

177-
private void ensureNoOpenTransaction()
183+
private void ensureNoOpenTransactionBeforeRunningSession()
184+
{
185+
if ( currentTransaction != null )
186+
{
187+
throw new ClientException( "Statements cannot be run directly on a session with an open transaction;" +
188+
" either run from within the transaction or use a different session." );
189+
}
190+
}
191+
192+
private void ensureNoOpenTransactionBeforeOpeningTransaction()
178193
{
179194
if ( currentTransaction != null )
180195
{
181-
throw new ClientException( "Please close the currently open transaction object before running " +
182-
"more statements/transactions in the current session." );
196+
throw new ClientException( "You cannot begin a transaction on a session with an open transaction;" +
197+
" either run from within the transaction or use a different session." );
183198
}
184199
}
185200

driver/src/main/java/org/neo4j/driver/internal/pool/InternalConnectionPool.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@
4343
/**
4444
* A basic connection pool that optimizes for threads being long-lived, acquiring/releasing many connections.
4545
* It uses a global queue as a fallback pool, but tries to avoid coordination by storing connections in a ThreadLocal.
46-
* <p>
46+
*
4747
* Safety is achieved by tracking thread locals getting garbage collected, returning connections to the global pool
4848
* when this happens.
49-
* <p>
49+
*
5050
* If threads are long-lived, this pool will achieve linearly scalable performance with overhead equivalent to a
5151
* hash-map lookup per acquire.
52-
* <p>
52+
*
5353
* If threads are short-lived, this pool is not ideal.
5454
*/
5555
public class InternalConnectionPool implements ConnectionPool
@@ -185,7 +185,7 @@ public PooledConnection allocate( Consumer<PooledConnection> release )
185185
if ( connector == null )
186186
{
187187
throw new ClientException(
188-
format( "Unsupported transport: '%s' in url: '%s'. Supported transports are: '%s'.",
188+
format( "Unsupported URI scheme: '%s' in url: '%s'. Supported transports are: '%s'.",
189189
uri.getScheme(), uri, connectorSchemes() ) );
190190
}
191191
Connection conn = connector.connect( uri, config, authToken );

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.neo4j.driver.v1.integration;
2020

21+
import org.junit.Ignore;
2122
import org.junit.Rule;
2223
import org.junit.Test;
2324

@@ -34,6 +35,7 @@
3435
import static org.junit.Assert.assertFalse;
3536
import static org.neo4j.driver.v1.Values.parameters;
3637

38+
@Ignore
3739
public class LoadCSVIT
3840
{
3941
@Rule

driver/src/test/java/org/neo4j/driver/v1/tck/DriverAuthSteps.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
import cucumber.api.java.en.And;
2525
import cucumber.api.java.en.Given;
2626
import cucumber.api.java.en.Then;
27-
import cucumber.runtime.CucumberException;
2827

2928
import java.io.File;
29+
import java.io.IOException;
30+
import java.nio.file.Files;
3031

3132
import org.neo4j.driver.internal.auth.InternalAuthToken;
3233
import org.neo4j.driver.v1.Driver;
@@ -43,12 +44,13 @@
4344
public class DriverAuthSteps
4445
{
4546
Driver driver = null;
46-
File tempFile = null;
47+
File tempDir = null;
4748

4849
@Before( "@auth" )
49-
public void setUp()
50+
public void setUp() throws IOException
5051
{
51-
tempFile = new File( "auth" );
52+
tempDir = Files.createTempDirectory("dbms").toFile();
53+
tempDir.deleteOnExit();
5254
}
5355

5456
@After( "@auth" )
@@ -57,14 +59,16 @@ public void reset()
5759

5860
try
5961
{
60-
driver.close();
61-
neo4j.restartServerOnEmptyDatabase( Neo4jSettings.DEFAULT );
62-
tempFile.delete();
62+
if (driver != null)
63+
{
64+
driver.close();
65+
}
66+
neo4j.useDefaultEncryptionKeyAndCert();
6367
}
6468
catch ( Exception e )
6569
{
6670
e.printStackTrace();
67-
throw new CucumberException( "Failed to reset database" );
71+
throw new RuntimeException( "Failed to reset database" );
6872
}
6973
}
7074

@@ -119,7 +123,7 @@ private Driver configureCredentials( String name, String oldPassword, String new
119123
{
120124
neo4j.restartServerOnEmptyDatabase( Neo4jSettings.DEFAULT
121125
.updateWith( Neo4jSettings.AUTH_ENABLED, "true" )
122-
.updateWith( Neo4jSettings.DATA_DIR, tempFile.getAbsolutePath() ) );
126+
.updateWith( Neo4jSettings.DATA_DIR, tempDir.getAbsolutePath().replace("\\", "/") ));
123127

124128
Driver driver = GraphDatabase.driver( neo4j.address(), new InternalAuthToken(
125129
parameters(

driver/src/test/java/org/neo4j/driver/v1/tck/DriverComplianceIT.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@
3232
* The base class to run all cucumber tests
3333
*/
3434
@RunWith( DriverCucumberAdapter.class )
35-
@CucumberOptions( features = {"target/resources/features"}, strict = true, tags = {"~@db",
36-
"~@in_dev"}, format = {"pretty"} )
35+
@CucumberOptions( features = {"target/resources/features"}, strict=true, tags={"~@db"}, format = {"pretty"})
3736
public class DriverComplianceIT
3837
{
3938
@Rule
40-
TemporaryFolder folder = new TemporaryFolder();
39+
TemporaryFolder folder = new TemporaryFolder( );
4140

4241
@ClassRule
4342
public static TestNeo4j neo4j = new TestNeo4j();

driver/src/test/java/org/neo4j/driver/v1/tck/DriverResultApiSteps.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
import org.neo4j.driver.v1.Statement;
3535
import org.neo4j.driver.v1.Value;
36-
import org.neo4j.driver.v1.exceptions.ClientException;
3736
import org.neo4j.driver.v1.summary.InputPosition;
3837
import org.neo4j.driver.v1.summary.Notification;
3938
import org.neo4j.driver.v1.summary.Plan;
@@ -75,15 +74,7 @@ public void theResultCursorIsFullyConsumed() throws Throwable
7574
{
7675
for ( CypherStatementRunner runner : runners )
7776
{
78-
try
79-
{
80-
runner.result().peek();
81-
}
82-
catch ( ClientException e )
83-
{
84-
return;
85-
}
86-
assertThat( runner.result().hasNext(), equalTo( false ) );
77+
assertThat( runner.result().list().isEmpty(), equalTo( true ) );
8778
}
8879
}
8980

driver/src/test/java/org/neo4j/driver/v1/tck/DriverSecurityComplianceSteps.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public void iShouldGetAHelpfulErrorExplainingThatCertificatedNotSigned() throws
246246
assertThat( exception, notNullValue() );
247247
assertThat( exception, instanceOf( ClientException.class ) );
248248
Throwable rootCause = getRootCause( exception );
249-
assertThat( rootCause.toString(), containsString( "No trusted certificate found") );
249+
assertThat( rootCause.toString(), containsString( "Signature does not match.") );
250250
}
251251

252252
@After("@tls")

0 commit comments

Comments
 (0)