test_class.file: dubbo-plugin/dubbo-qos/src/test/java/org/apache/dubbo/qos/server/handler/TelnetProcessHandlerTest.java
test_class.identifier: TelnetProcessHandlerTest
test_case.body: @Test
      public void testBye() throws Exception {
          ChannelHandlerContext context = mock(ChannelHandlerContext.class);
          TelnetProcessHandler handler = new TelnetProcessHandler();
          ChannelFuture future = mock(ChannelFuture.class);
          when(context.writeAndFlush("BYE!\n")).thenReturn(future);
          handler.channelRead0(context, "quit");
          verify(future).addListener(ChannelFutureListener.CLOSE);
      }
test_case.class_method_signature: TelnetProcessHandlerTest.testBye()
test_case.full_signature: @Test public void testBye()
test_case.identifier: testBye
test_case.invocations: mock mock thenReturn when writeAndFlush channelRead0 addListener verify
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testBye()
focal_class.declarator: log = LoggerFactory.getLogger(TelnetProcessHandler.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = LoggerFactory.getLogger(TelnetProcessHandler.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: commandExecutor = new DefaultCommandExecutor()
focal_class.modifier: private static
focal_class.original_string: private static CommandExecutor commandExecutor = new DefaultCommandExecutor();
focal_class.type: CommandExecutor
focal_class.var_name: commandExecutor
focal_class.file: dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/server/handler/TelnetProcessHandler.java
focal_class.identifier: TelnetProcessHandler
focal_class.class_method_signature: TelnetProcessHandler.channelRead0(ChannelHandlerContext ctx, String msg)
focal_class.full_signature: @Override protected void channelRead0(ChannelHandlerContext ctx, String msg)
focal_class.identifier: channelRead0
focal_class.modifiers: @Override protected
focal_class.parameters: (ChannelHandlerContext ctx, String msg)
focal_class.return: void
focal_class.signature: void channelRead0(ChannelHandlerContext ctx, String msg)
focal_class.class_method_signature: TelnetProcessHandler.getByeLabel()
focal_class.full_signature: private String getByeLabel()
focal_class.identifier: getByeLabel
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getByeLabel()
focal_class.superclass: extends SimpleChannelInboundHandler<String>
focal_method.body: @Override
      protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
  
          if (StringUtils.isBlank(msg)) {
              ctx.writeAndFlush(QosProcessHandler.PROMPT);
          } else {
              CommandContext commandContext = TelnetCommandDecoder.decode(msg);
              commandContext.setRemote(ctx.channel());
  
              try {
                  String result = commandExecutor.execute(commandContext);
                  if (StringUtils.isEquals(QosConstants.CLOSE, result)) {
                      ctx.writeAndFlush(getByeLabel()).addListener(ChannelFutureListener.CLOSE);
                  } else {
                      ctx.writeAndFlush(result + QosConstants.BR_STR + QosProcessHandler.PROMPT);
                  }
              } catch (NoSuchCommandException ex) {
                  ctx.writeAndFlush(msg + " :no such command");
                  ctx.writeAndFlush(QosConstants.BR_STR + QosProcessHandler.PROMPT);
                  log.error("can not found command " + commandContext, ex);
              } catch (Exception ex) {
                  ctx.writeAndFlush(msg + " :fail to execute commandContext by " + ex.getMessage());
                  ctx.writeAndFlush(QosConstants.BR_STR + QosProcessHandler.PROMPT);
                  log.error("execute commandContext got exception " + commandContext, ex);
              }
          }
      }
focal_method.class_method_signature: TelnetProcessHandler.channelRead0(ChannelHandlerContext ctx, String msg)
focal_method.full_signature: @Override protected void channelRead0(ChannelHandlerContext ctx, String msg)
focal_method.identifier: channelRead0
focal_method.invocations: isBlank writeAndFlush decode setRemote channel execute isEquals addListener writeAndFlush getByeLabel writeAndFlush writeAndFlush writeAndFlush error writeAndFlush getMessage writeAndFlush error
focal_method.modifiers: @Override protected
focal_method.parameters: (ChannelHandlerContext ctx, String msg)
focal_method.return: void
focal_method.signature: void channelRead0(ChannelHandlerContext ctx, String msg)