DebuggerSessionImpl implements IDebuggerSession { @Override public void handleInterrupt(final IMessageProcessor messageProcessor) throws InterruptProcessingException { if (messageProcessor != processor || !isRunning()) { return; } try { if (prePaused || sequence.getCurrentLevel() <= stepModeMaxDepth || sequence.isCompleted() || breakpointsStorage.shouldBreakAt(sequence)) { pauseProcessor(); } else if (sequence.getException() != null) { if (breakOnException) { pauseProcessor(); } else if (!sequence.processException()) { pauseProcessor(); } } } catch (AsynchronousOperationException | BreakpointStorageException e) { throw new InterruptProcessingException("Error occurred pausing processing of debuggable message.", e); } } DebuggerSessionImpl(final String id, final Object debuggerAddress); @Override void handleInterrupt(final IMessageProcessor messageProcessor); @Override Object executeCommand(final String name, final Object args); @Override void close();  }
@Test public void Should_pauseMessageProcessingWhenStepModeIsEnabled() throws Exception { Should_startDebugging(); c("stepMode", "all"); session.handleInterrupt(messageProcessorMock); verify(messageProcessorMock).pauseProcess(); assertEquals(true, c("isPaused", null)); assertEquals(false, c("isRunning", null)); }
@Test public void Should_notPauseMessageProcessingWhenStepModeIsDisabled() throws Exception { Should_startDebugging(); c("stepMode", "none"); session.handleInterrupt(messageProcessorMock); verify(messageProcessorMock, never()).pauseProcess(); assertEquals(false, c("isPaused", null)); assertEquals(true, c("isRunning", null)); }
@Test public void Should_createStackTrace() throws Exception { Should_startDebugging(); Object dump = new Object(); IObject dumpOptions = mock(IObject.class); session.handleInterrupt(messageProcessorMock); when(sequenceDumpStrategyMock.resolve(same(debuggerSequenceMock), same(dumpOptions))).thenReturn(dump); Object trace = c("getStackTrace", dumpOptions); assertSame(dump, trace); }
@Test public void Should_pauseMessageProcessingAfterPauseCommand() throws Exception { Should_startDebugging(); assertEquals(false, c("isPaused", null)); assertEquals(true, c("isRunning", null)); assertEquals(true, c("pause", null)); assertEquals(false, c("isPaused", null)); assertEquals(true, c("isRunning", null)); session.handleInterrupt(messageProcessorMock); verify(messageProcessorMock).pauseProcess(); reset(messageProcessorMock); assertEquals(true, c("isPaused", null)); assertEquals(false, c("isRunning", null)); assertEquals("OK", c("continue", null)); assertEquals(false, c("isPaused", null)); assertEquals(true, c("isRunning", null)); }
@Test public void Should_callChainOnCallCommand() throws Exception { Should_startDebugging(); c("pause", null); session.handleInterrupt(messageProcessorMock); IReceiverChain chainMock = mock(IReceiverChain.class); when(chainStorageMock.resolve(eq("chainName__id"))).thenReturn(chainMock); c("call", "chainName"); verify(debuggerSequenceMock).callChain(chainMock); }