### Question:
CaliperConfig { public VmConfig getVmConfig(String name) throws InvalidConfigurationException { checkNotNull(name); ImmutableMap<String, String> vmGroupMap = subgroupMap(properties, "vm"); ImmutableMap<String, String> vmMap = subgroupMap(vmGroupMap, name); File homeDir = getJdkHomeDir(vmGroupMap.get("baseDirectory"), vmMap.get("home"), name); return new VmConfig.Builder(homeDir) .addAllOptions(getArgs(vmGroupMap)) .addAllOptions(getArgs(vmMap)) .build(); } @VisibleForTesting  CaliperConfig(ImmutableMap<String, String> properties); ImmutableMap<String, String> properties(); VmConfig getDefaultVmConfig(); VmConfig getVmConfig(String name); ImmutableSet<String> getConfiguredInstruments(); InstrumentConfig getInstrumentConfig(String name); ImmutableSet<Class<? extends ResultProcessor>> getConfiguredResultProcessors(); ResultProcessorConfig getResultProcessorConfig(
      Class<? extends ResultProcessor> resultProcessorClass); @Override String toString();  }### Answer:
@Test public void getVmConfig_baseDirectoryAndName() throws Exception { File tempBaseDir = folder.newFolder(); File jdkHome = new File(tempBaseDir, "test"); jdkHome.mkdir(); CaliperConfig configuration = new CaliperConfig(ImmutableMap.of( "vm.baseDirectory", tempBaseDir.getAbsolutePath())); assertEquals(new VmConfig.Builder(jdkHome).build(), configuration.getVmConfig("test")); }
@Test public void getVmConfig_baseDirectoryAndHome() throws Exception { File tempBaseDir = folder.newFolder(); File jdkHome = new File(tempBaseDir, "test-home"); jdkHome.mkdir(); CaliperConfig configuration = new CaliperConfig(ImmutableMap.of( "vm.baseDirectory", tempBaseDir.getAbsolutePath(), "vm.test.home", "test-home")); assertEquals(new VmConfig.Builder(jdkHome).build(), configuration.getVmConfig("test")); }
@Test public void getVmConfig() throws Exception { File jdkHome = folder.newFolder(); CaliperConfig configuration = new CaliperConfig(ImmutableMap.of( "vm.args", "-a -b -c", "vm.test.home", jdkHome.getAbsolutePath(), "vm.test.args", " -d -e ")); assertEquals( new VmConfig.Builder(jdkHome) .addOption("-a") .addOption("-b") .addOption("-c") .addOption("-d") .addOption("-e") .build(), configuration.getVmConfig("test")); }
@Test public void getVmConfig_escapedSpacesInArgs() throws Exception { File jdkHome = folder.newFolder(); CaliperConfig configuration = new CaliperConfig(ImmutableMap.of( "vm.args", "-a=string\\ with\\ spa\\ces -b -c", "vm.test.home", jdkHome.getAbsolutePath())); assertEquals( new VmConfig.Builder(jdkHome) .addOption("-a=string with spaces") .addOption("-b") .addOption("-c") .build(), configuration.getVmConfig("test")); }