}
public void testImportConfigurationHonored() throws Exception {
final SystemManagerLocal systemManager = context.mock(SystemManagerLocal.class);
SystemSettingsImporter importer = new SystemSettingsImporter(null, systemManager);
String[] importableProps = SystemSettingsImporter.DEFAULT_IMPORTED_PROPERTIES_LIST.split("\\s*,\\s*");
final HashMap<String, String> settings = new HashMap<String, String>();
addImportableProps(settings);
final SystemSettings importedSettings = new SystemSettings(settings);
final List<String> allowedSettings = new ArrayList<String>();
for (int i = 0; i < importableProps.length; ++i) {
if (i % 2 == 0) {
allowedSettings.add(importableProps[i]);
}
}
context.checking(new Expectations() {
{
org.rhq.core.domain.common.composite.SystemSettings expectedImport = new org.rhq.core.domain.common.composite.SystemSettings();
for (String s : allowedSettings) {
expectedImport.put(SystemSetting.getByInternalName(s), settings.get(s));
}
oneOf(systemManager).deobfuscate(with(any(org.rhq.core.domain.common.composite.SystemSettings.class)));
oneOf(systemManager).setSystemSettings(with(any(Subject.class)), with(expectedImport));
}
});
Configuration importConfig = new Configuration();
importConfig.put(new PropertySimple(SystemSettingsImporter.PROPERTIES_TO_IMPORT_PROPERTY, StringUtil
.collectionToString(allowedSettings, ", ")));
importer.configure(importConfig);
importer.update(null, importedSettings);
importer.finishImport();
}