use of org.apache.archiva.configuration.model.UserInterfaceOptions in project archiva by apache.
the class ArchivaConfigurationTest method testStoreConfigurationUser.
@Test
public void testStoreConfigurationUser() throws Exception {
Path baseFile = getTestFile("target/test/test-file.xml");
Files.deleteIfExists(baseFile);
assertFalse(Files.exists(baseFile));
Path userFile = getTestFile("target/test/test-file-user.xml");
Files.deleteIfExists(userFile);
assertFalse(Files.exists(userFile));
Files.createDirectories(userFile.getParent());
FileUtils.writeStringToFile(userFile.toFile(), "<configuration/>", Charset.forName("UTF-8"));
ArchivaConfiguration archivaConfiguration = lookup(ArchivaConfiguration.class, "test-save-user");
Configuration configuration = new Configuration();
configuration.setWebapp(new WebappConfiguration());
configuration.getWebapp().setUi(new UserInterfaceOptions());
configuration.getWebapp().getUi().setAppletFindEnabled(false);
archivaConfiguration.save(configuration);
assertTrue("Check file exists", Files.exists(userFile));
assertFalse("Check file not created", Files.exists(baseFile));
// check it
configuration = archivaConfiguration.getConfiguration();
assertFalse("check value", configuration.getWebapp().getUi().isAppletFindEnabled());
}
use of org.apache.archiva.configuration.model.UserInterfaceOptions in project archiva by apache.
the class ArchivaConfigurationTest method testStoreConfiguration.
@Test
public void testStoreConfiguration() throws Exception {
Path file = getTestFile("target/test/test-file.xml");
Files.deleteIfExists(file);
assertFalse(Files.exists(file));
// TODO: remove with commons-configuration 1.4
// file.getParentFile().mkdirs();
// FileUtils.writeStringToFile( file, "<configuration/>", null );
DefaultArchivaConfiguration archivaConfiguration = (DefaultArchivaConfiguration) lookup(ArchivaConfiguration.class, "test-save");
archivaConfiguration.reload();
Configuration configuration = new Configuration();
configuration.setVersion("1");
configuration.setWebapp(new WebappConfiguration());
configuration.getWebapp().setUi(new UserInterfaceOptions());
configuration.getWebapp().getUi().setAppletFindEnabled(false);
// add a change listener
ConfigurationListener listener = mock(ConfigurationListener.class);
archivaConfiguration.addListener(listener);
listener.configurationEvent(new ConfigurationEvent(ConfigurationEvent.SAVED));
archivaConfiguration.save(configuration);
assertTrue("Check file exists", Files.exists(file));
// check it
configuration = archivaConfiguration.getConfiguration();
assertFalse("check value", configuration.getWebapp().getUi().isAppletFindEnabled());
// read it back
archivaConfiguration = (DefaultArchivaConfiguration) lookup(ArchivaConfiguration.class, "test-read-saved");
archivaConfiguration.reload();
configuration = archivaConfiguration.getConfiguration();
assertFalse("check value", configuration.getWebapp().getUi().isAppletFindEnabled());
}
use of org.apache.archiva.configuration.model.UserInterfaceOptions in project archiva by apache.
the class DefaultArchivaAdministration method updateUiConfiguration.
@Override
public void updateUiConfiguration(UiConfiguration uiConfiguration) throws RepositoryAdminException {
Configuration configuration = getArchivaConfiguration().getConfiguration();
if (uiConfiguration != null) {
UserInterfaceOptions userInterfaceOptions = getModelMapper().map(uiConfiguration, UserInterfaceOptions.class);
configuration.getWebapp().setUi(userInterfaceOptions);
} else {
configuration.getWebapp().setUi(null);
}
saveConfiguration(configuration);
}
use of org.apache.archiva.configuration.model.UserInterfaceOptions in project archiva by apache.
the class ArchivaConfigurationTest method testStoreConfigurationFallback.
@Test
public void testStoreConfigurationFallback() throws Exception {
Path baseFile = getTestFile("target/test/test-file.xml");
Files.deleteIfExists(baseFile);
assertFalse(Files.exists(baseFile));
Path userFile = getTestFile("target/test/test-file-user.xml");
Files.deleteIfExists(userFile);
assertFalse(Files.exists(userFile));
Files.createDirectories(baseFile.getParent());
FileUtils.writeStringToFile(baseFile.toFile(), "<configuration/>", Charset.forName("UTF-8"));
ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup(ArchivaConfiguration.class, "test-save-user-fallback");
archivaConfiguration.reload();
Configuration configuration = new Configuration();
configuration.setWebapp(new WebappConfiguration());
configuration.getWebapp().setUi(new UserInterfaceOptions());
configuration.getWebapp().getUi().setAppletFindEnabled(false);
archivaConfiguration.save(configuration);
assertTrue("Check file exists", Files.exists(baseFile));
assertFalse("Check file not created", Files.exists(userFile));
// check it
configuration = archivaConfiguration.getConfiguration();
assertFalse("check value", configuration.getWebapp().getUi().isAppletFindEnabled());
}
use of org.apache.archiva.configuration.model.UserInterfaceOptions in project archiva by apache.
the class ArchivaConfigurationTest method testStoreConfigurationLoadedFromDefaults.
@Test
public void testStoreConfigurationLoadedFromDefaults() throws Exception {
Path baseFile = getTestFile("target/test/test-file.xml");
Files.delete(baseFile);
assertFalse(Files.exists(baseFile));
Path userFile = getTestFile("target/test/test-file-user.xml");
Files.deleteIfExists(userFile);
assertFalse(Files.exists(userFile));
ArchivaConfiguration archivaConfiguration = lookup(ArchivaConfiguration.class, "test-save-user-defaults");
archivaConfiguration.reload();
Configuration configuration = new Configuration();
configuration.setWebapp(new WebappConfiguration());
configuration.getWebapp().setUi(new UserInterfaceOptions());
configuration.getWebapp().getUi().setAppletFindEnabled(false);
// add a change listener
ConfigurationListener listener = createConfigurationListenerMockControl();
archivaConfiguration.addListener(listener);
listener.configurationEvent(new ConfigurationEvent(ConfigurationEvent.SAVED));
archivaConfiguration.save(configuration);
assertTrue("Check file exists", Files.exists(userFile));
assertFalse("Check file not created", Files.exists(baseFile));
// check it
configuration = archivaConfiguration.getConfiguration();
assertFalse("check value", configuration.getWebapp().getUi().isAppletFindEnabled());
}
Aggregations