### Question:
Config { public void save( Writer writer ) { boolean empty = true; if( writer != null ) { PrintWriter output = new PrintWriter( writer ); Map<String,String> map = sections.get( DEFAULT_NAME ); if( map != null ) { empty &= (map.isEmpty()); saveMap( output, map ); } for( Map.Entry<String,Map<String,String>> entry : sections.entrySet() ) { if( !empty ) { output.println(); } String section = entry.getKey(); if( section != null && !section.equals( DEFAULT_NAME ) ) { map = sections.get( section ); output.print( SECTION_PREFIX ); output.print( section ); output.println( SECTION_SUFFIX ); empty = false; saveMap( output, map ); } } } } Config(); void load( Reader reader ); void save( Writer writer ); String get( String section, String name ); void set( String section, String name, String value );  }### Answer:
@Test public void testSave() throws Exception { Config c; StringWriter w; c = new Config(); c.save( null ); c = new Config(); w = new StringWriter(); c.save( w ); assertThat( w.toString(), is( "" ) ); c = new Config(); c.set( null, null, null ); w = new StringWriter(); c.save( w ); assertThat( w.toString(), is( "=" + NEWLINE ) ); c = new Config(); c.set( null, "name1", "value1" ); c.set( "section1", "name1", "value2" ); w = new StringWriter(); c.save( w ); assertThat( w.toString(), is( "name1=value1" + NEWLINE + NEWLINE + "[section1]" + NEWLINE + "name1=value2" ) ); }