use of org.eclipse.tycho.repository.p2base.artifact.provider.streaming.IArtifactSink in project tycho by eclipse.
the class LocalArtifactRepositoryP2APITest method testWriteArtifact.
@Test
public void testWriteArtifact() throws Exception {
IArtifactSink addSink = subject.newAddingArtifactSink(NEW_KEY);
addSink.beginWrite().write(new byte[33]);
addSink.commitWrite();
assertTrue(subject.contains(NEW_KEY));
assertTrue(subject.contains(localCanonicalDescriptorFor(NEW_KEY)));
assertThat(readSizeOfArtifact(NEW_KEY), is(33));
}
use of org.eclipse.tycho.repository.p2base.artifact.provider.streaming.IArtifactSink in project tycho by eclipse.
the class LocalArtifactRepositoryP2APITest method testGetArtifactToBrokenSink.
@Test(expected = ArtifactSinkException.class)
public void testGetArtifactToBrokenSink() throws Exception {
IArtifactSink brokenSink = new IArtifactSink() {
@Override
public IArtifactKey getArtifactToBeWritten() {
return ARTIFACT_A_KEY;
}
@Override
public boolean canBeginWrite() {
return true;
}
@Override
public OutputStream beginWrite() {
return testOutputStream;
}
@Override
public void commitWrite() throws ArtifactSinkException {
throw new ArtifactSinkException("simulated error on commit");
}
@Override
public void abortWrite() {
}
};
subject.getArtifact(brokenSink, null);
}
use of org.eclipse.tycho.repository.p2base.artifact.provider.streaming.IArtifactSink in project tycho by eclipse.
the class MirroringArtifactProvider method createCanonicalArtifactFromLocalPackedArtifact.
private void createCanonicalArtifactFromLocalPackedArtifact(IArtifactKey key) throws ProvisionException, ArtifactSinkException {
logger.info("Unpacking " + key.getId() + "_" + key.getVersion() + "...");
// TODO 397355 ignore ProvisionException.ARTIFACT_EXISTS
IArtifactSink sink = localArtifactRepository.newAddingArtifactSink(key);
localArtifactRepository.getArtifact(sink, monitor);
}
use of org.eclipse.tycho.repository.p2base.artifact.provider.streaming.IArtifactSink in project tycho by eclipse.
the class ModuleArtifactRepositoryTest method testWriteToRepository.
@Test
public void testWriteToRepository() throws Exception {
subject = ModuleArtifactRepository.createInstance(null, tempManager.newFolder("targetDir"));
// TODO this should not be necessary
subject.setGAV("", "", "");
IArtifactSink sink = subject.newAddingArtifactSink(BINARY_ARTIFACT_KEY, new WriteSessionStub());
writeAndClose(sink.beginWrite(), BINARY_ARTIFACT_SIZE);
sink.commitWrite();
assertThat(artifactSizeOf(BINARY_ARTIFACT_KEY, subject), is(BINARY_ARTIFACT_SIZE));
}
use of org.eclipse.tycho.repository.p2base.artifact.provider.streaming.IArtifactSink in project tycho by eclipse.
the class CompositeArtifactProviderTestBase method testGetArtifactWithNonRestartableSink.
@Test
public void testGetArtifactWithNonRestartableSink() throws Exception {
subject = createCompositeArtifactProvider(REPO_BUNDLE_A_CORRUPT, REPO_BUNDLE_A);
IArtifactSink nonRestartableSink = ArtifactSinkFactory.writeToStream(BUNDLE_A_KEY, testOutputStream);
status = subject.getArtifact(nonRestartableSink, null);
// first read attempt fails -> operation fails
assertThat(status, is(errorStatus()));
// original message from p2 as top-level status
assertThat(status.getMessage(), containsString("An error occurred while transferring artifact"));
}
Aggregations