Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump shadow from 1.2.4 to 6.1.0 #7

Open
wants to merge 12 commits into
base: release/3.x
Choose a base branch
from
Open
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: PowerMock CI

on:
push:
branches: [ release/3.x ]
pull_request:
branches: [ release/3.x ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 11 ]
fail-fast: false
name: Java ${{ matrix.java }}

steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: '${{ matrix.java }}'
distribution: 'temurin'
cache: 'gradle'
- name: Build
env:
SKIP_RELEASE: true
powermock.byte-code-framework: Javassist
# We are using && below on purpose
# ciPerformRelease must run only when the entire build has completed
# This guarantees that no release steps are executed when the build or tests fail
run: |
./gradlew assemble --stacktrace -PcheckJava6Compatibility \
&& ./gradlew -i --stacktrace check \
&& ./gradlew -i ciPerformRelease
8 changes: 7 additions & 1 deletion .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: "Validate Gradle Wrapper"
on: [push, pull_request]
on:
push:
branches:
- release/3.x
pull_request:
branches:
- release/3.x

jobs:
validation:
Expand Down
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

8 changes: 3 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url 'https://repo.spring.io/plugins-release'
}
Expand All @@ -13,9 +12,9 @@ buildscript {
classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7'
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:2.3.4'
classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.1'
classpath 'com.github.jengelman.gradle.plugins:shadow:6.1.0'
classpath 'org.shipkit:shipkit:2.3.5'
classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.5.4'
}
}

Expand All @@ -30,7 +29,6 @@ ext{
objenesisVersion = "3.2"
javassistVersion = "3.27.0-GA"
junitVersion = "4.12"
junitRulesVersion = "4.8.2"
testngVersion = "6.9.10"
xstreamVersion = "1.4.10"
mockitoVersion = "4.3.1"
Expand Down
2 changes: 1 addition & 1 deletion docs/generate_javadoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ read -p "Version to generate javadoc for: " version
project_names=(powermock-core powermock-api-easymock powermock-api-mockito powermock-api-mockito2 powermock-api-mockito-common\
powermock-reflect powermock-api-support powermock-module-junit4-common powermock-module-junit4 powermock-module-junit4-rule\
powermock-classloading-module powermock-classloading-xstream powermock-module-javaagent powermock-module-junit4-rule-agent\
powermock-module-junit3 powermock-module-junit4-legacy powermock-module-testng-common powermock-module-testng\
powermock-module-testng-common powermock-module-testng\
powermock-module-testng-agent powermock-modules-impl powermock-classloading-objenesis)

echo "Generating Javadoc for version ${version}."
Expand Down
16 changes: 0 additions & 16 deletions gradle/modules.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -259,22 +259,6 @@ project(":powermock-modules:powermock-module-junit4") {
}
}

project(":powermock-modules:powermock-module-junit4-legacy") {
description = "PowerMock support module for JUnit 4.0-4.3."

dependencies {
compile(project(":powermock-modules:powermock-module-junit4-common")) {
exclude group: 'junit', module: 'junit'
}
compile("junit:junit:4.3") {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
compile("org.hamcrest:hamcrest-core:${hamcrestVersion}")
testCompile("org.assertj:assertj-core:${assertjVersion}")
}
}


project(":powermock-modules:powermock-module-junit4-rule") {
description = "PowerMock support module for JUnit 4.x rules."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.easymock.EasyMock;
import org.easymock.IExpectationSetters;
import org.easymock.MockType;
import org.easymock.internal.MocksControl;
import org.powermock.core.MockRepository;
import org.powermock.core.spi.NewInvocationControl;
import org.powermock.core.spi.support.InvocationSubstitute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ class InvocationFactory {

Invocation createInvocation(final Object mock, final Method method, final MockCreationSettings settings,
final Object... arguments) {
final RealMethodBehavior realMethod = createRealMethod(mock, method, arguments);
final RealMethodBehavior<Object> realMethod = createRealMethod(mock, method, arguments);
return Mockito.framework()
.getInvocationFactory()
.createInvocation(mock, settings, method, realMethod, arguments);
}

private RealMethodBehavior createRealMethod(final Object delegator, final Method method,
private RealMethodBehavior<Object> createRealMethod(final Object delegator, final Method method,
final Object... arguments) {
return new RealMethodBehavior() {
return new RealMethodBehavior<Object>() {
@Override
public Object call() throws Exception {
final Class<?> type = Whitebox.getType(delegator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@
import org.powermock.configuration.GlobalConfiguration;
import org.powermock.reflect.Whitebox;

import java.io.File;
import java.lang.management.ManagementFactory;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.assertj.core.api.Java6Assertions.fail;
Expand All @@ -52,7 +58,7 @@ public void should_delegate_calls_to_mock_maker_from_configuration() {
ClassLoader currentCL = Thread.currentThread().getContextClassLoader();

try {
ClassLoader classLoader = new URLClassLoader(((URLClassLoader) currentCL).getURLs(), null);
ClassLoader classLoader = new URLClassLoader(urlsFromClassLoader(currentCL), null);
Thread.currentThread().setContextClassLoader(classLoader);

final Class<?> jUnitCoreClass = classLoader.loadClass(JUnitCore.class.getName());
Expand All @@ -72,8 +78,27 @@ public void should_delegate_calls_to_mock_maker_from_configuration() {
} finally {
Thread.currentThread().setContextClassLoader(currentCL);
}


}

private static URL[] urlsFromClassLoader(ClassLoader classLoader) {
if (classLoader instanceof URLClassLoader) {
return ((URLClassLoader) classLoader).getURLs();
}
List<URL> list = new ArrayList<URL>();
for (String classPathEntry : ManagementFactory.getRuntimeMXBean().getClassPath().split(File.pathSeparator)) {
list.add(toURL(classPathEntry));
}
return list.toArray(new URL[0]);
}

private static URL toURL(String classPathEntry) {
try {
return new File(classPathEntry).toURI().toURL();
}
catch (MalformedURLException ex) {
throw new IllegalArgumentException(
"URL could not be created from '" + classPathEntry + "'", ex);
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public class MockClassLoaderConfiguration {
"junit.*",
"org.pitest.*",
"org.powermock.modules.junit4.common.internal.*",
"org.powermock.modules.junit3.internal.PowerMockJUnit3RunnerDelegate*",
"org.powermock.core*",
"org.jacoco.agent.rt.*"
};
Expand All @@ -68,8 +67,6 @@ public class MockClassLoaderConfiguration {
"net.sf.cglib.",
"javassist.",
"org.powermock.modules.junit4.internal.",
"org.powermock.modules.junit4.legacy.internal.",
"org.powermock.modules.junit3.internal.",
"org.powermock"};

private final String[] specificClassesToLoadButNotModify = new String[]{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,7 @@
* <i>not</i> removed.
* <p>
* The annotation should always be combined with the
* {@code &#064;RunWith(PowerMockRunner.class)} if using junit 4.x or
*
* <pre>
* public static TestSuite suite() throws Exception {
* return new PowerMockSuite(MyTestCase.class);
* }
* </pre>
*
* if using junit3.
* {@code &#064;RunWith(PowerMockRunner.class)} if using junit 4.x.
*/
@Target( { ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,7 @@
*
* <p>
* The annotation should always be combined with the
* {@code &#064;RunWith(PowerMockRunner.class)} if using junit 4.x or
*
* <pre>
* public static TestSuite suite() throws Exception {
* return new PowerMockSuite(MyTestCase.class);
* }
* </pre>
*
* if using junit3.
* {@code &#064;RunWith(PowerMockRunner.class)} if using junit 4.x.
* <p>
* The difference between this annotation and the {@link PrepareOnlyThisForTest}
* annotation is that this annotation modifies the specified classes and all its
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,7 @@
*
* <p>
* The annotation should always be combined with the
* {@code &#064;RunWith(PowerMockRunner.class)} if using junit 4.x or
*
* <pre>
* public static TestSuite suite() throws Exception {
* return new PowerMockSuite(MyTestCase.class);
* }
* </pre>
*
* if using junit3.
* {@code &#064;RunWith(PowerMockRunner.class)} if using junit 4.x.
* <p>
* The difference between this annotation and the {@link PrepareForTest}
* annotation is that this annotation only modifies the specified classes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
import org.powermock.core.transformers.TransformStrategy;
import org.powermock.core.transformers.javassist.support.PowerMockExpressionEditor;

import java.io.File;
import java.io.OutputStream;

public class InstrumentMockTransformer extends AbstractJavaAssistMockTransformer {

private Class<?> mockGetawayClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ public interface TestSuiteChunker {
/**
* Should reflect whether or not this method is eligible for testing.
*
* @param testClass The class that defines the method.
* @param potentialTestMethod The method to inspect whether it should be executed in the
* test suite or not.
* @return {@code true} if the method is a test method and should be
* executed, {@code false} otherwise.
*/
boolean shouldExecuteTestForMethod(Class<?> testClass, Method potentialTestMethod);
boolean shouldExecuteTestForMethod(Method potentialTestMethod);
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private ClassLoader createDefaultMockLoader(final Class<?> testClass, final Coll
}

private void putMethodToChunk(TestCaseEntry testCaseEntry, Class<?> testClass, Method method) {
if (shouldExecuteTestForMethod(testClass, method)) {
if (shouldExecuteTestForMethod(method)) {
currentTestIndex++;
if (hasChunkAnnotation(method)) {
LinkedList<Method> methodsInThisChunk = new LinkedList<Method>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.dynamic.DynamicType.Builder;
import net.bytebuddy.implementation.FixedValue;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -43,7 +40,6 @@

import static org.assertj.core.api.Java6Assertions.assertThat;
import static java.util.Arrays.asList;
import static net.bytebuddy.matcher.ElementMatchers.isDeclaredBy;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertFalse;
import static org.junit.Assume.assumeThat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

import javassist.ClassPool;
import javassist.Loader;
import org.powermock.configuration.GlobalConfiguration;
import org.powermock.configuration.PowerMockConfiguration;
import org.powermock.core.classloader.MockClassLoader;
import org.powermock.core.transformers.MockTransformerChain;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.powermock.core.test;

import org.assertj.core.api.Condition;
import org.assertj.core.description.Description;
import org.powermock.core.classloader.MockClassLoaderFactoryTest;

import java.util.Collection;

Expand Down
Loading