Search in sources :

Example 1 with AbstractClient

use of org.neo4j.shell.impl.AbstractClient in project neo4j by neo4j.

the class CtrlCTest method shouldInstallProvidedHandlerAfterReadingUserInput.

@Test
public void shouldInstallProvidedHandlerAfterReadingUserInput() throws Exception {
    final StubCtrlCHandler handler = new StubCtrlCHandler();
    AbstractClient client = new AbstractClient(new HashMap<String, Serializable>(), handler) {

        @Override
        public ShellServer getServer() {
            try {
                return new FakeShellServer(null);
            } catch (RemoteException e) {
                throw new RuntimeException(e);
            }
        }

        @Override
        public Output getOutput() {
            try {
                return new CollectingOutput();
            } catch (RemoteException e) {
                throw new RuntimeException(e);
            }
        }

        @Override
        public String readLine(String ignored) {
            assertFalse("handler installed, expected it to not be there", handler.installed);
            return "CYPHER 2.1 RETURN 42;";
        }

        @Override
        public void evaluate(String output) {
            assertTrue("handler not installed, but expected to be there", handler.installed);
            end();
        }
    };
    client.grabPrompt();
    assertFalse("handler installed, expected it to not be there", handler.installed);
}
Also used : Serializable(java.io.Serializable) AbstractClient(org.neo4j.shell.impl.AbstractClient) CollectingOutput(org.neo4j.shell.impl.CollectingOutput) RemoteException(java.rmi.RemoteException) Test(org.junit.Test)

Aggregations

Serializable (java.io.Serializable)1 RemoteException (java.rmi.RemoteException)1 Test (org.junit.Test)1 AbstractClient (org.neo4j.shell.impl.AbstractClient)1 CollectingOutput (org.neo4j.shell.impl.CollectingOutput)1