ProguardMappingTest.kt
TLDR
This file contains a class called ProguardMappingTest
which contains a single method readAndParseMappingFile
. The method reads a Proguard mapping file, parses it, and tests the deobfuscation functionality provided by the ProguardMappingReader
class.
Methods
readAndParseMappingFile
This method reads a Proguard mapping file, parses it, and performs several tests to verify the deobfuscation functionality. It sets up a sample Proguard mapping file as a string, creates an instance of the ProguardMappingReader
, and reads the Proguard mapping using the readProguardMapping
method of the ProguardMappingReader
. It then asserts that the deobfuscated class and field names match the expected values using the assertThat
method from the Assertions
class.
Classes
ProguardMappingTest
This class provides a test case for the ProguardMappingReader
class. It contains the readAndParseMappingFile
method which tests the functionality of the ProguardMappingReader
.
package shark
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
class ProguardMappingTest {
@Test
fun readAndParseMappingFile() {
val proguardMappingText = """
# comment
com.test.ClearClassName1 -> com.test.ObfuscatedClassName1:
com.test.FieldType1 clearFieldName1 -> obfuscatedFieldName1
com.test.ClearClassName2 -> com.test.ObfuscatedClassName2:
com.test.FieldType2 clearFieldName2 -> obfuscatedFieldName2
""".trimIndent()
val proguardMapping =
ProguardMappingReader(proguardMappingText.byteInputStream(Charsets.UTF_8))
.readProguardMapping()
assertThat(
proguardMapping.deobfuscateClassName("com.test.ObfuscatedClassName1")
).isEqualTo("com.test.ClearClassName1")
assertThat(
proguardMapping.deobfuscateFieldName(
"com.test.ObfuscatedClassName1",
"obfuscatedFieldName1"
)
).isEqualTo("clearFieldName1")
assertThat(
proguardMapping.deobfuscateClassName("com.test.ObfuscatedClassName2")
).isEqualTo("com.test.ClearClassName2")
assertThat(
proguardMapping.deobfuscateFieldName(
"com.test.ObfuscatedClassName2",
"obfuscatedFieldName2"
)
).isEqualTo("clearFieldName2")
}
}