View Javadoc
1   package org.apache.maven.resolver.internal.ant;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
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  }