Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2018-12-06 06:13:36 -0500
committerMickael Istria2019-01-03 11:52:43 -0500
commita6ab14c73b11940914023aa8ef287d68f7999cbe (patch)
tree4643b8bedee8e0ce100913c7e45a028f076cc340
parent445d44156617ca5dca6db808bc432ddf964d7e11 (diff)
downloadm2e-core-a6ab14c73b11940914023aa8ef287d68f7999cbe.tar.gz
m2e-core-a6ab14c73b11940914023aa8ef287d68f7999cbe.tar.xz
m2e-core-a6ab14c73b11940914023aa8ef287d68f7999cbe.zip
Test for MNG-6530
Maven 3.6.x introduce a severe regression, discussed in MNG-6530. This tests checks whether m2e is affected by the regression (and it is) and will help to adopt a newer Maven version making sure the upstream bug doesn't cascade to m2e. Change-Id: Id19d7c41d5cf158d1766ada5abd4a623c22af02d Signed-off-by: Mickael Istria <mistria@redhat.com>
-rw-r--r--org.eclipse.m2e.core.tests/META-INF/MANIFEST.MF16
-rw-r--r--org.eclipse.m2e.core.tests/build.properties6
-rw-r--r--org.eclipse.m2e.core.tests/plugin.properties2
-rw-r--r--org.eclipse.m2e.core.tests/pom.xml40
-rw-r--r--org.eclipse.m2e.core.tests/resources/projects/testMNG6530/child/pom.xml20
-rw-r--r--org.eclipse.m2e.core.tests/resources/projects/testMNG6530/pom.xml23
-rw-r--r--org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/tests/MavenBugsTest.java72
-rw-r--r--pom.xml1
8 files changed, 180 insertions, 0 deletions
diff --git a/org.eclipse.m2e.core.tests/META-INF/MANIFEST.MF b/org.eclipse.m2e.core.tests/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..ea3e9074
--- /dev/null
+++ b/org.eclipse.m2e.core.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.eclipse.m2e.core.tests
+Bundle-Version: 1.10.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-Vendor: %Bundle-Vendor
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.m2e.core;bundle-version="[1.10.0,1.11.0)",
+ org.eclipse.m2e.tests.common;bundle-version="[1.10.0,1.11.0)",
+ org.junit;bundle-version="4.12.0",
+ org.eclipse.core.resources,
+ org.eclipse.core.runtime,
+ org.eclipse.m2e.maven.runtime;bundle-version="1.10.0",
+ javax.annotation;bundle-version="1.2.0"
+Eclipse-BundleShape: dir
diff --git a/org.eclipse.m2e.core.tests/build.properties b/org.eclipse.m2e.core.tests/build.properties
new file mode 100644
index 00000000..7d75703d
--- /dev/null
+++ b/org.eclipse.m2e.core.tests/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ plugin.properties,\
+ resources/,\
+ .
diff --git a/org.eclipse.m2e.core.tests/plugin.properties b/org.eclipse.m2e.core.tests/plugin.properties
new file mode 100644
index 00000000..c56fb146
--- /dev/null
+++ b/org.eclipse.m2e.core.tests/plugin.properties
@@ -0,0 +1,2 @@
+Bundle-Vendor = Eclipse.org - m2e
+Bundle-Name = Tests for m2e extension for m2e core \ No newline at end of file
diff --git a/org.eclipse.m2e.core.tests/pom.xml b/org.eclipse.m2e.core.tests/pom.xml
new file mode 100644
index 00000000..5756cf2c
--- /dev/null
+++ b/org.eclipse.m2e.core.tests/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (c) 2018 Red Hat Inc. and others
+
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
+ Mickael Istria (Red Hat Inc.) - Initial implementation
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>m2e-core</artifactId>
+ <version>1.10.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.eclipse.m2e.core.tests</artifactId>
+ <packaging>eclipse-test-plugin</packaging>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-surefire-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <useUIHarness>false</useUIHarness>
+ <useUIThread>false</useUIThread>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
diff --git a/org.eclipse.m2e.core.tests/resources/projects/testMNG6530/child/pom.xml b/org.eclipse.m2e.core.tests/resources/projects/testMNG6530/child/pom.xml
new file mode 100644
index 00000000..71d95f11
--- /dev/null
+++ b/org.eclipse.m2e.core.tests/resources/projects/testMNG6530/child/pom.xml
@@ -0,0 +1,20 @@
+<!-- Copyright (c) 2016 Red Hat Inc. and others
+
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
+ Mickael Istria (Red Hat Inc.) - Initial implementation
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.eclipse.m2e.tests.example1</groupId>
+ <artifactId>testMNG6530</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>child</artifactId>
+ <packaging>pom</packaging>
+</project> \ No newline at end of file
diff --git a/org.eclipse.m2e.core.tests/resources/projects/testMNG6530/pom.xml b/org.eclipse.m2e.core.tests/resources/projects/testMNG6530/pom.xml
new file mode 100644
index 00000000..3fa1653d
--- /dev/null
+++ b/org.eclipse.m2e.core.tests/resources/projects/testMNG6530/pom.xml
@@ -0,0 +1,23 @@
+<!-- Copyright (c) 2016 Red Hat Inc. and others
+
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
+ Mickael Istria (Red Hat Inc.) - Initial implementation
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.eclipse.m2e.tests.example1</groupId>
+ <artifactId>testMNG6530</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <modules>
+ <module>child</module>
+ </modules>
+ <properties>
+ <foo>bar</foo>
+ </properties>
+</project> \ No newline at end of file
diff --git a/org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/tests/MavenBugsTest.java b/org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/tests/MavenBugsTest.java
new file mode 100644
index 00000000..af121f17
--- /dev/null
+++ b/org.eclipse.m2e.core.tests/src/org/eclipse/m2e/core/tests/MavenBugsTest.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Red Hat Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.m2e.core.tests;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.utils.io.FileUtils;
+import org.apache.maven.shared.utils.io.IOUtil;
+
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.m2e.core.project.MavenProjectInfo;
+import org.eclipse.m2e.core.project.ProjectImportConfiguration;
+import org.eclipse.m2e.tests.common.JobHelpers;
+
+
+public class MavenBugsTest {
+
+ @Test
+ public void testMNG6530() throws Exception {
+ File sourceDirectory = new File(
+ FileLocator.toFileURL(getClass().getResource("/resources/projects/testMNG6530")).toURI());
+ File tempDirectory = Files.createTempDirectory(getClass().getSimpleName()).toFile();
+ try {
+ FileUtils.copyDirectoryStructure(sourceDirectory, tempDirectory);
+ List<MavenProjectInfo> toImport = new ArrayList<>(2);
+ toImport.add(new MavenProjectInfo("", new File(tempDirectory, "pom.xml"), null, null));
+ toImport.add(new MavenProjectInfo("", new File(tempDirectory, "child/pom.xml"), null, null));
+ MavenPlugin.getProjectConfigurationManager().importProjects(toImport, new ProjectImportConfiguration(), null,
+ new NullProgressMonitor());
+ JobHelpers.waitForJobsToComplete();
+
+ IProject parent = ResourcesPlugin.getWorkspace().getRoot().getProject("testMNG6530");
+ IProject child = ResourcesPlugin.getWorkspace().getRoot().getProject("child");
+ try {
+ IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().getProject(child);
+ MavenProject mavenProject = facade.getMavenProject(new NullProgressMonitor());
+ assertEquals("bar", mavenProject.getProperties().get("foo"));
+ String content = IOUtil.toString(parent.getFile("pom.xml").getContents()).replaceAll("bar", "lol");
+ parent.getFile("pom.xml").setContents(new ByteArrayInputStream(content.getBytes()), true, false, null);
+ JobHelpers.waitForJobsToComplete(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=542461
+ mavenProject = facade.getMavenProject(new NullProgressMonitor());
+ assertEquals("lol", mavenProject.getProperties().get("foo"));
+ } finally {
+ parent.delete(true, null);
+ child.delete(true, null);
+ }
+ } finally {
+ FileUtils.deleteDirectory(tempDirectory);
+ }
+ }
+}
diff --git a/pom.xml b/pom.xml
index f446c319..7f739ee3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -130,6 +130,7 @@
<module>org.eclipse.m2e.site</module>
<!-- testing -->
+ <module>org.eclipse.m2e.core.tests</module>
<module>org.eclipse.m2e.importer.tests</module>
<module>org.eclipse.m2e.binaryproject.tests</module>
</modules>

Back to the top