mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-01-26 20:30:29 +08:00
Merge pull request #29 from itwild/master
fit for class which enhanced by CGLIB
This commit is contained in:
commit
acc3f0bdf2
@ -17,6 +17,8 @@ public class ConstPool {
|
|||||||
public static final String MOCK_CONSTRUCTOR = "com.alibaba.testable.core.annotation.MockConstructor";
|
public static final String MOCK_CONSTRUCTOR = "com.alibaba.testable.core.annotation.MockConstructor";
|
||||||
public static final String TESTABLE_MOCK = "com.alibaba.testable.core.annotation.TestableMock";
|
public static final String TESTABLE_MOCK = "com.alibaba.testable.core.annotation.TestableMock";
|
||||||
|
|
||||||
|
public static final String CGLIB_CLASS_INFIX = "$$EnhancerByCGLIB$$";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the constructor method
|
* Name of the constructor method
|
||||||
*/
|
*/
|
||||||
|
@ -79,6 +79,11 @@ public class ClassUtil {
|
|||||||
* @return test class name
|
* @return test class name
|
||||||
*/
|
*/
|
||||||
public static String getTestClassName(String sourceClassName) {
|
public static String getTestClassName(String sourceClassName) {
|
||||||
|
// check the class if generated by CGLIB
|
||||||
|
int idx = sourceClassName.indexOf(ConstPool.CGLIB_CLASS_INFIX);
|
||||||
|
if (idx != -1) {
|
||||||
|
sourceClassName = sourceClassName.substring(0, idx);
|
||||||
|
}
|
||||||
return sourceClassName + ConstPool.TEST_POSTFIX;
|
return sourceClassName + ConstPool.TEST_POSTFIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user