Search in sources :

Example 1 with RequestHandler

use of org.openqa.grid.web.servlet.handler.RequestHandler in project zalenium by zalando.

the class ZaleniumRegistryTest method sessionIsProcessed.

@Test
public void sessionIsProcessed() {
    Map<String, Object> requestedCapability = new HashMap<>();
    requestedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
    requestedCapability.put(CapabilityType.PLATFORM_NAME, Platform.LINUX);
    GridRegistry registry = ZaleniumRegistry.newInstance(new Hub(new GridHubConfiguration()));
    RegistrationRequest req = TestUtils.getRegistrationRequestForTesting(40000, DockerSeleniumRemoteProxy.class.getCanonicalName());
    req.getConfiguration().capabilities.clear();
    req.getConfiguration().capabilities.addAll(TestUtils.getDockerSeleniumCapabilitiesForTesting());
    DockerSeleniumRemoteProxy p1 = new DockerSeleniumRemoteProxy(req, registry);
    try {
        registry.add(p1);
        RequestHandler newSessionRequest = TestUtils.createNewSessionHandler(registry, requestedCapability);
        newSessionRequest.process();
        TestSession session = newSessionRequest.getSession();
        session.setExternalKey(new ExternalSessionKey(UUID.randomUUID().toString()));
        registry.terminate(session, SessionTerminationReason.CLIENT_STOPPED_SESSION);
        Callable<Boolean> callable = () -> registry.getActiveSessions().size() == 0;
        await().pollInterval(Duration.FIVE_HUNDRED_MILLISECONDS).atMost(Duration.TWO_SECONDS).until(callable);
    } finally {
        registry.stop();
    }
}
Also used : ExternalSessionKey(org.openqa.grid.internal.ExternalSessionKey) HashMap(java.util.HashMap) DockerSeleniumRemoteProxy(de.zalando.ep.zalenium.proxy.DockerSeleniumRemoteProxy) RegistrationRequest(org.openqa.grid.common.RegistrationRequest) GridRegistry(org.openqa.grid.internal.GridRegistry) Hub(org.openqa.grid.web.Hub) RequestHandler(org.openqa.grid.web.servlet.handler.RequestHandler) TestSession(org.openqa.grid.internal.TestSession) GridHubConfiguration(org.openqa.grid.internal.utils.configuration.GridHubConfiguration) Test(org.junit.Test)

Aggregations

DockerSeleniumRemoteProxy (de.zalando.ep.zalenium.proxy.DockerSeleniumRemoteProxy)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 RegistrationRequest (org.openqa.grid.common.RegistrationRequest)1 ExternalSessionKey (org.openqa.grid.internal.ExternalSessionKey)1 GridRegistry (org.openqa.grid.internal.GridRegistry)1 TestSession (org.openqa.grid.internal.TestSession)1 GridHubConfiguration (org.openqa.grid.internal.utils.configuration.GridHubConfiguration)1 Hub (org.openqa.grid.web.Hub)1 RequestHandler (org.openqa.grid.web.servlet.handler.RequestHandler)1