1 package org.apache.maven.it;
2
3 import java.io.File;
4 import java.util.Properties;
5
6 import org.apache.maven.it.util.ResourceExtractor;
7
8
9
10
11
12
13 public class MavenITmng5771CoreExtensionsTest
14 extends AbstractMavenIntegrationTestCase
15 {
16 public MavenITmng5771CoreExtensionsTest()
17 {
18 super( "(3.2.5,)" );
19 }
20
21 public void testCoreExtension()
22 throws Exception
23 {
24 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5771-core-extensions" );
25
26 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
27 verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
28
29 verifier = newVerifier( new File( testDir, "client" ).getAbsolutePath() );
30 verifier.deleteDirectory( "target" );
31 verifier.deleteArtifacts( "org.apache.maven.its.it-core-extensions" );
32 verifier.getCliOptions().add( "-s" );
33 verifier.getCliOptions().add( new File( testDir, "settings.xml" ).getAbsolutePath() );
34 verifier.executeGoal( "validate" );
35 verifier.verifyErrorFreeLog();
36 verifier.resetStreams();
37 }
38
39 public void testCoreExtensionNoDescriptor()
40 throws Exception
41 {
42 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5771-core-extensions" );
43
44 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
45 verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
46
47 verifier = newVerifier( new File( testDir, "client-no-descriptor" ).getAbsolutePath() );
48 verifier.deleteDirectory( "target" );
49 verifier.deleteArtifacts( "org.apache.maven.its.it-core-extensions" );
50 verifier.getCliOptions().add( "-s" );
51 verifier.getCliOptions().add( new File( testDir, "settings.xml" ).getAbsolutePath() );
52 verifier.executeGoal( "validate" );
53 verifier.verifyErrorFreeLog();
54 verifier.resetStreams();
55 }
56
57
58
59
60 public void testCoreExtensionRetrievedFromAMirrorWithBasicAuthentication()
61 throws Exception
62 {
63 requiresMavenVersion( "[3.3.2,)" );
64
65 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5771-core-extensions" );
66
67 HttpServer server = HttpServer.builder()
68 .port(0)
69 .username("maven")
70 .password("secret")
71 .source(new File(testDir, "repo"))
72 .build();
73 server.start();
74
75 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
76 Properties properties = verifier.newDefaultFilterProperties();
77 properties.setProperty("@port@", Integer.toString( server.port() ) );
78 String mirrorOf;
79 if ( matchesVersionRange( "[4.0.0-alpha-1,)" ) )
80 {
81 mirrorOf = "*";
82 }
83 else
84 {
85 mirrorOf = "external:*";
86 }
87 properties.setProperty("@mirrorOf@", mirrorOf );
88 verifier.filterFile( "settings-template-mirror-auth.xml", "settings.xml", "UTF-8", properties );
89
90 verifier = newVerifier( new File( testDir, "client" ).getAbsolutePath() );
91 verifier.deleteDirectory( "target" );
92 verifier.deleteArtifacts( "org.apache.maven.its.it-core-extensions" );
93 verifier.getCliOptions().add( "-s" );
94 verifier.getCliOptions().add( new File( testDir, "settings.xml" ).getAbsolutePath() );
95 verifier.executeGoal( "validate" );
96 verifier.verifyErrorFreeLog();
97 verifier.resetStreams();
98
99 server.stop();
100 }
101 }