diff options
| author | 2020-07-06 06:34:10 -0400 | |
|---|---|---|
| committer | 2020-07-06 12:34:10 +0200 | |
| commit | f0885819aeeb2edbfcfc0b23566cccb571166a02 (patch) | |
| tree | d650aa68641fdfd9cc5f5ed0093229d1840506d8 /enigma/src/test | |
| parent | Fix "Mark as Deobfuscated" menu entry not working... this time without breaki... (diff) | |
| download | enigma-fork-f0885819aeeb2edbfcfc0b23566cccb571166a02.tar.gz enigma-fork-f0885819aeeb2edbfcfc0b23566cccb571166a02.tar.xz enigma-fork-f0885819aeeb2edbfcfc0b23566cccb571166a02.zip | |
Make class loading more flexible (#277)
Diffstat (limited to 'enigma/src/test')
9 files changed, 57 insertions, 42 deletions
diff --git a/enigma/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java b/enigma/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java index 1dc9748..1251535 100644 --- a/enigma/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java +++ b/enigma/src/test/java/cuchaz/enigma/PackageVisibilityIndexTest.java | |||
| @@ -11,12 +11,13 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.analysis.ClassCache; | ||
| 15 | import cuchaz.enigma.analysis.index.JarIndex; | 14 | import cuchaz.enigma.analysis.index.JarIndex; |
| 16 | import cuchaz.enigma.analysis.index.PackageVisibilityIndex; | 15 | import cuchaz.enigma.analysis.index.PackageVisibilityIndex; |
| 16 | import cuchaz.enigma.classprovider.JarClassProvider; | ||
| 17 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | 17 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 18 | import org.junit.Test; | 18 | import org.junit.Test; |
| 19 | 19 | ||
| 20 | import java.nio.file.Path; | ||
| 20 | import java.nio.file.Paths; | 21 | import java.nio.file.Paths; |
| 21 | 22 | ||
| 22 | import static cuchaz.enigma.TestEntryFactory.newClass; | 23 | import static cuchaz.enigma.TestEntryFactory.newClass; |
| @@ -25,7 +26,7 @@ import static org.hamcrest.Matchers.contains; | |||
| 25 | import static org.hamcrest.Matchers.containsInAnyOrder; | 26 | import static org.hamcrest.Matchers.containsInAnyOrder; |
| 26 | 27 | ||
| 27 | public class PackageVisibilityIndexTest { | 28 | public class PackageVisibilityIndexTest { |
| 28 | 29 | public static final Path JAR = Paths.get("build/test-obf/packageAccess.jar"); | |
| 29 | private static final ClassEntry KEEP = newClass("cuchaz/enigma/inputs/Keep"); | 30 | private static final ClassEntry KEEP = newClass("cuchaz/enigma/inputs/Keep"); |
| 30 | private static final ClassEntry BASE = newClass("a"); | 31 | private static final ClassEntry BASE = newClass("a"); |
| 31 | private static final ClassEntry SAME_PACKAGE_CHILD = newClass("b"); | 32 | private static final ClassEntry SAME_PACKAGE_CHILD = newClass("b"); |
| @@ -35,8 +36,9 @@ public class PackageVisibilityIndexTest { | |||
| 35 | private final JarIndex jarIndex; | 36 | private final JarIndex jarIndex; |
| 36 | 37 | ||
| 37 | public PackageVisibilityIndexTest() throws Exception { | 38 | public PackageVisibilityIndexTest() throws Exception { |
| 38 | ClassCache classCache = ClassCache.of(Paths.get("build/test-obf/packageAccess.jar")); | 39 | JarClassProvider jcp = new JarClassProvider(JAR); |
| 39 | jarIndex = classCache.index(ProgressListener.none()); | 40 | jarIndex = JarIndex.empty(); |
| 41 | jarIndex.indexJar(jcp.getClassNames(), jcp, ProgressListener.none()); | ||
| 40 | } | 42 | } |
| 41 | 43 | ||
| 42 | @Test | 44 | @Test |
diff --git a/enigma/src/test/java/cuchaz/enigma/TestDeobfed.java b/enigma/src/test/java/cuchaz/enigma/TestDeobfed.java index 494d959..6daa293 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestDeobfed.java +++ b/enigma/src/test/java/cuchaz/enigma/TestDeobfed.java | |||
| @@ -11,8 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.analysis.ClassCache; | 14 | import cuchaz.enigma.classprovider.ClasspathClassProvider; |
| 15 | import cuchaz.enigma.analysis.index.JarIndex; | ||
| 16 | import cuchaz.enigma.source.Decompiler; | 15 | import cuchaz.enigma.source.Decompiler; |
| 17 | import cuchaz.enigma.source.Decompilers; | 16 | import cuchaz.enigma.source.Decompilers; |
| 18 | import cuchaz.enigma.source.SourceSettings; | 17 | import cuchaz.enigma.source.SourceSettings; |
| @@ -28,27 +27,24 @@ import static org.hamcrest.MatcherAssert.assertThat; | |||
| 28 | import static org.hamcrest.Matchers.containsInAnyOrder; | 27 | import static org.hamcrest.Matchers.containsInAnyOrder; |
| 29 | 28 | ||
| 30 | public class TestDeobfed { | 29 | public class TestDeobfed { |
| 31 | private static Enigma enigma; | 30 | public static final Path OBF = Paths.get("build/test-obf/translation.jar"); |
| 32 | private static ClassCache classCache; | 31 | public static final Path DEOBF = Paths.get("build/test-deobf/translation.jar"); |
| 33 | private static JarIndex index; | 32 | private static EnigmaProject deobfProject; |
| 34 | 33 | ||
| 35 | @BeforeClass | 34 | @BeforeClass |
| 36 | public static void beforeClass() throws Exception { | 35 | public static void beforeClass() throws Exception { |
| 37 | enigma = Enigma.create(); | 36 | Enigma enigma = Enigma.create(); |
| 38 | 37 | ||
| 39 | Path obf = Paths.get("build/test-obf/translation.jar"); | 38 | Files.createDirectories(DEOBF.getParent()); |
| 40 | Path deobf = Paths.get("build/test-deobf/translation.jar"); | 39 | EnigmaProject obfProject = enigma.openJar(OBF, new ClasspathClassProvider(), ProgressListener.none()); |
| 41 | Files.createDirectories(deobf.getParent()); | 40 | obfProject.exportRemappedJar(ProgressListener.none()).write(DEOBF, ProgressListener.none()); |
| 42 | EnigmaProject project = enigma.openJar(obf, ProgressListener.none()); | ||
| 43 | project.exportRemappedJar(ProgressListener.none()).write(deobf, ProgressListener.none()); | ||
| 44 | 41 | ||
| 45 | classCache = ClassCache.of(deobf); | 42 | deobfProject = enigma.openJar(DEOBF, new ClasspathClassProvider(), ProgressListener.none()); |
| 46 | index = classCache.index(ProgressListener.none()); | ||
| 47 | } | 43 | } |
| 48 | 44 | ||
| 49 | @Test | 45 | @Test |
| 50 | public void obfEntries() { | 46 | public void obfEntries() { |
| 51 | assertThat(index.getEntryIndex().getClasses(), containsInAnyOrder( | 47 | assertThat(deobfProject.getJarIndex().getEntryIndex().getClasses(), containsInAnyOrder( |
| 52 | newClass("cuchaz/enigma/inputs/Keep"), | 48 | newClass("cuchaz/enigma/inputs/Keep"), |
| 53 | newClass("a"), | 49 | newClass("a"), |
| 54 | newClass("b"), | 50 | newClass("b"), |
| @@ -77,8 +73,7 @@ public class TestDeobfed { | |||
| 77 | 73 | ||
| 78 | @Test | 74 | @Test |
| 79 | public void decompile() { | 75 | public void decompile() { |
| 80 | EnigmaProject project = new EnigmaProject(enigma, classCache, index, new byte[20]); | 76 | Decompiler decompiler = Decompilers.PROCYON.create(deobfProject.getClassProvider(), new SourceSettings(false, false)); |
| 81 | Decompiler decompiler = Decompilers.PROCYON.create(project.getClassCache(), new SourceSettings(false, false)); | ||
| 82 | 77 | ||
| 83 | decompiler.getSource("a"); | 78 | decompiler.getSource("a"); |
| 84 | decompiler.getSource("b"); | 79 | decompiler.getSource("b"); |
diff --git a/enigma/src/test/java/cuchaz/enigma/TestDeobfuscator.java b/enigma/src/test/java/cuchaz/enigma/TestDeobfuscator.java index 6619d26..ae42235 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestDeobfuscator.java +++ b/enigma/src/test/java/cuchaz/enigma/TestDeobfuscator.java | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.classprovider.ClasspathClassProvider; | ||
| 14 | import cuchaz.enigma.source.Decompiler; | 15 | import cuchaz.enigma.source.Decompiler; |
| 15 | import cuchaz.enigma.source.Decompilers; | 16 | import cuchaz.enigma.source.Decompilers; |
| 16 | import cuchaz.enigma.source.SourceSettings; | 17 | import cuchaz.enigma.source.SourceSettings; |
| @@ -22,7 +23,7 @@ import java.nio.file.Paths; | |||
| 22 | public class TestDeobfuscator { | 23 | public class TestDeobfuscator { |
| 23 | private EnigmaProject openProject() throws IOException { | 24 | private EnigmaProject openProject() throws IOException { |
| 24 | Enigma enigma = Enigma.create(); | 25 | Enigma enigma = Enigma.create(); |
| 25 | return enigma.openJar(Paths.get("build/test-obf/loneClass.jar"), ProgressListener.none()); | 26 | return enigma.openJar(Paths.get("build/test-obf/loneClass.jar"), new ClasspathClassProvider(), ProgressListener.none()); |
| 26 | } | 27 | } |
| 27 | 28 | ||
| 28 | @Test | 29 | @Test |
| @@ -34,7 +35,7 @@ public class TestDeobfuscator { | |||
| 34 | @Test | 35 | @Test |
| 35 | public void decompileClass() throws Exception { | 36 | public void decompileClass() throws Exception { |
| 36 | EnigmaProject project = openProject(); | 37 | EnigmaProject project = openProject(); |
| 37 | Decompiler decompiler = Decompilers.PROCYON.create(project.getClassCache(), new SourceSettings(false, false)); | 38 | Decompiler decompiler = Decompilers.PROCYON.create(project.getClassProvider(), new SourceSettings(false, false)); |
| 38 | 39 | ||
| 39 | decompiler.getSource("a").asString(); | 40 | decompiler.getSource("a").asString(); |
| 40 | } | 41 | } |
diff --git a/enigma/src/test/java/cuchaz/enigma/TestInnerClasses.java b/enigma/src/test/java/cuchaz/enigma/TestInnerClasses.java index 85c72f8..6b60994 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestInnerClasses.java +++ b/enigma/src/test/java/cuchaz/enigma/TestInnerClasses.java | |||
| @@ -11,14 +11,16 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.analysis.ClassCache; | ||
| 15 | import cuchaz.enigma.analysis.index.JarIndex; | 14 | import cuchaz.enigma.analysis.index.JarIndex; |
| 15 | import cuchaz.enigma.classprovider.CachingClassProvider; | ||
| 16 | import cuchaz.enigma.classprovider.JarClassProvider; | ||
| 16 | import cuchaz.enigma.source.Decompiler; | 17 | import cuchaz.enigma.source.Decompiler; |
| 17 | import cuchaz.enigma.source.Decompilers; | 18 | import cuchaz.enigma.source.Decompilers; |
| 18 | import cuchaz.enigma.source.SourceSettings; | 19 | import cuchaz.enigma.source.SourceSettings; |
| 19 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | 20 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 20 | import org.junit.Test; | 21 | import org.junit.Test; |
| 21 | 22 | ||
| 23 | import java.nio.file.Path; | ||
| 22 | import java.nio.file.Paths; | 24 | import java.nio.file.Paths; |
| 23 | 25 | ||
| 24 | import static cuchaz.enigma.TestEntryFactory.newClass; | 26 | import static cuchaz.enigma.TestEntryFactory.newClass; |
| @@ -35,13 +37,16 @@ public class TestInnerClasses { | |||
| 35 | private static final ClassEntry ClassTreeLevel1 = newClass("f$a"); | 37 | private static final ClassEntry ClassTreeLevel1 = newClass("f$a"); |
| 36 | private static final ClassEntry ClassTreeLevel2 = newClass("f$a$a"); | 38 | private static final ClassEntry ClassTreeLevel2 = newClass("f$a$a"); |
| 37 | private static final ClassEntry ClassTreeLevel3 = newClass("f$a$a$a"); | 39 | private static final ClassEntry ClassTreeLevel3 = newClass("f$a$a$a"); |
| 40 | public static final Path JAR = Paths.get("build/test-obf/innerClasses.jar"); | ||
| 38 | private final JarIndex index; | 41 | private final JarIndex index; |
| 39 | private final Decompiler decompiler; | 42 | private final Decompiler decompiler; |
| 40 | 43 | ||
| 41 | public TestInnerClasses() throws Exception { | 44 | public TestInnerClasses() throws Exception { |
| 42 | ClassCache classCache = ClassCache.of(Paths.get("build/test-obf/innerClasses.jar")); | 45 | JarClassProvider jcp = new JarClassProvider(JAR); |
| 43 | index = classCache.index(ProgressListener.none()); | 46 | CachingClassProvider classProvider = new CachingClassProvider(jcp); |
| 44 | decompiler = Decompilers.PROCYON.create(classCache, new SourceSettings(false, false)); | 47 | index = JarIndex.empty(); |
| 48 | index.indexJar(jcp.getClassNames(), classProvider, ProgressListener.none()); | ||
| 49 | decompiler = Decompilers.PROCYON.create(classProvider, new SourceSettings(false, false)); | ||
| 45 | } | 50 | } |
| 46 | 51 | ||
| 47 | @Test | 52 | @Test |
diff --git a/enigma/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java b/enigma/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java index 48975c8..0790193 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java +++ b/enigma/src/test/java/cuchaz/enigma/TestJarIndexConstructorReferences.java | |||
| @@ -11,14 +11,16 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.analysis.ClassCache; | ||
| 15 | import cuchaz.enigma.analysis.EntryReference; | 14 | import cuchaz.enigma.analysis.EntryReference; |
| 16 | import cuchaz.enigma.analysis.index.JarIndex; | 15 | import cuchaz.enigma.analysis.index.JarIndex; |
| 16 | import cuchaz.enigma.classprovider.CachingClassProvider; | ||
| 17 | import cuchaz.enigma.classprovider.JarClassProvider; | ||
| 17 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | 18 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 18 | import cuchaz.enigma.translation.representation.entry.MethodDefEntry; | 19 | import cuchaz.enigma.translation.representation.entry.MethodDefEntry; |
| 19 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | 20 | import cuchaz.enigma.translation.representation.entry.MethodEntry; |
| 20 | import org.junit.Test; | 21 | import org.junit.Test; |
| 21 | 22 | ||
| 23 | import java.nio.file.Path; | ||
| 22 | import java.nio.file.Paths; | 24 | import java.nio.file.Paths; |
| 23 | import java.util.Collection; | 25 | import java.util.Collection; |
| 24 | 26 | ||
| @@ -28,6 +30,7 @@ import static org.hamcrest.Matchers.*; | |||
| 28 | 30 | ||
| 29 | public class TestJarIndexConstructorReferences { | 31 | public class TestJarIndexConstructorReferences { |
| 30 | 32 | ||
| 33 | public static final Path JAR = Paths.get("build/test-obf/constructors.jar"); | ||
| 31 | private JarIndex index; | 34 | private JarIndex index; |
| 32 | 35 | ||
| 33 | private ClassEntry baseClass = newClass("a"); | 36 | private ClassEntry baseClass = newClass("a"); |
| @@ -37,8 +40,9 @@ public class TestJarIndexConstructorReferences { | |||
| 37 | private ClassEntry callerClass = newClass("b"); | 40 | private ClassEntry callerClass = newClass("b"); |
| 38 | 41 | ||
| 39 | public TestJarIndexConstructorReferences() throws Exception { | 42 | public TestJarIndexConstructorReferences() throws Exception { |
| 40 | ClassCache classCache = ClassCache.of(Paths.get("build/test-obf/constructors.jar")); | 43 | JarClassProvider jcp = new JarClassProvider(JAR); |
| 41 | index = classCache.index(ProgressListener.none()); | 44 | index = JarIndex.empty(); |
| 45 | index.indexJar(jcp.getClassNames(), new CachingClassProvider(jcp), ProgressListener.none()); | ||
| 42 | } | 46 | } |
| 43 | 47 | ||
| 44 | @Test | 48 | @Test |
diff --git a/enigma/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java b/enigma/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java index 76e379c..a9045f9 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java +++ b/enigma/src/test/java/cuchaz/enigma/TestJarIndexInheritanceTree.java | |||
| @@ -11,11 +11,12 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.analysis.ClassCache; | ||
| 15 | import cuchaz.enigma.analysis.EntryReference; | 14 | import cuchaz.enigma.analysis.EntryReference; |
| 16 | import cuchaz.enigma.analysis.index.EntryIndex; | 15 | import cuchaz.enigma.analysis.index.EntryIndex; |
| 17 | import cuchaz.enigma.analysis.index.InheritanceIndex; | 16 | import cuchaz.enigma.analysis.index.InheritanceIndex; |
| 18 | import cuchaz.enigma.analysis.index.JarIndex; | 17 | import cuchaz.enigma.analysis.index.JarIndex; |
| 18 | import cuchaz.enigma.classprovider.CachingClassProvider; | ||
| 19 | import cuchaz.enigma.classprovider.JarClassProvider; | ||
| 19 | import cuchaz.enigma.translation.mapping.EntryResolver; | 20 | import cuchaz.enigma.translation.mapping.EntryResolver; |
| 20 | import cuchaz.enigma.translation.mapping.IndexEntryResolver; | 21 | import cuchaz.enigma.translation.mapping.IndexEntryResolver; |
| 21 | import cuchaz.enigma.translation.representation.AccessFlags; | 22 | import cuchaz.enigma.translation.representation.AccessFlags; |
| @@ -26,6 +27,7 @@ import cuchaz.enigma.translation.representation.entry.MethodEntry; | |||
| 26 | import org.junit.Test; | 27 | import org.junit.Test; |
| 27 | import org.objectweb.asm.Opcodes; | 28 | import org.objectweb.asm.Opcodes; |
| 28 | 29 | ||
| 30 | import java.nio.file.Path; | ||
| 29 | import java.nio.file.Paths; | 31 | import java.nio.file.Paths; |
| 30 | import java.util.Collection; | 32 | import java.util.Collection; |
| 31 | 33 | ||
| @@ -35,6 +37,7 @@ import static org.hamcrest.Matchers.*; | |||
| 35 | 37 | ||
| 36 | public class TestJarIndexInheritanceTree { | 38 | public class TestJarIndexInheritanceTree { |
| 37 | 39 | ||
| 40 | public static final Path JAR = Paths.get("build/test-obf/inheritanceTree.jar"); | ||
| 38 | private JarIndex index; | 41 | private JarIndex index; |
| 39 | 42 | ||
| 40 | private ClassEntry baseClass = newClass("a"); | 43 | private ClassEntry baseClass = newClass("a"); |
| @@ -44,10 +47,10 @@ public class TestJarIndexInheritanceTree { | |||
| 44 | private FieldEntry nameField = newField(baseClass, "a", "Ljava/lang/String;"); | 47 | private FieldEntry nameField = newField(baseClass, "a", "Ljava/lang/String;"); |
| 45 | private FieldEntry numThingsField = newField(subClassB, "a", "I"); | 48 | private FieldEntry numThingsField = newField(subClassB, "a", "I"); |
| 46 | 49 | ||
| 47 | public TestJarIndexInheritanceTree() | 50 | public TestJarIndexInheritanceTree() throws Exception { |
| 48 | throws Exception { | 51 | JarClassProvider jcp = new JarClassProvider(JAR); |
| 49 | ClassCache classCache = ClassCache.of(Paths.get("build/test-obf/inheritanceTree.jar")); | 52 | index = JarIndex.empty(); |
| 50 | index = classCache.index(ProgressListener.none()); | 53 | index.indexJar(jcp.getClassNames(), new CachingClassProvider(jcp), ProgressListener.none()); |
| 51 | } | 54 | } |
| 52 | 55 | ||
| 53 | @Test | 56 | @Test |
diff --git a/enigma/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java b/enigma/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java index 103c366..6e3755c 100644 --- a/enigma/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java +++ b/enigma/src/test/java/cuchaz/enigma/TestJarIndexLoneClass.java | |||
| @@ -15,6 +15,8 @@ import cuchaz.enigma.analysis.*; | |||
| 15 | import cuchaz.enigma.analysis.index.EntryIndex; | 15 | import cuchaz.enigma.analysis.index.EntryIndex; |
| 16 | import cuchaz.enigma.analysis.index.InheritanceIndex; | 16 | import cuchaz.enigma.analysis.index.InheritanceIndex; |
| 17 | import cuchaz.enigma.analysis.index.JarIndex; | 17 | import cuchaz.enigma.analysis.index.JarIndex; |
| 18 | import cuchaz.enigma.classprovider.CachingClassProvider; | ||
| 19 | import cuchaz.enigma.classprovider.JarClassProvider; | ||
| 18 | import cuchaz.enigma.translation.VoidTranslator; | 20 | import cuchaz.enigma.translation.VoidTranslator; |
| 19 | import cuchaz.enigma.translation.representation.AccessFlags; | 21 | import cuchaz.enigma.translation.representation.AccessFlags; |
| 20 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | 22 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| @@ -23,6 +25,7 @@ import cuchaz.enigma.translation.representation.entry.MethodDefEntry; | |||
| 23 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | 25 | import cuchaz.enigma.translation.representation.entry.MethodEntry; |
| 24 | import org.junit.Test; | 26 | import org.junit.Test; |
| 25 | 27 | ||
| 28 | import java.nio.file.Path; | ||
| 26 | import java.nio.file.Paths; | 29 | import java.nio.file.Paths; |
| 27 | import java.util.Collection; | 30 | import java.util.Collection; |
| 28 | import java.util.List; | 31 | import java.util.List; |
| @@ -33,11 +36,13 @@ import static org.hamcrest.Matchers.*; | |||
| 33 | 36 | ||
| 34 | public class TestJarIndexLoneClass { | 37 | public class TestJarIndexLoneClass { |
| 35 | 38 | ||
| 39 | public static final Path JAR = Paths.get("build/test-obf/loneClass.jar"); | ||
| 36 | private JarIndex index; | 40 | private JarIndex index; |
| 37 | 41 | ||
| 38 | public TestJarIndexLoneClass() throws Exception { | 42 | public TestJarIndexLoneClass() throws Exception { |
| 39 | ClassCache classCache = ClassCache.of(Paths.get("build/test-obf/loneClass.jar")); | 43 | JarClassProvider jcp = new JarClassProvider(JAR); |
| 40 | index = classCache.index(ProgressListener.none()); | 44 | index = JarIndex.empty(); |
| 45 | index.indexJar(jcp.getClassNames(), new CachingClassProvider(jcp), ProgressListener.none()); | ||
| 41 | } | 46 | } |
| 42 | 47 | ||
| 43 | @Test | 48 | @Test |
diff --git a/enigma/src/test/java/cuchaz/enigma/TokenChecker.java b/enigma/src/test/java/cuchaz/enigma/TokenChecker.java index 96fc6da..feef272 100644 --- a/enigma/src/test/java/cuchaz/enigma/TokenChecker.java +++ b/enigma/src/test/java/cuchaz/enigma/TokenChecker.java | |||
| @@ -12,11 +12,10 @@ | |||
| 12 | package cuchaz.enigma; | 12 | package cuchaz.enigma; |
| 13 | 13 | ||
| 14 | import com.google.common.collect.Lists; | 14 | import com.google.common.collect.Lists; |
| 15 | import cuchaz.enigma.analysis.ClassCache; | ||
| 16 | import cuchaz.enigma.analysis.EntryReference; | 15 | import cuchaz.enigma.analysis.EntryReference; |
| 17 | import cuchaz.enigma.source.SourceIndex; | 16 | import cuchaz.enigma.classprovider.CachingClassProvider; |
| 17 | import cuchaz.enigma.classprovider.JarClassProvider; | ||
| 18 | import cuchaz.enigma.source.*; | 18 | import cuchaz.enigma.source.*; |
| 19 | import cuchaz.enigma.source.Token; | ||
| 20 | import cuchaz.enigma.translation.representation.entry.Entry; | 19 | import cuchaz.enigma.translation.representation.entry.Entry; |
| 21 | 20 | ||
| 22 | import java.io.IOException; | 21 | import java.io.IOException; |
| @@ -28,8 +27,8 @@ public class TokenChecker { | |||
| 28 | private final Decompiler decompiler; | 27 | private final Decompiler decompiler; |
| 29 | 28 | ||
| 30 | protected TokenChecker(Path path) throws IOException { | 29 | protected TokenChecker(Path path) throws IOException { |
| 31 | ClassCache classCache = ClassCache.of(path); | 30 | CachingClassProvider classProvider = new CachingClassProvider(new JarClassProvider(path)); |
| 32 | decompiler = Decompilers.PROCYON.create(classCache, new SourceSettings(false, false)); | 31 | decompiler = Decompilers.PROCYON.create(classProvider, new SourceSettings(false, false)); |
| 33 | } | 32 | } |
| 34 | 33 | ||
| 35 | protected String getDeclarationToken(Entry<?> entry) { | 34 | protected String getDeclarationToken(Entry<?> entry) { |
diff --git a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestTinyV2InnerClasses.java b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestTinyV2InnerClasses.java index 65941e5..60c70b7 100644 --- a/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestTinyV2InnerClasses.java +++ b/enigma/src/test/java/cuchaz/enigma/translation/mapping/TestTinyV2InnerClasses.java | |||
| @@ -14,6 +14,7 @@ package cuchaz.enigma.translation.mapping; | |||
| 14 | import cuchaz.enigma.Enigma; | 14 | import cuchaz.enigma.Enigma; |
| 15 | import cuchaz.enigma.EnigmaProject; | 15 | import cuchaz.enigma.EnigmaProject; |
| 16 | import cuchaz.enigma.ProgressListener; | 16 | import cuchaz.enigma.ProgressListener; |
| 17 | import cuchaz.enigma.classprovider.ClasspathClassProvider; | ||
| 17 | import cuchaz.enigma.translation.mapping.serde.enigma.EnigmaMappingsReader; | 18 | import cuchaz.enigma.translation.mapping.serde.enigma.EnigmaMappingsReader; |
| 18 | 19 | ||
| 19 | import java.nio.file.Path; | 20 | import java.nio.file.Path; |
| @@ -30,7 +31,7 @@ public final class TestTinyV2InnerClasses { | |||
| 30 | 31 | ||
| 31 | // @Test | 32 | // @Test |
| 32 | public void testMappings() throws Exception { | 33 | public void testMappings() throws Exception { |
| 33 | EnigmaProject project = Enigma.create().openJar(jar, ProgressListener.none()); | 34 | EnigmaProject project = Enigma.create().openJar(jar, new ClasspathClassProvider(), ProgressListener.none()); |
| 34 | project.setMappings(EnigmaMappingsReader.DIRECTORY.read(mappings, ProgressListener.none(), project.getEnigma().getProfile().getMappingSaveParameters())); | 35 | project.setMappings(EnigmaMappingsReader.DIRECTORY.read(mappings, ProgressListener.none(), project.getEnigma().getProfile().getMappingSaveParameters())); |
| 35 | 36 | ||
| 36 | } | 37 | } |