RenameClassAdapterTestpublic class RenameClassAdapterTest extends Object
Fields Summary |
---|
private RenameClassAdapter | mOuter | private RenameClassAdapter | mInner |
Methods Summary |
---|
public void | setUp()
mOuter = new RenameClassAdapter(null, // cv
"com.pack.Old",
"org.blah.New");
mInner = new RenameClassAdapter(null, // cv
"com.pack.Old$Inner",
"org.blah.New$Inner");
| public void | tearDown()
| public void | testRenameInternalType()Renames an internal type name, e.g. "com.package.MyClass".
If the type doesn't need to be renamed, returns the input string as-is.
// a descriptor is not left untouched
assertEquals("Lorg.blah.New;", mOuter.renameInternalType("Lcom.pack.Old;"));
assertEquals("Lorg.blah.New$Inner;", mOuter.renameInternalType("Lcom.pack.Old$Inner;"));
// an actual FQCN
assertEquals("org.blah.New", mOuter.renameInternalType("com.pack.Old"));
assertEquals("org.blah.New$Inner", mOuter.renameInternalType("com.pack.Old$Inner"));
assertEquals("org.blah.New$Other", mInner.renameInternalType("com.pack.Old$Other"));
assertEquals("org.blah.New$Other", mInner.renameInternalType("com.pack.Old$Other"));
| public void | testRenameMethodDesc()Renames a method descriptor, i.e. applies renameType to all arguments and to the
return value.
assertEquals("(IDLorg.blah.New;[Lorg.blah.New$Inner;)Lorg.blah.New$Other;",
mOuter.renameMethodDesc("(IDLcom.pack.Old;[Lcom.pack.Old$Inner;)Lcom.pack.Old$Other;"));
| public void | testRenameType()Renames an object type, e.g. "Lcom.package.MyClass;" or an array type that has an
object element, e.g. "[Lcom.package.MyClass;"
If the type doesn't need to be renamed, returns the internal name of the input type.
// Skip. This is actually tested by testRenameTypeDesc above.
| public void | testRenameTypeDesc()Renames a type, e.g. "Lcom.package.My;"
If the type doesn't need to be renamed, returns the input string as-is.
// primitive types are left untouched
assertEquals("I", mOuter.renameTypeDesc("I"));
assertEquals("D", mOuter.renameTypeDesc("D"));
assertEquals("V", mOuter.renameTypeDesc("V"));
// object types that need no renaming are left untouched
assertEquals("Lcom.package.MyClass;", mOuter.renameTypeDesc("Lcom.package.MyClass;"));
assertEquals("Lcom.package.MyClass;", mInner.renameTypeDesc("Lcom.package.MyClass;"));
// object types that match the requirements
assertEquals("Lorg.blah.New;", mOuter.renameTypeDesc("Lcom.pack.Old;"));
assertEquals("Lorg.blah.New$Inner;", mInner.renameTypeDesc("Lcom.pack.Old$Inner;"));
// inner classes match the base type which is being renamed
assertEquals("Lorg.blah.New$Other;", mOuter.renameTypeDesc("Lcom.pack.Old$Other;"));
assertEquals("Lorg.blah.New$Other;", mInner.renameTypeDesc("Lcom.pack.Old$Other;"));
// arrays
assertEquals("[Lorg.blah.New;", mOuter.renameTypeDesc("[Lcom.pack.Old;"));
assertEquals("[[Lorg.blah.New;", mOuter.renameTypeDesc("[[Lcom.pack.Old;"));
assertEquals("[Lorg.blah.New;", mInner.renameTypeDesc("[Lcom.pack.Old;"));
assertEquals("[[Lorg.blah.New;", mInner.renameTypeDesc("[[Lcom.pack.Old;"));
|
|