package prefix should auto append dot

This commit is contained in:
金戟 2021-04-17 17:46:35 +08:00
parent 0c063e9b1f
commit d10478f95f
4 changed files with 7 additions and 7 deletions

View File

@ -32,7 +32,7 @@
```xml
<configuration>
<argLine>-javaagent:${settings.localRepository}/com/alibaba/testable/testable-agent/${testable.version}/testable-agent-${testable.version}.jar=mockScope=associated&amp;pkgPrefix=com.demo.</argLine>
<argLine>-javaagent:${settings.localRepository}/com/alibaba/testable/testable-agent/${testable.version}/testable-agent-${testable.version}.jar=mockScope=associated&amp;pkgPrefix=com.demo</argLine>
</configuration>
```
@ -42,5 +42,5 @@
```groovy
jvmArgs "-javaagent:${classpath.find { it.name.contains("testable-agent") }.absolutePath}=mockScope=associated&pkgPrefix=com.demo."
jvmArgs "-javaagent:${classpath.find { it.name.contains("testable-agent") }.absolutePath}=mockScope=associated&pkgPrefix=com.demo"
```

View File

@ -33,7 +33,7 @@ public class ArgumentParser {
} else if (k.equals(DUMP_PATH)) {
GlobalConfig.setDumpPath(v);
} else if (k.equals(PKG_PREFIX)) {
GlobalConfig.setPkgPrefix(v);
GlobalConfig.setPkgPrefixes(v);
} else if (k.equals(MOCK_SCOPE)) {
GlobalConfig.setDefaultMockScope(MockScope.of(v));
} else if (k.equals(CONFIG_FILE)) {

View File

@ -57,7 +57,7 @@ public class PropertiesParser {
} else if (k.equals(DUMP_PATH)) {
GlobalConfig.setDumpPath(v);
} else if (k.equals(PKG_PREFIX_WHITELIST)) {
GlobalConfig.setPkgPrefix(v);
GlobalConfig.setPkgPrefixes(v);
} else if (k.equals(DEFAULT_MOCK_SCOPE)) {
GlobalConfig.setDefaultMockScope(MockScope.of(v));
} else if (k.equals(ENABLE_THREAD_POOL)) {

View File

@ -141,9 +141,9 @@ public class TestableClassTransformer implements ClassFileTransformer {
if (null == className || className.contains(CGLIB_CLASS_PATTERN)) {
return true;
}
String whitePrefix = GlobalConfig.getPkgPrefix();
if (whitePrefix != null) {
for (String prefix : whitePrefix.split(COMMA)) {
List<String> whitePrefixes = GlobalConfig.getPkgPrefixes();
if (!whitePrefixes.isEmpty()) {
for (String prefix : whitePrefixes) {
if (className.startsWith(prefix)) {
// Only consider package in provided list as non-system class
return false;