summaryrefslogtreecommitdiff
path: root/test/cuchaz/enigma/TestSourceIndex.java
diff options
context:
space:
mode:
Diffstat (limited to 'test/cuchaz/enigma/TestSourceIndex.java')
-rw-r--r--test/cuchaz/enigma/TestSourceIndex.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/cuchaz/enigma/TestSourceIndex.java b/test/cuchaz/enigma/TestSourceIndex.java
new file mode 100644
index 0000000..357acb6
--- /dev/null
+++ b/test/cuchaz/enigma/TestSourceIndex.java
@@ -0,0 +1,50 @@
1/*******************************************************************************
2 * Copyright (c) 2014 Jeff Martin.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the GNU Public License v3.0
6 * which accompanies this distribution, and is available at
7 * http://www.gnu.org/licenses/gpl.html
8 *
9 * Contributors:
10 * Jeff Martin - initial API and implementation
11 ******************************************************************************/
12package cuchaz.enigma;
13
14import java.util.Set;
15import java.util.jar.JarFile;
16
17import org.junit.Test;
18
19import com.google.common.collect.Sets;
20import com.strobel.decompiler.languages.java.ast.CompilationUnit;
21
22import cuchaz.enigma.mapping.ClassEntry;
23
24public class TestSourceIndex {
25
26 // TEMP
27 //@Test
28 public void indexEverything()
29 throws Exception {
30 Deobfuscator deobfuscator = new Deobfuscator(new JarFile("input/1.8.jar"));
31
32 // get all classes that aren't inner classes
33 Set<ClassEntry> classEntries = Sets.newHashSet();
34 for (ClassEntry obfClassEntry : deobfuscator.getJarIndex().getObfClassEntries()) {
35 if (!obfClassEntry.isInnerClass()) {
36 classEntries.add(obfClassEntry);
37 }
38 }
39
40 for (ClassEntry obfClassEntry : classEntries) {
41 try {
42 CompilationUnit tree = deobfuscator.getSourceTree(obfClassEntry.getName());
43 String source = deobfuscator.getSource(tree);
44 deobfuscator.getSourceIndex(tree, source);
45 } catch (Throwable t) {
46 throw new Error("Unable to index " + obfClassEntry, t);
47 }
48 }
49 }
50}