use of org.eclipse.tycho.repository.p2base.artifact.provider.streaming.IArtifactSink in project tycho by eclipse.
the class LocalArtifactRepositoryP2APITest method testWriteArtifactAndCancel.
@Test
public void testWriteArtifactAndCancel() throws Exception {
IArtifactSink addSink = subject.newAddingArtifactSink(NEW_KEY);
addSink.beginWrite().write(new byte[33]);
addSink.abortWrite();
assertFalse(subject.contains(NEW_KEY));
assertFalse(subject.contains(localCanonicalDescriptorFor(NEW_KEY)));
}
use of org.eclipse.tycho.repository.p2base.artifact.provider.streaming.IArtifactSink in project tycho by eclipse.
the class LocalArtifactRepositoryP2APITest method testWriteArtifactOnSecondAttempt.
@Test
public void testWriteArtifactOnSecondAttempt() throws Exception {
IArtifactSink addSink = subject.newAddingArtifactSink(NEW_KEY);
addSink.beginWrite().write(new byte[11]);
addSink.beginWrite().write(new byte[22]);
addSink.commitWrite();
assertThat(subject.contains(NEW_KEY), is(true));
assertThat(subject.contains(localCanonicalDescriptorFor(NEW_KEY)), is(true));
assertThat(readSizeOfArtifact(NEW_KEY), is(22));
}
use of org.eclipse.tycho.repository.p2base.artifact.provider.streaming.IArtifactSink in project tycho by eclipse.
the class LocalArtifactRepositoryP2APITest method testReWriteArtifactFails.
@Test
public void testReWriteArtifactFails() throws Exception {
// LocalArtifactRepository doesn't allow overwrites -> this may be different in other IArtifactRepository implementations
ProvisionException expectedException = null;
try {
IArtifactSink addSink = subject.newAddingArtifactSink(ARTIFACT_A_KEY);
addSink.beginWrite();
addSink.commitWrite();
} catch (ProvisionException e) {
expectedException = e;
}
assertThat(expectedException, is(instanceOf(ProvisionException.class)));
assertThat(expectedException.getStatus().getCode(), is(ProvisionException.ARTIFACT_EXISTS));
}
Aggregations