From 960d111a1e9528a9c6c56f00777651aceea154da Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Wed, 22 Apr 2015 07:20:29 -0500 Subject: [PATCH] cleanup unit-tests to remove hacky renaming of control --- .../brut/androlib/BuildAndDecodeTest.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java index 5b037f8e..ea86d2d4 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java @@ -325,37 +325,39 @@ public class BuildAndDecodeTest { } } - private boolean compareBinaryFolder(String path, boolean res) + private void compareBinaryFolder(String path, boolean res) throws BrutException, IOException { + Boolean exists = true; + String tmp = ""; if (res) { tmp = File.separatorChar + "res" + File.separatorChar; } - FileDirectory fileDirectory = new FileDirectory(sTestOrigDir + tmp + path); + String location = tmp + path; + + FileDirectory fileDirectory = new FileDirectory(sTestOrigDir + location); Set files = fileDirectory.getFiles(true); for (String filename : files) { - File control = new File(filename); - // hacky fix - load test by changing name of control - File test = new File(control.toString().replace("testapp-orig", "testapp-new")); + File control = new File((sTestOrigDir + location), filename); + File test = new File((sTestNewDir + location), filename); - if (test.isFile() && control.isFile()) { - if (control.hashCode() != test.hashCode()) { - return false; - } + if (! test.isFile() || ! control.isFile()) { + exists = false; } } - return true; + + assertTrue(exists); } - private boolean compareResFolder(String path) throws BrutException, IOException { - return compareBinaryFolder(path, true); + private void compareResFolder(String path) throws BrutException, IOException { + compareBinaryFolder(path, true); } - private boolean compareLibsFolder(String path) throws BrutException, IOException { - return compareBinaryFolder(File.separatorChar + path,false); + private void compareLibsFolder(String path) throws BrutException, IOException { + compareBinaryFolder(File.separatorChar + path, false); } private void compareValuesFiles(String path) throws BrutException { @@ -380,9 +382,7 @@ public class BuildAndDecodeTest { Reader test = new FileReader(new File(sTestNewDir, path)); diff = new DetailedDiff(new Diff(control, test)); - } catch (SAXException ex) { - throw new BrutException(ex); - } catch (IOException ex) { + } catch (SAXException | IOException ex) { throw new BrutException(ex); }