use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepository in project tycho by eclipse.
the class PublishingRepositoryTest method testArtifactDescriptor.
@Test
public void testArtifactDescriptor() throws Exception {
// simulate that AttachedTestArtifact is the build output
insertTestArtifact(subject);
IArtifactRepository artifactRepo = subject.getArtifactRepository();
assertThat(allKeysIn(artifactRepo), hasItem(AttachedTestArtifact.key));
IArtifactDescriptor[] descriptors = artifactRepo.getArtifactDescriptors(AttachedTestArtifact.key);
assertThat(descriptors.length, is(1));
Map<String, String> props = descriptors[0].getProperties();
assertThat(props.get(RepositoryLayoutHelper.PROP_GROUP_ID), is(project.getGroupId()));
assertThat(props.get(RepositoryLayoutHelper.PROP_ARTIFACT_ID), is(project.getArtifactId()));
assertThat(props.get(RepositoryLayoutHelper.PROP_VERSION), is(project.getVersion()));
assertThat(props.get(RepositoryLayoutHelper.PROP_CLASSIFIER), is(AttachedTestArtifact.classifier));
}
use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepository in project tycho by eclipse.
the class RemoteArtifactTransferPolicyTest method loadDescriptorsFromRepository.
static IArtifactDescriptor[] loadDescriptorsFromRepository(String repository, P2Context p2Context) throws Exception {
IArtifactRepositoryManager repoManager = (IArtifactRepositoryManager) p2Context.getAgent().getService(IArtifactRepositoryManager.SERVICE_NAME);
File repoPath = ResourceUtil.resourceFile("repositories/rawformats/" + repository);
IArtifactRepository loadedRepo = repoManager.loadRepository(repoPath.toURI(), new NullProgressMonitor());
return loadedRepo.getArtifactDescriptors(DEFAULT_KEY);
}
use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepository in project tycho by eclipse.
the class FileRepositoryArtifactProviderTest method testConstructionWithNonArtifactFileRepository.
@Test(expected = IllegalArgumentException.class)
public void testConstructionWithNonArtifactFileRepository() throws Exception {
// i.e. not an IFileArtifactRepository
IArtifactRepository repository = mock(IArtifactRepository.class);
subject = new FileRepositoryArtifactProvider(loaderFor(repository), TRANSFER_POLICY);
subject.getArtifactFile(BUNDLE_A_KEY);
}
use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepository in project tycho by eclipse.
the class SimpleArtifactRepositoryIO method read.
/**
* Reads the artifact repository from the given stream, and returns the contained array of
* abstract artifact repositories.
*
* This method performs buffering, and closes the stream when finished.
*/
public IArtifactRepository read(URL location, InputStream input, IProgressMonitor monitor) throws ProvisionException {
BufferedInputStream bufferedInput = null;
try {
try {
bufferedInput = new BufferedInputStream(input);
Parser repositoryParser = new Parser(Activator.getContext(), Activator.ID);
repositoryParser.parse(input);
IStatus result = repositoryParser.getStatus();
switch(result.getSeverity()) {
case IStatus.CANCEL:
throw new OperationCanceledException();
case IStatus.ERROR:
throw new ProvisionException(result);
case IStatus.WARNING:
case IStatus.INFO:
LogHelper.log(result);
break;
case IStatus.OK:
break;
default:
// $NON-NLS-1$
throw new IllegalStateException("Unknown serverity value: " + result.getSeverity());
}
SimpleArtifactRepository repository = repositoryParser.getRepository();
if (repository == null)
throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_READ, Messages.io_parseError, null));
return repository;
} finally {
if (bufferedInput != null)
bufferedInput.close();
}
} catch (IOException ioe) {
String msg = NLS.bind(Messages.io_failedRead, location);
throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_READ, msg, ioe));
}
}
use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepository in project tycho by eclipse.
the class LocalArtifactRepositoryFactoryTest method testLoad.
@Test
public void testLoad() throws ProvisionException {
LocalArtifactRepository repo = new LocalArtifactRepository(localRepoIndices);
repo.save();
IArtifactRepository repo2 = subject.load(baseDir.toURI(), 0, new NullProgressMonitor());
Assert.assertEquals(repo, repo2);
}
Aggregations