add getInstances interface test

This commit is contained in:
hengyunabc 2021-05-07 19:47:02 +08:00
parent d7a0fdf1e8
commit f1d86b5c43
2 changed files with 28 additions and 0 deletions

View File

@ -151,5 +151,10 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,9 +1,13 @@
package arthas;
import org.assertj.core.api.Assertions;
import org.junit.Test;
import com.taobao.arthas.common.VmToolUtils;
import arthas.VmToolTest.AAA;
import arthas.VmToolTest.III;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.concurrent.atomic.AtomicLong;
@ -144,4 +148,23 @@ public class VmToolTest {
allLoadedClasses = null;
}
}
interface III {
}
class AAA implements III {
}
@Test
public void test_getInstances_interface() {
AAA aaa = new AAA();
VmTool vmtool = initVmTool();
III[] interfaceInstances = vmtool.getInstances(III.class);
Assertions.assertThat(interfaceInstances.length).isEqualTo(1);
AAA[] ObjectInstances = vmtool.getInstances(AAA.class);
Assertions.assertThat(ObjectInstances.length).isEqualTo(1);
Assertions.assertThat(interfaceInstances[0]).isEqualTo(ObjectInstances[0]);
}
}