@@ -329,6 +329,31 @@ Found problem:
329
329
" Failed to find content in output: " + stream.toString())
330
330
}
331
331
332
+ @ Test
333
+ def testFormatWithInvalidFeature (): Unit = {
334
+ val availableDirs = Seq (TestUtils .tempDir())
335
+ val properties = new Properties ()
336
+ properties.putAll(defaultStaticQuorumProperties)
337
+ properties.setProperty(" log.dirs" , availableDirs.mkString(" ," ))
338
+ assertEquals(" Unsupported feature: non.existent.feature. Supported features are: " +
339
+ " group.version, kraft.version, transaction.version" ,
340
+ assertThrows(classOf [FormatterException ], () =>
341
+ runFormatCommand(new ByteArrayOutputStream (), properties,
342
+ Seq (" --feature" , " non.existent.feature=20" ))).getMessage)
343
+ }
344
+
345
+ @ Test
346
+ def testFormatWithInvalidKRaftVersionLevel (): Unit = {
347
+ val availableDirs = Seq (TestUtils .tempDir())
348
+ val properties = new Properties ()
349
+ properties.putAll(defaultDynamicQuorumProperties)
350
+ properties.setProperty(" log.dirs" , availableDirs.mkString(" ," ))
351
+ assertEquals(" No feature:kraft.version with feature level 999" ,
352
+ assertThrows(classOf [IllegalArgumentException ], () =>
353
+ runFormatCommand(new ByteArrayOutputStream (), properties,
354
+ Seq (" --feature" , " kraft.version=999" , " --standalone" ))).getMessage)
355
+ }
356
+
332
357
@ Test
333
358
def testFormatWithReleaseVersionAndKRaftVersion (): Unit = {
334
359
val availableDirs = Seq (TestUtils .tempDir())
@@ -532,4 +557,25 @@ Found problem:
532
557
" SCRAM is only supported in metadata.version 3.5-IV2 or later." ,
533
558
assertThrows(classOf [FormatterException ], () => runFormatCommand(stream, properties, arguments.toSeq)).getMessage)
534
559
}
560
+
561
+ @ Test
562
+ def testParseNameAndLevel (): Unit = {
563
+ assertEquals((" foo.bar" , 56 .toShort), StorageTool .parseNameAndLevel(" foo.bar=56" ))
564
+ }
565
+
566
+ @ Test
567
+ def testParseNameAndLevelWithNoEquals (): Unit = {
568
+ assertEquals(" Can't parse feature=level string kraft.version5: equals sign not found." ,
569
+ assertThrows(classOf [RuntimeException ],
570
+ () => StorageTool .parseNameAndLevel(" kraft.version5" )).
571
+ getMessage)
572
+ }
573
+
574
+ @ Test
575
+ def testParseNameAndLevelWithNoNumber (): Unit = {
576
+ assertEquals(" Can't parse feature=level string kraft.version=foo: unable to parse foo as a short." ,
577
+ assertThrows(classOf [RuntimeException ],
578
+ () => StorageTool .parseNameAndLevel(" kraft.version=foo" )).
579
+ getMessage)
580
+ }
535
581
}
0 commit comments