From 89ab234a24ead978b2514c16e1e7f3fa31e22699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Tue, 5 Apr 2022 15:29:59 +0200 Subject: [PATCH] Reproducer for #845 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christoph Läubrich --- .../repository/artifacts.xml | 4 + .../repository/content.xml | 118 ++++++++++++++++++ .../sample.feature/build.properties | 1 + .../sample.feature/feature.xml | 10 ++ .../sample.feature/pom.xml | 34 +++++ .../feature/FeatureWithRestrictionsTest.java | 51 ++++++++ 6 files changed, 218 insertions(+) create mode 100644 tycho-its/projects/feature.restrictions/repository/artifacts.xml create mode 100644 tycho-its/projects/feature.restrictions/repository/content.xml create mode 100644 tycho-its/projects/feature.restrictions/sample.feature/build.properties create mode 100644 tycho-its/projects/feature.restrictions/sample.feature/feature.xml create mode 100644 tycho-its/projects/feature.restrictions/sample.feature/pom.xml create mode 100644 tycho-its/src/test/java/org/eclipse/tycho/test/feature/FeatureWithRestrictionsTest.java diff --git a/tycho-its/projects/feature.restrictions/repository/artifacts.xml b/tycho-its/projects/feature.restrictions/repository/artifacts.xml new file mode 100644 index 0000000000..ee8ae96723 --- /dev/null +++ b/tycho-its/projects/feature.restrictions/repository/artifacts.xml @@ -0,0 +1,4 @@ + + + + diff --git a/tycho-its/projects/feature.restrictions/repository/content.xml b/tycho-its/projects/feature.restrictions/repository/content.xml new file mode 100644 index 0000000000..96f6bace25 --- /dev/null +++ b/tycho-its/projects/feature.restrictions/repository/content.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Bundle-SymbolicName: org.apache.activemq.activemq-core Bundle-Version: 5.2.0 + + + + + + + + + + + + + + + + + (org.eclipse.update.install.features=true) + + + + + + + + + + + + + + + + + + (org.eclipse.update.install.features=true) + + + + + + + + + + + + + (org.eclipse.update.install.features=true) + + + + + + + + + true + + + + + + + + + + + + (org.eclipse.update.install.features=true) + + + + + + + + + true + + + + + + diff --git a/tycho-its/projects/feature.restrictions/sample.feature/build.properties b/tycho-its/projects/feature.restrictions/sample.feature/build.properties new file mode 100644 index 0000000000..64f93a9f0b --- /dev/null +++ b/tycho-its/projects/feature.restrictions/sample.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/tycho-its/projects/feature.restrictions/sample.feature/feature.xml b/tycho-its/projects/feature.restrictions/sample.feature/feature.xml new file mode 100644 index 0000000000..edd7e0c961 --- /dev/null +++ b/tycho-its/projects/feature.restrictions/sample.feature/feature.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/tycho-its/projects/feature.restrictions/sample.feature/pom.xml b/tycho-its/projects/feature.restrictions/sample.feature/pom.xml new file mode 100644 index 0000000000..6d127df6af --- /dev/null +++ b/tycho-its/projects/feature.restrictions/sample.feature/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + com.test + 1.0.0 + com.test.sample.feature + eclipse-feature + + 2.7.0 + file:/${project.basedir}/../repository + + + + + featureRepo + p2 + ${repo-url} + + + + + + + org.eclipse.tycho + tycho-maven-plugin + ${tycho-version} + true + + + + diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/feature/FeatureWithRestrictionsTest.java b/tycho-its/src/test/java/org/eclipse/tycho/test/feature/FeatureWithRestrictionsTest.java new file mode 100644 index 0000000000..c19ec347d9 --- /dev/null +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/feature/FeatureWithRestrictionsTest.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2022 Christoph Läubrich and others. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christoph Läubrich - initial API and implementation + *******************************************************************************/ +package org.eclipse.tycho.test.feature; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.util.List; +import java.util.Optional; + +import org.apache.maven.it.Verifier; +import org.eclipse.tycho.test.AbstractTychoIntegrationTest; +import org.eclipse.tycho.test.util.ResourceUtil; +import org.junit.Test; + +import de.pdark.decentxml.Document; +import de.pdark.decentxml.Element; +import de.pdark.decentxml.XMLParser; + +public class FeatureWithRestrictionsTest extends AbstractTychoIntegrationTest { + + @Test + public void testFeatureRestriction() throws Exception { + Verifier verifier = getVerifier("feature.restrictions/sample.feature", false, true); + verifier.setSystemProperty("repo-url", "file:" + + ResourceUtil.resolveTestResource("projects/feature.restrictions/repository").getAbsolutePath()); + verifier.executeGoals(List.of("clean", "package")); + verifier.verifyErrorFreeLog(); + File contentXml = new File(verifier.getBasedir(), "target/p2content.xml"); + Document artifactsDocument = XMLParser.parse(contentXml); + String unitId = "com.test.sample.feature.feature.group"; + Optional unit = artifactsDocument.getChild("units").getChildren("unit").stream().filter(elem -> { + return unitId.equals(elem.getAttributeValue("id")); + }).findFirst(); + assertTrue("Unit with id " + unitId + " not found", unit.isPresent()); + assertFalse("Version 2 was required by unit", + unit.stream().flatMap(elem -> elem.getChild("requires").getChildren("required").stream()) + .anyMatch(elem -> "[2.0.0,2.0.0]".equals(elem.getAttributeValue("range")))); + } +}