use of org.openqa.grid.common.RegistrationRequest in project zalenium by zalando.
the class TestUtils method getNewBasicRemoteProxy.
public static DockerSeleniumRemoteProxy getNewBasicRemoteProxy(String browser, String url, GridRegistry registry) throws MalformedURLException {
GridNodeConfiguration config = new GridNodeConfiguration();
URL u = new URL(url);
config.host = u.getHost();
config.port = u.getPort();
config.role = "webdriver";
RegistrationRequest req = RegistrationRequest.build(config);
req.getConfiguration().capabilities.clear();
DesiredCapabilities capability = new DesiredCapabilities();
capability.setBrowserName(browser);
req.getConfiguration().capabilities.add(capability);
return createProxy(registry, req);
}
use of org.openqa.grid.common.RegistrationRequest in project zalenium by zalando.
the class CloudTestingRemoteProxyTest method defaultValuesAreAlwaysNull.
@Test
public void defaultValuesAreAlwaysNull() {
try {
ObjectName objectName = new ObjectName("org.seleniumhq.grid:type=Hub");
ManagementFactory.getPlatformMBeanServer().getObjectInstance(objectName);
new JMXHelper().unregister(objectName);
} catch (MalformedObjectNameException | InstanceNotFoundException e) {
// Might be that the object does not exist, it is ok. Nothing to do, this is just a cleanup task.
}
GridRegistry registry = ZaleniumRegistry.newInstance(new Hub(new GridHubConfiguration()));
RegistrationRequest request = TestUtils.getRegistrationRequestForTesting(30003, CloudTestingRemoteProxy.class.getCanonicalName());
CloudTestingRemoteProxy proxy = CloudTestingRemoteProxy.getNewInstance(request, registry);
Assert.assertNull(proxy.getAccessKeyProperty());
Assert.assertNull(proxy.getAccessKeyValue());
Assert.assertNotNull(proxy.getCloudTestingServiceUrl());
Assert.assertNull(proxy.getUserNameProperty());
Assert.assertNull(proxy.getUserNameValue());
Assert.assertNotNull(proxy.getRemoteHost());
Assert.assertNull(proxy.getVideoFileExtension());
Assert.assertNull(proxy.getProxyName());
Assert.assertNull(proxy.getProxyClassName());
Assert.assertNull(proxy.getTestInformation("seleniumSessionId"));
}
use of org.openqa.grid.common.RegistrationRequest in project carina by qaprosoft.
the class ProxyInfo method process.
protected void process(HttpServletRequest request, HttpServletResponse response) throws IOException {
List<RegistrationRequest> proxies = new ArrayList<>();
Iterator<RemoteProxy> itr = this.getRegistry().getAllProxies().iterator();
while (itr.hasNext()) {
RemoteProxy proxy = itr.next();
proxies.add(proxy.getOriginalRegistrationRequest());
}
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
try {
mapper.writeValue(response.getWriter(), proxies);
response.setStatus(HttpStatus.SC_OK);
} catch (Exception e) {
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
} finally {
response.getWriter().close();
}
}
use of org.openqa.grid.common.RegistrationRequest in project zalenium by zalando.
the class DockerSeleniumRemoteProxyTest method setUp.
@Before
public void setUp() {
// Change the factory to return our version of the Container Client
if (this.currentIsKubernetesValue.get()) {
// This is needed in order to use a fresh version of the mock, otherwise the return values
// are gone, and returning them always is not the normal behaviour.
this.containerClient = KubernetesContainerMock.getMockedKubernetesContainerClient();
ContainerFactory.setKubernetesContainerClient((KubernetesContainerClient) containerClient);
} else {
ContainerFactory.setContainerClientGenerator(() -> containerClient);
}
ContainerFactory.setIsKubernetes(this.currentIsKubernetesValue);
try {
ObjectName objectName = new ObjectName("org.seleniumhq.grid:type=Hub");
ManagementFactory.getPlatformMBeanServer().getObjectInstance(objectName);
new JMXHelper().unregister(objectName);
} catch (MalformedObjectNameException | InstanceNotFoundException e) {
// Might be that the object does not exist, it is ok. Nothing to do, this is just a cleanup task.
}
registry = ZaleniumRegistry.newInstance(new Hub(new GridHubConfiguration()));
// Creating the configuration and the registration request of the proxy (node)
RegistrationRequest request = TestUtils.getRegistrationRequestForTesting(40000, DockerSeleniumRemoteProxy.class.getCanonicalName());
request.getConfiguration().capabilities.clear();
request.getConfiguration().capabilities.addAll(TestUtils.getDockerSeleniumCapabilitiesForTesting());
// Creating the proxy
proxy = DockerSeleniumRemoteProxy.getNewInstance(request, registry);
proxy.setContainerClient(containerClient);
}
use of org.openqa.grid.common.RegistrationRequest in project zalenium by zalando.
the class SauceLabsRemoteProxyTest method nodeHasCapabilitiesEvenWhenUrlCallFails.
@SuppressWarnings("ConstantConditions")
@Test
public void nodeHasCapabilitiesEvenWhenUrlCallFails() {
try {
CommonProxyUtilities commonProxyUtilities = mock(CommonProxyUtilities.class);
when(commonProxyUtilities.readJSONFromUrl(anyString(), anyString(), anyString())).thenReturn(null);
SauceLabsRemoteProxy.setCommonProxyUtilities(commonProxyUtilities);
RegistrationRequest request = TestUtils.getRegistrationRequestForTesting(30001, SauceLabsRemoteProxy.class.getCanonicalName());
request = SauceLabsRemoteProxy.updateSLCapabilities(request, "");
// Now the capabilities should be filled even if the url was not fetched
Assert.assertFalse(request.getConfiguration().capabilities.isEmpty());
} finally {
SauceLabsRemoteProxy.restoreCommonProxyUtilities();
}
}
Aggregations