Search in sources :

Example 1 with MockEventListener

use of com.google.security.zynamics.binnavi.Debug.Debugger.MockEventListener in project binnavi by google.

the class CAbstractConnectionTest method reconnect.

@Test
public void reconnect() throws DebugExceptionWrapper {
    // This test makes sure that consecutive runs of the debugger still receive messages
    final DebugCommand command = new DebugCommand(DebugCommandType.RESP_INFO, 0);
    command.addArgument(new DebugMessageRawArgument("<info><registers></registers><size>32</size><options></options></info>".getBytes()));
    final MockDebugger debugger = new MockDebugger(new byte[][] { "NAVI".getBytes(), command.toByteArray() });
    final MockEventListener listener = new MockEventListener();
    debugger.addListener(listener);
    debugger.connect();
    debugger.connection.m_reader.next();
    debugger.connection.m_reader.next();
    debugger.close();
    assertEquals("RECEIVED_TARGET_INFORMATION;", listener.events);
    debugger.connect();
    debugger.connection.m_reader.next();
    debugger.connection.m_reader.next();
    debugger.close();
    assertEquals("RECEIVED_TARGET_INFORMATION;RECEIVED_TARGET_INFORMATION;", listener.events);
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) DebugMessageRawArgument(com.google.security.zynamics.binnavi.debug.connection.packets.arguments.DebugMessageRawArgument) MockEventListener(com.google.security.zynamics.binnavi.Debug.Debugger.MockEventListener) DebugCommand(com.google.security.zynamics.binnavi.debug.connection.packets.commands.DebugCommand) Test(org.junit.Test)

Aggregations

MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)1 MockEventListener (com.google.security.zynamics.binnavi.Debug.Debugger.MockEventListener)1 DebugMessageRawArgument (com.google.security.zynamics.binnavi.debug.connection.packets.arguments.DebugMessageRawArgument)1 DebugCommand (com.google.security.zynamics.binnavi.debug.connection.packets.commands.DebugCommand)1 Test (org.junit.Test)1