fixed the IT 4554 as LocalPort is -1 if Jetty connector is not open. Error message in logs: [WARNING] Could not transfer metadata org.apache.maven.its.mng4554/maven-metadata.xml from/to central (http://localhost:-1/repo-1): Connect to localhost:80 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect

This commit is contained in:
tibordigana 2019-08-08 01:06:31 +02:00
parent 5721184d5e
commit 6b3e0f817d
1 changed files with 24 additions and 2 deletions

View File

@ -85,7 +85,17 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest
Server server = new Server( 0 ); Server server = new Server( 0 );
server.setHandler( handlerList ); server.setHandler( handlerList );
Connector connector = server.getConnectors()[0];
connector.setHost( "localhost" );
server.start(); 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() ); Verifier verifier = newVerifier( testDir.getAbsolutePath() );
try 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() ); assertFalse( new File( verifier.getArtifactMetadataPath( "org.apache.maven.its.mng4554", null, null, "maven-metadata-mng4554.xml" ) ).exists() );
} }
Properties filterProps = verifier.newDefaultFilterProperties(); 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" ); filterProps.setProperty( "@repo@", "repo-1" );
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps ); verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
verifier.addCliOption( "-s" ); verifier.addCliOption( "-s" );
@ -127,6 +137,7 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest
{ {
verifier.resetStreams(); verifier.resetStreams();
server.stop(); server.stop();
server.join();
} }
} }
@ -162,7 +173,17 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest
Server server = new Server( 0 ); Server server = new Server( 0 );
server.setHandler( handlerList ); server.setHandler( handlerList );
Connector connector = server.getConnectors()[0];
connector.setHost( "localhost" );
server.start(); 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() ); Verifier verifier = newVerifier( testDir.getAbsolutePath() );
try 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() ); assertFalse( new File( verifier.getArtifactMetadataPath( "org.apache.maven.its.mng4554", null, null, "maven-metadata-mng4554.xml" ) ).exists() );
} }
Properties filterProps = verifier.newDefaultFilterProperties(); 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" ); filterProps.setProperty( "@repo@", "repo-1" );
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps ); verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
verifier.addCliOption( "-U" ); verifier.addCliOption( "-U" );
@ -205,6 +226,7 @@ public class MavenITmng4554PluginPrefixMappingUpdateTest
{ {
verifier.resetStreams(); verifier.resetStreams();
server.stop(); server.stop();
server.join();
} }
} }