diff options
Diffstat (limited to 'test/cuchaz/enigma/TestTranslator.java')
| -rw-r--r-- | test/cuchaz/enigma/TestTranslator.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/cuchaz/enigma/TestTranslator.java b/test/cuchaz/enigma/TestTranslator.java new file mode 100644 index 0000000..290f6f0 --- /dev/null +++ b/test/cuchaz/enigma/TestTranslator.java | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | package cuchaz.enigma; | ||
| 2 | |||
| 3 | import static cuchaz.enigma.EntryFactory.*; | ||
| 4 | import static org.hamcrest.MatcherAssert.*; | ||
| 5 | import static org.hamcrest.Matchers.*; | ||
| 6 | |||
| 7 | import java.io.InputStream; | ||
| 8 | import java.io.InputStreamReader; | ||
| 9 | import java.util.jar.JarFile; | ||
| 10 | |||
| 11 | import org.junit.Test; | ||
| 12 | |||
| 13 | import cuchaz.enigma.mapping.Mappings; | ||
| 14 | import cuchaz.enigma.mapping.MappingsReader; | ||
| 15 | import cuchaz.enigma.mapping.TranslationDirection; | ||
| 16 | import cuchaz.enigma.mapping.Translator; | ||
| 17 | |||
| 18 | |||
| 19 | public class TestTranslator { | ||
| 20 | |||
| 21 | private Deobfuscator m_deobfuscator; | ||
| 22 | private Mappings m_mappings; | ||
| 23 | |||
| 24 | public TestTranslator() | ||
| 25 | throws Exception { | ||
| 26 | m_deobfuscator = new Deobfuscator(new JarFile("build/testTranslation.obf.jar")); | ||
| 27 | try (InputStream in = getClass().getResourceAsStream("/cuchaz/enigma/resources/translation.mappings")) { | ||
| 28 | m_mappings = new MappingsReader().read(new InputStreamReader(in)); | ||
| 29 | m_deobfuscator.setMappings(m_mappings); | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | @Test | ||
| 34 | public void deobfuscatingTranslations() | ||
| 35 | throws Exception { | ||
| 36 | Translator translator = m_deobfuscator.getTranslator(TranslationDirection.Deobfuscating); | ||
| 37 | assertThat(translator.translateEntry(newClass("none/a")), is(newClass("deobf/A"))); | ||
| 38 | } | ||
| 39 | } | ||