/** * This will make sure a registry exists and is valid m_port. If its not available or does not work for some reason, * it will select another port. This should really not happen usually. But it can. * * @return this for fluent API. Or IllegalStateException if a port has not been detected successfully. */ public synchronized RMIRegistry selectGracefully() { // if( ( m_port = select( m_defaultPort ) ) == UNSELECTED ) { int alternativePort = new FreePort(m_altMin, m_altTo).getPort(); if ((m_port = select(alternativePort)) == UNSELECTED) { throw new IllegalStateException("No port found for RMI at all. Even though " + alternativePort + " should have worked. Thats.. not. good. at. all."); } printTakenStatus(); // } return this; }
/** * This will make sure a registry exists and is valid m_port. * If its not available or does not work for some reason, it will select another port. * This should really not happen usually. But it can. * * @return this for fluent API. Or IllegalStateException if a port has not been detected successfully. */ public synchronized RMIRegistry selectGracefully() { //if( ( m_port = select( m_defaultPort ) ) == UNSELECTED ) { int alternativePort = new FreePort( m_altMin, m_altTo ).getPort(); if( ( m_port = select( alternativePort ) ) == UNSELECTED ) { throw new IllegalStateException( "No port found for RMI at all. Even though " + alternativePort + " should have worked. Thats.. not. good. at. all." ); } printTakenStatus(); //} return this; }
@Override public void runTest(TestDescription description, TestListener listener) { String filterExpression = "(&(objectClass=org.ops4j.pax.exam.ProbeInvoker))"; try { ServerSocket serverSocket = new ServerSocket(port.getPort()); TestListenerTask task = new TestListenerTask(serverSocket, listener); ExecutorService executor = Executors.newSingleThreadExecutor(); executor.submit(task); RemoteServiceReference[] references = remoteFramework.getServiceReferences( filterExpression, system.getTimeout().getValue(), TimeUnit.MILLISECONDS); remoteFramework.invokeMethodOnService(references[0], "runTestClass", description.toString()); executor.shutdown(); serverSocket.close(); } catch (InvocationTargetException exc) { LOG.error("", exc.getCause()); throw new TestContainerException(exc.getCause()); } // CHECKSTYLE:SKIP catch (Exception exc) { throw new TestContainerException(exc); } }
port = freePort.getPort(); LOG.debug("using RMI registry at port {}", port);
int port = freePort.getPort(); logger.debug("using RMI registry at port {}" + name, port); registry = LocateRegistry.createRegistry(port);
int port = freePort.getPort(); logger.debug("using RMI registry at port {}" + name, port); registry = LocateRegistry.createRegistry(port);
int port = freePort.getPort();
system = system.fork(new Option[] { systemProperty("java.protocol.handler.pkgs").value("org.ops4j.pax.url"), systemProperty(EXAM_INVOKER_PORT).value(Integer.toString(port.getPort())) }); List<String> vmArgs = createVmArguments();