@Test(expected = TestContainerException.class) public void forkWithInvalidBootClasspath() throws BundleException, IOException, InterruptedException, NotBoundException, URISyntaxException { ServiceLoader<FrameworkFactory> loader = ServiceLoader.load(FrameworkFactory.class); FrameworkFactory frameworkFactory = loader.iterator().next(); ForkedFrameworkFactory forkedFactory = new ForkedFrameworkFactory(frameworkFactory); List<String> bootClasspath = Arrays.asList( CoreOptions.maven("org.kohsuke.metainf-services", "metainf-services", "1.2").getURL() ); Map<String, Object> frameworkProperties = new HashMap<String, Object>(); frameworkProperties.put(Constants.FRAMEWORK_STORAGE, storage.getAbsolutePath()); frameworkProperties.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "org.kohsuke.metainf_services"); forkedFactory.fork(Collections.<String> emptyList(), Collections.<String, String> emptyMap(), frameworkProperties, null, bootClasspath); }
public RemoteFramework fork(List<String> vmArgs, Map<String, String> systemProperties, Map<String, Object> frameworkProperties, List<String> beforeFrameworkClasspath, List<String> afterFrameworkClasspath) { port = getPort(); LOG.debug("using RMI registry at port {}", port); String rmiName = "ExamRemoteFramework-" + UUID.randomUUID().toString(); try { String address = InetAddress.getLoopbackAddress().getHostAddress(); System.setProperty("java.rmi.server.hostname", address); registry = LocateRegistry.createRegistry(port); Map<String, String> systemPropsNew = new HashMap<>(systemProperties); systemPropsNew.put("java.rmi.server.hostname", address); systemPropsNew.put(RemoteFramework.RMI_PORT_KEY, Integer.toString(port)); systemPropsNew.put(RemoteFramework.RMI_NAME_KEY, rmiName); String[] vmOptions = buildSystemProperties(vmArgs, systemPropsNew); String[] args = buildFrameworkProperties(frameworkProperties); javaRunner = new ExamJavaRunner(false); javaRunner.exec(vmOptions, buildClasspath(beforeFrameworkClasspath, afterFrameworkClasspath), RemoteFrameworkImpl.class.getName(), args, getJavaHome(), null); return findRemoteFramework(address, port, rmiName); } catch (RemoteException | ExecutionException | URISyntaxException exc) { throw new TestContainerException(exc); } }
ForkedFrameworkFactory { public RemoteFramework fork(List<String> vmArgs, Map<String, String> systemProperties, Map<String, Object> frameworkProperties, List<String> beforeFrameworkClasspath, List<String> afterFrameworkClasspath) { port = getPort(); LOG.debug("using RMI registry at port {}", port); String rmiName = "ExamRemoteFramework-" + UUID.randomUUID().toString(); try { String address = InetAddress.getLoopbackAddress().getHostAddress(); System.setProperty("java.rmi.server.hostname", address); registry = LocateRegistry.createRegistry(port); Map<String, String> systemPropsNew = new HashMap<>(systemProperties); systemPropsNew.put("java.rmi.server.hostname", address); systemPropsNew.put(RemoteFramework.RMI_PORT_KEY, Integer.toString(port)); systemPropsNew.put(RemoteFramework.RMI_NAME_KEY, rmiName); String[] vmOptions = buildSystemProperties(vmArgs, systemPropsNew); String[] args = buildFrameworkProperties(frameworkProperties); javaRunner = new ExamJavaRunner(false); javaRunner.exec(vmOptions, buildClasspath(beforeFrameworkClasspath, afterFrameworkClasspath), RemoteFrameworkImpl.class.getName(), args, getJavaHome(), null); return findRemoteFramework(address, port, rmiName); } catch (RemoteException | ExecutionException | URISyntaxException exc) { throw new TestContainerException(exc); } } }
ForkedFrameworkFactory { public RemoteFramework fork(List<String> vmArgs, Map<String, String> systemProperties, Map<String, Object> frameworkProperties, List<String> beforeFrameworkClasspath, List<String> afterFrameworkClasspath) { port = getPort(); LOG.debug("using RMI registry at port {}", port); String rmiName = "ExamRemoteFramework-" + UUID.randomUUID().toString(); try { String address = InetAddress.getLoopbackAddress().getHostAddress(); System.setProperty("java.rmi.server.hostname", address); registry = LocateRegistry.createRegistry(port); Map<String, String> systemPropsNew = new HashMap<>(systemProperties); systemPropsNew.put("java.rmi.server.hostname", address); systemPropsNew.put(RemoteFramework.RMI_PORT_KEY, Integer.toString(port)); systemPropsNew.put(RemoteFramework.RMI_NAME_KEY, rmiName); String[] vmOptions = buildSystemProperties(vmArgs, systemPropsNew); String[] args = buildFrameworkProperties(frameworkProperties); javaRunner = new ExamJavaRunner(false); javaRunner.exec(vmOptions, buildClasspath(beforeFrameworkClasspath, afterFrameworkClasspath), RemoteFrameworkImpl.class.getName(), args, getJavaHome(), null); return findRemoteFramework(address, port, rmiName); } catch (RemoteException | ExecutionException | URISyntaxException exc) { throw new TestContainerException(exc); } } ForkedFrameworkFactory(FrameworkFactory frameworkFactory); }
ForkedFrameworkFactory { public RemoteFramework fork(List<String> vmArgs, Map<String, String> systemProperties, Map<String, Object> frameworkProperties, List<String> beforeFrameworkClasspath, List<String> afterFrameworkClasspath) { port = getPort(); LOG.debug("using RMI registry at port {}", port); String rmiName = "ExamRemoteFramework-" + UUID.randomUUID().toString(); try { String address = InetAddress.getLoopbackAddress().getHostAddress(); System.setProperty("java.rmi.server.hostname", address); registry = LocateRegistry.createRegistry(port); Map<String, String> systemPropsNew = new HashMap<>(systemProperties); systemPropsNew.put("java.rmi.server.hostname", address); systemPropsNew.put(RemoteFramework.RMI_PORT_KEY, Integer.toString(port)); systemPropsNew.put(RemoteFramework.RMI_NAME_KEY, rmiName); String[] vmOptions = buildSystemProperties(vmArgs, systemPropsNew); String[] args = buildFrameworkProperties(frameworkProperties); javaRunner = new ExamJavaRunner(false); javaRunner.exec(vmOptions, buildClasspath(beforeFrameworkClasspath, afterFrameworkClasspath), RemoteFrameworkImpl.class.getName(), args, getJavaHome(), null); return findRemoteFramework(address, port, rmiName); } catch (RemoteException | ExecutionException | URISyntaxException exc) { throw new TestContainerException(exc); } } ForkedFrameworkFactory(FrameworkFactory frameworkFactory); FrameworkFactory getFrameworkFactory(); void setFrameworkFactory(FrameworkFactory frameworkFactory); RemoteFramework fork(List<String> vmArgs, Map<String, String> systemProperties,
        Map<String, Object> frameworkProperties, List<String> beforeFrameworkClasspath,
        List<String> afterFrameworkClasspath); RemoteFramework fork(List<String> vmArgs, Map<String, String> systemProperties,
        Map<String, Object> frameworkProperties); void join(); }
ForkedFrameworkFactory { public RemoteFramework fork(List<String> vmArgs, Map<String, String> systemProperties, Map<String, Object> frameworkProperties, List<String> beforeFrameworkClasspath, List<String> afterFrameworkClasspath) { port = getPort(); LOG.debug("using RMI registry at port {}", port); String rmiName = "ExamRemoteFramework-" + UUID.randomUUID().toString(); try { String address = InetAddress.getLoopbackAddress().getHostAddress(); System.setProperty("java.rmi.server.hostname", address); registry = LocateRegistry.createRegistry(port); Map<String, String> systemPropsNew = new HashMap<>(systemProperties); systemPropsNew.put("java.rmi.server.hostname", address); systemPropsNew.put(RemoteFramework.RMI_PORT_KEY, Integer.toString(port)); systemPropsNew.put(RemoteFramework.RMI_NAME_KEY, rmiName); String[] vmOptions = buildSystemProperties(vmArgs, systemPropsNew); String[] args = buildFrameworkProperties(frameworkProperties); javaRunner = new ExamJavaRunner(false); javaRunner.exec(vmOptions, buildClasspath(beforeFrameworkClasspath, afterFrameworkClasspath), RemoteFrameworkImpl.class.getName(), args, getJavaHome(), null); return findRemoteFramework(address, port, rmiName); } catch (RemoteException | ExecutionException | URISyntaxException exc) { throw new TestContainerException(exc); } } ForkedFrameworkFactory(FrameworkFactory frameworkFactory); FrameworkFactory getFrameworkFactory(); void setFrameworkFactory(FrameworkFactory frameworkFactory); RemoteFramework fork(List<String> vmArgs, Map<String, String> systemProperties,
        Map<String, Object> frameworkProperties, List<String> beforeFrameworkClasspath,
        List<String> afterFrameworkClasspath); RemoteFramework fork(List<String> vmArgs, Map<String, String> systemProperties,
        Map<String, Object> frameworkProperties); void join();  }