### Question:
AMLExporter { public File writeBuildxml(File targetDir, String atlasBaseName) { if (atlasBaseName == null || atlasBaseName.equals(AtlasConfig.DEFAULTBASENAME) || atlasBaseName.equals("null")) { LOGGER.info("Not writing a build.xml for automatic publishing, because the basename is " + atlasBaseName + ". Please change it."); return null; } if (atlasBaseName.endsWith("/")) { atlasBaseName = atlasBaseName.substring(0, atlasBaseName.length() - 1); } String resLoc = "/autoPublish/build.xml"; URL templateBuildXml = GpUtil.class.getResource(resLoc); if (templateBuildXml == null) { LOGGER.error("Could not find " + resLoc + ". build.xml has not been created!"); return null; } String templString = IOUtil.readURLasString(templateBuildXml); String buildXmlContent = templString.replaceAll( Pattern.quote(ATLASBASENAME_TAG_IN_BUILDXML), atlasBaseName); targetDir.mkdirs(); File buildFile = new File(targetDir, "build.xml"); if (buildFile.exists()) { String existing; try { existing = IOUtil.readFileAsString(buildFile); if (buildXmlContent.equals(existing)) return buildFile; } catch (IOException e) { LOGGER.warn("Error reading existing build.xml, it will be recreated..."); } if (!buildFile.delete()) { LOGGER.error("Could not delete exitsing " + buildFile.getAbsolutePath() + ", to update it."); } } try { FileWriter fw = new FileWriter(buildFile); fw.write(buildXmlContent); fw.flush(); fw.close(); } catch (Exception e) { LOGGER.error( "Could not write build.xml for automatic publishing on http: e); return null; } return buildFile; } AMLExporter(final AtlasConfigEditable ace); File writeBuildxml(File targetDir, String atlasBaseName); boolean saveAtlasConfigEditable(); boolean saveAtlasConfigEditable(
			final AtlasStatusDialogInterface statusWindow); void setExportMode(boolean exportMode); boolean isExportMode(); void setAtlasXml(File atlasXml); File getAtlasXml(); AtlasConfigEditable getAce(); final static public String ATLASBASENAME_TAG_IN_BUILDXML; }### Answer:
@Test public void testWriteBuildxml() throws AtlasException, FactoryException, TransformException, SAXException, IOException, ParserConfigurationException, TransformerException { File newTempDir = TestingUtil.getNewTempDir(); getAce().setBaseName(AtlasConfig.DEFAULTBASENAME); File created = writeBuildxml(newTempDir, getAce().getBaseName()); assertNull(created); getAce().setBaseName( AtlasConfig.DEFAULTBASENAME + System.currentTimeMillis()); created = writeBuildxml(newTempDir, getAce().getBaseName()); assertNotNull(created); assertTrue(created.exists()); created = writeBuildxml(newTempDir, getAce().getBaseName() + "/"); assertNotNull(created); assertTrue(created.exists()); FileUtils.deleteDirectory(newTempDir); }