diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt1/DebugTagRetainedTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt1/DebugTagRetainedTest.java index 2e0658fc..68f555cb 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt1/DebugTagRetainedTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt1/DebugTagRetainedTest.java @@ -20,17 +20,19 @@ import brut.androlib.*; import brut.directory.ExtFile; import brut.common.BrutException; import brut.util.OS; +import org.custommonkey.xmlunit.XMLUnit; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import org.xml.sax.SAXException; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; /** * @author Connor Tumbleson @@ -70,16 +72,21 @@ public class DebugTagRetainedTest extends BaseTest { } @Test - public void DebugIsTruePriorToBeingFalseTest() throws IOException { + public void DebugIsTruePriorToBeingFalseTest() throws IOException, SAXException { String apk = "issue1235-new"; - String expected = TestUtils.replaceNewlines("\n" + - "\n" + - " " + - ""); + String expected = TestUtils.replaceNewlines("" + + " "); byte[] encoded = Files.readAllBytes(Paths.get(sTmpDir + File.separator + apk + File.separator + "AndroidManifest.xml")); String obtained = TestUtils.replaceNewlines(new String(encoded)); - assertEquals(expected, obtained); + + XMLUnit.setIgnoreWhitespace(true); + XMLUnit.setIgnoreAttributeOrder(true); + XMLUnit.setCompareUnmatched(false); + + assertXMLEqual(expected, obtained); } } \ No newline at end of file diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt1/ProviderAttributeTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt1/ProviderAttributeTest.java index e6cb4b8f..642965f8 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt1/ProviderAttributeTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/aapt1/ProviderAttributeTest.java @@ -23,16 +23,18 @@ import brut.androlib.TestUtils; import brut.directory.ExtFile; import brut.common.BrutException; import brut.util.OS; +import org.custommonkey.xmlunit.XMLUnit; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import org.xml.sax.SAXException; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; -import static org.junit.Assert.assertEquals; +import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; import static org.junit.Assert.assertTrue; public class ProviderAttributeTest extends BaseTest { @@ -50,7 +52,7 @@ public class ProviderAttributeTest extends BaseTest { } @Test - public void isProviderStringReplacementWorking() throws BrutException, IOException { + public void isProviderStringReplacementWorking() throws BrutException, IOException, SAXException { String apk = "issue636.apk"; // decode issue636.apk @@ -70,7 +72,7 @@ public class ProviderAttributeTest extends BaseTest { apkDecoder.decode(); String expected = TestUtils.replaceNewlines("\n" + - "\n" + + "\n" + " \n" + " \n" + " \n" + @@ -80,7 +82,12 @@ public class ProviderAttributeTest extends BaseTest { byte[] encoded = Files.readAllBytes(Paths.get(sTmpDir + File.separator + apk + ".out.two" + File.separator + "AndroidManifest.xml")); String obtained = TestUtils.replaceNewlines(new String(encoded)); - assertEquals(expected, obtained); + + XMLUnit.setIgnoreWhitespace(true); + XMLUnit.setIgnoreAttributeOrder(true); + XMLUnit.setCompareUnmatched(false); + + assertXMLEqual(expected, obtained); } private boolean fileExists(String filepath) { diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/ExternalEntityTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/ExternalEntityTest.java index dceaca5d..6cd58b5c 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/ExternalEntityTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/decode/ExternalEntityTest.java @@ -62,11 +62,11 @@ public class ExternalEntityTest extends BaseTest { @Test public void doctypeTest() throws IOException { - String expected = TestUtils.replaceNewlines("\n" + - "\n" + - " \n" + - ""); + String expected = TestUtils.replaceNewlines("" + + " "); byte[] encoded = Files.readAllBytes(Paths.get(sTestOrigDir + File.separator + "output" + File.separator + "AndroidManifest.xml")); String obtained = TestUtils.replaceNewlines(new String(encoded)); diff --git a/brut.apktool/apktool-lib/src/test/resources/aapt1/issue767/issue767.apk b/brut.apktool/apktool-lib/src/test/resources/aapt1/issue767/issue767.apk index fdc88b03..7eff5752 100644 Binary files a/brut.apktool/apktool-lib/src/test/resources/aapt1/issue767/issue767.apk and b/brut.apktool/apktool-lib/src/test/resources/aapt1/issue767/issue767.apk differ diff --git a/brut.apktool/apktool-lib/src/test/resources/aapt1/testapp/AndroidManifest.xml b/brut.apktool/apktool-lib/src/test/resources/aapt1/testapp/AndroidManifest.xml index 057f5576..313ccae1 100644 --- a/brut.apktool/apktool-lib/src/test/resources/aapt1/testapp/AndroidManifest.xml +++ b/brut.apktool/apktool-lib/src/test/resources/aapt1/testapp/AndroidManifest.xml @@ -1,5 +1,5 @@ - +