@Test(expected = InvalidParameterException.class)
  public void notExtendingProxyExisting() {
    Map<String, Object> app1 = new HashMap<>();
    GridNodeConfiguration config = new GridNodeConfiguration();
    app1.put(CapabilityType.APPLICATION_NAME, "app1");
    config.proxy = "java.lang.String";

    RegistrationRequest req = new RegistrationRequest();
    req.addDesiredCapability(app1);
    req.setConfiguration(config);

    BaseRemoteProxy.getNewInstance(req, registry);
  }
  // when some mandatory param are missing -> InvalidParameterException
  @Test(expected = InvalidParameterException.class)
  public void badConfig() {
    Map<String, Object> app1 = new HashMap<>();
    GridNodeConfiguration config = new GridNodeConfiguration();
    app1.put(CapabilityType.APPLICATION_NAME, "app1");
    config.proxy = "I Don't exist";

    RegistrationRequest req = new RegistrationRequest();
    req.addDesiredCapability(app1);
    req.setConfiguration(config);

    // requires Custom1 & Custom1 set in config to work.
    BaseRemoteProxy.getNewInstance(req, registry);
  }
  @Test
  public void existing() {
    Map<String, Object> app1 = new HashMap<>();
    GridNodeConfiguration config = new GridNodeConfiguration();
    app1.put(CapabilityType.APPLICATION_NAME, "app1");
    config.proxy = "org.openqa.grid.plugin.MyRemoteProxy";

    config.custom.put("Custom1", "A");
    config.custom.put("Custom2", "B");

    RegistrationRequest req = new RegistrationRequest();
    req.addDesiredCapability(app1);
    req.setConfiguration(config);

    RemoteProxy p = BaseRemoteProxy.getNewInstance(req, registry);

    assertEquals(p.getClass(), MyRemoteProxy.class);
    MyRemoteProxy myRemoteProxy = (MyRemoteProxy) p;
    assertEquals("A", myRemoteProxy.getCustom1());
    assertEquals("B", myRemoteProxy.getCustom2());
    assertEquals("A", myRemoteProxy.getConfig().custom.get("Custom1"));
    assertEquals("B", myRemoteProxy.getConfig().custom.get("Custom2"));
  }