use of com.teamscale.jacoco.agent.util.InMemoryUploader in project teamscale-jacoco-agent by cqse.
the class DelayedUploaderTest method shouldStoreToCacheIfCommitIsNotKnown.
@Test
public void shouldStoreToCacheIfCommitIsNotKnown(@TempDir Path outputPath) throws IOException {
Path coverageFilePath = outputPath.resolve(String.format("jacoco-%d.xml", ZonedDateTime.now().toInstant().toEpochMilli()));
CoverageFile coverageFile = new CoverageFile(Files.createFile(coverageFilePath).toFile());
InMemoryUploader destination = new InMemoryUploader();
DelayedUploader<?> store = new DelayedUploader<>(commit -> destination, outputPath);
store.upload(coverageFile);
assertThat(Files.list(outputPath).collect(Collectors.toList())).contains(coverageFilePath);
assertThat(destination.getUploadedFiles()).doesNotContain(coverageFile);
}
use of com.teamscale.jacoco.agent.util.InMemoryUploader in project teamscale-jacoco-agent by cqse.
the class DelayedUploaderTest method shouldStoreToDestinationIfCommitIsKnown.
@Test
public void shouldStoreToDestinationIfCommitIsKnown(@TempDir Path outputPath) throws IOException {
Path coverageFilePath = outputPath.resolve(String.format("jacoco-%d.xml", ZonedDateTime.now().toInstant().toEpochMilli()));
CoverageFile coverageFile = new CoverageFile(Files.createFile(coverageFilePath).toFile());
InMemoryUploader destination = new InMemoryUploader();
DelayedUploader<String> store = new DelayedUploader<>(commit -> destination, outputPath);
store.setCommitAndTriggerAsynchronousUpload("a2afb54566aaa");
store.upload(coverageFile);
assertThat(Files.list(outputPath).collect(Collectors.toList())).doesNotContain(coverageFilePath);
assertThat(destination.getUploadedFiles()).contains(coverageFile);
}
use of com.teamscale.jacoco.agent.util.InMemoryUploader in project teamscale-jacoco-agent by cqse.
the class DelayedCommitDescriptorRetrievalTest method locatorShouldTriggerUploadOfCachedXmls.
@Test
public void locatorShouldTriggerUploadOfCachedXmls(@TempDir Path outputPath) throws Exception {
ExecutorService storeExecutor = Executors.newSingleThreadExecutor();
Path coverageFilePath = outputPath.resolve(String.format("jacoco-%d.xml", ZonedDateTime.now().toInstant().toEpochMilli()));
CoverageFile coverageFile = new CoverageFile(Files.createFile(coverageFilePath).toFile());
InMemoryUploader destination = new InMemoryUploader();
DelayedUploader<String> store = new DelayedUploader<>(commit -> destination, outputPath, storeExecutor);
ExecutorService locatorExecutor = Executors.newSingleThreadExecutor();
GitPropertiesLocator<String> locator = new GitPropertiesLocator<>(store, GitPropertiesLocatorUtils::getRevisionFromGitProperties, locatorExecutor);
store.upload(coverageFile);
locator.searchFileForGitPropertiesAsync(new File(getClass().getResource("git-properties.jar").toURI()), true);
locatorExecutor.shutdown();
locatorExecutor.awaitTermination(5, TimeUnit.SECONDS);
storeExecutor.shutdown();
storeExecutor.awaitTermination(5, TimeUnit.SECONDS);
assertThat(Files.list(outputPath).anyMatch(path -> path.equals(coverageFilePath))).isFalse();
assertThat(destination.getUploadedFiles().contains(coverageFile)).isTrue();
}
use of com.teamscale.jacoco.agent.util.InMemoryUploader in project teamscale-jacoco-agent by cqse.
the class DelayedUploaderTest method shouldAsynchronouslyStoreToDestinationOnceCommitIsKnown.
@Test
public void shouldAsynchronouslyStoreToDestinationOnceCommitIsKnown(@TempDir Path outputPath) throws Exception {
Path coverageFilePath = outputPath.resolve(String.format("jacoco-%d.xml", ZonedDateTime.now().toInstant().toEpochMilli()));
CoverageFile coverageFile = new CoverageFile(Files.createFile(coverageFilePath).toFile());
InMemoryUploader destination = new InMemoryUploader();
ExecutorService executor = Executors.newSingleThreadExecutor();
DelayedUploader<String> store = new DelayedUploader<>(commit -> destination, outputPath, executor);
store.upload(coverageFile);
store.setCommitAndTriggerAsynchronousUpload("a2afb54566aaa");
executor.shutdown();
executor.awaitTermination(5, TimeUnit.SECONDS);
assertThat(Files.list(outputPath).collect(Collectors.toList())).doesNotContain(coverageFilePath);
assertThat(destination.getUploadedFiles()).contains(coverageFile);
}
Aggregations