@Test public void testTopicValidator_NotPass() { RemotingCommand response = RemotingCommand.createResponseCommand(-1, ""); Boolean res = TopicValidator.validateTopic("", response); assertThat(res).isFalse(); assertThat(response.getCode()).isEqualTo(ResponseCode.SYSTEM_ERROR); assertThat(response.getRemark()).contains("The specified topic is blank"); clearResponse(response); res = TopicValidator.validateTopic("../TopicTest", response); assertThat(res).isFalse(); assertThat(response.getCode()).isEqualTo(ResponseCode.SYSTEM_ERROR); assertThat(response.getRemark()).contains("The specified topic contains illegal characters"); clearResponse(response); res = TopicValidator.validateTopic(generateString(128), response); assertThat(res).isFalse(); assertThat(response.getCode()).isEqualTo(ResponseCode.SYSTEM_ERROR); assertThat(response.getRemark()).contains("The specified topic is longer than topic max length."); }
public static boolean validateTopic(String topic, RemotingCommand response) { if (UtilAll.isBlank(topic)) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("The specified topic is blank."); return false; } if (!regularExpressionMatcher(topic, PATTERN)) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("The specified topic contains illegal characters, allowing only " + VALID_PATTERN_STR); return false; } if (topic.length() > TOPIC_MAX_LENGTH) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("The specified topic is longer than topic max length."); return false; } return true; }
TopicValidator { public static boolean validateTopic(String topic, RemotingCommand response) { if (UtilAll.isBlank(topic)) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("The specified topic is blank."); return false; } if (!regularExpressionMatcher(topic, PATTERN)) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("The specified topic contains illegal characters, allowing only " + VALID_PATTERN_STR); return false; } if (topic.length() > TOPIC_MAX_LENGTH) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("The specified topic is longer than topic max length."); return false; } return true; } }
TopicValidator { public static boolean validateTopic(String topic, RemotingCommand response) { if (UtilAll.isBlank(topic)) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("The specified topic is blank."); return false; } if (!regularExpressionMatcher(topic, PATTERN)) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("The specified topic contains illegal characters, allowing only " + VALID_PATTERN_STR); return false; } if (topic.length() > TOPIC_MAX_LENGTH) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("The specified topic is longer than topic max length."); return false; } return true; }  }
TopicValidator { public static boolean validateTopic(String topic, RemotingCommand response) { if (UtilAll.isBlank(topic)) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("The specified topic is blank."); return false; } if (!regularExpressionMatcher(topic, PATTERN)) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("The specified topic contains illegal characters, allowing only " + VALID_PATTERN_STR); return false; } if (topic.length() > TOPIC_MAX_LENGTH) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("The specified topic is longer than topic max length."); return false; } return true; }  static boolean validateTopic(String topic, RemotingCommand response); static boolean isSystemTopic(String topic, RemotingCommand response); static boolean isSystemTopic(String topic); static boolean isNotAllowedSendTopic(String topic); static boolean isNotAllowedSendTopic(String topic, RemotingCommand response); static void addSystemTopic(String systemTopic); static Set<String> getSystemTopicSet(); static Set<String> getNotAllowedSendTopicSet(); }
TopicValidator { public static boolean validateTopic(String topic, RemotingCommand response) { if (UtilAll.isBlank(topic)) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("The specified topic is blank."); return false; } if (!regularExpressionMatcher(topic, PATTERN)) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("The specified topic contains illegal characters, allowing only " + VALID_PATTERN_STR); return false; } if (topic.length() > TOPIC_MAX_LENGTH) { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark("The specified topic is longer than topic max length."); return false; } return true; }  static boolean validateTopic(String topic, RemotingCommand response); static boolean isSystemTopic(String topic, RemotingCommand response); static boolean isSystemTopic(String topic); static boolean isNotAllowedSendTopic(String topic); static boolean isNotAllowedSendTopic(String topic, RemotingCommand response); static void addSystemTopic(String systemTopic); static Set<String> getSystemTopicSet(); static Set<String> getNotAllowedSendTopicSet(); static final String AUTO_CREATE_TOPIC_KEY_TOPIC; static final String RMQ_SYS_SCHEDULE_TOPIC; static final String RMQ_SYS_BENCHMARK_TOPIC; static final String RMQ_SYS_TRANS_HALF_TOPIC; static final String RMQ_SYS_TRACE_TOPIC; static final String RMQ_SYS_TRANS_OP_HALF_TOPIC; static final String RMQ_SYS_TRANS_CHECK_MAX_TIME_TOPIC; static final String RMQ_SYS_SELF_TEST_TOPIC; static final String RMQ_SYS_OFFSET_MOVED_EVENT; static final String SYSTEM_TOPIC_PREFIX; }