use of org.eclipse.tycho.p2.impl.test.ArtifactMock in project tycho by eclipse.
the class P2ResolverTest method testSourceBundle.
@Test
public void testSourceBundle() throws Exception {
String featureId = "org.eclipse.tycho.p2.impl.resolver.test.feature01";
projectToResolve = createReactorProject(resourceFile("sourcebundles/feature01"), TYPE_ECLIPSE_FEATURE, featureId);
File bundle = resourceFile("sourcebundles/bundle01");
String bundleId = "org.eclipse.tycho.p2.impl.resolver.test.bundle01";
String bundleVersion = "1.0.0-SNAPSHOT";
reactorProjects.add(createReactorProject(bundle, TYPE_ECLIPSE_PLUGIN, bundleId));
ReactorProjectStub sb = new ReactorProjectStub(bundle, bundleId, bundleId, bundleVersion, TYPE_ECLIPSE_PLUGIN);
DependencyMetadata metadata = new SourcesBundleDependencyMetadataGenerator().generateMetadata(new ArtifactMock(sb, "source"), getEnvironments(), null);
sb.setDependencyMetadata(metadata);
reactorProjects.add(sb);
result = singleEnv(impl.resolveDependencies(getTargetPlatform(), projectToResolve));
assertEquals(3, result.getArtifacts().size());
List<P2ResolutionResult.Entry> entries = new ArrayList<>(result.getArtifacts());
Collections.sort(entries, new Comparator<Entry>() {
@Override
public int compare(Entry entry1, Entry entry2) {
return entry1.getId().compareTo(entry2.getId());
}
});
assertEquals("org.eclipse.tycho.p2.impl.resolver.test.bundle01", entries.get(0).getId());
assertEquals("org.eclipse.tycho.p2.impl.resolver.test.bundle01.source", entries.get(1).getId());
assertEquals("org.eclipse.tycho.p2.impl.resolver.test.feature01", entries.get(2).getId());
assertEquals(bundle, entries.get(0).getLocation());
assertEquals(bundle, entries.get(1).getLocation());
assertEquals("sources", entries.get(1).getClassifier());
}
use of org.eclipse.tycho.p2.impl.test.ArtifactMock in project tycho by eclipse.
the class P2ResolverTestBase method addContextProject.
protected final void addContextProject(File projectRoot, String packaging) throws IOException {
ArtifactMock artifact = new ArtifactMock(projectRoot.getAbsoluteFile(), DEFAULT_GROUP_ID, projectRoot.getName(), DEFAULT_VERSION, packaging);
DependencyMetadata metadata = fullGenerator.generateMetadata(artifact, getEnvironments());
pomDependencies.addMavenArtifact(artifact, metadata.getInstallableUnits());
}
use of org.eclipse.tycho.p2.impl.test.ArtifactMock in project tycho by eclipse.
the class P2GeneratorImplTest method testOptionalImportPackage_REQUIRE.
@Test
public void testOptionalImportPackage_REQUIRE() throws Exception {
DefaultDependencyMetadataGenerator generator = createDependencyMetadataGenerator();
File location = new File("resources/generator/optional-import-package").getCanonicalFile();
ArtifactMock artifactMock = new ArtifactMock(location, "optional-import-package", "optional-import-package", "0.0.1", "eclipse-plugin");
Set<Object> units = generator.generateMetadata(artifactMock, getEnvironments(), OptionalResolutionAction.REQUIRE).getMetadata();
assertEquals(1, units.size());
IInstallableUnit iu = getUnit("optional-import-package", units);
assertNotNull(iu);
List<IRequirement> requirements = new ArrayList<>(iu.getRequirements());
assertEquals(1, requirements.size());
IRequiredCapability requirement = (IRequiredCapability) requirements.get(0);
assertTrue(requirement.isGreedy());
assertEquals(1, requirement.getMin());
assertEquals(1, requirement.getMax());
assertEquals(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, requirement.getNamespace());
assertEquals("org.osgi.framework", requirement.getName());
}
use of org.eclipse.tycho.p2.impl.test.ArtifactMock in project tycho by eclipse.
the class FeatureRootAdviceTest method testGetProjectBaseDir.
@Test
public void testGetProjectBaseDir() throws Exception {
ArtifactMock defaultArtifactMock = createDefaultArtifactMock();
assertEquals(FEATURE_PROJECT_TEST_RESOURCE_ROOT.getCanonicalFile(), FeatureRootAdvice.getProjectBaseDir(defaultArtifactMock).getCanonicalFile());
// null checks
ArtifactMock wrongTypeArtifactMock = new ArtifactMock(new File(FEATURE_JAR_REL_PATH).getCanonicalFile(), GROUP_ID, ARTIFACT_ID, VERSION, "eclipse-plugin");
assertNull(FeatureRootAdvice.getProjectBaseDir(wrongTypeArtifactMock));
ArtifactMock invalidLocationArtifactMock = new ArtifactMock(new File("resources/rootfiles/feature-project/target/feature.jar").getCanonicalFile(), GROUP_ID, ARTIFACT_ID, VERSION, PACKAGING_TYPE);
assertNull(FeatureRootAdvice.getProjectBaseDir(invalidLocationArtifactMock));
ArtifactMock invalidRelativeLocationArtifactMock = new ArtifactMock(new File(FEATURE_JAR_REL_PATH), GROUP_ID, ARTIFACT_ID, VERSION, PACKAGING_TYPE);
assertNull(FeatureRootAdvice.getProjectBaseDir(invalidRelativeLocationArtifactMock));
}
use of org.eclipse.tycho.p2.impl.test.ArtifactMock in project tycho by eclipse.
the class TargetPlatformBundlePublisherTest method testPomDependencyOnOtherType.
@Test
public void testPomDependencyOnOtherType() throws Exception {
File otherFile = resourceFile("platformbuilder/pom-dependencies/other-type.xml");
IArtifactFacade otherArtifact = new ArtifactMock(otherFile, GROUP_ID, ARTIFACT_ID, VERSION, "pom");
IInstallableUnit unit = subject.attemptToPublishBundle(otherArtifact);
assertNull(unit);
}
Aggregations