use of org.eclipse.equinox.p2.core.ProvisionException 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));
}
use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.
the class LocalArtifactRepositoryP2APITest method testReWriteArtifactViaStreamFails.
@SuppressWarnings("deprecation")
@Test
public void testReWriteArtifactViaStreamFails() throws Exception {
ProvisionException expectedException = null;
try {
OutputStream addSink = subject.getOutputStream(ARTIFACT_A_CANONICAL);
addSink.write(new byte[1]);
addSink.close();
} catch (ProvisionException e) {
expectedException = e;
}
assertThat(expectedException, is(instanceOf(ProvisionException.class)));
assertThat(expectedException.getStatus().getCode(), is(ProvisionException.ARTIFACT_EXISTS));
}
use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.
the class LocalArtifactRepositoryTest method testGetRawArtifactDummy.
@Test
public void testGetRawArtifactDummy() throws ProvisionException, IOException {
LocalArtifactRepository repo = new LocalArtifactRepository(localRepoIndices);
ArtifactDescriptor p2Artifact = newBundleArtifactDescriptor(false);
byte[] content = new byte[] { 111, 112 };
writeDummyArtifact(repo, p2Artifact, content);
Assert.assertTrue(repo.contains(p2Artifact.getArtifactKey()));
ByteArrayOutputStream destination = new ByteArrayOutputStream();
repo.getRawArtifact(p2Artifact, destination, new NullProgressMonitor());
Assert.assertArrayEquals(content, destination.toByteArray());
}
use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.
the class ModuleArtifactRepository method load.
private void load() throws ProvisionException {
try {
FileInputStream p2DataFileStream = new FileInputStream(p2DataFile);
try {
Set<IArtifactDescriptor> descriptors = new ArtifactsIO().readXML(p2DataFileStream);
for (IArtifactDescriptor descriptor : descriptors) {
ModuleArtifactDescriptor internalDescriptor = getInternalDescriptorFromLoadedDescriptor(descriptor, p2DataFile);
// TODO check that GAV properties match module GAV
internalAddInternalDescriptor(internalDescriptor);
}
} finally {
p2DataFileStream.close();
}
} catch (IOException e) {
throw failedReadException(p2DataFile, null, e);
}
}
use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.
the class ModuleMetadataRepository method load.
private void load() throws ProvisionException {
try {
MetadataIO io = new MetadataIO();
FileInputStream is = new FileInputStream(storage);
units.addAll(io.readXML(is));
} catch (IOException e) {
String message = "I/O error while reading repository from " + storage;
int code = ProvisionException.REPOSITORY_FAILED_READ;
Status status = new Status(IStatus.ERROR, BUNDLE_ID, code, message, e);
throw new ProvisionException(status);
}
}
Aggregations