1 package org.apache.maven.plugins.repository.it;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import static org.apache.maven.plugins.repository.it.support.IntegrationTestUtils.getTestDir;
23 import static org.apache.maven.plugins.repository.testutil.Assertions.assertZipContents;
24 import static junit.framework.Assert.fail;
25
26 import org.apache.maven.it.VerificationException;
27 import org.apache.maven.it.Verifier;
28 import org.apache.maven.plugins.repository.it.support.IntegrationTestUtils;
29 import org.apache.maven.plugins.repository.testutil.Assertions;
30 import org.junit.Test;
31
32 import java.io.File;
33 import java.io.IOException;
34 import java.net.URISyntaxException;
35 import java.util.HashSet;
36 import java.util.List;
37 import java.util.Set;
38
39 public class BundleCreateIT
40 {
41
42 @SuppressWarnings( "unchecked" )
43 @Test
44 public void createWithSCMInfoProvided()
45 throws IOException, URISyntaxException, VerificationException
46 {
47 File dir = getTestDir( "bundle-create" );
48
49 Verifier verifier = new Verifier( dir.getAbsolutePath() );
50
51 verifier.getCliOptions().add( "--settings ../settings.xml" );
52
53 String prefix = IntegrationTestUtils.getCliPluginPrefix();
54
55 verifier.executeGoal( prefix + "bundle-create" );
56 verifier.verifyErrorFreeLog();
57 verifier.resetStreams();
58
59 File bundleSource = new File( dir, "target/test-1.0-bundle.jar" );
60
61 Set<String> requiredEntries = new HashSet<String>();
62 requiredEntries.add( "pom.xml" );
63 requiredEntries.add( "test-1.0.jar" );
64 requiredEntries.add( "test-1.0-sources.jar" );
65
66 assertZipContents( requiredEntries, Assertions.EMPTY_ENTRY_NAMES, bundleSource );
67 }
68
69 @SuppressWarnings( "unchecked" )
70 @Test
71 public void createWithSCMInfoMissing()
72 throws IOException, URISyntaxException, VerificationException
73 {
74 File dir = getTestDir( "bundle-create-no-scm" );
75
76 Verifier verifier = new Verifier( dir.getAbsolutePath() );
77
78 List<String> cliOptions = verifier.getCliOptions();
79 cliOptions.add( "--settings ../settings.xml" );
80
81 String prefix = IntegrationTestUtils.getCliPluginPrefix();
82
83 try
84 {
85 verifier.executeGoal( prefix + "bundle-create" );
86 verifier.verifyErrorFreeLog();
87
88 fail( "No SCM Section provided, build should fail." );
89 }
90 catch( VerificationException e )
91 {
92
93 }
94 finally
95 {
96 verifier.resetStreams();
97 }
98 }
99
100 @SuppressWarnings( "unchecked" )
101 @Test
102 public void createFromAlternativePom()
103 throws Exception
104 {
105 File dir = getTestDir( "bundle-create-alt-pom" );
106
107 Verifier verifier = new Verifier( dir.getAbsolutePath() );
108
109 verifier.getCliOptions().add( "-f alternative-pom.xml --settings ../settings.xml" );
110
111 String prefix = IntegrationTestUtils.getCliPluginPrefix();
112
113 verifier.executeGoal( prefix + "bundle-create" );
114 verifier.verifyErrorFreeLog();
115 verifier.resetStreams();
116
117 File bundleSource = new File( dir, "target/test-1.0-bundle.jar" );
118
119 Set<String> requiredEntries = new HashSet<String>();
120 requiredEntries.add( "pom.xml" );
121 requiredEntries.add( "test-1.0.jar" );
122 requiredEntries.add( "test-1.0-sources.jar" );
123
124 assertZipContents( requiredEntries, Assertions.EMPTY_ENTRY_NAMES, bundleSource );
125 }
126
127 }