use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.
the class DependencyCollectorTest method missingDependencies.
@Test
public void missingDependencies() {
InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription();
String time = Long.toString(System.currentTimeMillis());
iud.setId(time);
iud.setVersion(Version.createOSGi(0, 0, 0, time));
ArrayList<IRequirement> requirements = new ArrayList<>();
VersionRange range = new VersionRange("[1.2.3,1.2.4)");
requirements.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "this.is.a.missing.iu", range, null, 1, /* min */
1, /* max */
true));
iud.setRequirements(requirements.toArray(new IRequirement[requirements.size()]));
HashSet<IInstallableUnit> rootUIs = new HashSet<>();
rootUIs.add(MetadataFactory.createInstallableUnit(iud));
ResolutionDataImpl data = new ResolutionDataImpl(ExecutionEnvironmentTestUtils.NOOP_EE_RESOLUTION_HINTS);
data.setRootIUs(rootUIs);
data.setAdditionalRequirements(new ArrayList<IRequirement>());
data.setAvailableIUs(Collections.<IInstallableUnit>emptyList());
DependencyCollector dc = new DependencyCollector(logVerifier.getLogger());
dc.setData(data);
try {
dc.resolve(Collections.<String, String>emptyMap(), new NullProgressMonitor());
Assert.fail();
} catch (RuntimeException e) {
Throwable cause = e.getCause();
Assert.assertTrue(cause instanceof ProvisionException);
ProvisionException pe = (ProvisionException) cause;
Assert.assertTrue(pe.getStatus().isMultiStatus());
MultiStatus status = (MultiStatus) pe.getStatus();
Assert.assertEquals(1, status.getChildren().length);
Assert.assertTrue(e.toString().contains("this.is.a.missing.iu"));
}
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.
the class ProjectorResolutionStrategyTest method testFixSwtWithNLSFragmentPresent.
@Test
public void testFixSwtWithNLSFragmentPresent() throws Exception {
selectedIUs.add(InstallableUnitUtil.createIU("org.eclipse.swt", "1.0.0"));
IInstallableUnit swtImplFragment = createSwtFragment("linux", "gtk", "x86_64", null);
IInstallableUnit swtNLSFragment = createSwtFragment("linux", "gtk", "x86_64", "de");
final List<IInstallableUnit> availableIUs = new ArrayList<>();
availableIUs.addAll(selectedIUs);
availableIUs.add(swtNLSFragment);
availableIUs.add(swtImplFragment);
strategy.fixSWT(availableIUs, selectedIUs, createSelectionContext("linux", "gtk", "x86_64"), monitor);
assertThat(selectedIUs.size(), is(2));
assertThat(selectedIUs, hasItem(swtImplFragment));
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.
the class ProjectorResolutionStrategyTest method testFixSwtSwtFragmentInRootIUs.
@Test
public void testFixSwtSwtFragmentInRootIUs() throws Exception {
IInstallableUnit rootIU = createSwtFragment("linux", "gtk", "x86_64", null);
selectedIUs.add(InstallableUnitUtil.createIU("org.eclipse.swt", "1.0.0"));
invokefixSwtWithLinuxFragmentPresent(rootIU, selectedIUs);
assertThat(selectedIUs.size(), is(1));
assertThat(selectedIUs, hasItem(InstallableUnitUtil.createIU("org.eclipse.swt", "1.0.0")));
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.
the class ProjectorResolutionStrategyTest method invokefixSwtWithLinuxFragmentPresent.
private void invokefixSwtWithLinuxFragmentPresent(IInstallableUnit rootIU, final List<IInstallableUnit> selectedIUs) {
data.setRootIUs(Collections.singleton(rootIU));
final List<IInstallableUnit> availableIUs = new ArrayList<>();
IInstallableUnit swtImplFragment = createSwtFragment("linux", "gtk", "x86_64", null);
availableIUs.addAll(selectedIUs);
availableIUs.add(swtImplFragment);
strategy.fixSWT(availableIUs, selectedIUs, createSelectionContext("linux", "gtk", "x86_64"), monitor);
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.
the class ProjectorResolutionStrategyTest method createSwtFragment.
private IInstallableUnit createSwtFragment(String os, String ws, String arch, String nls) {
Map<String, String> capsMap = new HashMap<>();
capsMap.put("osgi.fragment", "org.eclipse.swt");
if (nls == null) {
// NLS fragments do not provide packages
capsMap.put("java.package", "foo");
}
String iuSuffix;
iuSuffix = os + "." + ws + "." + arch;
if (nls != null) {
iuSuffix += "." + nls;
}
IInstallableUnit linuxSwtFragment = InstallableUnitUtil.createIUWithCapabilitiesAndFilter("org.eclipse.swt." + iuSuffix, "1.0.0", createCapabilities(capsMap), "(&(osgi.arch=" + arch + ")(osgi.os=" + os + ")(osgi.ws=" + ws + "))");
return linuxSwtFragment;
}
Aggregations