From 186ad813762e415139806774e01a0a9cfb9b3a6b Mon Sep 17 00:00:00 2001 From: nsingh Date: Thu, 22 Feb 2018 12:06:53 -0800 Subject: [PATCH] Fixed failing test case in Windows --- .../boot/java/utils/test/VSCodeSourceLinksTest.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/headless-services/commons/commons-boot/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/VSCodeSourceLinksTest.java b/headless-services/commons/commons-boot/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/VSCodeSourceLinksTest.java index 7a1d4c0bf..3c6b5db88 100644 --- a/headless-services/commons/commons-boot/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/VSCodeSourceLinksTest.java +++ b/headless-services/commons/commons-boot/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/VSCodeSourceLinksTest.java @@ -13,7 +13,8 @@ package org.springframework.ide.vscode.boot.java.utils.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import java.net.URL; +import java.io.File; +import java.net.URI; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Optional; @@ -53,7 +54,12 @@ public class VSCodeSourceLinksTest { Optional url = new VSCodeSourceLinks(null).sourceLinkUrlForFQName(project, "com.example.EmptyBoot15WebAppApplication"); assertTrue(url.isPresent()); Path projectPath = Paths.get(project.pom().getParent()); - Path relativePath = projectPath.relativize(Paths.get(new URL(url.get()).getPath())); + URI uri = URI.create(url.get()); + + // Use File to get rid of the fragment parts of the URL. The URL may have fragments that indicate line and column numbers + uri = new File(uri.getPath()).toURI(); + + Path relativePath = projectPath.relativize(Paths.get(uri)); assertEquals(Paths.get("src/main/java/com/example/EmptyBoot15WebAppApplication.java"), relativePath); String positionPart = url.get().substring(url.get().lastIndexOf('#')); assertEquals("#7,14", positionPart);