diff options
Diffstat (limited to 'test/cuchaz/enigma/TestDeobfuscator.java')
| -rw-r--r-- | test/cuchaz/enigma/TestDeobfuscator.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/cuchaz/enigma/TestDeobfuscator.java b/test/cuchaz/enigma/TestDeobfuscator.java new file mode 100644 index 0000000..129d7b2 --- /dev/null +++ b/test/cuchaz/enigma/TestDeobfuscator.java | |||
| @@ -0,0 +1,54 @@ | |||
| 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 | ******************************************************************************/ | ||
| 12 | package cuchaz.enigma; | ||
| 13 | |||
| 14 | import static org.junit.Assert.*; | ||
| 15 | |||
| 16 | import java.io.IOException; | ||
| 17 | import java.util.List; | ||
| 18 | import java.util.jar.JarFile; | ||
| 19 | |||
| 20 | import org.junit.Test; | ||
| 21 | |||
| 22 | import com.google.common.collect.Lists; | ||
| 23 | |||
| 24 | import cuchaz.enigma.mapping.ClassEntry; | ||
| 25 | |||
| 26 | public class TestDeobfuscator { | ||
| 27 | |||
| 28 | private Deobfuscator getDeobfuscator() throws IOException { | ||
| 29 | return new Deobfuscator(new JarFile("build/testLoneClass.obf.jar")); | ||
| 30 | } | ||
| 31 | |||
| 32 | @Test | ||
| 33 | public void loadJar() throws Exception { | ||
| 34 | getDeobfuscator(); | ||
| 35 | } | ||
| 36 | |||
| 37 | @Test | ||
| 38 | public void getClasses() throws Exception { | ||
| 39 | Deobfuscator deobfuscator = getDeobfuscator(); | ||
| 40 | List<ClassEntry> obfClasses = Lists.newArrayList(); | ||
| 41 | List<ClassEntry> deobfClasses = Lists.newArrayList(); | ||
| 42 | deobfuscator.getSeparatedClasses(obfClasses, deobfClasses); | ||
| 43 | assertEquals(1, obfClasses.size()); | ||
| 44 | assertEquals("none/a", obfClasses.get(0).getName()); | ||
| 45 | assertEquals(1, deobfClasses.size()); | ||
| 46 | assertEquals("cuchaz/enigma/inputs/Keep", deobfClasses.get(0).getName()); | ||
| 47 | } | ||
| 48 | |||
| 49 | @Test | ||
| 50 | public void decompileClass() throws Exception { | ||
| 51 | Deobfuscator deobfuscator = getDeobfuscator(); | ||
| 52 | deobfuscator.getSource(deobfuscator.getSourceTree("none/a")); | ||
| 53 | } | ||
| 54 | } | ||