diff options
Diffstat (limited to 'src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java')
| -rw-r--r-- | src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java b/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java index 01d4bab..edb859a 100644 --- a/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java +++ b/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java | |||
| @@ -4,62 +4,67 @@ | |||
| 4 | * are made available under the terms of the GNU Lesser General Public | 4 | * are made available under the terms of the GNU Lesser General Public |
| 5 | * License v3.0 which accompanies this distribution, and is available at | 5 | * License v3.0 which accompanies this distribution, and is available at |
| 6 | * http://www.gnu.org/licenses/lgpl.html | 6 | * http://www.gnu.org/licenses/lgpl.html |
| 7 | * | 7 | * |
| 8 | * Contributors: | 8 | * Contributors: |
| 9 | * Jeff Martin - initial API and implementation | 9 | * Jeff Martin - initial API and implementation |
| 10 | ******************************************************************************/ | 10 | ******************************************************************************/ |
| 11 | |||
| 11 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 12 | 13 | ||
| 13 | import static cuchaz.enigma.TestEntryFactory.*; | 14 | import cuchaz.enigma.analysis.EntryReference; |
| 14 | import static org.hamcrest.MatcherAssert.*; | 15 | import cuchaz.enigma.analysis.JarIndex; |
| 15 | import static org.hamcrest.Matchers.*; | 16 | import cuchaz.enigma.mapping.BehaviorEntry; |
| 17 | import cuchaz.enigma.mapping.ClassEntry; | ||
| 18 | import org.junit.Test; | ||
| 16 | 19 | ||
| 17 | import java.io.File; | 20 | import java.io.File; |
| 18 | import java.util.Collection; | 21 | import java.util.Collection; |
| 19 | import java.util.jar.JarFile; | 22 | import java.util.jar.JarFile; |
| 20 | 23 | ||
| 21 | import org.junit.Test; | 24 | import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByConstructor; |
| 22 | 25 | import static cuchaz.enigma.TestEntryFactory.newBehaviorReferenceByMethod; | |
| 23 | import cuchaz.enigma.analysis.EntryReference; | 26 | import static cuchaz.enigma.TestEntryFactory.newClass; |
| 24 | import cuchaz.enigma.analysis.JarIndex; | 27 | import static cuchaz.enigma.TestEntryFactory.newConstructor; |
| 25 | import cuchaz.enigma.mapping.BehaviorEntry; | 28 | import static org.hamcrest.MatcherAssert.assertThat; |
| 26 | import cuchaz.enigma.mapping.ClassEntry; | 29 | import static org.hamcrest.Matchers.containsInAnyOrder; |
| 30 | import static org.hamcrest.Matchers.empty; | ||
| 31 | import static org.hamcrest.Matchers.is; | ||
| 27 | 32 | ||
| 28 | public class TestJarIndexConstructorReferences { | 33 | public class TestJarIndexConstructorReferences { |
| 29 | 34 | ||
| 30 | private JarIndex index; | 35 | private JarIndex index; |
| 31 | 36 | ||
| 32 | private ClassEntry baseClass = newClass("a"); | 37 | private ClassEntry baseClass = newClass("a"); |
| 33 | private ClassEntry subClass = newClass("d"); | 38 | private ClassEntry subClass = newClass("d"); |
| 34 | private ClassEntry subsubClass = newClass("e"); | 39 | private ClassEntry subsubClass = newClass("e"); |
| 35 | private ClassEntry defaultClass = newClass("c"); | 40 | private ClassEntry defaultClass = newClass("c"); |
| 36 | private ClassEntry callerClass = newClass("b"); | 41 | private ClassEntry callerClass = newClass("b"); |
| 37 | 42 | ||
| 38 | public TestJarIndexConstructorReferences() | 43 | public TestJarIndexConstructorReferences() |
| 39 | throws Exception { | 44 | throws Exception { |
| 40 | File jarFile = new File("build/test-obf/constructors.jar"); | 45 | File jarFile = new File("build/test-obf/constructors.jar"); |
| 41 | index = new JarIndex(); | 46 | index = new JarIndex(); |
| 42 | index.indexJar(new JarFile(jarFile), false); | 47 | index.indexJar(new JarFile(jarFile), false); |
| 43 | } | 48 | } |
| 44 | 49 | ||
| 45 | @Test | 50 | @Test |
| 46 | public void obfEntries() { | 51 | public void obfEntries() { |
| 47 | assertThat(index.getObfClassEntries(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, | 52 | assertThat(index.getObfClassEntries(), containsInAnyOrder(newClass("cuchaz/enigma/inputs/Keep"), baseClass, |
| 48 | subClass, subsubClass, defaultClass, callerClass)); | 53 | subClass, subsubClass, defaultClass, callerClass)); |
| 49 | } | 54 | } |
| 50 | 55 | ||
| 51 | @Test | 56 | @Test |
| 52 | @SuppressWarnings("unchecked") | 57 | @SuppressWarnings("unchecked") |
| 53 | public void baseDefault() { | 58 | public void baseDefault() { |
| 54 | BehaviorEntry source = newConstructor(baseClass, "()V"); | 59 | BehaviorEntry source = newConstructor(baseClass, "()V"); |
| 55 | Collection<EntryReference<BehaviorEntry,BehaviorEntry>> references = index.getBehaviorReferences(source); | 60 | Collection<EntryReference<BehaviorEntry, BehaviorEntry>> references = index.getBehaviorReferences(source); |
| 56 | assertThat(references, containsInAnyOrder( | 61 | assertThat(references, containsInAnyOrder( |
| 57 | newBehaviorReferenceByMethod(source, callerClass.getName(), "a", "()V"), | 62 | newBehaviorReferenceByMethod(source, callerClass.getName(), "a", "()V"), |
| 58 | newBehaviorReferenceByConstructor(source, subClass.getName(), "()V"), | 63 | newBehaviorReferenceByConstructor(source, subClass.getName(), "()V"), |
| 59 | newBehaviorReferenceByConstructor(source, subClass.getName(), "(III)V") | 64 | newBehaviorReferenceByConstructor(source, subClass.getName(), "(III)V") |
| 60 | )); | 65 | )); |
| 61 | } | 66 | } |
| 62 | 67 | ||
| 63 | @Test | 68 | @Test |
| 64 | @SuppressWarnings("unchecked") | 69 | @SuppressWarnings("unchecked") |
| 65 | public void baseInt() { | 70 | public void baseInt() { |
| @@ -68,7 +73,7 @@ public class TestJarIndexConstructorReferences { | |||
| 68 | newBehaviorReferenceByMethod(source, callerClass.getName(), "b", "()V") | 73 | newBehaviorReferenceByMethod(source, callerClass.getName(), "b", "()V") |
| 69 | )); | 74 | )); |
| 70 | } | 75 | } |
| 71 | 76 | ||
| 72 | @Test | 77 | @Test |
| 73 | @SuppressWarnings("unchecked") | 78 | @SuppressWarnings("unchecked") |
| 74 | public void subDefault() { | 79 | public void subDefault() { |
| @@ -78,7 +83,7 @@ public class TestJarIndexConstructorReferences { | |||
| 78 | newBehaviorReferenceByConstructor(source, subClass.getName(), "(I)V") | 83 | newBehaviorReferenceByConstructor(source, subClass.getName(), "(I)V") |
| 79 | )); | 84 | )); |
| 80 | } | 85 | } |
| 81 | 86 | ||
| 82 | @Test | 87 | @Test |
| 83 | @SuppressWarnings("unchecked") | 88 | @SuppressWarnings("unchecked") |
| 84 | public void subInt() { | 89 | public void subInt() { |
| @@ -89,7 +94,7 @@ public class TestJarIndexConstructorReferences { | |||
| 89 | newBehaviorReferenceByConstructor(source, subsubClass.getName(), "(I)V") | 94 | newBehaviorReferenceByConstructor(source, subsubClass.getName(), "(I)V") |
| 90 | )); | 95 | )); |
| 91 | } | 96 | } |
| 92 | 97 | ||
| 93 | @Test | 98 | @Test |
| 94 | @SuppressWarnings("unchecked") | 99 | @SuppressWarnings("unchecked") |
| 95 | public void subIntInt() { | 100 | public void subIntInt() { |
| @@ -98,13 +103,13 @@ public class TestJarIndexConstructorReferences { | |||
| 98 | newBehaviorReferenceByMethod(source, callerClass.getName(), "e", "()V") | 103 | newBehaviorReferenceByMethod(source, callerClass.getName(), "e", "()V") |
| 99 | )); | 104 | )); |
| 100 | } | 105 | } |
| 101 | 106 | ||
| 102 | @Test | 107 | @Test |
| 103 | public void subIntIntInt() { | 108 | public void subIntIntInt() { |
| 104 | BehaviorEntry source = newConstructor(subClass, "(III)V"); | 109 | BehaviorEntry source = newConstructor(subClass, "(III)V"); |
| 105 | assertThat(index.getBehaviorReferences(source), is(empty())); | 110 | assertThat(index.getBehaviorReferences(source), is(empty())); |
| 106 | } | 111 | } |
| 107 | 112 | ||
| 108 | @Test | 113 | @Test |
| 109 | @SuppressWarnings("unchecked") | 114 | @SuppressWarnings("unchecked") |
| 110 | public void subsubInt() { | 115 | public void subsubInt() { |
| @@ -113,7 +118,7 @@ public class TestJarIndexConstructorReferences { | |||
| 113 | newBehaviorReferenceByMethod(source, callerClass.getName(), "f", "()V") | 118 | newBehaviorReferenceByMethod(source, callerClass.getName(), "f", "()V") |
| 114 | )); | 119 | )); |
| 115 | } | 120 | } |
| 116 | 121 | ||
| 117 | @Test | 122 | @Test |
| 118 | @SuppressWarnings("unchecked") | 123 | @SuppressWarnings("unchecked") |
| 119 | public void defaultConstructable() { | 124 | public void defaultConstructable() { |