diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4554PluginPrefixMappingUpdateTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4554PluginPrefixMappingUpdateTest.java index 2955d65b2a..c4e6979be8 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4554PluginPrefixMappingUpdateTest.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4554PluginPrefixMappingUpdateTest.java @@ -85,7 +85,17 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest Server server = new Server( 0 ); server.setHandler( handlerList ); + Connector connector = server.getConnectors()[0]; + connector.setHost( "localhost" ); server.start(); + while ( !server.isRunning() || !server.isStarted() ) + { + if ( server.isFailed() ) + { + fail( "Couldn't bind the server socket to a free port!" ); + } + Thread.sleep( 100L ); + } Verifier verifier = newVerifier( testDir.getAbsolutePath() ); try @@ -102,7 +112,7 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest assertFalse( new File( verifier.getArtifactMetadataPath( "org.apache.maven.its.mng4554", null, null, "maven-metadata-mng4554.xml" ) ).exists() ); } Properties filterProps = verifier.newDefaultFilterProperties(); - filterProps.setProperty( "@port@", Integer.toString( server.getConnectors()[0].getLocalPort() ) ); + filterProps.setProperty( "@port@", Integer.toString( connector.getLocalPort() ) ); filterProps.setProperty( "@repo@", "repo-1" ); verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps ); verifier.addCliOption( "-s" ); @@ -127,6 +137,7 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest { verifier.resetStreams(); server.stop(); + server.join(); } } @@ -162,7 +173,17 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest Server server = new Server( 0 ); server.setHandler( handlerList ); + Connector connector = server.getConnectors()[0]; + connector.setHost( "localhost" ); server.start(); + while ( !server.isRunning() || !server.isStarted() ) + { + if ( server.isFailed() ) + { + fail( "Couldn't bind the server socket to a free port!" ); + } + Thread.sleep( 100L ); + } Verifier verifier = newVerifier( testDir.getAbsolutePath() ); try @@ -179,7 +200,7 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest assertFalse( new File( verifier.getArtifactMetadataPath( "org.apache.maven.its.mng4554", null, null, "maven-metadata-mng4554.xml" ) ).exists() ); } Properties filterProps = verifier.newDefaultFilterProperties(); - filterProps.setProperty( "@port@", Integer.toString( server.getConnectors()[0].getLocalPort() ) ); + filterProps.setProperty( "@port@", Integer.toString( connector.getLocalPort() ) ); filterProps.setProperty( "@repo@", "repo-1" ); verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps ); verifier.addCliOption( "-U" ); @@ -205,6 +226,7 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest { verifier.resetStreams(); server.stop(); + server.join(); } }