1 package org.apache.maven.resolver.internal.ant;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import static org.hamcrest.MatcherAssert.*;
23 import static org.hamcrest.Matchers.*;
24
25 import java.io.File;
26 import java.io.IOException;
27
28 import junit.framework.JUnit4TestAdapter;
29 import org.junit.Test;
30
31 public class SettingsTest
32 extends AntBuildsTest
33 {
34 public static junit.framework.Test suite()
35 {
36 return new JUnit4TestAdapter( SettingsTest.class );
37 }
38
39 @Test
40 public void testUserSettings()
41 {
42 executeTarget( "testUserSettings" );
43 assertThat( "user settings not set", AntRepoSys.getInstance( getProject() ).getUserSettings().getName(),
44 equalTo( "userSettings.xml" ) );
45 }
46
47 @Test
48 public void testGlobalSettings()
49 {
50 executeTarget( "testGlobalSettings" );
51 assertThat( "global settings not set", AntRepoSys.getInstance( getProject() ).getGlobalSettings().getName(),
52 equalTo( "globalSettings.xml" ) );
53 }
54
55 @Test
56 public void testBothSettings()
57 {
58 executeTarget( "testBothSettings" );
59 assertThat( "global settings not set", AntRepoSys.getInstance( getProject() ).getGlobalSettings().getName(),
60 equalTo( "globalSettings.xml" ) );
61 assertThat( "user settings not set", AntRepoSys.getInstance( getProject() ).getUserSettings().getName(),
62 equalTo( "userSettings.xml" ) );
63 }
64
65 @Test
66 public void testFallback()
67 throws IOException
68 {
69 executeTarget("setUp");
70 assertThat( "no fallback to local settings",
71 AntRepoSys.getInstance( getProject() ).getUserSettings().getAbsolutePath(), endsWith( ".m2"
72 + File.separator + "settings.xml" ) );
73 }
74 }