### Question:
GrinderProperties extends Properties { public final void saveSingleProperty(String name) throws PersistenceException { if (m_file == null) { throw new PersistenceException("No associated file"); } try { final Properties properties = new Properties(); InputStream inputStream = null; try { inputStream = new FileInputStream(m_file); properties.load(inputStream); } catch (IOException e) { UncheckedInterruptedException.ioException(e); } finally { Closer.close(inputStream); } OutputStream outputStream = null; try { outputStream = new FileOutputStream(m_file); final String value = getProperty(name); if (value != null) { properties.setProperty(name, value); } else { properties.remove(name); } properties.store(outputStream, generateFileHeader()); } finally { Closer.close(outputStream); } } catch (IOException e) { UncheckedInterruptedException.ioException(e); throw new PersistenceException( "Error writing properties file '" + m_file.getPath() + '\'', e); } } GrinderProperties();  GrinderProperties(File file); final File getAssociatedFile(); final void setAssociatedFile(File file); final void save(); final void saveSingleProperty(String name); final void setErrorWriter(PrintWriter writer); final synchronized GrinderProperties getPropertySubset(String prefix); final int getInt(String propertyName, int defaultValue); final void setInt(String propertyName, int value); final long getLong(String propertyName, long defaultValue); final void setLong(String propertyName, long value); final short getShort(String propertyName, short defaultValue); final void setShort(String propertyName, short value); final double getDouble(String propertyName, double defaultValue); final void setDouble(String propertyName, double value); final boolean getBoolean(String propertyName, boolean defaultValue); final void setBoolean(String propertyName, boolean value); final File getFile(String propertyName, File defaultValue); final File resolveRelativeFile(File file); final void setFile(String propertyName, File value); static final String SCRIPT; static final String LOG_DIRECTORY; static final String CONSOLE_HOST; static final String CONSOLE_PORT; static final File DEFAULT_PROPERTIES; static final File DEFAULT_SCRIPT; }### Answer:
@Test public void testSaveSingleProperty() throws Exception { try { assertNull(m_grinderProperties.getAssociatedFile()); m_grinderProperties.setProperty("foo", "bah"); m_grinderProperties.saveSingleProperty("foo"); fail("Expected GrinderException as no associated file"); } catch (GrinderException e) { } final File file = File.createTempFile("testing", "1234", getDirectory()); final Properties plainProperties = new Properties(); plainProperties.setProperty("existing", "property"); final OutputStream out = new FileOutputStream(file); plainProperties.store(out, ""); out.close(); final GrinderProperties properties = new GrinderProperties(file); assertEquals(file, properties.getAssociatedFile()); properties.putAll(m_allSet); properties.setProperty("foo", "bah"); properties.saveSingleProperty("foo"); properties.setBoolean("blah", true); properties.saveSingleProperty("blah"); final InputStream in = new FileInputStream(file); plainProperties.load(in); in.close(); assertEquals(3, plainProperties.size()); assertEquals("bah", plainProperties.getProperty("foo")); assertEquals("property", plainProperties.getProperty("existing")); assertEquals("true", plainProperties.getProperty("blah")); }