public class PluginMergerTest extends TestBase {
@Test
public void testMergeByAttribute() throws IOException {
PluginFileMerger fileMerger = new PluginFileMerger();
String name = "override-test";
StringBuilder sb = new StringBuilder();
String newline = System.getProperty("line.separator");
sb.append("<create creator=\"new\" javascript=\"UserAjax\" scope=\"application\">");
sb.append(newline).append("<param name=\"class\" value=\"com.mycompany.plugins.ajax.MyCompanyUserAjax\"/>");
sb.append(newline).append("</create>");
String dwr = sb.toString();
Map<String,String> overrideMap = new HashMap<String, String>();
overrideMap.put("create", "javascript");
sb = new StringBuilder("<!DOCTYPE dwr PUBLIC \"-//GetAhead Limited//DTD Direct Web Remoting 3.0//EN\" \"http://getahead.org/dwr//dwr30.dtd\">");
sb.append("<dwr>");
sb.append("<allow>");
sb.append("<create creator=\"new\" javascript=\"UserAjax\" scope=\"application\">");
sb.append("<param name=\"class\" value=\"com.dotmarketing.portlets.user.ajax.UserAjax\"/>");
sb.append("</create>");
sb.append("<!-- Don't ever delete the following comment tags, it will break the plugin system -->");
sb.append("<!-- BEGIN PLUGINS -->");
sb.append("<!-- END PLUGINS -->");
sb.append("</allow>");
sb.append("</dwr>");
InputStream input = new ByteArrayInputStream(sb.toString().getBytes());
String fileContent = fileMerger.mergeByAttribute(input, "<!-- BEGIN PLUGINS -->",
"<!-- END PLUGINS -->", "<!-- BEGIN PLUGIN:" + name + " -->", "<!-- END PLUGIN:" + name + " -->", dwr,
overrideMap, "<!-- BEGIN OVERRIDE:" + name, " END OVERRIDE:" + name + " -->", "<!-- BEGIN OVERRIDE");
sb = new StringBuilder("<!-- BEGIN OVERRIDE:override-test");