Cleanup (test)

master
Roman Shevchenko 10 years ago
parent cf72873535
commit ccd7b93497
  1. 31
      test/org/jetbrains/java/decompiler/SingleClassesTest.java

@ -21,6 +21,9 @@ import org.junit.Before;
import org.junit.Test;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ -60,14 +63,7 @@ public class SingleClassesTest {
assertTrue(classFile.isFile());
ConsoleDecompiler decompiler = fixture.getDecompiler();
decompiler.addSpace(classFile, true);
File[] innerClasses = classFile.getParentFile().listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.matches(testName + "\\$.+\\.class");
}
});
for (File inner : innerClasses) {
for (File inner : collectClasses(classFile)) {
decompiler.addSpace(inner, true);
}
@ -88,6 +84,25 @@ public class SingleClassesTest {
}
}
private static List<File> collectClasses(File classFile) {
List<File> files = new ArrayList<File>();
files.add(classFile);
File parent = classFile.getParentFile();
if (parent != null) {
final String pattern = classFile.getName().replace(".class", "") + "\\$.+\\.class";
File[] inner = parent.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.matches(pattern);
}
});
if (inner != null) Collections.addAll(files, inner);
}
return files;
}
private static String getContent(File file) throws IOException {
Reader reader = new InputStreamReader(new FileInputStream(file), "UTF-8");
try {

Loading…
Cancel
Save