use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class DockerSeleniumRemoteProxyTest method testIsMarkedAsPassedAndFailedWithCookie.
@Test
public void testIsMarkedAsPassedAndFailedWithCookie() {
// Supported desired capability for the test session
Map<String, Object> requestedCapability = getCapabilitySupportedByDockerSelenium();
// Start polling thread
proxy.startPolling();
// Get a test session
TestSession newSession = proxy.getNewSession(requestedCapability);
Assert.assertNotNull(newSession);
// The node should be busy since there is a session in it
Assert.assertTrue(proxy.isBusy());
// We release the session, the node should be free
WebDriverRequest request = mock(WebDriverRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
when(request.getMethod()).thenReturn("POST");
when(request.getRequestType()).thenReturn(RequestType.REGULAR);
when(request.getPathInfo()).thenReturn("/cookie");
when(request.getBody()).thenReturn("{\"cookie\": {\"name\": \"zaleniumTestPassed\", \"value\": true}}");
proxy.beforeCommand(newSession, request, response);
Assert.assertEquals(TestInformation.TestStatus.SUCCESS, proxy.getTestInformation().getTestStatus());
when(request.getBody()).thenReturn("{\"cookie\": {\"name\": \"zaleniumTestPassed\", \"value\": false}}");
proxy.beforeCommand(newSession, request, response);
Assert.assertEquals(TestInformation.TestStatus.FAILED, proxy.getTestInformation().getTestStatus());
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class DockerSeleniumRemoteProxyTest method nodeShutsDownWhenTestIsIdle.
@Test
public void nodeShutsDownWhenTestIsIdle() {
// Supported desired capability for the test session
Map<String, Object> requestedCapability = getCapabilitySupportedByDockerSelenium();
requestedCapability.put("idleTimeout", 1L);
DockerSeleniumRemoteProxy spyProxy = spy(proxy);
// Start pulling thread
spyProxy.startPolling();
// Get a test session
TestSession newSession = spyProxy.getNewSession(requestedCapability);
Assert.assertNotNull(newSession);
// Start the session
WebDriverRequest webDriverRequest = mock(WebDriverRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
when(webDriverRequest.getMethod()).thenReturn("POST");
when(webDriverRequest.getRequestType()).thenReturn(RequestType.START_SESSION);
when(webDriverRequest.getPathInfo()).thenReturn("/something");
spyProxy.beforeCommand(newSession, webDriverRequest, response);
// The node should be busy since there is a session in it
Assert.assertTrue(spyProxy.isBusy());
// The node should tear down after the maximum idle time is elapsed
Assert.assertTrue(spyProxy.isBusy());
Callable<Boolean> callable = () -> registry.getProxyById(spyProxy.getId()) == null;
await().pollInterval(Duration.FIVE_HUNDRED_MILLISECONDS).atMost(Duration.FIVE_SECONDS).until(callable);
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class DockerSeleniumStarterRemoteProxyTest method containerIsStartedWhenScreenResolutionIsProvided.
@Test
public void containerIsStartedWhenScreenResolutionIsProvided() {
// Supported desired capability for the test session
Dimension customScreenSize = new Dimension(1280, 760);
Map<String, Object> supportedCapability = new HashMap<>();
supportedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.FIREFOX);
supportedCapability.put(CapabilityType.PLATFORM_NAME, Platform.ANY);
String screenResolution = String.format("%sx%s", customScreenSize.getWidth(), customScreenSize.getHeight());
supportedCapability.put("screenResolution", screenResolution);
TestSession testSession = spyProxy.getNewSession(supportedCapability);
Assert.assertNull(testSession);
verify(spyProxy, timeout(1000).times(1)).startDockerSeleniumContainer(timeZone, customScreenSize);
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class DockerSeleniumStarterRemoteProxyTest method noContainerIsStartedWhenBrowserCapabilityIsAbsent.
@Test
public void noContainerIsStartedWhenBrowserCapabilityIsAbsent() {
// Browser is absent
Map<String, Object> nonSupportedCapability = new HashMap<>();
nonSupportedCapability.put(CapabilityType.PLATFORM_NAME, Platform.LINUX);
TestSession testSession = spyProxy.getNewSession(nonSupportedCapability);
Assert.assertNull(testSession);
verify(spyProxy, never()).startDockerSeleniumContainer(timeZone, screenSize);
verify(spyProxy, never()).startDockerSeleniumContainer(timeZone, screenSize);
}
use of org.openqa.grid.internal.TestSession in project zalenium by zalando.
the class DockerSeleniumStarterRemoteProxyTest method containerIsStartedWhenChromeCapabilitiesAreSupported.
@Test
public void containerIsStartedWhenChromeCapabilitiesAreSupported() {
// Supported desired capability for the test session
Map<String, Object> supportedCapability = new HashMap<>();
supportedCapability.put(CapabilityType.BROWSER_NAME, BrowserType.CHROME);
supportedCapability.put(CapabilityType.PLATFORM_NAME, Platform.LINUX);
TestSession testSession = spyProxy.getNewSession(supportedCapability);
Assert.assertNull(testSession);
verify(spyProxy, timeout(1000).times(1)).startDockerSeleniumContainer(timeZone, screenSize);
}
Aggregations