Search in sources :

Example 21 with IArtifactRepository

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));
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) Test(org.junit.Test)

Example 22 with IArtifactRepository

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);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IArtifactRepositoryManager(org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) File(java.io.File)

Example 23 with IArtifactRepository

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);
}
Also used : IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) Test(org.junit.Test)

Example 24 with IArtifactRepository

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));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) SimpleArtifactRepository(org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository) BufferedInputStream(java.io.BufferedInputStream) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IOException(java.io.IOException) XMLParser(org.eclipse.equinox.internal.p2.persistence.XMLParser)

Example 25 with IArtifactRepository

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);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) Test(org.junit.Test)

Aggregations

IArtifactRepository (org.eclipse.equinox.p2.repository.artifact.IArtifactRepository)23 Test (org.junit.Test)11 IStatus (org.eclipse.core.runtime.IStatus)7 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)6 File (java.io.File)4 OutputStream (java.io.OutputStream)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 Status (org.eclipse.core.runtime.Status)3 IProvisioningAgent (org.eclipse.equinox.p2.core.IProvisioningAgent)3 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)3 IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)3 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)3 IMetadataRepository (org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 IPublisherAction (org.eclipse.equinox.p2.publisher.IPublisherAction)2 IPublisherAdvice (org.eclipse.equinox.p2.publisher.IPublisherAdvice)2 IPublisherInfo (org.eclipse.equinox.p2.publisher.IPublisherInfo)2 Publisher (org.eclipse.equinox.p2.publisher.Publisher)2