Search in sources :

Example 6 with IArtifactSink

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)));
}
Also used : IArtifactSink(org.eclipse.tycho.repository.p2base.artifact.provider.streaming.IArtifactSink) Test(org.junit.Test)

Example 7 with IArtifactSink

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));
}
Also used : IArtifactSink(org.eclipse.tycho.repository.p2base.artifact.provider.streaming.IArtifactSink) Test(org.junit.Test)

Example 8 with IArtifactSink

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));
}
Also used : ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) IArtifactSink(org.eclipse.tycho.repository.p2base.artifact.provider.streaming.IArtifactSink) Test(org.junit.Test)

Aggregations

IArtifactSink (org.eclipse.tycho.repository.p2base.artifact.provider.streaming.IArtifactSink)8 Test (org.junit.Test)7 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)1 ArtifactSinkException (org.eclipse.tycho.repository.p2base.artifact.provider.streaming.ArtifactSinkException)1