Search in sources :

Example 1 with FakeDriver

use of org.neo4j.shell.test.bolt.FakeDriver in project neo4j by neo4j.

the class BoltStateHandlerTest method serverVersionIsNotEmptyAfterConnect.

@Test
public void serverVersionIsNotEmptyAfterConnect() throws CommandException {
    Driver fakeDriver = new FakeDriver();
    BoltStateHandler handler = new BoltStateHandler((s, authToken, config) -> fakeDriver, false);
    handler.connect(config);
    assertEquals("4.3.0", handler.getServerVersion());
}
Also used : Driver(org.neo4j.driver.Driver) FakeDriver(org.neo4j.shell.test.bolt.FakeDriver) FakeDriver(org.neo4j.shell.test.bolt.FakeDriver) Test(org.junit.Test)

Example 2 with FakeDriver

use of org.neo4j.shell.test.bolt.FakeDriver in project neo4j by neo4j.

the class BoltStateHandlerTest method fallbackTest.

private void fallbackTest(String initialScheme, String fallbackScheme, Runnable failer) throws CommandException {
    final String[] uriScheme = new String[1];
    RecordingDriverProvider provider = new RecordingDriverProvider() {

        @Override
        public Driver apply(String uri, AuthToken authToken, Config config) {
            uriScheme[0] = uri.substring(0, uri.indexOf(':'));
            if (uriScheme[0].equals(initialScheme)) {
                failer.run();
            }
            super.apply(uri, authToken, config);
            return new FakeDriver();
        }
    };
    BoltStateHandler handler = new BoltStateHandler(provider, false);
    ConnectionConfig config = new ConnectionConfig(initialScheme, "", -1, "", "", Encryption.DEFAULT, ABSENT_DB_NAME);
    handler.connect(config);
    assertEquals(fallbackScheme, uriScheme[0]);
}
Also used : ConnectionConfig(org.neo4j.shell.ConnectionConfig) Config(org.neo4j.driver.Config) SessionConfig(org.neo4j.driver.SessionConfig) AuthToken(org.neo4j.driver.AuthToken) FakeDriver(org.neo4j.shell.test.bolt.FakeDriver) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ConnectionConfig(org.neo4j.shell.ConnectionConfig)

Aggregations

FakeDriver (org.neo4j.shell.test.bolt.FakeDriver)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 AuthToken (org.neo4j.driver.AuthToken)1 Config (org.neo4j.driver.Config)1 Driver (org.neo4j.driver.Driver)1 SessionConfig (org.neo4j.driver.SessionConfig)1 ConnectionConfig (org.neo4j.shell.ConnectionConfig)1