View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.its;
20  
21  import java.io.File;
22  import java.io.IOException;
23  import java.net.URISyntaxException;
24  import java.util.Collections;
25  import java.util.HashSet;
26  import java.util.Set;
27  
28  import junit.framework.Assert;
29  import org.apache.maven.it.VerificationException;
30  import org.apache.maven.it.Verifier;
31  import org.junit.Test;
32  
33  import static org.apache.its.util.TestUtils.archivePathFromChild;
34  import static org.apache.its.util.TestUtils.archivePathFromProject;
35  import static org.apache.its.util.TestUtils.assertZipContents;
36  import static org.apache.its.util.TestUtils.getTestDir;
37  
38  public class IT_000_BasicArchiveCreation {
39  
40      private static final String BASENAME = "basics";
41      private static final String VERSION = "1";
42  
43      @Test
44      public void execute() throws VerificationException, IOException, URISyntaxException {
45          File testDir = getTestDir(BASENAME);
46  
47          Verifier verifier = new Verifier(testDir.getAbsolutePath());
48  
49          verifier.executeGoal("package");
50  
51          verifier.verifyErrorFreeLog();
52          verifier.resetStreams();
53  
54          // make sure the tar did NOT get created by default
55          File tarAssemblyFile = new File(testDir, "target/" + BASENAME + "-" + VERSION + "-source-release.tar.gz");
56          Assert.assertFalse("tar assembly should not have been created", tarAssemblyFile.exists());
57  
58          File assembly = new File(testDir, "target/" + BASENAME + "-" + VERSION + "-source-release.zip");
59  
60          Set<String> required = new HashSet<String>();
61  
62          required.add(archivePathFromProject(BASENAME, VERSION, "/pom.xml"));
63          required.add(archivePathFromChild(BASENAME, VERSION, "child1", "pom.xml"));
64          required.add(archivePathFromChild(BASENAME, VERSION, "child2", "/pom.xml"));
65  
66          required.add(
67                  archivePathFromChild(BASENAME, VERSION, "child1", "/src/main/java/org/apache/assembly/it/App.java"));
68          required.add(archivePathFromChild(
69                  BASENAME, VERSION, "child1", "/src/main/resources/META-INF/plexus/components.xml"));
70  
71          required.add(
72                  archivePathFromChild(BASENAME, VERSION, "child2", "/src/main/java/org/apache/assembly/it/App.java"));
73  
74          Set<String> banned = Collections.emptySet();
75  
76          assertZipContents(required, banned, assembly);
77      }
78  }