ShardingCTLShowBackendHandler implements TextProtocolBackendHandler { @Override public BackendResponse execute() { Optional<ShardingCTLShowStatement> showStatement = new ShardingCTLShowParser(sql).doParse(); if (!showStatement.isPresent()) { throw new InvalidShardingCTLFormatException(sql); } switch (showStatement.get().getValue()) { case "TRANSACTION_TYPE": return createResponsePackets("TRANSACTION_TYPE", backendConnection.getTransactionStatus().getTransactionType().name()); case "CACHED_CONNECTIONS": return createResponsePackets("CACHED_CONNECTIONS", backendConnection.getConnectionSize()); default: throw new UnsupportedShardingCTLTypeException(sql); } } ShardingCTLShowBackendHandler(final String sql, final BackendConnection backendConnection); @Override BackendResponse execute(); @Override boolean next(); @Override QueryData getQueryData();  }
@Test(expected = UnsupportedShardingCTLTypeException.class) public void assertShowCachedConnectionFailed() { backendConnection.setCurrentSchema("schema"); new ShardingCTLShowBackendHandler("sctl:show cached_connectionss", backendConnection).execute(); }
@Test(expected = InvalidShardingCTLFormatException.class) public void assertShowCTLFormatError() { backendConnection.setCurrentSchema("schema"); new ShardingCTLShowBackendHandler("sctl:show=xx", backendConnection).execute(); }