public class BaseTransUnitsTest extends TestCase {
public void test_RenameAttributeTU() {
Document doc = parseCPResource("testpage1.html");
SmooksResourceConfiguration resourceConfiguration = new SmooksResourceConfiguration("body", "device", "xxx");
Element body = (Element)XmlUtil.getNode(doc, "/html/body");
RenameAttributeTU tu;
resourceConfiguration.setParameter("attributeName", "attrib1");
resourceConfiguration.setParameter("attributeNewName", "attrib2");
tu = Configurator.configure(new RenameAttributeTU(), resourceConfiguration);
tu.visitAfter(body, null);
assertEquals("Default overwrite protection failed.", "value2", body.getAttribute("attrib2"));
resourceConfiguration.setParameter("overwrite", "true");
tu = Configurator.configure(new RenameAttributeTU(), resourceConfiguration);
tu.visitAfter(body, null);
assertFalse("Rename failed to remove target attribute.", body.hasAttribute("attrib1"));
assertEquals("Overwrite failed.", "value1", body.getAttribute("attrib2"));
}