1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.protolog.tool 18 19 import com.google.common.truth.Truth.assertThat 20 import org.junit.Assert.assertEquals 21 import org.junit.Assert.assertThrows 22 import org.junit.Test 23 24 class CommandOptionsTest { 25 companion object { 26 val TEST_JAVA_SRC = listOf( 27 "frameworks/base/services/core/java/com/android/server/wm/" + 28 "AccessibilityController.java", 29 "frameworks/base/services/core/java/com/android/server/wm/ActivityDisplay.java", 30 "frameworks/base/services/core/java/com/android/server/wm/" + 31 "ActivityMetricsLaunchObserver.java" 32 ) 33 private const val TEST_PROTOLOG_CLASS = "com.android.server.wm.ProtoLog" 34 private const val TEST_PROTOLOGIMPL_CLASS = "com.android.server.wm.ProtoLogImpl" 35 private const val TEST_PROTOLOGCACHE_CLASS = "com.android.server.wm.ProtoLog\$Cache" 36 private const val TEST_PROTOLOGGROUP_CLASS = "com.android.internal.protolog.ProtoLogGroup" 37 private const val TEST_PROTOLOGGROUP_JAR = "out/soong/.intermediates/frameworks/base/" + 38 "services/core/services.core.wm.protologgroups/android_common/javac/" + 39 "services.core.wm.protologgroups.jar" 40 private const val TEST_VIEWER_CONFIG_FILE_PATH = "/some/viewer/config/file/path.pb" 41 private const val TEST_LEGACY_VIEWER_CONFIG_FILE_PATH = 42 "/some/viewer/config/file/path.json.gz" 43 private const val TEST_LEGACY_OUTPUT_FILE_PATH = "/some/output/file/path.winscope" 44 private const val TEST_SRC_JAR = "out/soong/.temp/sbox175955373/" + 45 "services.core.wm.protolog.srcjar" 46 private const val TEST_VIEWER_JSON = "out/soong/.temp/sbox175955373/" + 47 "services.core.wm.protolog.json" 48 private const val TEST_LOG = "./test_log.pb" 49 } 50 51 @Test noCommandnull52 fun noCommand() { 53 val exception = assertThrows<InvalidCommandException>(InvalidCommandException::class.java) { 54 CommandOptions(arrayOf()) 55 } 56 assertThat(exception).hasMessageThat().contains("No command specified") 57 } 58 59 @Test invalidCommandnull60 fun invalidCommand() { 61 val testLine = "invalid" 62 val exception = assertThrows<InvalidCommandException>(InvalidCommandException::class.java) { 63 CommandOptions(testLine.split(' ').toTypedArray()) 64 } 65 assertThat(exception).hasMessageThat().contains("Unknown command") 66 } 67 68 @Test transformClassesnull69 fun transformClasses() { 70 val testLine = "transform-protolog-calls " + 71 "--protolog-class $TEST_PROTOLOG_CLASS " + 72 "--loggroups-class $TEST_PROTOLOGGROUP_CLASS " + 73 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 74 "--viewer-config-file-path $TEST_VIEWER_CONFIG_FILE_PATH " + 75 "--legacy-viewer-config-file-path $TEST_LEGACY_VIEWER_CONFIG_FILE_PATH " + 76 "--legacy-output-file-path $TEST_LEGACY_OUTPUT_FILE_PATH " + 77 "--output-srcjar $TEST_SRC_JAR ${TEST_JAVA_SRC.joinToString(" ")}" 78 val cmd = CommandOptions(testLine.split(' ').toTypedArray()) 79 assertEquals(CommandOptions.TRANSFORM_CALLS_CMD, cmd.command) 80 assertEquals(TEST_PROTOLOG_CLASS, cmd.protoLogClassNameArg) 81 assertEquals(TEST_PROTOLOGGROUP_CLASS, cmd.protoLogGroupsClassNameArg) 82 assertEquals(TEST_PROTOLOGGROUP_JAR, cmd.protoLogGroupsJarArg) 83 assertEquals(TEST_VIEWER_CONFIG_FILE_PATH, cmd.viewerConfigFilePathArg) 84 assertEquals(TEST_LEGACY_VIEWER_CONFIG_FILE_PATH, cmd.legacyViewerConfigFilePathArg) 85 assertEquals(TEST_LEGACY_OUTPUT_FILE_PATH, cmd.legacyOutputFilePath) 86 assertEquals(TEST_SRC_JAR, cmd.outputSourceJarArg) 87 assertEquals(TEST_JAVA_SRC, cmd.javaSourceArgs) 88 } 89 90 @Test transformClasses_noViewerConfigFilenull91 fun transformClasses_noViewerConfigFile() { 92 val testLine = "transform-protolog-calls " + 93 "--protolog-class $TEST_PROTOLOG_CLASS " + 94 "--loggroups-class $TEST_PROTOLOGGROUP_CLASS " + 95 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 96 "--legacy-viewer-config-file-path $TEST_LEGACY_VIEWER_CONFIG_FILE_PATH " + 97 "--legacy-output-file-path $TEST_LEGACY_OUTPUT_FILE_PATH " + 98 "--output-srcjar $TEST_SRC_JAR ${TEST_JAVA_SRC.joinToString(" ")}" 99 val exception = assertThrows<InvalidCommandException>(InvalidCommandException::class.java) { 100 CommandOptions(testLine.split(' ').toTypedArray()) 101 } 102 assertThat(exception).hasMessageThat().contains("--viewer-config-file-path") 103 } 104 105 @Test transformClasses_noLegacyViewerConfigFilenull106 fun transformClasses_noLegacyViewerConfigFile() { 107 val testLine = "transform-protolog-calls " + 108 "--protolog-class $TEST_PROTOLOG_CLASS " + 109 "--loggroups-class $TEST_PROTOLOGGROUP_CLASS " + 110 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 111 "--viewer-config-file-path $TEST_VIEWER_CONFIG_FILE_PATH " + 112 "--legacy-output-file-path $TEST_LEGACY_OUTPUT_FILE_PATH " + 113 "--output-srcjar $TEST_SRC_JAR ${TEST_JAVA_SRC.joinToString(" ")}" 114 val cmd = CommandOptions(testLine.split(' ').toTypedArray()) 115 assertEquals(CommandOptions.TRANSFORM_CALLS_CMD, cmd.command) 116 assertEquals(TEST_PROTOLOG_CLASS, cmd.protoLogClassNameArg) 117 assertEquals(TEST_PROTOLOGGROUP_CLASS, cmd.protoLogGroupsClassNameArg) 118 assertEquals(TEST_PROTOLOGGROUP_JAR, cmd.protoLogGroupsJarArg) 119 assertEquals(TEST_VIEWER_CONFIG_FILE_PATH, cmd.viewerConfigFilePathArg) 120 assertEquals(null, cmd.legacyViewerConfigFilePathArg) 121 assertEquals(TEST_LEGACY_OUTPUT_FILE_PATH, cmd.legacyOutputFilePath) 122 assertEquals(TEST_SRC_JAR, cmd.outputSourceJarArg) 123 assertEquals(TEST_JAVA_SRC, cmd.javaSourceArgs) 124 } 125 126 @Test transformClasses_noLegacyOutputFilenull127 fun transformClasses_noLegacyOutputFile() { 128 val testLine = "transform-protolog-calls " + 129 "--protolog-class $TEST_PROTOLOG_CLASS " + 130 "--loggroups-class $TEST_PROTOLOGGROUP_CLASS " + 131 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 132 "--viewer-config-file-path $TEST_VIEWER_CONFIG_FILE_PATH " + 133 "--legacy-viewer-config-file-path $TEST_LEGACY_VIEWER_CONFIG_FILE_PATH " + 134 "--output-srcjar $TEST_SRC_JAR ${TEST_JAVA_SRC.joinToString(" ")}" 135 val cmd = CommandOptions(testLine.split(' ').toTypedArray()) 136 assertEquals(CommandOptions.TRANSFORM_CALLS_CMD, cmd.command) 137 assertEquals(TEST_PROTOLOG_CLASS, cmd.protoLogClassNameArg) 138 assertEquals(TEST_PROTOLOGGROUP_CLASS, cmd.protoLogGroupsClassNameArg) 139 assertEquals(TEST_PROTOLOGGROUP_JAR, cmd.protoLogGroupsJarArg) 140 assertEquals(TEST_VIEWER_CONFIG_FILE_PATH, cmd.viewerConfigFilePathArg) 141 assertEquals(TEST_LEGACY_VIEWER_CONFIG_FILE_PATH, cmd.legacyViewerConfigFilePathArg) 142 assertEquals(null, cmd.legacyOutputFilePath) 143 assertEquals(TEST_SRC_JAR, cmd.outputSourceJarArg) 144 assertEquals(TEST_JAVA_SRC, cmd.javaSourceArgs) 145 } 146 147 @Test transformClasses_noProtoLogClassnull148 fun transformClasses_noProtoLogClass() { 149 val testLine = "transform-protolog-calls " + 150 "--loggroups-class $TEST_PROTOLOGGROUP_CLASS " + 151 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 152 "--viewer-config-file-path $TEST_VIEWER_CONFIG_FILE_PATH " + 153 "--legacy-viewer-config-file-path $TEST_LEGACY_VIEWER_CONFIG_FILE_PATH " + 154 "--legacy-output-file-path $TEST_LEGACY_OUTPUT_FILE_PATH " + 155 "--output-srcjar $TEST_SRC_JAR ${TEST_JAVA_SRC.joinToString(" ")}" 156 val exception = assertThrows<InvalidCommandException>(InvalidCommandException::class.java) { 157 CommandOptions(testLine.split(' ').toTypedArray()) 158 } 159 assertThat(exception).hasMessageThat().contains("--protolog-class") 160 } 161 162 @Test transformClasses_noProtoLogGroupClassnull163 fun transformClasses_noProtoLogGroupClass() { 164 val testLine = "transform-protolog-calls " + 165 "--protolog-class $TEST_PROTOLOG_CLASS " + 166 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 167 "--viewer-config-file-path $TEST_VIEWER_CONFIG_FILE_PATH " + 168 "--legacy-viewer-config-file-path $TEST_LEGACY_VIEWER_CONFIG_FILE_PATH " + 169 "--legacy-output-file-path $TEST_LEGACY_OUTPUT_FILE_PATH " + 170 "--output-srcjar $TEST_SRC_JAR ${TEST_JAVA_SRC.joinToString(" ")}" 171 val exception = assertThrows<InvalidCommandException>(InvalidCommandException::class.java) { 172 CommandOptions(testLine.split(' ').toTypedArray()) 173 } 174 assertThat(exception).hasMessageThat().contains("--loggroups-class") 175 } 176 177 @Test transformClasses_noProtoLogGroupJarnull178 fun transformClasses_noProtoLogGroupJar() { 179 val testLine = "transform-protolog-calls " + 180 "--protolog-class $TEST_PROTOLOG_CLASS " + 181 "--loggroups-class $TEST_PROTOLOGGROUP_CLASS " + 182 "--viewer-config-file-path $TEST_VIEWER_CONFIG_FILE_PATH " + 183 "--legacy-viewer-config-file-path $TEST_LEGACY_VIEWER_CONFIG_FILE_PATH " + 184 "--legacy-output-file-path $TEST_LEGACY_OUTPUT_FILE_PATH " + 185 "--output-srcjar $TEST_SRC_JAR ${TEST_JAVA_SRC.joinToString(" ")}" 186 val exception = assertThrows<InvalidCommandException>(InvalidCommandException::class.java) { 187 CommandOptions(testLine.split(' ').toTypedArray()) 188 } 189 assertThat(exception).hasMessageThat().contains("--loggroups-jar") 190 } 191 192 @Test transformClasses_noOutJarnull193 fun transformClasses_noOutJar() { 194 val testLine = "transform-protolog-calls " + 195 "--protolog-class $TEST_PROTOLOG_CLASS " + 196 "--loggroups-class $TEST_PROTOLOGGROUP_CLASS " + 197 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 198 "--viewer-config-file-path $TEST_VIEWER_CONFIG_FILE_PATH " + 199 "--legacy-viewer-config-file-path $TEST_LEGACY_VIEWER_CONFIG_FILE_PATH " + 200 "--legacy-output-file-path $TEST_LEGACY_OUTPUT_FILE_PATH " + 201 "${TEST_JAVA_SRC.joinToString(" ")}" 202 val exception = assertThrows<InvalidCommandException>(InvalidCommandException::class.java) { 203 CommandOptions(testLine.split(' ').toTypedArray()) 204 } 205 assertThat(exception).hasMessageThat().contains("--output-srcjar") 206 } 207 208 @Test transformClasses_noJavaInputnull209 fun transformClasses_noJavaInput() { 210 val testLine = "transform-protolog-calls " + 211 "--protolog-class $TEST_PROTOLOG_CLASS " + 212 "--loggroups-class $TEST_PROTOLOGGROUP_CLASS " + 213 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 214 "--viewer-config-file-path $TEST_VIEWER_CONFIG_FILE_PATH " + 215 "--legacy-viewer-config-file-path $TEST_LEGACY_VIEWER_CONFIG_FILE_PATH " + 216 "--legacy-output-file-path $TEST_LEGACY_OUTPUT_FILE_PATH " + 217 "--output-srcjar $TEST_SRC_JAR" 218 val exception = assertThrows<InvalidCommandException>(InvalidCommandException::class.java) { 219 CommandOptions(testLine.split(' ').toTypedArray()) 220 } 221 assertThat(exception).hasMessageThat().contains("No java source input files") 222 } 223 224 @Test transformClasses_invalidProtoLogClassnull225 fun transformClasses_invalidProtoLogClass() { 226 val testLine = "transform-protolog-calls " + 227 "--protolog-class invalid " + 228 "--loggroups-class $TEST_PROTOLOGGROUP_CLASS " + 229 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 230 "--viewer-config-file-path $TEST_VIEWER_CONFIG_FILE_PATH " + 231 "--legacy-viewer-config-file-path $TEST_LEGACY_VIEWER_CONFIG_FILE_PATH " + 232 "--legacy-output-file-path $TEST_LEGACY_OUTPUT_FILE_PATH " + 233 "--output-srcjar $TEST_SRC_JAR ${TEST_JAVA_SRC.joinToString(" ")}" 234 val exception = assertThrows<InvalidCommandException>(InvalidCommandException::class.java) { 235 CommandOptions(testLine.split(' ').toTypedArray()) 236 } 237 assertThat(exception).hasMessageThat().contains("class name invalid") 238 } 239 240 @Test transformClasses_invalidProtoLogGroupClassnull241 fun transformClasses_invalidProtoLogGroupClass() { 242 val testLine = "transform-protolog-calls " + 243 "--protolog-class $TEST_PROTOLOG_CLASS " + 244 "--loggroups-class invalid " + 245 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 246 "--viewer-config-file-path $TEST_VIEWER_CONFIG_FILE_PATH " + 247 "--legacy-viewer-config-file-path $TEST_LEGACY_VIEWER_CONFIG_FILE_PATH " + 248 "--legacy-output-file-path $TEST_LEGACY_OUTPUT_FILE_PATH " + 249 "--output-srcjar $TEST_SRC_JAR ${TEST_JAVA_SRC.joinToString(" ")}" 250 val exception = assertThrows<InvalidCommandException>(InvalidCommandException::class.java) { 251 CommandOptions(testLine.split(' ').toTypedArray()) 252 } 253 assertThat(exception).hasMessageThat().contains("class name invalid") 254 } 255 256 @Test transformClasses_invalidProtoLogGroupJarnull257 fun transformClasses_invalidProtoLogGroupJar() { 258 val testLine = "transform-protolog-calls " + 259 "--protolog-class $TEST_PROTOLOG_CLASS " + 260 "--loggroups-class $TEST_PROTOLOGGROUP_CLASS " + 261 "--loggroups-jar invalid.txt " + 262 "--viewer-config-file-path $TEST_VIEWER_CONFIG_FILE_PATH " + 263 "--legacy-viewer-config-file-path $TEST_LEGACY_VIEWER_CONFIG_FILE_PATH " + 264 "--legacy-output-file-path $TEST_LEGACY_OUTPUT_FILE_PATH " + 265 "--output-srcjar $TEST_SRC_JAR ${TEST_JAVA_SRC.joinToString(" ")}" 266 val exception = assertThrows<InvalidCommandException>(InvalidCommandException::class.java) { 267 CommandOptions(testLine.split(' ').toTypedArray()) 268 } 269 assertThat(exception).hasMessageThat() 270 .contains("Jar file required, got invalid.txt instead") 271 } 272 273 @Test transformClasses_invalidOutJarnull274 fun transformClasses_invalidOutJar() { 275 val testLine = "transform-protolog-calls " + 276 "--protolog-class $TEST_PROTOLOG_CLASS " + 277 "--loggroups-class $TEST_PROTOLOGGROUP_CLASS " + 278 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 279 "--viewer-config-file-path $TEST_VIEWER_CONFIG_FILE_PATH " + 280 "--legacy-viewer-config-file-path $TEST_LEGACY_VIEWER_CONFIG_FILE_PATH " + 281 "--legacy-output-file-path $TEST_LEGACY_OUTPUT_FILE_PATH " + 282 "--output-srcjar invalid.pb ${TEST_JAVA_SRC.joinToString(" ")}" 283 val exception = assertThrows<InvalidCommandException>(InvalidCommandException::class.java) { 284 CommandOptions(testLine.split(' ').toTypedArray()) 285 } 286 assertThat(exception).hasMessageThat() 287 .contains("Source jar file required, got invalid.pb instead") 288 } 289 290 @Test transformClasses_invalidJavaInputnull291 fun transformClasses_invalidJavaInput() { 292 val testLine = "transform-protolog-calls " + 293 "--protolog-class $TEST_PROTOLOG_CLASS " + 294 "--loggroups-class $TEST_PROTOLOGGROUP_CLASS " + 295 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 296 "--viewer-config-file-path $TEST_VIEWER_CONFIG_FILE_PATH " + 297 "--legacy-viewer-config-file-path $TEST_LEGACY_VIEWER_CONFIG_FILE_PATH " + 298 "--legacy-output-file-path $TEST_LEGACY_OUTPUT_FILE_PATH " + 299 "--output-srcjar $TEST_SRC_JAR invalid.py" 300 val exception = assertThrows<InvalidCommandException>(InvalidCommandException::class.java) { 301 CommandOptions(testLine.split(' ').toTypedArray()) 302 } 303 assertThat(exception).hasMessageThat() 304 .contains("Not a java or kotlin source file invalid.py") 305 } 306 307 @Test transformClasses_unknownParamnull308 fun transformClasses_unknownParam() { 309 val testLine = "transform-protolog-calls --protolog-class $TEST_PROTOLOG_CLASS " + 310 "--unknown test --protolog-impl-class $TEST_PROTOLOGIMPL_CLASS " + 311 "--protolog-cache-class $TEST_PROTOLOGCACHE_CLASS " + 312 "--loggroups-class $TEST_PROTOLOGGROUP_CLASS " + 313 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 314 "--output-srcjar $TEST_SRC_JAR ${TEST_JAVA_SRC.joinToString(" ")}" 315 val exception = assertThrows<InvalidCommandException>(InvalidCommandException::class.java) { 316 CommandOptions(testLine.split(' ').toTypedArray()) 317 } 318 assertThat(exception).hasMessageThat().contains("--unknown") 319 } 320 321 @Test transformClasses_noValuenull322 fun transformClasses_noValue() { 323 val testLine = "transform-protolog-calls --protolog-class $TEST_PROTOLOG_CLASS " + 324 "--loggroups-class " + 325 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 326 "--output-srcjar $TEST_SRC_JAR ${TEST_JAVA_SRC.joinToString(" ")}" 327 val exception = assertThrows<InvalidCommandException>(InvalidCommandException::class.java) { 328 CommandOptions(testLine.split(' ').toTypedArray()) 329 } 330 assertThat(exception).hasMessageThat().contains("No value for --loggroups-class") 331 } 332 333 @Test generateConfig_jsonnull334 fun generateConfig_json() { 335 val testLine = "generate-viewer-config " + 336 "--protolog-class $TEST_PROTOLOG_CLASS " + 337 "--loggroups-class $TEST_PROTOLOGGROUP_CLASS " + 338 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 339 "--viewer-config-type json " + 340 "--viewer-config $TEST_VIEWER_JSON ${TEST_JAVA_SRC.joinToString(" ")}" 341 val cmd = CommandOptions(testLine.split(' ').toTypedArray()) 342 assertEquals(CommandOptions.GENERATE_CONFIG_CMD, cmd.command) 343 assertEquals(TEST_PROTOLOG_CLASS, cmd.protoLogClassNameArg) 344 assertEquals(TEST_PROTOLOGGROUP_CLASS, cmd.protoLogGroupsClassNameArg) 345 assertEquals(TEST_PROTOLOGGROUP_JAR, cmd.protoLogGroupsJarArg) 346 assertEquals(TEST_VIEWER_JSON, cmd.viewerConfigFileNameArg) 347 assertEquals(TEST_JAVA_SRC, cmd.javaSourceArgs) 348 } 349 350 @Test generateConfig_protonull351 fun generateConfig_proto() { 352 val testLine = "generate-viewer-config " + 353 "--protolog-class $TEST_PROTOLOG_CLASS " + 354 "--loggroups-class $TEST_PROTOLOGGROUP_CLASS " + 355 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 356 "--viewer-config-type proto " + 357 "--viewer-config $TEST_VIEWER_JSON ${TEST_JAVA_SRC.joinToString(" ")}" 358 val cmd = CommandOptions(testLine.split(' ').toTypedArray()) 359 assertEquals(CommandOptions.GENERATE_CONFIG_CMD, cmd.command) 360 assertEquals(TEST_PROTOLOG_CLASS, cmd.protoLogClassNameArg) 361 assertEquals(TEST_PROTOLOGGROUP_CLASS, cmd.protoLogGroupsClassNameArg) 362 assertEquals(TEST_PROTOLOGGROUP_JAR, cmd.protoLogGroupsJarArg) 363 assertEquals(TEST_VIEWER_JSON, cmd.viewerConfigFileNameArg) 364 assertEquals(TEST_JAVA_SRC, cmd.javaSourceArgs) 365 } 366 367 @Test generateConfig_noViewerConfignull368 fun generateConfig_noViewerConfig() { 369 val testLine = "generate-viewer-config --protolog-class $TEST_PROTOLOG_CLASS " + 370 "--loggroups-class $TEST_PROTOLOGGROUP_CLASS " + 371 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 372 TEST_JAVA_SRC.joinToString(" ") 373 val exception = assertThrows<InvalidCommandException>(InvalidCommandException::class.java) { 374 CommandOptions(testLine.split(' ').toTypedArray()) 375 } 376 assertThat(exception).hasMessageThat().contains("--viewer-config required") 377 } 378 379 @Test generateConfig_invalidViewerConfignull380 fun generateConfig_invalidViewerConfig() { 381 val testLine = "generate-viewer-config --protolog-class $TEST_PROTOLOG_CLASS " + 382 "--loggroups-class $TEST_PROTOLOGGROUP_CLASS " + 383 "--loggroups-jar $TEST_PROTOLOGGROUP_JAR " + 384 "--viewer-config invalid.yaml ${TEST_JAVA_SRC.joinToString(" ")}" 385 val exception = assertThrows<InvalidCommandException>(InvalidCommandException::class.java) { 386 CommandOptions(testLine.split(' ').toTypedArray()) 387 } 388 assertThat(exception).hasMessageThat().contains("required, got invalid.yaml instead") 389 } 390 391 @Test readLognull392 fun readLog() { 393 val testLine = "read-log --viewer-config $TEST_VIEWER_JSON $TEST_LOG" 394 val cmd = CommandOptions(testLine.split(' ').toTypedArray()) 395 assertEquals(CommandOptions.READ_LOG_CMD, cmd.command) 396 assertEquals(TEST_VIEWER_JSON, cmd.viewerConfigFileNameArg) 397 assertEquals(TEST_LOG, cmd.logProtofileArg) 398 } 399 } 400