### Question:
AntrunXmlPlexusConfigurationWriter { public void write( PlexusConfiguration configuration, File file, String customTaskPrefix, String antTargetName ) throws IOException { MXSerializer serializer = new MXSerializer(); serializer.setProperty( "http: System.getProperty( "line.separator" ) ); serializer.setProperty( "http: BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream( file ) ); try { serializer.setOutput( bos, AntRunMojo.UTF_8 ); serializer.startDocument( AntRunMojo.UTF_8, null ); if ( !customTaskPrefix.isEmpty() ) { serializer.setPrefix( customTaskPrefix, AntRunMojo.TASK_URI ); } serializer.startTag( null, "project" ); serializer.attribute( null, "name", "maven-antrun-" ); serializer.attribute( null, "default", antTargetName ); write( configuration, serializer ); serializer.endTag( null, "project" ); serializer.endDocument(); } finally { IOUtil.close( bos ); } }  void write( PlexusConfiguration configuration, File file, String customTaskPrefix, String antTargetName );  }### Answer:
@Test public void testBasic() throws Exception { configuration.getChild( "echo", true ).setAttribute( "message", "Hello" ); configurationWriter.write( configuration, file, "", TARGET_NAME ); assertXmlIsExpected( "/configuration-writer/basic.xml", file ); }
@Test public void testEmptyTarget() throws Exception { configurationWriter.write( configuration, file, "", TARGET_NAME ); assertXmlIsExpected( "/configuration-writer/empty-target.xml", file ); }
@Test public void testCustomTaskPrefix() throws Exception { PlexusConfiguration child = configuration.getChild( "mvn:foo", true ); child.setAttribute( "attr1", "val1" ); child.setValue( "The first value." ); child = configuration.getChild( "bar", true ); child.setAttribute( "attr2", "val2" ); child.setValue( "The second value." ); configurationWriter.write( configuration, file, "mvn", TARGET_NAME ); assertXmlIsExpected( "/configuration-writer/custom-task-prefix.xml", file ); }
@Test public void testCombineAttributes() throws Exception { configuration.setAttribute( "combine.children", "append" ); configuration.setAttribute( "description", "foo" ); configuration.getChild( "child", true ).setAttribute( "combine.self", "override" ); configurationWriter.write( configuration, file, "", TARGET_NAME ); assertXmlIsExpected( "/configuration-writer/combine-attributes.xml", file ); }