1 package org.apache.maven.project.path;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23
24 import junit.framework.TestCase;
25
26 @SuppressWarnings( "deprecation" )
27 public class DefaultPathTranslatorTest
28 extends TestCase
29 {
30
31 public void testAlignToBasedirWhereBasedirExpressionIsTheCompleteValue()
32 {
33 File basedir = new File( System.getProperty( "java.io.tmpdir" ), "test" ).getAbsoluteFile();
34
35 String aligned = new DefaultPathTranslator().alignToBaseDirectory( "${basedir}", basedir );
36
37 assertEquals( basedir.getAbsolutePath(), aligned );
38 }
39
40 public void testAlignToBasedirWhereBasedirExpressionIsTheValuePrefix()
41 {
42 File basedir = new File( System.getProperty( "java.io.tmpdir" ), "test" ).getAbsoluteFile();
43
44 String aligned = new DefaultPathTranslator().alignToBaseDirectory( "${basedir}/dir", basedir );
45
46 assertEquals( new File( basedir, "dir" ).getAbsolutePath(), aligned );
47 }
48
49 public void testUnalignToBasedirWherePathEqualsBasedir()
50 {
51 File basedir = new File( System.getProperty( "java.io.tmpdir" ), "test" ).getAbsoluteFile();
52
53 String unaligned = new DefaultPathTranslator().unalignFromBaseDirectory( basedir.getAbsolutePath(), basedir );
54
55 assertEquals( ".", unaligned );
56 }
57
58 }