Skip to content

Commit

Permalink
Fix smashed imports
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaDemianenko committed Jun 14, 2018
1 parent 1b13daf commit 8a8311a
Show file tree
Hide file tree
Showing 84 changed files with 778 additions and 722 deletions.
Expand Up @@ -19,7 +19,6 @@
*/
package org.neo4j.bolt.runtime.integration;

import org.hamcrest.MatcherAssert;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
Expand All @@ -35,12 +34,7 @@

import org.neo4j.bolt.AbstractBoltTransportsTest;
import org.neo4j.bolt.runtime.BoltConnection;
import org.neo4j.bolt.v1.messaging.message.DiscardAllMessage;
import org.neo4j.bolt.v1.messaging.message.InitMessage;
import org.neo4j.bolt.v1.messaging.message.RunMessage;
import org.neo4j.bolt.v1.messaging.util.MessageMatchers;
import org.neo4j.bolt.v1.transport.integration.Neo4jWithSocket;
import org.neo4j.bolt.v1.transport.integration.TransportTestUtil;
import org.neo4j.bolt.v1.transport.socket.client.TransportConnection;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.kernel.api.exceptions.Status;
Expand All @@ -54,8 +48,14 @@
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.isA;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.neo4j.bolt.v1.messaging.message.DiscardAllMessage.discardAll;
import static org.neo4j.bolt.v1.messaging.message.InitMessage.init;
import static org.neo4j.bolt.v1.messaging.message.RunMessage.run;
import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgFailure;
import static org.neo4j.bolt.v1.messaging.util.MessageMatchers.msgSuccess;
import static org.neo4j.bolt.v1.transport.integration.Neo4jWithSocket.DEFAULT_CONNECTOR_KEY;
import static org.neo4j.bolt.v1.transport.integration.TransportTestUtil.eventuallyReceives;

@RunWith( Parameterized.class )
public class BoltSchedulerShouldReportFailureWhenBusyIT extends AbstractBoltTransportsTest
Expand Down Expand Up @@ -119,8 +119,8 @@ public void shouldReportFailureWhenAllThreadsInThreadPoolAreBusy() throws Throwa
{
connection3 = connectAndPerformBoltHandshake( newConnection() );

connection3.send( util.chunk( InitMessage.init( "TestClient/1.1", emptyMap() ) ) );
MatcherAssert.assertThat( connection3, util.eventuallyReceives(
connection3.send( util.chunk( init( "TestClient/1.1", emptyMap() ) ) );
assertThat( connection3, util.eventuallyReceives(
msgFailure( Status.Request.NoThreadsAvailable, "There are no available threads to serve this request at the moment" ) ) );

userLogProvider.assertContainsMessageContaining(
Expand Down Expand Up @@ -182,27 +182,27 @@ private void enterStreaming( TransportConnection connection, int sleepSeconds )
{
connectAndPerformBoltHandshake( connection );

connection.send( util.chunk( InitMessage.init( "TestClient/1.1", emptyMap() ) ) );
MatcherAssert.assertThat( connection, util.eventuallyReceives( MessageMatchers.msgSuccess() ) );
connection.send( util.chunk( init( "TestClient/1.1", emptyMap() ) ) );
assertThat( connection, util.eventuallyReceives( msgSuccess() ) );

SECONDS.sleep( sleepSeconds ); // sleep a bit to allow worker thread return back to the pool

connection.send( util.chunk( RunMessage.run( "UNWIND RANGE (1, 100) AS x RETURN x" ) ) );
MatcherAssert.assertThat( connection, util.eventuallyReceives( MessageMatchers.msgSuccess() ) );
connection.send( util.chunk( run( "UNWIND RANGE (1, 100) AS x RETURN x" ) ) );
assertThat( connection, util.eventuallyReceives( msgSuccess() ) );
}

private TransportConnection connectAndPerformBoltHandshake( TransportConnection connection ) throws Exception
{
connection.connect( address ).send( util.acceptedVersions( 1, 0, 0, 0 ) );
MatcherAssert.assertThat( connection, TransportTestUtil.eventuallyReceives( new byte[]{0, 0, 0, 1} ) );
assertThat( connection, eventuallyReceives( new byte[]{0, 0, 0, 1} ) );
return connection;
}

private void exitStreaming( TransportConnection connection ) throws Exception
{
connection.send( util.chunk( DiscardAllMessage.discardAll() ) );
connection.send( util.chunk( discardAll() ) );

MatcherAssert.assertThat( connection, util.eventuallyReceives( MessageMatchers.msgSuccess() ) );
assertThat( connection, util.eventuallyReceives( msgSuccess() ) );
}

private void close( TransportConnection connection )
Expand Down
Expand Up @@ -19,21 +19,21 @@
*/
package org.neo4j.bolt.v1.runtime.integration;

import org.hamcrest.MatcherAssert;
import org.junit.Rule;
import org.junit.Test;

import org.neo4j.bolt.AbstractBoltTransportsTest;
import org.neo4j.bolt.v1.messaging.message.InitMessage;
import org.neo4j.bolt.v1.transport.integration.Neo4jWithSocket;
import org.neo4j.bolt.v1.transport.integration.TransportTestUtil;
import org.neo4j.bolt.v1.transport.socket.client.TransportConnection;
import org.neo4j.helpers.HostnamePort;
import org.neo4j.kernel.configuration.BoltConnector;
import org.neo4j.test.rule.SuppressOutput;

import static java.util.Collections.emptyMap;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.neo4j.bolt.v1.transport.integration.Neo4jWithSocket.DEFAULT_CONNECTOR_KEY;
import static org.neo4j.bolt.v1.transport.integration.TransportTestUtil.eventuallyDisconnects;
import static org.neo4j.kernel.configuration.BoltConnector.EncryptionLevel.REQUIRED;

public class BoltConfigIT extends AbstractBoltTransportsTest
Expand Down Expand Up @@ -70,14 +70,14 @@ private void assertConnectionRejected( HostnamePort address, TransportConnection
client.connect( address )
.send( util.defaultAcceptedVersions() );

MatcherAssert.assertThat( client, TransportTestUtil.eventuallyDisconnects() );
assertThat( client, eventuallyDisconnects() );
}

private void assertConnectionAccepted( HostnamePort address, TransportConnection client ) throws Exception
{
client.connect( address )
.send( util.defaultAcceptedVersions() )
.send( util.chunk( InitMessage.init( "TestClient/1.1", emptyMap() ) ) );
MatcherAssert.assertThat( client, util.eventuallyReceivesSelectedProtocolVersion() );
assertThat( client, util.eventuallyReceivesSelectedProtocolVersion() );
}
}
Expand Up @@ -19,20 +19,21 @@
*/
package org.neo4j.bolt.v1.runtime.integration;

import org.hamcrest.MatcherAssert;
import org.junit.Rule;
import org.junit.Test;

import org.neo4j.bolt.BoltChannel;
import org.neo4j.bolt.testing.BoltMatchers;
import org.neo4j.bolt.testing.BoltResponseRecorder;
import org.neo4j.bolt.v1.runtime.BoltStateMachine;
import org.neo4j.kernel.api.exceptions.Status;
import org.neo4j.kernel.internal.Version;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;
import static org.neo4j.bolt.testing.BoltMatchers.failedWithStatus;
import static org.neo4j.bolt.testing.BoltMatchers.succeeded;
import static org.neo4j.bolt.testing.BoltMatchers.succeededWithMetadata;
import static org.neo4j.bolt.testing.BoltMatchers.verifyKillsConnection;
import static org.neo4j.helpers.collection.MapUtil.map;
import static org.neo4j.values.storable.Values.TRUE;
import static org.neo4j.values.storable.Values.stringValue;
Expand Down Expand Up @@ -62,8 +63,8 @@ public void shouldGiveCredentialsExpiredStatusOnExpiredCredentials() throws Thro
machine.run( "CREATE ()", EMPTY_MAP, recorder );

// Then
MatcherAssert.assertThat( recorder.nextResponse(), succeededWithMetadata( "credentials_expired", TRUE ) );
MatcherAssert.assertThat( recorder.nextResponse(), failedWithStatus( Status.Security.CredentialsExpired ) );
assertThat( recorder.nextResponse(), succeededWithMetadata( "credentials_expired", TRUE ) );
assertThat( recorder.nextResponse(), failedWithStatus( Status.Security.CredentialsExpired ) );
}

@Test
Expand All @@ -82,7 +83,7 @@ public void shouldGiveKernelVersionOnInit() throws Throwable
machine.run( "CREATE ()", EMPTY_MAP, recorder );

// Then
MatcherAssert.assertThat( recorder.nextResponse(), succeededWithMetadata( "server", stringValue( version ) ) );
assertThat( recorder.nextResponse(), succeededWithMetadata( "server", stringValue( version ) ) );
}

@Test
Expand All @@ -93,14 +94,14 @@ public void shouldCloseConnectionAfterAuthenticationFailure() throws Throwable

// When... then
BoltResponseRecorder recorder = new BoltResponseRecorder();
BoltMatchers.verifyKillsConnection( () -> machine.init( USER_AGENT, map(
verifyKillsConnection( () -> machine.init( USER_AGENT, map(
"scheme", "basic",
"principal", "neo4j",
"credentials", "j4oen"
), recorder ) );

// ...and
MatcherAssert.assertThat( recorder.nextResponse(), failedWithStatus( Status.Security.Unauthorized ) );
assertThat( recorder.nextResponse(), failedWithStatus( Status.Security.Unauthorized ) );
}

@Test
Expand All @@ -119,7 +120,7 @@ public void shouldBeAbleToActOnSessionWhenUpdatingCredentials() throws Throwable
machine.run( "CREATE ()", EMPTY_MAP, recorder );

// then
MatcherAssert.assertThat( recorder.nextResponse(), BoltMatchers.succeeded() );
MatcherAssert.assertThat( recorder.nextResponse(), BoltMatchers.succeeded() );
assertThat( recorder.nextResponse(), succeeded() );
assertThat( recorder.nextResponse(), succeeded() );
}
}
Expand Up @@ -20,7 +20,6 @@
package org.neo4j.bolt.v1.runtime.integration;

import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;

Expand All @@ -29,7 +28,6 @@
import java.util.concurrent.atomic.AtomicReference;

import org.neo4j.bolt.BoltChannel;
import org.neo4j.bolt.testing.BoltMatchers;
import org.neo4j.bolt.testing.BoltResponseRecorder;
import org.neo4j.bolt.testing.RecordedBoltResponse;
import org.neo4j.bolt.v1.messaging.BoltResponseMessage;
Expand All @@ -54,6 +52,7 @@
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.neo4j.bolt.testing.BoltMatchers.failedWithStatus;
import static org.neo4j.bolt.testing.BoltMatchers.succeeded;
import static org.neo4j.bolt.testing.BoltMatchers.verifyKillsConnection;
import static org.neo4j.bolt.testing.NullResponseHandler.nullResponseHandler;
import static org.neo4j.bolt.v1.messaging.BoltResponseMessage.IGNORED;
Expand Down Expand Up @@ -152,7 +151,7 @@ public void shouldExecuteStatement() throws Throwable
machine.run( "CREATE (n {k:'k'}) RETURN n.k", EMPTY_PARAMS, recorder );

// Then
assertThat( recorder.nextResponse(), BoltMatchers.succeeded() );
assertThat( recorder.nextResponse(), succeeded() );

// When
recorder.reset();
Expand All @@ -179,7 +178,7 @@ public void shouldSucceedOn__run__pullAll__run() throws Throwable
machine.run( "RETURN 1", EMPTY_PARAMS, recorder );

// Then
assertThat( recorder.nextResponse(), BoltMatchers.succeeded() );
assertThat( recorder.nextResponse(), succeeded() );
}

@Test
Expand All @@ -198,7 +197,7 @@ public void shouldSucceedOn__run__discardAll__run() throws Throwable
machine.run( "RETURN 1", EMPTY_PARAMS, recorder );

// Then
assertThat( recorder.nextResponse(), BoltMatchers.succeeded() );
assertThat( recorder.nextResponse(), succeeded() );
}

@Test
Expand All @@ -214,17 +213,17 @@ public void shouldSucceedOn__run_BEGIN__pullAll__run_COMMIT__pullALL__run_COMMIT
machine.pullAll( recorder );
machine.run( "COMMIT", EMPTY_PARAMS, recorder );
machine.pullAll( recorder );
assertThat( recorder.nextResponse(), BoltMatchers.succeeded() );
assertThat( recorder.nextResponse(), BoltMatchers.succeeded() );
assertThat( recorder.nextResponse(), BoltMatchers.succeeded() );
assertThat( recorder.nextResponse(), BoltMatchers.succeeded() );
assertThat( recorder.nextResponse(), succeeded() );
assertThat( recorder.nextResponse(), succeeded() );
assertThat( recorder.nextResponse(), succeeded() );
assertThat( recorder.nextResponse(), succeeded() );

// When I run a new statement
recorder.reset();
machine.run( "BEGIN", EMPTY_PARAMS, recorder );

// Then
assertThat( recorder.nextResponse(), BoltMatchers.succeeded() );
assertThat( recorder.nextResponse(), succeeded() );
}

@Test
Expand Down Expand Up @@ -334,7 +333,7 @@ public void shouldHandleImplicitCommitFailure() throws Throwable
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.run( "MATCH (n:Victim) DELETE n", EMPTY_PARAMS, recorder );
// Then the statement running should have succeeded
assertThat( recorder.nextResponse(), BoltMatchers.succeeded() );
assertThat( recorder.nextResponse(), succeeded() );

recorder.reset();
machine.discardAll( recorder );
Expand Down Expand Up @@ -373,8 +372,8 @@ public void shouldAllowUserControlledRollbackOnExplicitTxFailure() throws Throwa
machine.run( "ROLLBACK", EMPTY_PARAMS, recorder );

// Then both operations should succeed
assertThat( recorder.nextResponse(), BoltMatchers.succeeded() );
assertThat( recorder.nextResponse(), BoltMatchers.succeeded() );
assertThat( recorder.nextResponse(), succeeded() );
assertThat( recorder.nextResponse(), succeeded() );
}

@Test
Expand Down Expand Up @@ -637,7 +636,7 @@ private Record[] runAndPull( BoltStateMachine machine, String statement, MapValu
machine.run( statement, params, nullResponseHandler() );
machine.pullAll( recorder );
RecordedBoltResponse response = recorder.nextResponse();
Assert.assertEquals( expectedResponse, response.message() );
assertEquals( expectedResponse, response.message() );
return response.records();
}

Expand Down

0 comments on commit 8a8311a

Please sign in to comment.