From be5def62257b64e1c7ce9d722dfdf73e887a3b3d Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Wed, 16 Mar 2011 13:01:32 +0300 Subject: SONAR-2280 ProjectFileSystem.resolvePath should return canonical file --- .../resources/DefaultProjectFileSystemTest.java | 28 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'sonar-plugin-api/src/test/java') diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/DefaultProjectFileSystemTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/DefaultProjectFileSystemTest.java index a32c84bc3dd..72e88d2979e 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/DefaultProjectFileSystemTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/DefaultProjectFileSystemTest.java @@ -19,8 +19,17 @@ */ package org.sonar.api.resources; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.endsWith; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.SystemUtils; +import org.apache.maven.project.MavenProject; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeMatcher; @@ -32,11 +41,6 @@ import org.sonar.api.test.MavenTestUtils; import java.io.File; import java.util.List; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; - public class DefaultProjectFileSystemTest { private Project project = null; @@ -143,6 +147,20 @@ public class DefaultProjectFileSystemTest { assertThat(files.size(), is(2)); } + /** + * See http://jira.codehaus.org/browse/SONAR-2280 + */ + @Test + public void resolvePathShouldReturnCanonicalFile() { + MavenProject pom = mock(MavenProject.class); + when(pom.getBasedir()).thenReturn(new File("/project")); + Project project = new Project("").setPom(pom); + DefaultProjectFileSystem fs = new DefaultProjectFileSystem(project, null); + + assertThat(fs.resolvePath(".").getAbsolutePath(), endsWith("project")); + assertThat(fs.resolvePath("../project").getAbsolutePath(), endsWith("project")); + } + /** * Example of hidden files/directories : .DSStore, .svn, .git */ -- cgit v1.2.3