use of de.zalando.ep.zalenium.util.DockerContainerMock 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 de.zalando.ep.zalenium.util.DockerContainerMock 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());
}
use of de.zalando.ep.zalenium.util.DockerContainerMock in project zalenium by zalando.
the class ZaleniumConsoleServletTest 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(30000, DockerSeleniumStarterRemoteProxy.class.getCanonicalName());
DockerSeleniumStarterRemoteProxy proxyZero = DockerSeleniumStarterRemoteProxy.getNewInstance(registrationRequest, registry);
registrationRequest = TestUtils.getRegistrationRequestForTesting(30001, SauceLabsRemoteProxy.class.getCanonicalName());
CommonProxyUtilities commonProxyUtilities = mock(CommonProxyUtilities.class);
when(commonProxyUtilities.readJSONFromUrl(anyString(), anyString(), anyString())).thenReturn(null);
SauceLabsRemoteProxy.setCommonProxyUtilities(commonProxyUtilities);
SauceLabsRemoteProxy sauceLabsProxy = SauceLabsRemoteProxy.getNewInstance(registrationRequest, registry);
registrationRequest = TestUtils.getRegistrationRequestForTesting(30002, BrowserStackRemoteProxy.class.getCanonicalName());
BrowserStackRemoteProxy.setCommonProxyUtilities(commonProxyUtilities);
BrowserStackRemoteProxy browserStackRemoteProxy = BrowserStackRemoteProxy.getNewInstance(registrationRequest, registry);
registrationRequest = TestUtils.getRegistrationRequestForTesting(30003, TestingBotRemoteProxy.class.getCanonicalName());
TestingBotRemoteProxy.setCommonProxyUtilities(commonProxyUtilities);
TestingBotRemoteProxy testingBotRemoteProxy = TestingBotRemoteProxy.getNewInstance(registrationRequest, registry);
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();
List<MutableCapabilities> capabilities = DockerSeleniumStarterRemoteProxy.getCapabilities();
MutableCapabilities desiredCapabilities = new MutableCapabilities();
desiredCapabilities.setCapability(CapabilityType.BROWSER_NAME, "NEW_BROWSER");
desiredCapabilities.setCapability(CapabilityType.PLATFORM_NAME, Platform.LINUX);
desiredCapabilities.setCapability(RegistrationRequest.MAX_INSTANCES, 1);
capabilities.add(desiredCapabilities);
registrationRequest.getConfiguration().capabilities.addAll(capabilities);
DockerSeleniumRemoteProxy proxyTwo = DockerSeleniumRemoteProxy.getNewInstance(registrationRequest, registry);
registry.add(proxyZero);
registry.add(proxyOne);
registry.add(proxyTwo);
registry.add(sauceLabsProxy);
registry.add(browserStackRemoteProxy);
registry.add(testingBotRemoteProxy);
request = mock(HttpServletRequest.class);
response = mock(HttpServletResponse.class);
when(request.getParameter("config")).thenReturn("true");
when(request.getParameter("configDebug")).thenReturn("true");
when(request.getServerName()).thenReturn("localhost");
when(response.getOutputStream()).thenReturn(TestUtils.getMockedServletOutputStream());
}
Aggregations