1 package org.apache.maven.it;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.it.util.ResourceExtractor;
23 import org.eclipse.jetty.server.NetworkConnector;
24 import org.eclipse.jetty.server.Request;
25 import org.eclipse.jetty.server.Server;
26 import org.eclipse.jetty.server.handler.AbstractHandler;
27 import org.eclipse.jetty.server.handler.DefaultHandler;
28 import org.eclipse.jetty.server.handler.HandlerList;
29
30 import javax.servlet.http.HttpServletRequest;
31 import javax.servlet.http.HttpServletResponse;
32 import java.io.File;
33 import java.util.ArrayList;
34 import java.util.Collections;
35 import java.util.List;
36 import java.util.Properties;
37
38
39
40
41
42
43 public class MavenITmng4772PluginVersionResolutionDoesntTouchDisabledRepoTest
44 extends AbstractMavenIntegrationTestCase
45 {
46
47 public MavenITmng4772PluginVersionResolutionDoesntTouchDisabledRepoTest()
48 {
49 super( "[2.0.3,3.0-alpha-1),[3.0-beta-3,)" );
50 }
51
52
53
54
55
56
57
58 public void testit()
59 throws Exception
60 {
61 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4772" );
62
63 final List<String> requestedUris = Collections.synchronizedList( new ArrayList<String>() );
64
65 AbstractHandler logHandler = new AbstractHandler()
66 {
67 @Override
68 public void handle( String target, Request baseRequest, HttpServletRequest request,
69 HttpServletResponse response )
70 {
71 requestedUris.add( request.getRequestURI() );
72 }
73 };
74
75 HandlerList handlerList = new HandlerList();
76 handlerList.addHandler( logHandler );
77 handlerList.addHandler( new DefaultHandler() );
78
79 Server server = new Server( 0 );
80 server.setHandler( handlerList );
81 server.start();
82
83 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
84 try
85 {
86 if ( server.isFailed() )
87 {
88 fail( "Couldn't bind the server socket to a free port!" );
89 }
90 int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
91 System.out.println( "Bound server socket to the port " + port );
92 verifier.setAutoclean( false );
93 verifier.deleteDirectory( "target" );
94 Properties filterProps = verifier.newDefaultFilterProperties();
95 filterProps.setProperty( "@port@", Integer.toString( port ) );
96 verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
97 verifier.addCliOption( "-U" );
98 verifier.addCliOption( "-s" );
99 verifier.addCliOption( "settings.xml" );
100 verifier.executeGoal( "org.apache.maven.its.mng4772:maven-it-plugin:touch" );
101 verifier.verifyErrorFreeLog();
102 fail( "Build should have failed to resolve version for unknown plugin" );
103 }
104 catch ( VerificationException e )
105 {
106
107 }
108 finally
109 {
110 verifier.resetStreams();
111 server.stop();
112 server.join();
113 }
114
115 assertTrue( requestedUris.toString(), requestedUris.isEmpty() );
116 }
117 }