@BeforeClass
  public static void setup() throws Exception {
    registry = Registry.getNewInstanceForTestOnly();
    hub = Hub.getNewInstanceForTest(PortProber.findFreePort(), registry);

    status = new URL("http://" + hub.getHost() + ":" + hub.getPort() + "/grid/status");
    host = new HttpHost(hub.getHost(), hub.getPort());

    hub.start();

    p1 = RemoteProxyFactory.getNewBasicRemoteProxy("app1", "http://machine1:4444/");
    p2 = RemoteProxyFactory.getNewBasicRemoteProxy("app1", "http://machine2:4444/");
    p3 = RemoteProxyFactory.getNewBasicRemoteProxy("app1", "http://machine3:4444/");
    p4 = RemoteProxyFactory.getNewBasicRemoteProxy("app1", "http://machine4:4444/");

    RegistrationRequest req = new RegistrationRequest();
    Map<String, Object> capability = new HashMap<String, Object>();
    capability.put("applicationName", "custom app");
    req.addDesiredCapabilitiy(capability);

    Map<String, Object> config = new HashMap<String, Object>();
    config.put("url", "http://machine5:4444/");
    req.setConfiguration(config);
    customProxy = new MyCustomProxy(req);

    registry.add(p1);
    registry.add(p2);
    registry.add(p3);
    registry.add(p4);
    registry.add(customProxy);
  }
Esempio n. 2
0
  /** create a hub with 1 IE and 1 FF */
  @BeforeClass
  public static void setup() {
    registry = Registry.newInstance();
    ie.put(APP, "IE");
    ff.put(APP, "FF");

    p1 = RemoteProxyFactory.getNewBasicRemoteProxy(ie, "http://machine1:4444", registry);
    p2 = RemoteProxyFactory.getNewBasicRemoteProxy(ff, "http://machine2:4444", registry);
    registry.add(p1);
    registry.add(p2);
  }
Esempio n. 3
0
  @Test
  public void removeIfPresent() {
    Registry registry = Registry.newInstance();
    try {
      ProxySet set = new ProxySet(true);
      RemoteProxy p1 =
          RemoteProxyFactory.getNewBasicRemoteProxy("app1", "http://machine1:4444/", registry);

      set.add(p1);

      p1.getTestSlots().get(0).getNewSession(new HashMap<String, Object>());

      // Make sure the proxy and its test session show up in the registry.
      Assert.assertEquals(1, set.size());
      Assert.assertNotNull(p1.getTestSlots().get(0).getSession());

      registry.removeIfPresent(p1);

      // Make sure both the proxy and the test session assigned to it are removed from the registry.
      Assert.assertEquals(0, set.size());
      Assert.assertNull(p1.getTestSlots().get(0).getSession());
    } finally {
      registry.stop();
    }
  }
  /** create a hub with 1 IE and 1 FF */
  @BeforeClass
  public static void setup() {
    registry = new Registry();
    ff.put(APP, "FF");

    p1 = RemoteProxyFactory.getNewBasicRemoteProxy(ff, "http://machine1:4444", registry);
    registry.add(p1);
  }
  /** Test setting cookies. Not complete. */
  @Test
  public void test() throws Exception {
    // Make a proxy factory and tell it where the server is:
    HttpURL base = new HttpURL("http://domain/atom/-/");
    RemoteProxyFactory factory = new RemoteProxyFactory(base);

    // Tell it who I am (give it authentication-cookie):
    String value = "23456789";
    factory.setCookie("ACSID", value);
    factory.setCookie("another", value);

    // Get a proxy:
    @SuppressWarnings("unused")
    AtomProxy<User> proxy = factory.get(User.class);

    // Get my user
    @SuppressWarnings("unused")
    GDataParameters params = new GDataParameters();
    // List<User> users=proxy.get(params);
    // if(users.size()!=1)throw new RuntimeException();
  }