Search in sources :

Example 1 with RepositoryReferences

use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.

the class MirrorApplicationServiceTest method sourceRepos.

public static RepositoryReferences sourceRepos(String... repoIds) {
    RepositoryReferences result = new RepositoryReferences();
    for (String repoId : repoIds) {
        result.addMetadataRepository(ResourceUtil.resourceFile("repositories/" + repoId));
        result.addArtifactRepository(ResourceUtil.resourceFile("repositories/" + repoId));
    }
    return result;
}
Also used : RepositoryReferences(org.eclipse.tycho.p2.tools.RepositoryReferences)

Example 2 with RepositoryReferences

use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.

the class VerifierServiceImplTest method testFileRepositoryWithTamperedArtifact.

@Test
public void testFileRepositoryWithTamperedArtifact() throws Exception {
    final RepositoryReferences repositories = sourceRepos("invalid/tampered_file");
    assertEquals(false, verify(repositories));
    assertTrue(firstErrorLine().contains("osgi.bundle"));
    assertTrue(firstErrorLine().contains("jarsigning"));
    assertTrue(remainingErrorText().contains("dummy.class"));
    assertTrue(remainingErrorText().contains("has been tampered"));
}
Also used : RepositoryReferences(org.eclipse.tycho.p2.tools.RepositoryReferences) Test(org.junit.Test)

Example 3 with RepositoryReferences

use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.

the class VerifierServiceImplTest method testFileRepositoryWithWrongMd5Sum.

@Test
public void testFileRepositoryWithWrongMd5Sum() throws Exception {
    final RepositoryReferences repositories = sourceRepos("invalid/wrong_checksum");
    assertEquals(false, verify(repositories));
    // we expect two errors to be reported: the feature "jarsinging.feature" has a wrong md5 hash and
    // the osgi.bundle "jarsigning" has also a wrong md5 hash.
    // As each error is reported on two lines, we have 4 lines of error messages:
    assertEquals(logger.errors.size(), 4);
    // The first and third line contain the names of the units in error:
    String unitsInError = logger.errors.get(0) + logger.errors.get(2);
    assertTrue(unitsInError.contains("jarsigning.feature") && unitsInError.contains("osgi.bundle"));
    // The second and fourth line contain the type of error: md5 hash
    assertTrue(logger.errors.get(1).toLowerCase(Locale.ENGLISH).contains("md5 hash"));
    assertTrue(logger.errors.get(3).toLowerCase(Locale.ENGLISH).contains("md5 hash"));
}
Also used : RepositoryReferences(org.eclipse.tycho.p2.tools.RepositoryReferences) Test(org.junit.Test)

Example 4 with RepositoryReferences

use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.

the class VerifierServiceImplTest method testValidFileRepository.

@Test
public void testValidFileRepository() throws Exception {
    final RepositoryReferences repositories = sourceRepos("selfsigned");
    assertEquals(true, verify(repositories));
}
Also used : RepositoryReferences(org.eclipse.tycho.p2.tools.RepositoryReferences) Test(org.junit.Test)

Example 5 with RepositoryReferences

use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.

the class MirrorApplicationServiceImpl method mirrorStandalone.

@Override
public void mirrorStandalone(RepositoryReferences sources, DestinationRepositoryDescriptor destination, Collection<IUDescription> seedIUs, MirrorOptions mirrorOptions, BuildOutputDirectory tempDirectory) throws FacadeException {
    IProvisioningAgent agent = Activator.createProvisioningAgent(tempDirectory);
    try {
        final MirrorApplication mirrorApp = createMirrorApplication(sources, destination, agent, mirrorOptions.isIncludePacked());
        mirrorApp.setSlicingOptions(createSlicingOptions(mirrorOptions));
        mirrorApp.setIgnoreErrors(mirrorOptions.isIgnoreErrors());
        try {
            // we want to see mirror progress as this is a possibly long-running operation
            mirrorApp.setVerbose(true);
            mirrorApp.setLog(new LogListener(mavenContext.getLogger()));
            mirrorApp.setSourceIUs(querySourceIus(seedIUs, mirrorApp.getCompositeMetadataRepository(), sources));
            IStatus returnStatus = mirrorApp.run(null);
            checkStatus(returnStatus, mirrorOptions.isIgnoreErrors());
        } catch (ProvisionException e) {
            throw new FacadeException(MIRROR_FAILURE_MESSAGE + ": " + StatusTool.collectProblems(e.getStatus()), e);
        }
    } finally {
        agent.stop();
    }
}
Also used : FacadeException(org.eclipse.tycho.p2.tools.FacadeException) IStatus(org.eclipse.core.runtime.IStatus) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) IProvisioningAgent(org.eclipse.equinox.p2.core.IProvisioningAgent)

Aggregations

RepositoryReferences (org.eclipse.tycho.p2.tools.RepositoryReferences)10 File (java.io.File)6 FacadeException (org.eclipse.tycho.p2.tools.FacadeException)4 Test (org.junit.Test)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 MojoFailureException (org.apache.maven.plugin.MojoFailureException)3 DependencySeed (org.eclipse.tycho.core.resolver.shared.DependencySeed)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 IStatus (org.eclipse.core.runtime.IStatus)2 IProvisioningAgent (org.eclipse.equinox.p2.core.IProvisioningAgent)2 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)2 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)2 TargetPlatformConfiguration (org.eclipse.tycho.core.TargetPlatformConfiguration)2 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)2 DestinationRepositoryDescriptor (org.eclipse.tycho.p2.tools.DestinationRepositoryDescriptor)2 IUDescription (org.eclipse.tycho.p2.tools.mirroring.facade.IUDescription)2 FileOutputStream (java.io.FileOutputStream)1 MalformedURLException (java.net.MalformedURLException)1 HashSet (java.util.HashSet)1