Package org.rhq.enterprise.server.sync.importers

Examples of org.rhq.enterprise.server.sync.importers.SystemSettingsImporter


public class SystemSettingsImporterTest extends JMockTest {

    public void testNullConfigurationUnderstoodAsDefault() throws Exception {
        final SystemManagerLocal systemManager = context.mock(SystemManagerLocal.class);

        SystemSettingsImporter importer = new SystemSettingsImporter(null, systemManager);

        final HashMap<String, String> settings = new HashMap<String, String>();
        settings.put(SystemSetting.BASE_URL.getInternalName(), "url");
        addImportableProps(settings);
        final SystemSettings importedSettings = new SystemSettings(settings);

        context.checking(new Expectations() {
            {
                org.rhq.core.domain.common.composite.SystemSettings expectedImport = org.rhq.core.domain.common
                    .composite.SystemSettings.fromMap(settings);

                //base url is not imported by default
                expectedImport.remove(SystemSetting.BASE_URL);

                oneOf(systemManager).deobfuscate(with(any(org.rhq.core.domain.common.composite.SystemSettings.class)));
                oneOf(systemManager).setSystemSettings(with(any(Subject.class)), with(expectedImport));
            }
        });

        importer.configure(null);

        importer.update(null, importedSettings);

        importer.finishImport();
    }
View Full Code Here


    }

    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();
    }
View Full Code Here

    public Exporter<NoSingleEntity, SystemSettings> getExporter() {
        return new SystemSettingsExporter(subject, systemManager);
    }

    public Importer<NoSingleEntity, SystemSettings> getImporter() {
        return new SystemSettingsImporter(subject, systemManager);
    }
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.sync.importers.SystemSettingsImporter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.