Source:
public void testPlaceholderSubstitution ( ) throws ManifestMerger2.MergeFailureException , java.io.IOException , javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException { java.lang.String xml = "" + ( ( ( "<manifest versionCode=\"34\" versionName=\"3.4\"\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" ) + " <activity android:name=\".activityOne\" android:label=\"${labelName}\"/>\n" ) + "</manifest>" ) ; java.util.Map < java.lang.String , java.lang.String > placeholders = com.google.common.collect.ImmutableMap.of ( "labelName" , "injectedLabelName" ) ; com.android.sdklib.mock.MockLog mockLog = new com.android.sdklib.mock.MockLog ( ) ; java.io.File inputFile = com.android.manifmerger.ManifestMerger2SmallTest.inputAsFile ( "testPlaceholderSubstitution" , xml ) ; try { com.android.manifmerger.MergingReport mergingReport = com.android.manifmerger.ManifestMerger2.newMerger ( inputFile , mockLog , ManifestMerger2.MergeType.APPLICATION ) . setPlaceHolderValues ( placeholders ) . merge ( ) ; assertTrue ( mergingReport.getResult ( ) . isSuccess ( ) ) ; assertTrue ( mergingReport.getMergedDocument ( ) . isPresent ( ) ) ; com.android.manifmerger.XmlDocument xmlDocument = mergingReport.getMergedDocument ( ) . get ( ) ; com.google.common.base.Optional < com.android.manifmerger.XmlElement > activityOne = xmlDocument.getByTypeAndKey ( ManifestModel.NodeTypes.ACTIVITY , ".activityOne" ) ; assertTrue ( activityOne.isPresent ( ) ) ; com.google.common.base.Optional < com.android.manifmerger.XmlAttribute > attribute = activityOne.get ( ) . getAttribute ( com.android.manifmerger.XmlNode.fromXmlName ( "android:label" ) ) ; assertTrue ( attribute.isPresent ( ) ) ; assertEquals ( "injectedLabelName" , attribute.get ( ) . getValue ( ) ) ; } finally { inputFile.delete ( ) ; } }

Target:
public void testPlaceholderSubstitution ( ) throws ManifestMerger2.MergeFailureException , java.io.IOException , javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException { java.lang.String xml = "" + ( ( ( "<manifest package=\"foo\" versionCode=\"34\" versionName=\"3.4\"\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" ) + " <activity android:name=\".activityOne\" android:label=\"${labelName}\"/>\n" ) + "</manifest>" ) ; java.util.Map < java.lang.String , java.lang.String > placeholders = com.google.common.collect.ImmutableMap.of ( "labelName" , "injectedLabelName" ) ; com.android.sdklib.mock.MockLog mockLog = new com.android.sdklib.mock.MockLog ( ) ; java.io.File inputFile = com.android.manifmerger.ManifestMerger2SmallTest.inputAsFile ( "testPlaceholderSubstitution" , xml ) ; try { com.android.manifmerger.MergingReport mergingReport = com.android.manifmerger.ManifestMerger2.newMerger ( inputFile , mockLog , ManifestMerger2.MergeType.APPLICATION ) . setPlaceHolderValues ( placeholders ) . merge ( ) ; assertTrue ( mergingReport.getResult ( ) . isSuccess ( ) ) ; assertTrue ( mergingReport.getMergedDocument ( ) . isPresent ( ) ) ; com.android.manifmerger.XmlDocument xmlDocument = mergingReport.getMergedDocument ( ) . get ( ) ; com.google.common.base.Optional < com.android.manifmerger.XmlElement > activityOne = xmlDocument.getByTypeAndKey ( ManifestModel.NodeTypes.ACTIVITY , "foo.activityOne" ) ; assertTrue ( activityOne.isPresent ( ) ) ; com.google.common.base.Optional < com.android.manifmerger.XmlAttribute > attribute = activityOne.get ( ) . getAttribute ( com.android.manifmerger.XmlNode.fromXmlName ( "android:label" ) ) ; assertTrue ( attribute.isPresent ( ) ) ; assertEquals ( "injectedLabelName" , attribute.get ( ) . getValue ( ) ) ; } finally { inputFile.delete ( ) ; } }