Example #1
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();
    }
  }
Example #2
0
  public TestSlot(
      RemoteProxy proxy, SeleniumProtocol protocol, String path, Map<String, Object> capabilities) {
    this.proxy = proxy;
    this.protocol = protocol;
    this.path = path;

    CapabilityMatcher c = proxy.getCapabilityHelper();
    if (c == null) {
      throw new InvalidParameterException(
          "the proxy needs to have a valid "
              + "capabilityMatcher to support have some test slots attached to it");
    }
    matcher = proxy.getCapabilityHelper();
    this.capabilities = capabilities;
  }
Example #3
0
 boolean performAfterSessionEvent() {
   // run the pre-release listener
   try {
     if (proxy instanceof TestSessionListener) {
       if (showWarning && proxy.getMaxNumberOfConcurrentTestSessions() != 1) {
         log.warning(
             "WARNING : using a afterSession on a proxy that can support multiple tests is risky.");
         showWarning = false;
       }
       ((TestSessionListener) proxy).afterSession(currentSession);
     }
   } catch (Throwable t) {
     log.severe(
         "Error running afterSession for " + currentSession + " the test slot is now dead.");
     t.printStackTrace();
     return false;
   }
   return true;
 }