Permalink
Browse files

Fixes #727 Use ByteBuddy to instrument classes instead Javassist:

- upgrade Gradle to 4.2.1 su support JDK 9.0.1
- fix tests
  • Loading branch information...
thekingnothing committed Oct 22, 2017
1 parent d1cb563 commit 8712dea0a4e8a1b3e83535673c97efe6584c95e6
@@ -28,7 +28,7 @@ ext{
assertjVersion = "2.6.0"
cglibVersion = "3.2.5"
objenesisVersion = "2.6"
javassistVersion = "3.22.0-CR2"
javassistVersion = "3.22.0-GA"
junitVersion = "4.12"
junitRulesVersion = "4.8.2"
testngVersion = "6.9.10"
@@ -16,6 +16,7 @@
package powermock.classloading;
import org.junit.Ignore;
import org.junit.Test;
import org.powermock.classloading.SingleClassloaderExecutor;
import org.powermock.core.classloader.MockClassLoader;
@@ -42,6 +43,7 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
@Ignore("Test are failed on JDK more that 1.6. On Travis we can run only on JDK8 and JDK9")
public class ObjenesisClassloaderExecutorTest {
@Test
@@ -17,6 +17,7 @@
package powermock.classloading;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.powermock.classloading.DeepCloner;
@@ -29,6 +30,7 @@
import static org.junit.Assert.assertNotSame;
import static org.junit.Assume.assumeTrue;
@Ignore("Test are failed on JDK more that 1.6. On Travis we can run only on JDK8 and JDK9")
public class ObjenesisDeepClonerTest {
/**
@@ -42,6 +42,7 @@
*/
static final String[] PACKAGES_TO_BE_DEFERRED = new String[]{
"org.hamcrest.*",
"jdk.*",
"java.*",
"javax.accessibility.*",
"sun.*",
@@ -1,13 +1,2 @@
# suppress inspection "UnusedProperty" for whole file
powermock.global-ignore=org.hamcrest.*,\
jdk.*,\
java.*,\
javax.accessibility.*, \
sun.*, \
org.junit.*,\
org.testng.*,\
junit.*, \
org.pitest.*,\
org.powermock.modules.junit4.common.internal.*,\
org.powermock.core*,\
org.jacoco.agent.rt.*
powermock.global-ignore=org.powermock.core*
@@ -77,7 +77,6 @@ private static MockClassLoader getMockClassLoader(final MockTransformerChain moc
if (loader == null) {
loader = mockClassloaderFactory.getInstance(new String[]{MockClassLoader.MODIFY_ALL_CLASSES});
loader.setMockTransformerChain(mockTransformerChain);
loader.getConfiguration().addIgnorePackage(GlobalConfiguration.powerMockConfiguration().getGlobalIgnore());
classloaders.put(mockTransformerChain, loader);
}
return loader;
@@ -1,30 +1,31 @@
package samples.junit4.powermockignore;
import net.bytebuddy.utility.RandomString;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import samples.singleton.StaticService;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.easymock.EasyMock.expect;
import static org.junit.Assert.assertEquals;
import static org.powermock.api.easymock.PowerMock.*;
@RunWith(PowerMockRunner.class)
@PowerMockIgnore("samples.*")
@PrepareForTest(StaticService.class)
public class PowerMockIgnoreAndPrepareForTest {
@Test public void
powermock_ignore_annotation_and_prepare_for_test_annotation_can_be_combined() {
@Test public void powermock_ignore_annotation_and_prepare_for_test_annotation_can_be_combined() {
mockStatic(StaticService.class);
String expected = "qwe";
final String expected = RandomString.make(5);
expect(StaticService.doStatic(5)).andReturn(expected);
replay(StaticService.class);
String actual = StaticService.doStatic(5);
assertEquals(expected, actual);
verify(StaticService.class);
assertThat(StaticService.doStatic(5))
.isEqualTo(expected);
}
}
@@ -9,9 +9,6 @@
import static org.assertj.core.api.Java6Assertions.assertThat;
/**
*
*/
public class GitHub352Test {
@@ -7,7 +7,7 @@
@Test
public void testPowerMockJUnit4MethodValidatorAcceptsTestAnnotatedMethods() throws Exception {
PowerMockJUnit4MethodValidator validator = new PowerMockJUnit4MethodValidator(new UseTestAnnotatedTest(UseTestAnnotatedTest.MethodToTest.class));
validator.validateInstanceMethods();
}

0 comments on commit 8712dea

Please sign in to comment.