[Test] Add unit tests for StoreType.fromString tolerant parsing contract
Description
store/src/main/java/org/apache/rocketmq/store/StoreType.java's tolerant parsing has no direct unit test:
public static Set<StoreType> fromString(String str) {
if (str == null || str.trim().isEmpty()) {
return Collections.emptySet();
}
return Arrays.stream(str.split(";"))
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(s -> Arrays.stream(StoreType.values())
.filter(type -> type.getStoreType().equalsIgnoreCase(s))
.findFirst()
.orElse(null))
.filter(Objects::nonNull)
.collect(Collectors.toSet());
}fromString is the parsing path behind the storeType broker configuration (used by CombineConsumeQueueStore to select the consume-queue implementation), and its behavior is full of deliberate edge cases that nothing currently pins down:
null/ empty string / all-whitespace input → empty set- case-insensitive matching (
DEFAULT,default,DefaultRocksDB, ...) - surrounding whitespace trimmed per segment
- empty segments between semicolons skipped (
"default;;rocksdb") - duplicate entries deduplicated by the returned
Set - unknown tokens silently dropped (
"default;unknown"→{default})
There is no StoreTypeTest in the repo, and no existing test calls fromString directly. A future refactor of this method (e.g. switching to an enum valueOf or changing separator handling) would silently change broker store-type parsing with no failing test.
Expected behavior
Add a StoreTypeTest covering the behaviors above so the parsing contract is locked (e.g. " default ; DEFAULTROCKSDB;default;unknown;; " → {DEFAULT, DEFAULTROCKSDB}).
Source: apache/rocketmq