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.Handler;
24 import org.eclipse.jetty.server.NetworkConnector;
25 import org.eclipse.jetty.server.Server;
26 import org.eclipse.jetty.server.handler.DefaultHandler;
27 import org.eclipse.jetty.server.handler.HandlerList;
28 import org.eclipse.jetty.server.handler.ResourceHandler;
29
30 import java.io.File;
31 import java.net.InetAddress;
32 import java.util.List;
33 import java.util.Properties;
34
35
36
37
38
39
40 public class MavenITmng4991NonProxyHostsTest
41 extends AbstractMavenIntegrationTestCase
42 {
43
44 public MavenITmng4991NonProxyHostsTest()
45 {
46 super( "[2.0.3,3.0-alpha-1),[3.0.3,)" );
47 }
48
49
50
51
52
53
54 public void testit()
55 throws Exception
56 {
57 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4991" );
58
59 ResourceHandler resourceHandler = new ResourceHandler();
60 resourceHandler.setResourceBase( new File( testDir, "repo" ).getAbsolutePath() );
61
62 HandlerList handlers = new HandlerList();
63 handlers.setHandlers( new Handler[] { resourceHandler, new DefaultHandler() } );
64
65 Server server = new Server( 0 );
66 server.setHandler( handlers );
67
68
69
70
71
72 Server proxy = new Server( 0 );
73 proxy.setHandler( new DefaultHandler() );
74
75 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
76 try
77 {
78 server.start();
79 if ( server.isFailed() )
80 {
81 fail( "Couldn't bind the server socket to a free port!" );
82 }
83
84 proxy.start();
85 if ( proxy.isFailed() )
86 {
87 fail( "Couldn't bind the server socket to a free port!" );
88 }
89
90 verifier.setAutoclean( false );
91 verifier.deleteDirectory( "target" );
92 verifier.deleteArtifacts( "org.apache.maven.its.mng4991" );
93 Properties filterProps = verifier.newDefaultFilterProperties();
94 int port = ( (NetworkConnector) server.getConnectors()[0] ).getLocalPort();
95 filterProps.setProperty( "@port@", Integer.toString( port ) );
96 int proxyPort = ( (NetworkConnector) proxy.getConnectors()[0] ).getLocalPort();
97 filterProps.setProperty( "@proxyPort@", Integer.toString( proxyPort ) );
98 filterProps.setProperty( "@localhost@", InetAddress.getLoopbackAddress().getCanonicalHostName() );
99 verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
100 verifier.addCliOption( "-s" );
101 verifier.addCliOption( "settings.xml" );
102 verifier.executeGoal( "validate" );
103 verifier.verifyErrorFreeLog();
104 }
105 finally
106 {
107 verifier.resetStreams();
108 server.stop();
109 proxy.stop();
110 server.join();
111 proxy.join();
112 }
113
114 List<String> compile = verifier.loadLines( "target/compile.txt", "UTF-8" );
115
116 assertTrue( compile.toString(), compile.contains( "dep-0.1.jar" ) );
117 }
118 }