View Javadoc

1   package org.apache.maven.it;
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 org.apache.maven.it.Verifier;
23  import org.apache.maven.it.util.ResourceExtractor;
24  
25  import java.io.File;
26  import java.util.Properties;
27  
28  /**
29   * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3600">MNG-3600</a>.
30   * 
31   * @version $Id: MavenITmng3600DeploymentModeDefaultsTest.java 1165035 2011-09-04 14:40:36Z hboutemy $
32   */
33  public class MavenITmng3600DeploymentModeDefaultsTest
34      extends AbstractMavenIntegrationTestCase
35  {
36  
37      public MavenITmng3600DeploymentModeDefaultsTest()
38      {
39          super( "(2.1.0-M1,3.0-alpha-1),[3.0.1,)" );
40      }
41  
42      public void testitMNG3600NoSettings()
43          throws Exception
44      {
45          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3600" );
46  
47          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
48  
49          new File( testDir, "wagon.properties" ).delete();
50          verifier.setLogFileName( "log-no-settings.txt" );
51          verifier.executeGoal( "validate" );
52          verifier.verifyErrorFreeLog();
53          verifier.resetStreams();
54  
55          verifier.assertFilePresent( "wagon.properties" );
56          Properties props = verifier.loadProperties( "wagon.properties" );
57          assertNull( props.get( "directory.mode" ) );
58          assertNull( props.get( "file.mode" ) );
59      }
60  
61      public void testitMNG3600ServerDefaults()
62          throws Exception
63      {
64          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3600" );
65  
66          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
67  
68          new File( testDir, "wagon.properties" ).delete();
69          verifier.getCliOptions().add( "--settings" );
70          verifier.getCliOptions().add( "settings-server-defaults.xml" );
71          verifier.setLogFileName( "log-server-defaults.txt" );
72          verifier.executeGoal( "validate" );
73          verifier.verifyErrorFreeLog();
74          verifier.resetStreams();
75  
76          verifier.assertFilePresent( "wagon.properties" );
77          Properties props = verifier.loadProperties( "wagon.properties" );
78          assertNull( props.get( "directory.mode" ) );
79          assertNull( props.get( "file.mode" ) );
80      }
81  
82      public void testitMNG3600ModesSet()
83          throws Exception
84      {
85          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3600" );
86  
87          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
88  
89          new File( testDir, "wagon.properties" ).delete();
90          verifier.getCliOptions().add( "--settings" );
91          verifier.getCliOptions().add( "settings-modes-set.xml" );
92          verifier.setLogFileName( "log-modes-set.txt" );
93          verifier.executeGoal( "validate" );
94          verifier.verifyErrorFreeLog();
95          verifier.resetStreams();
96  
97          verifier.assertFilePresent( "wagon.properties" );
98          Properties props = verifier.loadProperties( "wagon.properties" );
99          assertEquals( "700", props.get( "directory.mode" ) );
100         assertEquals( "600", props.get( "file.mode" ) );
101     }
102 
103 }