public void testSaveGlobalProxyConfiguration() throws Exception { Configuration config = nexusConfiguration.getConfigurationModel(); assertEquals(null, config.getGlobalHttpProxySettings()); assertTrue(!globalHttpProxySettings.isEnabled()); globalHttpProxySettings.setHostname("testhost.proxy.com"); globalHttpProxySettings.setPort(1234); nexusConfiguration.saveConfiguration(); // force reload nexusConfiguration.loadConfiguration(true); config = nexusConfiguration.getConfigurationModel(); String proxyHostName = nexusConfiguration.getGlobalRemoteStorageContext().getRemoteProxySettings().getHostname(); int proxyPort = nexusConfiguration.getGlobalRemoteStorageContext().getRemoteProxySettings().getPort(); assertEquals( nexusConfiguration.getConfigurationModel().getGlobalHttpProxySettings().getProxyHostname(), proxyHostName); assertEquals( nexusConfiguration.getConfigurationModel().getGlobalHttpProxySettings().getProxyPort(), proxyPort); }
public void testLoadConfiguration() throws Exception { // get it Configuration config = nexusConfiguration.getConfigurationModel(); // check it for default value assertEquals("smtp-host", config.getSmtpConfiguration().getHostname()); // modify it nexusEmailer.setSMTPHostname("NEW-HOST"); // save it nexusConfiguration.saveConfiguration(); // replace it again with default "from behind" InputStreamFacade isf = new InputStreamFacade() { public InputStream getInputStream() throws IOException { return getClass().getResourceAsStream("/META-INF/nexus/nexus.xml"); } }; FileUtils.copyStreamToFile(isf, new File(getNexusConfiguration())); // force reload nexusConfiguration.loadConfiguration(true); // get the config config = nexusConfiguration.getConfigurationModel(); // it again contains default value, coz we overwritten it before assertEquals("smtp-host", config.getSmtpConfiguration().getHostname()); assertEquals("smtp-host", nexusEmailer.getSMTPHostname()); }
public synchronized Repository createRepository(CRepository settings) throws ConfigurationException, IOException { validateRepository(settings, true); // create it, will do runtime validation Repository repository = instantiateRepository(getConfigurationModel(), settings); // now add it to config, since it is validated and successfully created getConfigurationModel().addRepository(settings); // save saveConfiguration(); return repository; }
public void testSaveConfiguration() throws Exception { Configuration config = nexusConfiguration.getConfigurationModel(); assertEquals(true, this.securitySystem.isSecurityEnabled()); this.securitySystem.setSecurityEnabled(false); nexusConfiguration.saveConfiguration(); nexusConfiguration.loadConfiguration(); config = nexusConfiguration.getConfigurationModel(); assertEquals(false, this.securitySystem.isSecurityEnabled()); }
public void testNEXUS2212SaveInvalidConfig() throws Exception { Configuration nexusConfig = nexusConfiguration.getConfigurationModel(); CRepository centralCRepo = null; for (CRepository cRepo : nexusConfig.getRepositories()) { if (cRepo.getId().equals("central")) { centralCRepo = cRepo; break; } } assertNotNull(centralCRepo); centralCRepo.setLocalStatus(LocalStatus.OUT_OF_SERVICE.name()); nexusConfiguration.saveConfiguration(); }
public synchronized void deleteRepository(String id) throws NoSuchRepositoryException, IOException, ConfigurationException { Repository repository = repositoryRegistry.getRepository(id); // put out of service so wont be accessed any longer repository.setLocalStatus(LocalStatus.OUT_OF_SERVICE); // disable indexing for same purpose repository.setIndexable(false); repository.setSearchable(false); // remove dependants too // ======= // shadows // (fail if any repo references the currently processing one) List<ShadowRepository> shadows = repositoryRegistry.getRepositoriesWithFacet(ShadowRepository.class); for (Iterator<ShadowRepository> i = shadows.iterator(); i.hasNext(); ) { ShadowRepository shadow = i.next(); if (repository.getId().equals(shadow.getMasterRepository().getId())) { throw new RepositoryDependentException(repository, shadow); } } // ====== // groups // (correction in config only, registry DOES handle it) // since NEXUS-1770, groups are "self maintaining" // =========== // pahMappings // (correction, since registry is completely unaware of this component) List<CPathMappingItem> pathMappings = getConfigurationModel().getRepositoryGrouping().getPathMappings(); for (Iterator<CPathMappingItem> i = pathMappings.iterator(); i.hasNext(); ) { CPathMappingItem item = i.next(); item.removeRepository(id); } // =========== // and finally // this cleans it properly from the registry (from reposes and repo groups) repositoryRegistry.removeRepository(id); List<CRepository> reposes = getConfigurationModel().getRepositories(); for (Iterator<CRepository> i = reposes.iterator(); i.hasNext(); ) { CRepository repo = i.next(); if (repo.getId().equals(id)) { i.remove(); saveConfiguration(); releaseRepository(repository, getConfigurationModel(), repo); return; } } throw new NoSuchRepositoryException(id); }
@Deprecated // see above protected void applyAndSaveConfiguration() throws IOException { saveConfiguration(); }