made this test smarter

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@927848 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2010-03-26 13:42:27 +00:00
parent 256789a4ff
commit ad7faf9b1a
1 changed files with 11 additions and 4 deletions
solr/src/test/org/apache/solr/core

View File

@ -54,15 +54,20 @@ public class TestJmxMonitoredMap {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
for (int i = 0; i < 5; i++) { int retries = 5;
for (int i = 0; i < retries; i++) {
try { try {
ServerSocket server = new ServerSocket(0); ServerSocket server = new ServerSocket(0);
port = server.getLocalPort(); try {
server.close(); port = server.getLocalPort();
} finally {
server.close();
}
// System.out.println("Using port: " + port); // System.out.println("Using port: " + port);
try { try {
LocateRegistry.createRegistry(port); LocateRegistry.createRegistry(port);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e;
} }
String url = "service:jmx:rmi:///jndi/rmi://:" + port + "/solrjmx"; String url = "service:jmx:rmi:///jndi/rmi://:" + port + "/solrjmx";
JmxConfiguration config = new JmxConfiguration(true, null, url); JmxConfiguration config = new JmxConfiguration(true, null, url);
@ -72,7 +77,9 @@ public class TestJmxMonitoredMap {
mbeanServer = connector.getMBeanServerConnection(); mbeanServer = connector.getMBeanServerConnection();
break; break;
} catch (Exception e) { } catch (Exception e) {
if(retries == (i + 1)) {
throw e;
}
} }
} }
} }