mirror of
https://github.com/alibaba/arthas.git
synced 2026-12-04 15:46:01 +00:00
test(mcp): cover line in Java SDK integration tests
This commit is contained in:
1 parent
c78033b7cd
commit
4ea01d8574
1 file changed
+26
+26
@@ -66,6 +66,7 @@ class ArthasMcpJavaSdkIT {
|
||||
"heapdump",
|
||||
"jad",
|
||||
"jvm",
|
||||
"line",
|
||||
"mc",
|
||||
"mbean",
|
||||
"memory",
|
||||
@@ -165,6 +166,24 @@ class ArthasMcpJavaSdkIT {
|
||||
}
|
||||
|
||||
private static void assertToolSideEffects(String toolName, Environment env, String body) throws Exception {
|
||||
if ("line".equals(toolName)) {
|
||||
JsonNode results = OBJECT_MAPPER.readTree(body).path("results");
|
||||
assertThat(results.isArray()).as("line results, body=%s", body).isTrue();
|
||||
JsonNode lineList = null;
|
||||
for (JsonNode result : results) {
|
||||
if ("line-list".equals(result.path("type").asText())) {
|
||||
lineList = result;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertThat(lineList).as("line --list-lines result, body=%s", body).isNotNull();
|
||||
assertThat(lineList.path("className").asText()).isEqualTo(TARGET_CLASS_PATTERN);
|
||||
assertThat(lineList.path("methodName").asText()).isEqualTo(TARGET_METHOD_PATTERN);
|
||||
assertThat(lineList.path("lines").isArray()).isTrue();
|
||||
assertThat(lineList.path("lines").size()).isGreaterThan(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if ("heapdump".equals(toolName)) {
|
||||
Path heapdumpFile = env.tempHome.resolve("heapdump.hprof");
|
||||
assertThat(heapdumpFile).exists();
|
||||
@@ -270,6 +289,13 @@ class ArthasMcpJavaSdkIT {
|
||||
return args;
|
||||
}
|
||||
|
||||
if ("line".equals(toolName)) {
|
||||
args.put("classPattern", TARGET_CLASS_PATTERN);
|
||||
args.put("methodPattern", TARGET_METHOD_PATTERN);
|
||||
args.put("listLines", true);
|
||||
return args;
|
||||
}
|
||||
|
||||
if ("dump".equals(toolName)) {
|
||||
args.put("classPattern", TARGET_CLASS_PATTERN);
|
||||
Path outDir = env.tempHome.resolve("dump-output");
|
||||
|
||||
Reference in new issue
Block a user