use of org.commonjava.indy.audit.ChangeSummary in project indy by Commonjava.
the class DataFileStoreDataManager method install.
@Override
public void install() throws IndyDataException {
if (!manager.getDataFile(INDY_STORE).isDirectory()) {
final ChangeSummary summary = new ChangeSummary(ChangeSummary.SYSTEM_USER, "Initializing defaults");
storeArtifactStore(new RemoteRepository(MAVEN_PKG_KEY, "central", "http://repo.maven.apache.org/maven2/"), summary, true, false, new EventMetadata());
storeArtifactStore(new Group(MAVEN_PKG_KEY, "public", new StoreKey(StoreType.remote, "central")), summary, true, false, new EventMetadata());
}
}
use of org.commonjava.indy.audit.ChangeSummary in project indy by Commonjava.
the class GitManagerConcurrentTest method addToRepoWhileGettingHeadCommit.
@BMRules(rules = { @BMRule(name = "init rendezvous", targetClass = "GitManager", targetMethod = "<init>", targetLocation = "ENTRY", action = "createRendezvous($0, 2, true)"), @BMRule(name = "getHeadCommit call", targetClass = "GitManager", targetMethod = "getHeadCommit(File)", targetLocation = "ENTRY", action = "debug(\"getHeadCommit() waiting...\"); rendezvous($0); debug(\"getHeadCommit(): thread proceeding.\")"), @BMRule(name = "addAndCommitPaths call", targetClass = "GitManager", targetMethod = "addAndCommitPaths(ChangeSummary,Collection)", targetLocation = "ENTRY", action = "debug(\"addAndCommitPaths() waiting...\"); rendezvous($0); debug(\"addAndCommitPaths(): thread proceeding.\")") })
@Test
public void addToRepoWhileGettingHeadCommit() throws Exception {
final int threshold = 2;
final Executor pool = Executors.newFixedThreadPool(threshold);
CountDownLatch latch = new CountDownLatch(threshold);
final File f = new File(cloneDir, String.format("test.txt"));
FileUtils.write(f, "This is a test");
final String user = "testAddAndCommit";
git.addAndCommitFiles(new ChangeSummary(user, "first commit"), f);
pool.execute(() -> {
try {
git.getHeadCommit(f);
} catch (Exception e) {
e.printStackTrace();
failed = true;
} finally {
latch.countDown();
}
});
pool.execute(() -> {
try {
FileUtils.write(f, "This is another test");
git.addAndCommitFiles(new ChangeSummary(user, "second commit"), f);
} catch (Exception e) {
e.printStackTrace();
failed = true;
} finally {
latch.countDown();
}
});
latch.await();
if (failed) {
fail();
}
}
use of org.commonjava.indy.audit.ChangeSummary in project indy by Commonjava.
the class GitManagerConcurrentTest method concurrentDeleteFromRepo.
@BMRules(rules = { @BMRule(name = "init rendezvous", targetClass = "GitManager", targetMethod = "<init>", targetLocation = "ENTRY", action = "createRendezvous($0, 2, true)"), @BMRule(name = "deleteAndCommitPaths call", targetClass = "GitManager", targetMethod = "deleteAndCommitPaths(ChangeSummary,Collection)", targetLocation = "ENTRY", action = "rendezvous($0); debug(Thread.currentThread().getName() + \": thread proceeding.\")") })
@Test
public void concurrentDeleteFromRepo() throws Exception {
final int threshold = 2;
for (int i = 0; i < threshold; i++) {
try {
final File f = new File(cloneDir, String.format("test%s.txt", i));
FileUtils.write(f, String.format("This is a test %s", i));
final String user = "test" + i;
final String log = "test commit " + i;
git.addAndCommitFiles(new ChangeSummary(user, log), f);
} catch (Exception e) {
e.printStackTrace();
failed = true;
}
}
final Executor pool = Executors.newFixedThreadPool(threshold);
CountDownLatch latch = new CountDownLatch(threshold);
for (int i = 0; i < threshold; i++) {
final int j = i;
pool.execute(() -> {
try {
final File f = new File(cloneDir, String.format("test%s.txt", j));
final String user = "test" + j;
final String log = "delete test" + j + ".txt";
git.deleteAndCommit(new ChangeSummary(user, log), f);
} catch (Exception e) {
e.printStackTrace();
failed = true;
} finally {
latch.countDown();
}
});
}
latch.await();
if (failed) {
fail();
}
}
use of org.commonjava.indy.audit.ChangeSummary in project indy by Commonjava.
the class GitManagerTest method addToClonedRepoAndRetrieveCommitLog.
@Test
public void addToClonedRepoAndRetrieveCommitLog() throws Exception {
final File root = unpackRepo("test-indy-data.zip");
final File cloneDir = temp.newFolder();
FileUtils.forceDelete(cloneDir);
final String email = "me@nowhere.com";
// NOTE: Leave off generation of file-list changed in commit message (third parameter, below)
final GitConfig config = new GitConfig(cloneDir, root.toURI().toURL().toExternalForm(), false).setUserEmail(email);
final GitManager git = new GitManager(config);
final File f = new File(cloneDir, "test.txt");
FileUtils.write(f, "This is a test");
final String user = "test";
final String log = "test commit";
git.addAndCommitFiles(new ChangeSummary(user, log), f);
final List<ChangeSummary> changelog = git.getChangelog(f, 0, 1);
assertThat(changelog, notNullValue());
assertThat(changelog.size(), equalTo(1));
assertThat(changelog.get(0).getUser(), equalTo(user));
assertThat(changelog.get(0).getSummary(), equalTo(log));
}
use of org.commonjava.indy.audit.ChangeSummary in project indy by Commonjava.
the class IndySiteConfigLookupTest method checkServerCertPemIsConfigured.
@Test
public void checkServerCertPemIsConfigured() throws IndyDataException {
RemoteRepository remote = new RemoteRepository(MAVEN_PKG_KEY, "test", "http://test.com/repo");
remote.setServerCertPem("AAAAFFFFFSDADFADSFASDFASDFASDFASDFASDFsa");
remote.setServerTrustPolicy("self-signed");
MemoryStoreDataManager storeData = new MemoryStoreDataManager(true);
storeData.storeArtifactStore(remote, new ChangeSummary(ChangeSummary.SYSTEM_USER, "This is a test"), false, false, new EventMetadata());
IndySiteConfigLookup lookup = new IndySiteConfigLookup(storeData);
SiteConfig siteConfig = lookup.lookup("remote:test");
assertThat(siteConfig.getServerCertPem(), equalTo(remote.getServerCertPem()));
}
Aggregations