Testing Method Signature Parsing Implementation in Alibaba Arthas
The SpyImplTest suite validates core string parsing functionality in Alibaba Arthas’s advisor component, focusing on method and invocation information handling. This test suite ensures reliable parsing of method signatures and invocation details essential for the diagnostic tooling.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
alibaba/arthas
core/src/test/java/com/taobao/arthas/core/advisor/SpyImplTest.java
package com.taobao.arthas.core.advisor;
import org.assertj.core.api.Assertions;
import org.junit.Test;
import com.taobao.arthas.core.util.StringUtils;
/**
*
* @author hengyunabc 2021-07-14
*
*/
public class SpyImplTest {
@Test
public void testSplitMethodInfo() throws Throwable {
Assertions.assertThat(StringUtils.splitMethodInfo("a|b")).containsExactly("a", "b");
Assertions.assertThat(StringUtils.splitMethodInfo("xxxxxxxxxx|fffffffffff")).containsExactly("xxxxxxxxxx",
"fffffffffff");
Assertions.assertThat(StringUtils.splitMethodInfo("print|(ILjava/util/List;)V")).containsExactly("print",
"(ILjava/util/List;)V");
}
@Test
public void testSplitInvokeInfo() throws Throwable {
Assertions.assertThat(StringUtils.splitInvokeInfo("demo/MathGame|primeFactors|(I)Ljava/util/List;|24"))
.containsExactly("demo/MathGame", "primeFactors", "(I)Ljava/util/List;", "24");
}
}