Permalink
Browse files

[ci maven-central-release] PowerMock 2.0 Release without ByteBuddy (#948

)

Preparing PowerMock 2.0 Release without ByteBuddy 

* Remove all ByteBuddy Classloader code (#727)
* Fix tests
* Update Libraries
  • Loading branch information...
thekingnothing committed Oct 24, 2018
1 parent 5a89275 commit 0ef7538b151d87875b5c6b9703141257045656f8
Showing with 43 additions and 1,951 deletions.
  1. +7 −7 build.gradle
  2. +2 −2 gradle/wrapper/gradle-wrapper.properties
  3. +15 −6 .../src/main/java/org/powermock/api/mockito/internal/invocation/InvocationControlAssertionError.java
  4. +2 −2 powermock-core/src/main/java/org/powermock/core/ClassReplicaCreator.java
  5. +0 −14 powermock-core/src/main/java/org/powermock/core/classloader/ByteCodeFramework.java
  6. +0 −142 powermock-core/src/main/java/org/powermock/core/classloader/bytebuddy/ByteBuddyMockClassLoader.java
  7. +0 −11 powermock-core/src/main/java/org/powermock/core/transformers/TestClassTransformerBuilder.java
  8. +0 −59 ...ore/src/main/java/org/powermock/core/transformers/bytebuddy/AbstractByteBuddyMockTransformer.java
  9. +0 −26 ...k-core/src/main/java/org/powermock/core/transformers/bytebuddy/AbstractMethodMockTransformer.java
  10. +0 −26 ...ore/src/main/java/org/powermock/core/transformers/bytebuddy/AbstractTestAwareMockTransformer.java
  11. +0 −68 ...src/main/java/org/powermock/core/transformers/bytebuddy/ByteBuddyMockTransformerChainFactory.java
  12. +0 −50 ...re/src/main/java/org/powermock/core/transformers/bytebuddy/ClassFinalModifierMockTransformer.java
  13. +0 −190 ...-core/src/main/java/org/powermock/core/transformers/bytebuddy/ConstructorCallMockTransformer.java
  14. +0 −46 .../src/main/java/org/powermock/core/transformers/bytebuddy/ConstructorModifiersMockTransformer.java
  15. +0 −51 powermock-core/src/main/java/org/powermock/core/transformers/bytebuddy/MethodMockTransformer.java
  16. +0 −136 ...ock-core/src/main/java/org/powermock/core/transformers/bytebuddy/NativeMethodMockTransformer.java
  17. +0 −44 ...ore/src/main/java/org/powermock/core/transformers/bytebuddy/StaticFinalFieldsMockTransformer.java
  18. +0 −85 ...ore/src/main/java/org/powermock/core/transformers/bytebuddy/StaticInitializerMockTransformer.java
  19. +0 −37 ...core/src/main/java/org/powermock/core/transformers/bytebuddy/VisitorByteBuddyMockTransformer.java
  20. +0 −7 powermock-core/src/main/java/org/powermock/core/transformers/bytebuddy/advice/MethodDispatcher.java
  21. +0 −27 ...e/src/main/java/org/powermock/core/transformers/bytebuddy/advice/MockGatewayMethodDispatcher.java
  22. +0 −52 powermock-core/src/main/java/org/powermock/core/transformers/bytebuddy/advice/MockMethodAdvice.java
  23. +0 −20 ...ck-core/src/main/java/org/powermock/core/transformers/bytebuddy/advice/MockMethodDispatchers.java
  24. +0 −46 ...k-core/src/main/java/org/powermock/core/transformers/bytebuddy/advice/MockStaticMethodAdvice.java
  25. +0 −257 ...va/org/powermock/core/transformers/bytebuddy/constructor/ConstructorCallMethodVisitorWrapper.java
  26. +0 −54 powermock-core/src/main/java/org/powermock/core/transformers/bytebuddy/support/ByteBuddyClass.java
  27. +0 −54 ...src/main/java/org/powermock/core/transformers/bytebuddy/support/ByteBuddyClassWrapperFactory.java
  28. +0 −41 .../main/java/org/powermock/core/transformers/bytebuddy/testclass/ByteBuddyTestClassTransformer.java
  29. +0 −39 .../org/powermock/core/transformers/bytebuddy/testclass/ForMethodsByteBuddyTestClassTransformer.java
  30. +0 −24 ...mock/core/transformers/bytebuddy/testclass/FromAllMethodsExceptByteBuddyTestClassTransformer.java
  31. +0 −8 powermock-core/src/main/java/org/powermock/core/transformers/bytebuddy/testclass/MethodFilter.java
  32. +0 −82 ...ain/java/org/powermock/core/transformers/bytebuddy/testclass/RemoveTestAnnotationFromMethods.java
  33. +0 −62 ...main/java/org/powermock/core/transformers/bytebuddy/testclass/TestClassTransformationBuilder.java
  34. +0 −7 ...in/java/org/powermock/core/transformers/bytebuddy/testclass/TestClassTransformationOperation.java
  35. +0 −14 ...n/java/org/powermock/core/transformers/bytebuddy/testclass/TestClassTransformationOperations.java
  36. +3 −3 powermock-core/src/test/java/org/powermock/configuration/support/ConfigurationFactoryImplTest.java
  37. +0 −22 powermock-core/src/test/java/org/powermock/core/classloader/MockClassLoaderBuilderTest.java
  38. +1 −46 powermock-core/src/test/java/org/powermock/core/classloader/MockClassLoaderFactoryTest.java
  39. +5 −28 powermock-core/src/test/java/org/powermock/core/classloader/MockClassLoaderTest.java
  40. +1 −2 powermock-core/src/test/java/org/powermock/core/test/MockClassLoaderFactory.java
  41. +0 −2 ...ock-core/src/test/java/org/powermock/core/transformers/ClassFinalModifierMockTransformerTest.java
  42. +0 −4 powermock-core/src/test/java/org/powermock/core/transformers/ConstructorCallMockTransformerTest.java
  43. +0 −2 ...k-core/src/test/java/org/powermock/core/transformers/ConstructorModifiersMockTransformerTest.java
  44. +1 −9 powermock-core/src/test/java/org/powermock/core/transformers/MethodsMockTransformerTest.java
  45. +1 −4 powermock-core/src/test/java/org/powermock/core/transformers/MockTransformerTestHelper.java
  46. +0 −7 powermock-core/src/test/java/org/powermock/core/transformers/NativeMethodsMockTransformerTest.java
  47. +0 −1 ...mock-core/src/test/java/org/powermock/core/transformers/StaticFinalFieldsMockTransformerTest.java
  48. +0 −7 powermock-core/src/test/java/org/powermock/core/transformers/StaticMethodsMockTransformerTest.java
  49. +0 −2 ...e/src/test/java/org/powermock/core/transformers/SuppressStaticInitializerMockTransformerTest.java
  50. +0 −10 ...rmock-core/src/test/java/org/powermock/core/transformers/mock/MockGatewaySpyMethodDispatcher.java
  51. +1 −1 powermock-core/src/test/resources/org/powermock/extensions/test_configuration.properties
  52. +2 −3 tests/mockito/junit4/src/test/java/samples/powermockito/junit4/bugs/github806/DoThrowTest.java
  53. +2 −2 version.properties
@@ -11,31 +11,31 @@ buildscript {
}
dependencies {
classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'net.researchgate:gradle-release:2.4.0'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
classpath 'org.shipkit:shipkit:0.9.45'
classpath 'org.shipkit:shipkit:2.0.31'
classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.1'
}
}
ext{
gradleScriptDir = "${rootProject.projectDir}/gradle"
byteBuddy = "1.8.3"
byteBuddy = "1.9.2"
easymockVersion = "3.5.1"
hamcrestVersion = "1.3"
assertjVersion = "2.6.0"
cglibVersion = "3.2.5"
objenesisVersion = "2.6"
objenesisVersion = "3.0"
//javassistVersion = "3.23.0-GA" need java-9
javassistVersion = "3.22.0-GA"
junitVersion = "4.12"
junitRulesVersion = "4.8.2"
testngVersion = "6.9.10"
xstreamVersion = "1.4.10"
mockitoVersion = "2.10.0"
mockitoVersion = "2.23.0"
servletVersion = "2.5"
systemRulesVersion = "1.16.0"
jacocoVersion = "0.7.7.201606060606"
eclipseJdt = "3.3.0-v_771"
checkstyleVersion= "7.6.1"
@@ -65,5 +65,5 @@ jar{
}
task wrapper(type: Wrapper) {
gradleVersion = '4.7'
gradleVersion = '4.10.2'
}
@@ -1,5 +1,5 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
@@ -24,6 +24,7 @@
private static final String AT = "at";
private static final String ERROR_LOCATION_MARKER = "->";
private static final String COLON_NEWLINE = ":\n";
private static final String NEWLINE_POINT = "\n.";
private static final String HERE_TEXT = "here:\n";
private static final String UNDESIRED_INVOCATION_TEXT = " Undesired invocation:";
private static final String POWER_MOCKITO_CLASS_NAME = "org.powermock.api.mockito.PowerMockito";
@@ -106,8 +107,8 @@ private static String changeMessageContent(String message) {
removeAndReplaceText(builder, HERE_TEXT, ' ');
removeAndReplaceText(builder, COLON_NEWLINE, ' ');
final String finalMessage = builder.toString().trim();
return finalMessage;
return builder.toString().trim();
}
private static StringBuilder removeFailureLocations(String message) {
@@ -124,17 +125,25 @@ private static StringBuilder removeFailureLocations(String message) {
private static void removeAndReplaceText(StringBuilder builder, String text, char appender) {
int currentTextIndex = builder.indexOf(text);
int previousTextIndex = 0;
int previousTextIndex;
boolean isSingleConcat = true;
while (currentTextIndex > 0) {
previousTextIndex = currentTextIndex;
builder.delete(currentTextIndex, currentTextIndex + text.length());
currentTextIndex = builder.indexOf(text);
final int length = builder.length();
if (isLastFinding(currentTextIndex) && !isSingleConcat) {
builder.replace(builder.length(), builder.length(), ".");
final int start = builder.charAt(length - 1) == '\n' ? length - 1 : length;
builder.replace(start, length, ".");
} else {
builder.replace(previousTextIndex, previousTextIndex + 1, String.valueOf(
builder.charAt(previousTextIndex)).toLowerCase());
final int end = previousTextIndex < length ? previousTextIndex + 1 : length;
builder.replace(
previousTextIndex, end,
String.valueOf(builder.charAt(previousTextIndex)).toLowerCase()
);
builder.insert(previousTextIndex, String.valueOf(appender));
currentTextIndex++;
isSingleConcat = false;
@@ -60,7 +60,7 @@
code, newClass);
}
return newClass.toClass(this.getClass().getClassLoader(), this.getClass().getProtectionDomain());
return (Class<T>) newClass.toClass(this.getClass().getClassLoader(), this.getClass().getProtectionDomain());
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -105,7 +105,7 @@
CtConstructor copy = CtNewConstructor.copy(ctConstructor, newClass, null);
newClass.addConstructor(copy);
}
return newClass.toClass(this.getClass().getClassLoader(), this.getClass().getProtectionDomain());
return (Class<T>) newClass.toClass(this.getClass().getClassLoader(), this.getClass().getProtectionDomain());
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -6,10 +6,8 @@
import org.powermock.core.classloader.annotations.PrepareOnlyThisForTest;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.core.classloader.annotations.UseClassPathAdjuster;
import org.powermock.core.classloader.bytebuddy.ByteBuddyMockClassLoader;
import org.powermock.core.classloader.javassist.JavassistMockClassLoader;
import org.powermock.core.transformers.MockTransformerChainFactory;
import org.powermock.core.transformers.bytebuddy.ByteBuddyMockTransformerChainFactory;
import org.powermock.core.transformers.javassist.JavassistMockTransformerChainFactory;
import java.lang.reflect.AnnotatedElement;
@@ -27,18 +25,6 @@ MockClassLoader createClassloader(final MockClassLoaderConfiguration configurati
MockTransformerChainFactory createTransformerChainFactory() {
return new JavassistMockTransformerChainFactory();
}
},
ByteBuddy {
@Override
MockClassLoader createClassloader(final MockClassLoaderConfiguration configuration,
final UseClassPathAdjuster useClassPathAdjuster) {
return new ByteBuddyMockClassLoader(configuration);
}
@Override
MockTransformerChainFactory createTransformerChainFactory() {
return new ByteBuddyMockTransformerChainFactory();
}
};
public static ByteCodeFramework getByteCodeFrameworkForMethod(final Class<?> testClass, final Method method) {

This file was deleted.

Oops, something went wrong.
@@ -1,10 +1,7 @@
package org.powermock.core.transformers;
import javassist.CtMethod;
import net.bytebuddy.description.method.MethodDescription;
import org.powermock.core.classloader.ByteCodeFramework;
import org.powermock.core.transformers.bytebuddy.testclass.ForMethodsByteBuddyTestClassTransformer;
import org.powermock.core.transformers.bytebuddy.testclass.FromAllMethodsExceptByteBuddyTestClassTransformer;
import org.powermock.core.transformers.javassist.testclass.ForMethodsJavaAssistTestClassTransformer;
import org.powermock.core.transformers.javassist.testclass.FromAllMethodsExceptJavaAssistTestClassTransformer;
@@ -65,10 +62,6 @@ public TestClassTransformer fromMethods(final Collection<Method> testMethodsThat
return new ForMethodsJavaAssistTestClassTransformer(
testClass, testMethodAnnotation, MethodSignatures.Javassist.<CtMethod>methodSignatureWriter(), testMethodsThatRunOnOtherClassLoaders
);
case ByteBuddy:
return new ForMethodsByteBuddyTestClassTransformer(
testClass, testMethodAnnotation, MethodSignatures.ByteBuddy.<MethodDescription>methodSignatureWriter(), testMethodsThatRunOnOtherClassLoaders
);
default:
throw new IllegalArgumentException(String.format("Unknown bytecode framework `%s`", byteCodeFramework));
}
@@ -80,10 +73,6 @@ public TestClassTransformer fromAllMethodsExcept(Method singleMethodToRunOnTarge
return new FromAllMethodsExceptJavaAssistTestClassTransformer(
testClass, testMethodAnnotation, MethodSignatures.Javassist.<CtMethod>methodSignatureWriter(), singleMethodToRunOnTargetClassLoader
);
case ByteBuddy:
return new FromAllMethodsExceptByteBuddyTestClassTransformer(
testClass, testMethodAnnotation, MethodSignatures.ByteBuddy.<MethodDescription>methodSignatureWriter(), singleMethodToRunOnTargetClassLoader
);
default:
throw new IllegalArgumentException(String.format("Unknown bytecode framework `%s`", byteCodeFramework));
}

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 0ef7538

Please sign in to comment.