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

View File

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