public void testLoadConfiguration() throws Exception {
    // get it
    Configuration config = nexusConfiguration.getConfigurationModel();

    // check it for default value
    assertEquals("smtp-host", config.getSmtpConfiguration().getHostname());

    // modify it
    nexusEmailer.setSMTPHostname("NEW-HOST");

    // save it
    nexusConfiguration.saveConfiguration();

    // replace it again with default "from behind"
    InputStreamFacade isf =
        new InputStreamFacade() {

          public InputStream getInputStream() throws IOException {
            return getClass().getResourceAsStream("/META-INF/nexus/nexus.xml");
          }
        };
    FileUtils.copyStreamToFile(isf, new File(getNexusConfiguration()));

    // force reload
    nexusConfiguration.loadConfiguration(true);

    // get the config
    config = nexusConfiguration.getConfigurationModel();

    // it again contains default value, coz we overwritten it before
    assertEquals("smtp-host", config.getSmtpConfiguration().getHostname());
    assertEquals("smtp-host", nexusEmailer.getSMTPHostname());
  }
  private void setupEmailConfig() throws IOException, XmlPullParserException {
    FileInputStream fis = null;
    Configuration config = null;
    try {
      fis = new FileInputStream(this.getNexusConfiguration());

      NexusConfigurationXpp3Reader reader = new NexusConfigurationXpp3Reader();
      config = reader.read(fis);

      config.getSmtpConfiguration().setPort(this.emailServerPort);
      config.getSmtpConfiguration().setHostname("localhost");
      // config.getSmtpConfiguration().setDebugMode( true );

    } finally {
      IOUtil.close(fis);
    }

    // now write it back out
    FileWriter writer = null;

    try {
      writer = new FileWriter(this.getNexusConfiguration());
      new NexusConfigurationXpp3Writer().write(writer, config);
    } finally {
      IOUtil.close(writer);
    }
  }