use of com.google.gerrit.server.config.FileBasedAllProjectsConfigProvider in project gerrit by GerritCodeReview.
the class AllProjectsConfigTest method setUp.
@Before
public void setUp() throws Exception {
sitePaths = new SitePaths(temporaryFolder.newFolder().toPath());
Files.createDirectories(sitePaths.etc_dir);
Path gitPath = sitePaths.resolve("git");
StoredConfig gerritConfig = new FileBasedConfig(sitePaths.resolve("etc").resolve("gerrit.config").toFile(), FS.DETECTED);
gerritConfig.load();
gerritConfig.setString("gerrit", null, "basePath", gitPath.toAbsolutePath().toString());
gerritConfig.setString("gerrit", null, "allProjects", ALL_PROJECTS);
gerritConfig.save();
Files.createDirectories(sitePaths.resolve("git"));
allProjectsRepoFile = gitPath.resolve("All-The-Projects.git").toFile();
try (Repository repo = new FileRepository(allProjectsRepoFile)) {
repo.create(true);
}
InMemorySecureStore secureStore = new InMemorySecureStore();
InitFlags flags = new InitFlags(sitePaths, secureStore, ImmutableList.of(), false);
Section.Factory sections = (name, subsection) -> new Section(flags, sitePaths, secureStore, ui, name, subsection);
AllProjectsConfigProvider configProvider = new FileBasedAllProjectsConfigProvider(sitePaths);
allProjectsConfig = new AllProjectsConfig(new AllProjectsNameOnInitProvider(sections), configProvider, sitePaths, flags);
}
use of com.google.gerrit.server.config.FileBasedAllProjectsConfigProvider in project gerrit by GerritCodeReview.
the class ProjectConfigTest method allProjectsProjectConfigInSitePaths_hashForKeyChangesWithnFileChanges.
@Test
public void allProjectsProjectConfigInSitePaths_hashForKeyChangesWithnFileChanges() throws Exception {
Path tmp = Files.createTempFile("gerrit_test_", "_site");
Files.deleteIfExists(tmp);
SitePaths sitePaths = new SitePaths(tmp);
FileBasedAllProjectsConfigProvider allProjectsConfigProvider = new FileBasedAllProjectsConfigProvider(sitePaths);
byte[] hashedContents = ProjectCacheImpl.allProjectsFileProjectConfigHash(allProjectsConfigProvider.get(ALL_PROJECTS));
// Empty/absent config
assertThat(hashedContents).isEqualTo(new byte[16]);
FileBasedConfig fileBasedConfig = new FileBasedConfig(sitePaths.etc_dir.resolve(ALL_PROJECTS.get()).resolve(ProjectConfig.PROJECT_CONFIG).toFile(), FS.DETECTED);
fileBasedConfig.setString("plugin", "my-plugin", "key", "value");
fileBasedConfig.save();
hashedContents = ProjectCacheImpl.allProjectsFileProjectConfigHash(allProjectsConfigProvider.get(ALL_PROJECTS));
assertThat(hashedContents).isEqualTo(new byte[] { -53, -97, -1, 52, -119, 104, -13, -41, -7, 82, -90, 126, -32, -13, -91, 49 });
}
use of com.google.gerrit.server.config.FileBasedAllProjectsConfigProvider in project gerrit by GerritCodeReview.
the class ProjectConfigTest method setUp.
@Before
public void setUp() throws Exception {
sitePaths = new SitePaths(temporaryFolder.newFolder().toPath());
Files.createDirectories(sitePaths.etc_dir);
factory = new ProjectConfig.Factory(ALL_PROJECTS, new FileBasedAllProjectsConfigProvider(sitePaths));
db = new InMemoryRepository(new DfsRepositoryDescription("repo"));
tr = new TestRepository<>(db);
}
use of com.google.gerrit.server.config.FileBasedAllProjectsConfigProvider in project gerrit by GerritCodeReview.
the class ProjectConfigSchemaUpdateTest method setUp.
@Before
public void setUp() throws Exception {
sitePaths = new SitePaths(temporaryFolder.newFolder().toPath());
Files.createDirectories(sitePaths.etc_dir);
Path gitPath = sitePaths.resolve("git");
StoredConfig gerritConfig = new FileBasedConfig(sitePaths.gerrit_config.toFile(), FS.DETECTED);
gerritConfig.load();
gerritConfig.setString("gerrit", null, "basePath", gitPath.toAbsolutePath().toString());
gerritConfig.setString("gerrit", null, "allProjects", ALL_PROJECTS);
gerritConfig.save();
Files.createDirectories(sitePaths.resolve("git"));
allProjectsRepoFile = gitPath.resolve("All-The-Projects.git").toFile();
try (Repository repo = new FileRepository(allProjectsRepoFile)) {
repo.create(true);
}
FileBasedAllProjectsConfigProvider configProvider = new FileBasedAllProjectsConfigProvider(sitePaths);
factory = new ProjectConfigSchemaUpdate.Factory(new AllProjectsName(ALL_PROJECTS), configProvider);
}
Aggregations