Skip to content

Commit 08f1c7c

Browse files
committed
Fix failing tests for the M2E-PDE connector console printout handler
and clean-up ConsoleTest. The 'ConsoleTest.testConsole_debuggerAttachmentAndLinkAlignmentAndBehavior_tychoProject' failed because the test-case used the out-dated Tycho version 3.0.0, which seems to have a dependency that pulls in Apache's 'commons-parent' version 35 that is considered as invalid by recent Maven versions: org\apache\commons\commons-parent\35\commons-parent-35.pom: UTF-8 BOM plus xml decl of ISO-8859-1 is incompatible (position: START_DOCUMENT seen <?xml version="1.0" encoding="ISO-8859-1"... @1:42)
1 parent fc87858 commit 08f1c7c

File tree

4 files changed

+20
-36
lines changed

4 files changed

+20
-36
lines changed

org.eclipse.m2e.core.ui.tests/resources/projects/simple-tycho/.mvn/extensions.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<extension>
33
<groupId>org.eclipse.tycho</groupId>
44
<artifactId>tycho-build</artifactId>
5-
<version>3.0.0</version>
5+
<version>4.0.8</version>
66
</extension>
77
</extensions>

org.eclipse.m2e.core.ui.tests/resources/projects/simple-tycho/pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<packaging>pom</packaging>
1010

1111
<properties>
12-
<tycho.version>3.0.0</tycho.version>
12+
<tycho.version>4.0.8</tycho.version>
1313
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1414
</properties>
1515

@@ -37,18 +37,18 @@
3737
<version>${tycho.version}</version>
3838
<configuration>
3939
<target>
40-
<artifact>
41-
<groupId>org.eclipse.m2e.tests</groupId>
42-
<artifactId>simple.target</artifactId>
43-
<version>1.0.0-SNAPSHOT</version>
44-
</artifact>
40+
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
41+
<repository location="https://download.eclipse.org/eclipse/updates/4.32/"/>
42+
<unit id="org.eclipse.equinox.launcher" version="0.0.0"/>
43+
<unit id="org.eclipse.core.runtime" version="0.0.0"/>
44+
<unit id="org.junit" version="0.0.0"/>
45+
</location>
4546
</target>
4647
</configuration>
4748
</plugin>
4849
</plugins>
4950
</build>
5051
<modules>
51-
<module>simple.target</module>
5252
<module>simple.tests</module>
5353
</modules>
5454
</project>

org.eclipse.m2e.core.ui.tests/resources/projects/simple-tycho/simple.target/simple.target.target

Lines changed: 0 additions & 13 deletions
This file was deleted.

org.eclipse.m2e.core.ui.tests/src/org/eclipse/m2e/core/ui/tests/ConsoleTest.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
import java.io.File;
3131
import java.io.IOException;
32-
import java.io.InputStream;
3332
import java.net.URISyntaxException;
3433
import java.net.URL;
3534
import java.nio.file.Files;
@@ -52,6 +51,7 @@
5251
import org.eclipse.core.resources.ResourcesPlugin;
5352
import org.eclipse.core.runtime.CoreException;
5453
import org.eclipse.core.runtime.FileLocator;
54+
import org.eclipse.core.runtime.IPath;
5555
import org.eclipse.core.runtime.NullProgressMonitor;
5656
import org.eclipse.debug.core.DebugPlugin;
5757
import org.eclipse.debug.core.ILaunch;
@@ -178,7 +178,7 @@ public void testConsole_debuggerAttachmentAndLinkAlignmentAndBehavior_tychoProje
178178
assertLinkTextAndOpenedEditor(0, "org.eclipse.m2e.tests:" + TYCHO_TEST_PROJECT, //
179179
ManifestEditor.class, TYCHO_TEST_PROJECT, document);
180180

181-
assertLinkTextAndOpenedEditor(3, TYCHO_TEST_PROJECT, //
181+
assertLinkTextAndOpenedEditor(-2, TYCHO_TEST_PROJECT, //
182182
ManifestEditor.class, TYCHO_TEST_PROJECT, document);
183183

184184
assertDebugeePrintOutAndDebuggerLaunch(document, TYCHO_TEST_PROJECT, "8000");
@@ -188,7 +188,8 @@ private void assertLinkTextAndOpenedEditor(int index, String expectedLinkText, C
188188
String expectedEditorTitle, IDocument document) throws Exception {
189189

190190
Position[] positions = document.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY);
191-
ConsoleHyperlinkPosition link = (ConsoleHyperlinkPosition) positions[index];
191+
int i = index < 0 ? positions.length + index : index;
192+
ConsoleHyperlinkPosition link = (ConsoleHyperlinkPosition) positions[i];
192193

193194
assertEquals(expectedLinkText, document.get(link.getOffset(), link.getLength()));
194195

@@ -218,10 +219,11 @@ private static void assertDebugeePrintOutAndDebuggerLaunch(IDocument document, S
218219
.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""));
219220
assertEquals(ILaunchManager.DEBUG_MODE, debugLaunch.getLaunchMode());
220221
long startTime = System.currentTimeMillis();
221-
while (!debugLaunch.isTerminated() && System.currentTimeMillis() - startTime < 10000 ) {
222+
while (!debugLaunch.isTerminated() && System.currentTimeMillis() - startTime < 10000) {
222223
Thread.onSpinWait();
223224
}
224-
assertTrue("Debug launch " + debugLaunch.getLaunchConfiguration().getName() + " is not terminated yet after waiting for 10 seconds", debugLaunch.isTerminated());
225+
assertTrue("Debug launch " + debugLaunch.getLaunchConfiguration().getName()
226+
+ " is not terminated yet after waiting for 10 seconds", debugLaunch.isTerminated());
225227
}
226228

227229
// --- common utility methods ---
@@ -251,11 +253,9 @@ private static Path importProjectIntoWorkspace(String containerPath, String test
251253

252254
Path tempProjectFolder = copyTestProjectIntoWorkspace(containerPath);
253255
Path projectPath = tempProjectFolder.resolve(testProjectName);
254-
try (InputStream input = Files.newInputStream(projectPath.resolve(".project"))) {
255-
IProjectDescription description = workspace.loadProjectDescription(input);
256-
description.setLocationURI(projectPath.toUri());
257-
project.create(description, null);
258-
}
256+
IPath projectFile = IPath.fromPath(projectPath.resolve(".project"));
257+
IProjectDescription description = workspace.loadProjectDescription(projectFile);
258+
project.create(description, null);
259259
project.open(monitor);
260260
// build project to make it available in the PluginRegistryManager
261261
project.refreshLocal(IResource.DEPTH_INFINITE, null);
@@ -265,7 +265,6 @@ private static Path importProjectIntoWorkspace(String containerPath, String test
265265
return Path.of(project.getLocationURI()).getParent();
266266
}
267267

268-
269268
private static Path copyTestProjectIntoWorkspace(String projectName) throws IOException, URISyntaxException {
270269
String projectPath = "/resources/projects/" + projectName;
271270
// import project into workspace, the super class cleans up after each test
@@ -335,12 +334,10 @@ public void documentAboutToBeChanged(DocumentEvent event) { // ignore
335334
}
336335

337336
private static boolean isBuildFinished(String text) {
338-
return lines(text)
339-
.anyMatch(l -> l.startsWith("[INFO] Finished at: ")
340-
|| l.startsWith("[\u001B[1;34mINFO\u001B[m] Finished at: "));
337+
return lines(text).anyMatch(
338+
l -> l.startsWith("[INFO] Finished at: ") || l.startsWith("[\u001B[1;34mINFO\u001B[m] Finished at: "));
341339
}
342340

343-
344341
private static final Pattern LINE_SEPARATOR = Pattern.compile("\\R");
345342

346343
private static Stream<String> lines(String consoleText) {

0 commit comments

Comments
 (0)