@Test
  public void defaultToRemoteProxy() {
    GridNodeConfiguration nodeConfiguration = new GridNodeConfiguration();
    new JCommander(nodeConfiguration, "-role", "webdriver", "-host", "localhost");
    RegistrationRequest res = RegistrationRequest.build(nodeConfiguration);
    res.getCapabilities().clear();
    RegistrationRequest req = res;

    Map<String, Object> app1 = new HashMap<>();
    GridNodeConfiguration config = new GridNodeConfiguration();
    app1.put(CapabilityType.APPLICATION_NAME, "app1");

    req.addDesiredCapability(app1);
    req.setConfiguration(config);

    // requires Custom1 & Custom1 set in config to work.
    RemoteProxy p = BaseRemoteProxy.getNewInstance(req, registry);
    assertEquals(BaseRemoteProxy.class, p.getClass());
  }
  // because this method is called asynchronously and no one waits for the completion,
  // exception needs to be reported explicitly.
  public Void call() throws Exception {
    try {
      RegistrationRequest c = RegistrationRequest.build(args);
      for (DesiredCapabilities dc : c.getCapabilities()) {
        JenkinsCapabilityMatcher.enhanceCapabilities(dc, nodeName);
      }
      SelfRegisteringRemote remote = new SelfRegisteringRemote(c);
      PropertyUtils.setProperty(SeleniumConstants.PROPERTY_INSTANCE, remote);
      remote.startRemoteServer();
      remote.startRegistrationProcess();

      Channel.current().waitForProperty(SeleniumConstants.PROPERTY_LOCK);
      return null;
    } catch (Exception e) {
      e.printStackTrace();
      throw e;
    } catch (Error e) {
      e.printStackTrace();
      throw e;
    }
  }