View Javadoc
1   package org.apache.maven.archiver;
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.assertj.core.api.Assertions.assertThat;
23  import static org.assertj.core.api.Assertions.entry;
24  
25  import java.util.Map;
26  
27  import org.junit.Before;
28  import org.junit.Test;
29  
30  /**
31   * @author Karl Heinz Marbaise <a href="mailto:khmarbaise@apache.org">khmarbaise@apache.org</a>.
32   */
33  public class MavenArchiveConfigurationTest
34  {
35  
36      private MavenArchiveConfiguration archive;
37  
38      @Before
39      public void before()
40      {
41          archive = new MavenArchiveConfiguration();
42          archive.setManifest( new ManifestConfiguration() );
43          archive.setForced( false );
44          archive.setCompress( false );
45          archive.setIndex( false );
46      }
47  
48      @Test
49      public void addingSingleEntryShouldBeReturned()
50      {
51          archive.addManifestEntry( "key1", "value1" );
52          Map<String, String> manifestEntries = archive.getManifestEntries();
53          assertThat( manifestEntries ).containsExactly( entry( "key1", "value1" ) );
54      }
55  
56      @Test
57      public void addingTwoEntriesShouldBeReturnedInInsertOrder()
58      {
59          archive.addManifestEntry( "key1", "value1" );
60          archive.addManifestEntry( "key2", "value2" );
61          Map<String, String> manifestEntries = archive.getManifestEntries();
62          assertThat( manifestEntries ).containsExactly( entry( "key1", "value1" ), entry( "key2", "value2" ) );
63      }
64  
65      @Test
66      public void addingThreeEntriesShouldBeReturnedInInsertOrder()
67      {
68          archive.addManifestEntry( "key1", "value1" );
69          archive.addManifestEntry( "key2", "value2" );
70          archive.addManifestEntry( "key3", "value3" );
71          Map<String, String> manifestEntries = archive.getManifestEntries();
72          assertThat( manifestEntries ).containsExactly( entry( "key1", "value1" ), entry( "key2", "value2" ),
73                                                         entry( "key3", "value3" ) );
74      }
75  }