use of org.openqa.grid.internal.utils.configuration.GridHubConfiguration 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.internal.utils.configuration.GridHubConfiguration in project zalenium by zalando.
the class DockerSeleniumStarterRemoteProxyTest 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)
request = TestUtils.getRegistrationRequestForTesting(30000, DockerSeleniumStarterRemoteProxy.class.getCanonicalName());
// Creating the proxy
DockerSeleniumStarterRemoteProxy.setContainerClient(containerClient);
DockerSeleniumStarterRemoteProxy.setSleepIntervalMultiplier(0);
DockerSeleniumStarterRemoteProxy proxy = DockerSeleniumStarterRemoteProxy.getNewInstance(request, registry);
timeZone = DockerSeleniumStarterRemoteProxy.getConfiguredTimeZone();
screenSize = DockerSeleniumStarterRemoteProxy.getConfiguredScreenSize();
// Spying on the proxy to see if methods are invoked or not
spyProxy = spy(proxy);
}
use of org.openqa.grid.internal.utils.configuration.GridHubConfiguration in project zalenium by zalando.
the class ZaleniumRegistryTest method proxyIsRemoved.
@Test
public void proxyIsRemoved() throws Exception {
GridRegistry registry = ZaleniumRegistry.newInstance(new Hub(new GridHubConfiguration()));
DockerSeleniumRemoteProxy p1 = TestUtils.getNewBasicRemoteProxy("app1", "http://machine1:4444/", registry);
try {
registry.add(p1);
assertTrue(registry.getAllProxies().size() == 1);
registry.removeIfPresent(p1);
assertTrue(registry.getAllProxies().size() == 0);
} finally {
registry.stop();
}
}
use of org.openqa.grid.internal.utils.configuration.GridHubConfiguration in project zalenium by zalando.
the class LiveNodeServletTest method setUp.
@Before
public void setUp() throws IOException {
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()));
this.originalContainerClient = ContainerFactory.getContainerClientGenerator();
ContainerFactory.setContainerClientGenerator(DockerContainerMock::getMockedDockerContainerClient);
// Creating the configuration and the registration request of the proxy (node)
RegistrationRequest registrationRequest = TestUtils.getRegistrationRequestForTesting(40000, DockerSeleniumRemoteProxy.class.getCanonicalName());
registrationRequest.getConfiguration().capabilities.clear();
registrationRequest.getConfiguration().capabilities.addAll(DockerSeleniumStarterRemoteProxy.getCapabilities());
DockerSeleniumRemoteProxy proxyOne = DockerSeleniumRemoteProxy.getNewInstance(registrationRequest, registry);
registrationRequest = TestUtils.getRegistrationRequestForTesting(40001, DockerSeleniumRemoteProxy.class.getCanonicalName());
registrationRequest.getConfiguration().capabilities.clear();
registrationRequest.getConfiguration().capabilities.addAll(DockerSeleniumStarterRemoteProxy.getCapabilities());
DockerSeleniumRemoteProxy proxyTwo = DockerSeleniumRemoteProxy.getNewInstance(registrationRequest, registry);
registry.add(proxyOne);
registry.add(proxyTwo);
request = mock(HttpServletRequest.class);
response = mock(HttpServletResponse.class);
when(request.getParameter("refresh")).thenReturn("1");
when(request.getServerName()).thenReturn("localhost");
when(response.getOutputStream()).thenReturn(TestUtils.getMockedServletOutputStream());
}
use of org.openqa.grid.internal.utils.configuration.GridHubConfiguration in project zalenium by zalando.
the class VncAuthenticationServletTest method setUp.
@Before
public void setUp() throws IOException {
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()));
this.originalContainerClient = ContainerFactory.getContainerClientGenerator();
ContainerFactory.setContainerClientGenerator(DockerContainerMock::getMockedDockerContainerClient);
// Creating the configuration and the registration request of the proxy (node)
RegistrationRequest registrationRequest = TestUtils.getRegistrationRequestForTesting(40000, DockerSeleniumRemoteProxy.class.getCanonicalName());
registrationRequest.getConfiguration().capabilities.clear();
registrationRequest.getConfiguration().capabilities.addAll(DockerSeleniumStarterRemoteProxy.getCapabilities());
DockerSeleniumRemoteProxy proxyOne = DockerSeleniumRemoteProxy.getNewInstance(registrationRequest, registry);
registrationRequest = TestUtils.getRegistrationRequestForTesting(40001, DockerSeleniumRemoteProxy.class.getCanonicalName());
registrationRequest.getConfiguration().capabilities.clear();
registrationRequest.getConfiguration().capabilities.addAll(DockerSeleniumStarterRemoteProxy.getCapabilities());
DockerSeleniumRemoteProxy proxyTwo = DockerSeleniumRemoteProxy.getNewInstance(registrationRequest, registry);
registry.add(proxyOne);
registry.add(proxyTwo);
request = mock(HttpServletRequest.class);
response = mock(HttpServletResponse.class);
when(request.getParameter("refresh")).thenReturn("1");
when(request.getServerName()).thenReturn("localhost");
when(response.getOutputStream()).thenReturn(TestUtils.getMockedServletOutputStream());
}
Aggregations