コード例 #1
0
  @Test
  public void loadConfigurationFileBackslash() throws Exception {
    Properties properties = new Properties();

    String filename =
        new ClassPathResource("dynamic/pkg/runtime.conf", getClassLoader()).getLocationOnDisk();
    String[] args = new String[] {"-configFile=" + filename, "-configFileEncoding=UTF-8"};

    Main.loadConfiguration(properties, args);

    assertEquals(1, properties.size());
    assertEquals("at\\runtime", properties.getProperty("loaded"));
  }
コード例 #2
0
  @Test
  public void loadConfigurationFile() throws Exception {
    Properties properties = new Properties();
    properties.put("existing", "still there!");
    properties.put("override", "loses :-(");

    String filename =
        new ClassPathResource("test.properties", getClassLoader()).getLocationOnDisk();
    String[] args = new String[] {"-configFile=" + filename, "-configFileEncoding=UTF-8"};

    Main.loadConfiguration(properties, args);

    assertEquals(4, properties.size());
    assertEquals("still there!", properties.getProperty("existing"));
    assertEquals("räbbit 123", properties.getProperty("roger"));
    assertEquals("wins :-)", properties.getProperty("override"));
  }