diff options
Diffstat (limited to 'src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java')
| -rw-r--r-- | src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java | 67 |
1 files changed, 29 insertions, 38 deletions
diff --git a/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java b/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java index 8efa57c..6cab1c8 100644 --- a/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java +++ b/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java | |||
| @@ -4,44 +4,35 @@ | |||
| 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.*; |
| 14 | import static org.hamcrest.MatcherAssert.*; | 15 | import cuchaz.enigma.mapping.*; |
| 15 | import static org.hamcrest.Matchers.*; | 16 | import org.junit.Test; |
| 16 | 17 | ||
| 17 | import java.util.Collection; | 18 | import java.util.Collection; |
| 18 | import java.util.Set; | 19 | import java.util.Set; |
| 19 | import java.util.jar.JarFile; | 20 | import java.util.jar.JarFile; |
| 20 | 21 | ||
| 21 | import org.junit.Test; | 22 | import static cuchaz.enigma.TestEntryFactory.*; |
| 22 | 23 | import static org.hamcrest.MatcherAssert.assertThat; | |
| 23 | import cuchaz.enigma.analysis.Access; | 24 | import static org.hamcrest.Matchers.*; |
| 24 | import cuchaz.enigma.analysis.ClassImplementationsTreeNode; | ||
| 25 | import cuchaz.enigma.analysis.ClassInheritanceTreeNode; | ||
| 26 | import cuchaz.enigma.analysis.EntryReference; | ||
| 27 | import cuchaz.enigma.analysis.JarIndex; | ||
| 28 | import cuchaz.enigma.analysis.MethodInheritanceTreeNode; | ||
| 29 | import cuchaz.enigma.mapping.BehaviorEntry; | ||
| 30 | import cuchaz.enigma.mapping.ClassEntry; | ||
| 31 | import cuchaz.enigma.mapping.FieldEntry; | ||
| 32 | import cuchaz.enigma.mapping.MethodEntry; | ||
| 33 | import cuchaz.enigma.mapping.Translator; | ||
| 34 | 25 | ||
| 35 | public class TestJarIndexLoneClass { | 26 | public class TestJarIndexLoneClass { |
| 36 | 27 | ||
| 37 | private JarIndex index; | 28 | private JarIndex index; |
| 38 | 29 | ||
| 39 | public TestJarIndexLoneClass() | 30 | public TestJarIndexLoneClass() |
| 40 | throws Exception { | 31 | throws Exception { |
| 41 | index = new JarIndex(); | 32 | index = new JarIndex(); |
| 42 | index.indexJar(new JarFile("build/test-obf/loneClass.jar"), false); | 33 | index.indexJar(new JarFile("build/test-obf/loneClass.jar"), false); |
| 43 | } | 34 | } |
| 44 | 35 | ||
| 45 | @Test | 36 | @Test |
| 46 | public void obfEntries() { | 37 | public void obfEntries() { |
| 47 | assertThat(index.getObfClassEntries(), containsInAnyOrder( | 38 | assertThat(index.getObfClassEntries(), containsInAnyOrder( |
| @@ -49,7 +40,7 @@ public class TestJarIndexLoneClass { | |||
| 49 | newClass("a") | 40 | newClass("a") |
| 50 | )); | 41 | )); |
| 51 | } | 42 | } |
| 52 | 43 | ||
| 53 | @Test | 44 | @Test |
| 54 | public void translationIndex() { | 45 | public void translationIndex() { |
| 55 | assertThat(index.getTranslationIndex().getSuperclass(new ClassEntry("a")), is(new ClassEntry("java/lang/Object"))); | 46 | assertThat(index.getTranslationIndex().getSuperclass(new ClassEntry("a")), is(new ClassEntry("java/lang/Object"))); |
| @@ -59,7 +50,7 @@ public class TestJarIndexLoneClass { | |||
| 59 | assertThat(index.getTranslationIndex().getSubclass(new ClassEntry("a")), is(empty())); | 50 | assertThat(index.getTranslationIndex().getSubclass(new ClassEntry("a")), is(empty())); |
| 60 | assertThat(index.getTranslationIndex().getSubclass(new ClassEntry("cuchaz/enigma/inputs/Keep")), is(empty())); | 51 | assertThat(index.getTranslationIndex().getSubclass(new ClassEntry("cuchaz/enigma/inputs/Keep")), is(empty())); |
| 61 | } | 52 | } |
| 62 | 53 | ||
| 63 | @Test | 54 | @Test |
| 64 | public void access() { | 55 | public void access() { |
| 65 | assertThat(index.getAccess(newField("a", "a", "Ljava/lang/String;")), is(Access.PRIVATE)); | 56 | assertThat(index.getAccess(newField("a", "a", "Ljava/lang/String;")), is(Access.PRIVATE)); |
| @@ -67,7 +58,7 @@ public class TestJarIndexLoneClass { | |||
| 67 | assertThat(index.getAccess(newField("a", "b", "Ljava/lang/String;")), is(nullValue())); | 58 | assertThat(index.getAccess(newField("a", "b", "Ljava/lang/String;")), is(nullValue())); |
| 68 | assertThat(index.getAccess(newField("a", "a", "LFoo;")), is(nullValue())); | 59 | assertThat(index.getAccess(newField("a", "a", "LFoo;")), is(nullValue())); |
| 69 | } | 60 | } |
| 70 | 61 | ||
| 71 | @Test | 62 | @Test |
| 72 | public void classInheritance() { | 63 | public void classInheritance() { |
| 73 | ClassInheritanceTreeNode node = index.getClassInheritance(new Translator(), newClass("a")); | 64 | ClassInheritanceTreeNode node = index.getClassInheritance(new Translator(), newClass("a")); |
| @@ -75,7 +66,7 @@ public class TestJarIndexLoneClass { | |||
| 75 | assertThat(node.getObfClassName(), is("a")); | 66 | assertThat(node.getObfClassName(), is("a")); |
| 76 | assertThat(node.getChildCount(), is(0)); | 67 | assertThat(node.getChildCount(), is(0)); |
| 77 | } | 68 | } |
| 78 | 69 | ||
| 79 | @Test | 70 | @Test |
| 80 | public void methodInheritance() { | 71 | public void methodInheritance() { |
| 81 | MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); | 72 | MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); |
| @@ -84,19 +75,19 @@ public class TestJarIndexLoneClass { | |||
| 84 | assertThat(node.getMethodEntry(), is(source)); | 75 | assertThat(node.getMethodEntry(), is(source)); |
| 85 | assertThat(node.getChildCount(), is(0)); | 76 | assertThat(node.getChildCount(), is(0)); |
| 86 | } | 77 | } |
| 87 | 78 | ||
| 88 | @Test | 79 | @Test |
| 89 | public void classImplementations() { | 80 | public void classImplementations() { |
| 90 | ClassImplementationsTreeNode node = index.getClassImplementations(new Translator(), newClass("a")); | 81 | ClassImplementationsTreeNode node = index.getClassImplementations(new Translator(), newClass("a")); |
| 91 | assertThat(node, is(nullValue())); | 82 | assertThat(node, is(nullValue())); |
| 92 | } | 83 | } |
| 93 | 84 | ||
| 94 | @Test | 85 | @Test |
| 95 | public void methodImplementations() { | 86 | public void methodImplementations() { |
| 96 | MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); | 87 | MethodEntry source = newMethod("a", "a", "()Ljava/lang/String;"); |
| 97 | assertThat(index.getMethodImplementations(new Translator(), source), is(empty())); | 88 | assertThat(index.getMethodImplementations(new Translator(), source), is(empty())); |
| 98 | } | 89 | } |
| 99 | 90 | ||
| 100 | @Test | 91 | @Test |
| 101 | public void relatedMethodImplementations() { | 92 | public void relatedMethodImplementations() { |
| 102 | Set<MethodEntry> entries = index.getRelatedMethodImplementations(newMethod("a", "a", "()Ljava/lang/String;")); | 93 | Set<MethodEntry> entries = index.getRelatedMethodImplementations(newMethod("a", "a", "()Ljava/lang/String;")); |
| @@ -104,53 +95,53 @@ public class TestJarIndexLoneClass { | |||
| 104 | newMethod("a", "a", "()Ljava/lang/String;") | 95 | newMethod("a", "a", "()Ljava/lang/String;") |
| 105 | )); | 96 | )); |
| 106 | } | 97 | } |
| 107 | 98 | ||
| 108 | @Test | 99 | @Test |
| 109 | @SuppressWarnings("unchecked") | 100 | @SuppressWarnings("unchecked") |
| 110 | public void fieldReferences() { | 101 | public void fieldReferences() { |
| 111 | FieldEntry source = newField("a", "a", "Ljava/lang/String;"); | 102 | FieldEntry source = newField("a", "a", "Ljava/lang/String;"); |
| 112 | Collection<EntryReference<FieldEntry,BehaviorEntry>> references = index.getFieldReferences(source); | 103 | Collection<EntryReference<FieldEntry, BehaviorEntry>> references = index.getFieldReferences(source); |
| 113 | assertThat(references, containsInAnyOrder( | 104 | assertThat(references, containsInAnyOrder( |
| 114 | newFieldReferenceByConstructor(source, "a", "(Ljava/lang/String;)V"), | 105 | newFieldReferenceByConstructor(source, "a", "(Ljava/lang/String;)V"), |
| 115 | newFieldReferenceByMethod(source, "a", "a", "()Ljava/lang/String;") | 106 | newFieldReferenceByMethod(source, "a", "a", "()Ljava/lang/String;") |
| 116 | )); | 107 | )); |
| 117 | } | 108 | } |
| 118 | 109 | ||
| 119 | @Test | 110 | @Test |
| 120 | public void behaviorReferences() { | 111 | public void behaviorReferences() { |
| 121 | assertThat(index.getBehaviorReferences(newMethod("a", "a", "()Ljava/lang/String;")), is(empty())); | 112 | assertThat(index.getBehaviorReferences(newMethod("a", "a", "()Ljava/lang/String;")), is(empty())); |
| 122 | } | 113 | } |
| 123 | 114 | ||
| 124 | @Test | 115 | @Test |
| 125 | public void innerClasses() { | 116 | public void innerClasses() { |
| 126 | assertThat(index.getInnerClasses(newClass("a")), is(empty())); | 117 | assertThat(index.getInnerClasses(newClass("a")), is(empty())); |
| 127 | } | 118 | } |
| 128 | 119 | ||
| 129 | @Test | 120 | @Test |
| 130 | public void outerClass() { | 121 | public void outerClass() { |
| 131 | assertThat(index.getOuterClass(newClass("a")), is(nullValue())); | 122 | assertThat(index.getOuterClass(newClass("a")), is(nullValue())); |
| 132 | } | 123 | } |
| 133 | 124 | ||
| 134 | @Test | 125 | @Test |
| 135 | public void isAnonymousClass() { | 126 | public void isAnonymousClass() { |
| 136 | assertThat(index.isAnonymousClass(newClass("a")), is(false)); | 127 | assertThat(index.isAnonymousClass(newClass("a")), is(false)); |
| 137 | } | 128 | } |
| 138 | 129 | ||
| 139 | @Test | 130 | @Test |
| 140 | public void interfaces() { | 131 | public void interfaces() { |
| 141 | assertThat(index.getInterfaces("a"), is(empty())); | 132 | assertThat(index.getInterfaces("a"), is(empty())); |
| 142 | } | 133 | } |
| 143 | 134 | ||
| 144 | @Test | 135 | @Test |
| 145 | public void implementingClasses() { | 136 | public void implementingClasses() { |
| 146 | assertThat(index.getImplementingClasses("a"), is(empty())); | 137 | assertThat(index.getImplementingClasses("a"), is(empty())); |
| 147 | } | 138 | } |
| 148 | 139 | ||
| 149 | @Test | 140 | @Test |
| 150 | public void isInterface() { | 141 | public void isInterface() { |
| 151 | assertThat(index.isInterface("a"), is(false)); | 142 | assertThat(index.isInterface("a"), is(false)); |
| 152 | } | 143 | } |
| 153 | 144 | ||
| 154 | @Test | 145 | @Test |
| 155 | public void testContains() { | 146 | public void testContains() { |
| 156 | assertThat(index.containsObfClass(newClass("a")), is(true)); | 147 | assertThat(index.containsObfClass(newClass("a")), is(true)); |