Example usage for org.openqa.selenium.remote CapabilityType APPLICATION_NAME

List of usage examples for org.openqa.selenium.remote CapabilityType APPLICATION_NAME

Introduction

In this page you can find the example usage for org.openqa.selenium.remote CapabilityType APPLICATION_NAME.

Prototype

String APPLICATION_NAME

To view the source code for org.openqa.selenium.remote CapabilityType APPLICATION_NAME.

Click Source Link

Usage

From source file:org.openqa.grid.internal.AddingProxyAgainFreesResources.java

License:Apache License

/**
 * create a hub with 1 node accepting 1 FF
 *
 * @throws InterruptedException//from   ww w  . j a v  a  2 s.  c  o m
 */
@BeforeClass
public static void setup() throws Exception {
    registry = Registry.newInstance();
    ff.put(CapabilityType.APPLICATION_NAME, "FF");
    p1 = RemoteProxyFactory.getNewBasicRemoteProxy(ff, "http://machine1:4444", registry);
    registry.add(p1);

    handler = GridHelper.createNewSessionHandler(registry, ff);

    // use all the spots ( so 1 ) of the grid so that a queue builds up
    handler.process();
    session = handler.getSession();

    // the test has been assigned.
    assertNotNull(session);

    // add the request to the queue

    handler2 = GridHelper.createNewSessionHandler(registry, ff);
    new Thread(new Runnable() { // Thread safety reviewed
        public void run() {
            handler2.process();
        }
    }).start();
    // the 1 slot of the node is used.
    assertEquals(1, p1.getTotalUsed());

    // registering the node again should discard the existing test. The node
    // will be fresh as far as the grid is concerned so the 2nd test that
    // was waiting in the queue should be processed.
    registry.add(p1);

}

From source file:org.openqa.grid.internal.BaseRemoteProxyTest.java

License:Apache License

@BeforeClass
public static void setup() throws Exception {

    app1Capability.put(CapabilityType.APPLICATION_NAME, "app1");
    app2Capability.put(CapabilityType.APPLICATION_NAME, "app2");

    p1 = RemoteProxyFactory.getNewBasicRemoteProxy(app1Capability, "http://machine1:4444/", registry);
    List<Map<String, Object>> caps = new ArrayList<>();
    caps.add(app1Capability);/*w  w  w  .  j  a  v  a2 s . c o m*/
    caps.add(app2Capability);
    p2 = RemoteProxyFactory.getNewBasicRemoteProxy(caps, "http://machine4:4444/", registry);

}

From source file:org.openqa.grid.internal.BaseRemoteProxyTest.java

License:Apache License

@Test(expected = GridException.class)
public void create() {
    Map<String, Object> cap = new HashMap<>();
    cap.put(CapabilityType.APPLICATION_NAME, "corrupted");

    GridNodeConfiguration config = new Gson().fromJson("{\"remoteHost\":\"ebay.com\"}",
            GridNodeConfiguration.class);
    config.capabilities.add(new DesiredCapabilities(cap));
    RegistrationRequest request = new RegistrationRequest(config);

    new BaseRemoteProxy(request, registry);
}

From source file:org.openqa.grid.internal.ConcurrencyLockTest.java

License:Apache License

/**
 * create a hub with 1 IE and 1 FF/* w w  w .  j  ava2s .co  m*/
 */
@BeforeClass
public static void setup() throws Exception {
    registry = Registry.newInstance();
    ie.put(CapabilityType.APPLICATION_NAME, "IE");
    ff.put(CapabilityType.APPLICATION_NAME, "FF");

    RemoteProxy p1 = RemoteProxyFactory.getNewBasicRemoteProxy(ie, "http://machine1:4444", registry);
    RemoteProxy p2 = RemoteProxyFactory.getNewBasicRemoteProxy(ff, "http://machine2:4444", registry);
    registry.add(p1);
    registry.add(p2);

}

From source file:org.openqa.grid.internal.ConcurrencyLockTest.java

License:Apache License

private void runTests2(Map<String, Object> cap) throws InterruptedException {

    MockedRequestHandler newSessionHandler = GridHelper.createNewSessionHandler(registry, cap);

    if (cap.get(CapabilityType.APPLICATION_NAME).equals("FF")) {
        // start the FF right away
        newSessionHandler.process();//www . j  a v  a  2  s . c o  m
        TestSession s = newSessionHandler.getSession();
        Thread.sleep(2000);
        results.add("FF");
        registry.terminateSynchronousFOR_TEST_ONLY(s);
    } else {
        // wait for 1 sec before starting IE to make sure the FF proxy is
        // busy with the 3 FF requests.
        Thread.sleep(1000);
        newSessionHandler.process();
        results.add("IE");
    }
    // at that point, the hub has recieved first 3 FF requests that are
    // queued and 1 IE request 1sec later, after the FF are already blocked
    // in the queue.The blocked FF request shouldn't block IE from starting,
    // so IE should be done first.
}

From source file:org.openqa.grid.internal.GridShutdownTest.java

License:Apache License

@Test(timeout = 5000)
public void shutdown() throws Exception {

    final Map<String, Object> ff = new HashMap<>();
    ff.put(CapabilityType.APPLICATION_NAME, "FF");
    ff.put(MAX_INSTANCES, 1);//from www  .ja va 2s.  co  m

    final Registry registry = Registry.newInstance();

    RemoteProxy p1 = RemoteProxyFactory.getNewBasicRemoteProxy(ff, "http://machine1:4444", registry);
    registry.add(p1);
    registry.setThrowOnCapabilityNotPresent(true);

    MockedRequestHandler newSessionRequest = GridHelper.createNewSessionHandler(registry, ff);
    newSessionRequest.process();

    final int before = getCurrentThreadCount();
    final CountDownLatch latch = new CountDownLatch(numRequests());
    List<Thread> threads = new ArrayList<>();
    for (int i = 0; i < numRequests(); i++) {
        final Thread thread = new Thread(new Runnable() { // Thread safety reviewed
            public void run() {
                latch.countDown();
                RequestHandler newSessionRequest = GridHelper.createNewSessionHandler(registry, ff);
                newSessionRequest.process();
            }
        }, "TestThread" + i);
        threads.add(thread);
        thread.start();
    }
    Thread.sleep(500);
    latch.await();
    assertEquals(before + numRequests(), getCurrentThreadCount());
    registry.stop();
    for (Thread thread : threads) {
        thread.join();
    }
    assertTrue(getCurrentThreadCount() <= before);
}

From source file:org.openqa.grid.internal.listener.CommandListenerTest.java

License:Apache License

@BeforeClass
public static void prepare() {
    app1.put(CapabilityType.APPLICATION_NAME, "app1");
    GridNodeConfiguration config = new GridNodeConfiguration();
    config.capabilities.add(new DesiredCapabilities(app1));
    req = new RegistrationRequest(config);
}

From source file:org.openqa.grid.internal.listener.RegistrationListenerTest.java

License:Apache License

@Before
public void prepareReqRequest() {
    app1.put(CapabilityType.APPLICATION_NAME, "app1");
    req = new RegistrationRequest();
    req.getConfiguration().capabilities.add(new DesiredCapabilities(app1));
    req.getConfiguration().host = "machine1";
    req.getConfiguration().port = 4444;/* www.  ja va2s. c  o  m*/
}

From source file:org.openqa.grid.internal.listener.SessionListenerTest.java

License:Apache License

@BeforeClass
public static void prepare() {
    app1.put(CapabilityType.APPLICATION_NAME, "app1");
    req = new RegistrationRequest();
    req.getConfiguration().capabilities.add(new DesiredCapabilities(app1));
}

From source file:org.openqa.grid.internal.listener.SessionListenerTest.java

License:Apache License

/**
 * using a proxy that times out instantly and spends a long time in the after method. check
 * aftermethod cannot be executed twice for a session.
 *//* w  ww.j a  va2s  .  co  m*/
@Test
public void doubleRelease() throws InterruptedException {
    RegistrationRequest req = new RegistrationRequest();
    Map<String, Object> cap = new HashMap<>();
    cap.put(CapabilityType.APPLICATION_NAME, "app1");
    req.getConfiguration().timeout = 1;
    req.getConfiguration().cleanUpCycle = 1;
    req.getConfiguration().maxSession = 2;
    req.getConfiguration().capabilities.add(new DesiredCapabilities(cap));

    Registry registry = Registry.newInstance();
    try {
        final SlowAfterSession proxy = new SlowAfterSession(req, registry);
        proxy.setupTimeoutListener();
        registry.add(proxy);

        RequestHandler r = GridHelper.createNewSessionHandler(registry, app1);
        r.process();
        TestSession session = r.getSession();

        Thread.sleep(1005);
        // the session has timed out -> doing the long after method.
        assertEquals(session.get("after"), true);

        // manually closing the session, starting a 2nd release process.
        registry.terminate(session, SessionTerminationReason.CLIENT_STOPPED_SESSION);

        // the 2nd release process shouldn't be executed as one is already
        // processed.
        assertNull(session.get("ERROR"));
    } finally {
        registry.stop();
    }

}