stager.stage( stagingSessionToken, ImmutableList.of(
@Test public void testStage() throws Exception { String stagingSessionToken = "token"; File file = temp.newFile(); byte[] content = "foo-bar-baz".getBytes(StandardCharsets.UTF_8); String contentSha256 = Hashing.sha256().newHasher().putBytes(content).hash().toString(); try (FileChannel contentChannel = new FileOutputStream(file).getChannel()) { contentChannel.write(ByteBuffer.wrap(content)); } stager.stage(stagingSessionToken, Collections.singleton(StagedFile.of(file, file.getName()))); assertThat(service.getStagedArtifacts().entrySet(), hasSize(1)); byte[] stagedContent = Iterables.getOnlyElement(service.getStagedArtifacts().values()); assertThat(stagedContent, equalTo(content)); ArtifactMetadata staged = service.getManifest().getArtifact(0); assertThat(staged.getName(), equalTo(file.getName())); String manifestSha256 = staged.getSha256(); assertThat(contentSha256, equalTo(manifestSha256)); assertThat(service.getManifest().getArtifactCount(), equalTo(1)); assertThat(staged, equalTo(Iterables.getOnlyElement(service.getStagedArtifacts().keySet()))); }
ArtifactServiceStager stager = ArtifactServiceStager.overChannel(artifactChannel.get()); LOG.debug("Actual files staged: {}", filesToStage); retrievalToken = stager.stage(stagingSessionToken, filesToStage); } catch (CloseableResource.CloseException e) { LOG.warn("Error closing artifact staging channel", e);