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 ManifestConfiguration manifestConfiguration;
37  
38      private MavenArchiveConfiguration archive;
39  
40      @Before
41      public void before()
42      {
43          this.manifestConfiguration = new ManifestConfiguration();
44          archive = new MavenArchiveConfiguration();
45          archive.setManifest( manifestConfiguration );
46          archive.setForced( false );
47          archive.setCompress( false );
48          archive.setIndex( false );
49      }
50  
51      @Test
52      public void addingSingleEntryShouldBeReturned()
53      {
54          archive.addManifestEntry( "key1", "value1" );
55          Map<String, String> manifestEntries = archive.getManifestEntries();
56          assertThat( manifestEntries ).containsExactly( entry( "key1", "value1" ) );
57      }
58  
59      @Test
60      public void addingTwoEntriesShouldBeReturnedInInsertOrder()
61      {
62          archive.addManifestEntry( "key1", "value1" );
63          archive.addManifestEntry( "key2", "value2" );
64          Map<String, String> manifestEntries = archive.getManifestEntries();
65          assertThat( manifestEntries ).containsExactly( entry( "key1", "value1" ), entry( "key2", "value2" ) );
66      }
67  
68      @Test
69      public void addingThreeEntriesShouldBeReturnedInInsertOrder()
70      {
71          archive.addManifestEntry( "key1", "value1" );
72          archive.addManifestEntry( "key2", "value2" );
73          archive.addManifestEntry( "key3", "value3" );
74          Map<String, String> manifestEntries = archive.getManifestEntries();
75          assertThat( manifestEntries ).containsExactly( entry( "key1", "value1" ), entry( "key2", "value2" ),
76                                                         entry( "key3", "value3" ) );
77      }
78  }