LightDecompiler { public static String decompile(byte[] source) { return decompile("Temp", source); }  static String decompile(byte[] source); static String decompile(String fileName, byte[] source); static List<String> decompile(List<byte[]> sources);  }
@Test public void testDecompile() throws Exception { FernFlowerDecompiler decompiler = new FernFlowerDecompiler(); decompiler.setByteCode(TestUtil.load(TestMethods.class.getName())); Fernflower fernflower = new Fernflower(decompiler, decompiler, new HashMap<String, Object>(), new FernFlowerLogger()); try { fernflower.getStructContext().addSpaceForLight("", absolutePath(), true); fernflower.decompileContext(); if (SystemProperty.WINDOWS_OS) { assertThat(decompiler.getContent(), is(EXPECT)); } } finally { fernflower.clearContext(); } }
@Test public void testDecompileUseAPI() throws Exception { FernFlowerDecompiler decompiler = new FernFlowerDecompiler(); decompiler.setByteCode(TestUtil.load(TestMethods.class.getName())); Fernflower fernflower = new Fernflower(decompiler, decompiler, new HashMap<String, Object>(), new FernFlowerLogger()); try { fernflower.getStructContext().addSpace(new File(absolutePath()), true); fernflower.decompileContext(); assertThat(LightDecompiler.decompile(TestUtil.load(TestMethods.class.getName())), is(decompiler.getContent())); assertThat(LightDecompiler.decompile(TestMethods.class.getSimpleName(), TestUtil.load(TestMethods.class.getName())), is(decompiler.getContent())); } finally { fernflower.clearContext(); } }
@Test public void testDecompileUseAPIForArray() throws Exception { assertThat(LightDecompiler.decompile(TestUtil.load(TestMethods.class.getName())), is(EXPECT)); assertThat(LightDecompiler.decompile(new ArrayList<byte[]>()), notNullValue()); List<byte[]> sources = new ArrayList<byte[]>(); sources.add(TestUtil.load(TestMethods.class.getName())); sources.add(TestUtil.load(TestMethods.class.getName())); sources.add(TestUtil.load(TestMethods.class.getName())); List<String> result = LightDecompiler.decompile(sources); assertThat(result.size(), is(sources.size())); for (String source : result) { assertThat(source, is(EXPECT)); } }