1 package org.apache.maven.surefire.its;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.surefire.its.fixture.OutputValidator;
23 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
24 import org.apache.maven.surefire.its.fixture.SurefireLauncher;
25 import org.junit.Test;
26
27 import java.io.File;
28 import java.io.IOException;
29
30 import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
31 import static org.fest.assertions.Assertions.assertThat;
32 import static org.hamcrest.CoreMatchers.containsString;
33 import static org.hamcrest.CoreMatchers.is;
34 import static org.junit.Assume.assumeTrue;
35
36
37
38
39
40
41
42
43
44 public class LongWindowsPathIT
45 extends SurefireJUnit4IntegrationTestCase
46 {
47 private static final String PROJECT_DIR = "long-windows-path";
48 private static final String LONG_PATH = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
49
50
51 private static final String LONG_DIR = LONG_PATH + LONG_PATH + LONG_PATH;
52
53 @Test
54 public void shouldRunInSystemTmp() throws Exception
55 {
56 assumeTrue( IS_OS_WINDOWS );
57
58 OutputValidator validator = unpack().setForkJvm()
59 .showErrorStackTraces()
60 .executeTest()
61 .verifyErrorFreeLog();
62
63 validator.assertThatLogLine( containsString( "SUREFIRE-1400 user.dir=" ), is( 1 ) )
64 .assertThatLogLine( containsString( "SUREFIRE-1400 surefire.real.class.path=" ), is( 1 ) );
65
66 for ( String line : validator.loadLogLines() )
67 {
68 if ( line.contains( "SUREFIRE-1400 user.dir=" ) )
69 {
70 File buildDir = new File( System.getProperty( "user.dir" ), "target" );
71 File itBaseDir = new File( buildDir, "LongWindowsPathIT_shouldRunInSystemTmp" );
72
73 assertThat( line )
74 .contains( itBaseDir.getAbsolutePath() );
75 }
76 else if ( line.contains( "SUREFIRE-1400 surefire.real.class.path=" ) )
77 {
78 assertThat( line )
79 .contains( System.getProperty( "java.io.tmpdir" ) );
80 }
81 }
82 }
83
84 private SurefireLauncher unpack() throws IOException
85 {
86 return unpack( PROJECT_DIR );
87 }
88 }