### Question:
PropertiesUtils { public static void listOrdered(Properties properties, Writer writer) { Set<String> propertyNames = properties.stringPropertyNames(); List<String> listOfPropertyNames = new ArrayList<>(propertyNames); Collections.sort(listOfPropertyNames); boolean written = false; for (String propertyName : listOfPropertyNames) { try { if (written) writer.append(NEW_LINE); writer.append(propertyName) .append('=') .append(properties.getProperty(propertyName)); written = true; } catch (IOException e) { throw new RuntimeException("unable to list properties", e); } } } private  PropertiesUtils(); static Properties subProperties(Properties properties, String prefix); static void listOrdered(Properties properties, Writer writer); static void copy(Properties source, Properties dest, CopyMode copyMode); static Properties loadFromResource(String resourceClasspath);  }### Answer:
@Test public void list_ordered() { Properties props = new Properties(); props.setProperty("b", "2"); props.setProperty("a", "1"); props.setProperty("c", "3"); StringWriter writer = new StringWriter(); PropertiesUtils.listOrdered(props, writer); assertTrue(writer.toString().startsWith("a=1" + NEW_LINE)); assertTrue(writer.toString().endsWith(NEW_LINE + "c=3")); }