java-powermock-fix-java-files.patch
| 1 | From 1ac84b58b4383fa118d98c35956d722d11cf449e Mon Sep 17 00:00:00 2001 |
| 2 | From: Julien Lepiller <julien@lepiller.eu> |
| 3 | Date: Tue, 22 Aug 2017 20:40:27 +0200 |
| 4 | Subject: [PATCH] Fix java files. |
| 5 | |
| 6 | --- |
| 7 | .../internal/impl/DelegatingPowerMockRunner.java | 13 +++++++--- |
| 8 | .../java/org/powermock/reflect/WhiteBoxTest.java | 30 +++++++++++----------- |
| 9 | .../reflect/internal/proxy/ClassFactory.java | 6 ++--- |
| 10 | 3 files changed, 27 insertions(+), 22 deletions(-) |
| 11 | |
| 12 | diff --git a/powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/internal/impl/DelegatingPowerMockRunner.java b/powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/internal/impl/DelegatingPowerMockRunner.java |
| 13 | index 301f854..caecbbd 100644 |
| 14 | --- a/powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/internal/impl/DelegatingPowerMockRunner.java |
| 15 | +++ b/powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/internal/impl/DelegatingPowerMockRunner.java |
| 16 | @@ -98,12 +98,17 @@ implements PowerMockJUnitRunnerDelegate, Filterable { |
| 17 | @Override |
| 18 | public Runner call() throws Exception { |
| 19 | try { |
| 20 | - return Whitebox.invokeConstructor( |
| 21 | - testClass.isAnnotationPresent(PowerMockRunnerDelegate.class) |
| 22 | - ? testClass.getAnnotation(PowerMockRunnerDelegate.class).value() |
| 23 | - : PowerMockRunnerDelegate.DefaultJUnitRunner.class, |
| 24 | + if(testClass.isAnnotationPresent(PowerMockRunnerDelegate.class)) { |
| 25 | + return Whitebox.invokeConstructor( |
| 26 | + testClass.getAnnotation(PowerMockRunnerDelegate.class).value(), |
| 27 | new Class[] {Class.class}, |
| 28 | new Object[] {testClass}); |
| 29 | + } else { |
| 30 | + return Whitebox.invokeConstructor( |
| 31 | + PowerMockRunnerDelegate.DefaultJUnitRunner.class, |
| 32 | + new Class[] {Class.class}, |
| 33 | + new Object[] {testClass}); |
| 34 | + } |
| 35 | } catch (ConstructorNotFoundException rootProblem) { |
| 36 | if (testClass.isAnnotationPresent(PowerMockRunnerDelegate.class) |
| 37 | && JUnitVersion.isGreaterThanOrEqualTo("4.5")) { |
| 38 | diff --git a/powermock-reflect/src/test/java/org/powermock/reflect/WhiteBoxTest.java b/powermock-reflect/src/test/java/org/powermock/reflect/WhiteBoxTest.java |
| 39 | index bf1e2e3..0d60487 100644 |
| 40 | --- a/powermock-reflect/src/test/java/org/powermock/reflect/WhiteBoxTest.java |
| 41 | +++ b/powermock-reflect/src/test/java/org/powermock/reflect/WhiteBoxTest.java |
| 42 | @@ -248,7 +248,7 @@ public class WhiteBoxTest { |
| 43 | |
| 44 | @Test |
| 45 | public void testMethodWithPrimitiveAndWrappedInt_primtive_wrapped() throws Exception { |
| 46 | - assertEquals(17, Whitebox.invokeMethod(new ClassWithPrivateMethods(), "methodWithPrimitiveAndWrappedInt", |
| 47 | + assertEquals((Integer)17, Whitebox.invokeMethod(new ClassWithPrivateMethods(), "methodWithPrimitiveAndWrappedInt", |
| 48 | new Class[]{int.class, Integer.class}, 9, Integer.valueOf(8))); |
| 49 | } |
| 50 | |
| 51 | @@ -257,7 +257,7 @@ public class WhiteBoxTest { |
| 52 | int expected = 123; |
| 53 | Whitebox.setInternalState(ClassWithInternalState.class, "staticState", expected); |
| 54 | assertEquals(expected, ClassWithInternalState.getStaticState()); |
| 55 | - assertEquals(expected, Whitebox.getInternalState(ClassWithInternalState.class, "staticState")); |
| 56 | + assertEquals(expected, (int)Whitebox.getInternalState(ClassWithInternalState.class, "staticState")); |
| 57 | } |
| 58 | |
| 59 | @Test |
| 60 | @@ -334,25 +334,25 @@ public class WhiteBoxTest { |
| 61 | @Test |
| 62 | public void testInvokeVarArgsMethod_multipleValues() throws Exception { |
| 63 | ClassWithPrivateMethods tested = new ClassWithPrivateMethods(); |
| 64 | - assertEquals(6, Whitebox.invokeMethod(tested, "varArgsMethod", 1, 2, 3)); |
| 65 | + assertEquals(6, (int)Whitebox.invokeMethod(tested, "varArgsMethod", 1, 2, 3)); |
| 66 | } |
| 67 | |
| 68 | @Test |
| 69 | public void testInvokeVarArgsMethod_noArguments() throws Exception { |
| 70 | ClassWithPrivateMethods tested = new ClassWithPrivateMethods(); |
| 71 | - assertEquals(0, Whitebox.invokeMethod(tested, "varArgsMethod")); |
| 72 | + assertEquals(0, (int)Whitebox.invokeMethod(tested, "varArgsMethod")); |
| 73 | } |
| 74 | |
| 75 | @Test |
| 76 | public void testInvokeVarArgsMethod_oneArgument() throws Exception { |
| 77 | ClassWithPrivateMethods tested = new ClassWithPrivateMethods(); |
| 78 | - assertEquals(4, Whitebox.invokeMethod(tested, "varArgsMethod", 2)); |
| 79 | + assertEquals(4, (int)Whitebox.invokeMethod(tested, "varArgsMethod", 2)); |
| 80 | } |
| 81 | |
| 82 | @Test |
| 83 | public void testInvokeVarArgsMethod_invokeVarArgsWithOneArgument() throws Exception { |
| 84 | ClassWithPrivateMethods tested = new ClassWithPrivateMethods(); |
| 85 | - assertEquals(1, Whitebox.invokeMethod(tested, "varArgsMethod", new Class<?>[]{int[].class}, 1)); |
| 86 | + assertEquals(1, (int)Whitebox.invokeMethod(tested, "varArgsMethod", new Class<?>[]{int[].class}, 1)); |
| 87 | } |
| 88 | |
| 89 | @Test |
| 90 | @@ -376,7 +376,7 @@ public class WhiteBoxTest { |
| 91 | ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState() { |
| 92 | }; |
| 93 | Whitebox.setInternalState(tested, fieldName, value); |
| 94 | - assertEquals(value, Whitebox.getInternalState(tested, fieldName)); |
| 95 | + assertEquals(value, (int)Whitebox.getInternalState(tested, fieldName)); |
| 96 | } |
| 97 | |
| 98 | @Test |
| 99 | @@ -387,8 +387,8 @@ public class WhiteBoxTest { |
| 100 | ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState() { |
| 101 | }; |
| 102 | Whitebox.setInternalState(tested, fieldName, value); |
| 103 | - assertEquals(value, Whitebox.getInternalState(tested, fieldName)); |
| 104 | - assertEquals(-1, Whitebox.getInternalState(tested, fieldName, ClassWithInternalState.class)); |
| 105 | + assertEquals(value, (int)Whitebox.getInternalState(tested, fieldName)); |
| 106 | + assertEquals(-1, (int)Whitebox.getInternalState(tested, fieldName, ClassWithInternalState.class)); |
| 107 | } |
| 108 | |
| 109 | @Test(expected = IllegalArgumentException.class) |
| 110 | @@ -398,7 +398,7 @@ public class WhiteBoxTest { |
| 111 | ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState() { |
| 112 | }; |
| 113 | Whitebox.setInternalState(tested, fieldName, new Object()); |
| 114 | - assertEquals(value, Whitebox.getInternalState(tested, fieldName)); |
| 115 | + assertEquals(value, (int)Whitebox.getInternalState(tested, fieldName)); |
| 116 | } |
| 117 | |
| 118 | @Test(expected = IllegalArgumentException.class) |
| 119 | @@ -408,7 +408,7 @@ public class WhiteBoxTest { |
| 120 | ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState() { |
| 121 | }; |
| 122 | Whitebox.setInternalState(tested, fieldName, (Object) null); |
| 123 | - assertEquals(value, Whitebox.getInternalState(tested, fieldName)); |
| 124 | + assertEquals(value, (int)Whitebox.getInternalState(tested, fieldName)); |
| 125 | } |
| 126 | |
| 127 | @Test |
| 128 | @@ -417,8 +417,8 @@ public class WhiteBoxTest { |
| 129 | ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState(); |
| 130 | Whitebox.setInternalState(tested, int.class, value); |
| 131 | assertEquals(value, (int) Whitebox.getInternalState(tested, int.class)); |
| 132 | - assertEquals(value, Whitebox.getInternalState(tested, "anotherInternalState")); |
| 133 | - assertEquals(value, Whitebox.getInternalState(tested, "anotherInternalState", |
| 134 | + assertEquals(value, (int)Whitebox.getInternalState(tested, "anotherInternalState")); |
| 135 | + assertEquals(value, (int)Whitebox.getInternalState(tested, "anotherInternalState", |
| 136 | ClassWithChildThatHasInternalState.class)); |
| 137 | } |
| 138 | |
| 139 | @@ -429,7 +429,7 @@ public class WhiteBoxTest { |
| 140 | Whitebox.setInternalState(tested, int.class, value, ClassWithInternalState.class); |
| 141 | assertEquals(42, (int) Whitebox.getInternalState(tested, int.class)); |
| 142 | assertEquals(value, (int) Whitebox.getInternalState(tested, int.class, ClassWithInternalState.class)); |
| 143 | - assertEquals(value, Whitebox.getInternalState(tested, "staticState", ClassWithInternalState.class)); |
| 144 | + assertEquals(value, (int)Whitebox.getInternalState(tested, "staticState", ClassWithInternalState.class)); |
| 145 | } |
| 146 | |
| 147 | @Test |
| 148 | @@ -619,7 +619,7 @@ public class WhiteBoxTest { |
| 149 | @Test |
| 150 | public void testInvokeMethodWithBothNormalAndVarArgsParameter() throws Exception { |
| 151 | ClassWithPrivateMethods tested = new ClassWithPrivateMethods(); |
| 152 | - assertEquals(4, Whitebox.invokeMethod(tested, "varArgsMethod2", 1, 2, 3)); |
| 153 | + assertEquals(4, (int)Whitebox.invokeMethod(tested, "varArgsMethod2", 1, 2, 3)); |
| 154 | } |
| 155 | |
| 156 | @Test |
| 157 | diff --git a/powermock-reflect/src/test/java/org/powermock/reflect/internal/proxy/ClassFactory.java b/powermock-reflect/src/test/java/org/powermock/reflect/internal/proxy/ClassFactory.java |
| 158 | index a5e5fda..14b8bbe 100644 |
| 159 | --- a/powermock-reflect/src/test/java/org/powermock/reflect/internal/proxy/ClassFactory.java |
| 160 | +++ b/powermock-reflect/src/test/java/org/powermock/reflect/internal/proxy/ClassFactory.java |
| 161 | @@ -1,8 +1,8 @@ |
| 162 | package org.powermock.reflect.internal.proxy; |
| 163 | |
| 164 | -import net.sf.cglib.asm.ClassWriter; |
| 165 | -import net.sf.cglib.asm.MethodVisitor; |
| 166 | -import net.sf.cglib.asm.Opcodes; |
| 167 | +import org.objectweb.asm.ClassWriter; |
| 168 | +import org.objectweb.asm.MethodVisitor; |
| 169 | +import org.objectweb.asm.Opcodes; |
| 170 | |
| 171 | class ClassFactory implements Opcodes { |
| 172 | |
| 173 | -- |
| 174 | 2.14.1 |
| 175 | |
| 176 |