use of org.openqa.selenium.remote.server.jmx.JMXHelper 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.selenium.remote.server.jmx.JMXHelper 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.selenium.remote.server.jmx.JMXHelper 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.selenium.remote.server.jmx.JMXHelper in project zalenium by zalando.
the class DockerSeleniumStarterRemoteProxyTest method fallbackToDefaultAmountValuesWhenVariablesAreNotIntegers.
@Test
public void fallbackToDefaultAmountValuesWhenVariablesAreNotIntegers() throws MalformedObjectNameException {
// Mock the environment class that serves as proxy to retrieve env variables
Environment environment = mock(Environment.class, withSettings().useConstructor());
when(environment.getEnvVariable(DockerSeleniumStarterRemoteProxy.ZALENIUM_DESIRED_CONTAINERS)).thenReturn("ABC_NON_INTEGER");
when(environment.getEnvVariable(DockerSeleniumStarterRemoteProxy.ZALENIUM_MAX_DOCKER_SELENIUM_CONTAINERS)).thenReturn("ABC_NON_INTEGER");
when(environment.getEnvVariable(DockerSeleniumStarterRemoteProxy.ZALENIUM_SCREEN_HEIGHT)).thenReturn("ABC_NON_INTEGER");
when(environment.getEnvVariable(DockerSeleniumStarterRemoteProxy.ZALENIUM_SCREEN_WIDTH)).thenReturn("ABC_NON_INTEGER");
when(environment.getEnvVariable(DockerSeleniumStarterRemoteProxy.ZALENIUM_TZ)).thenReturn("ABC_NON_STANDARD_TIME_ZONE");
when(environment.getIntEnvVariable(any(String.class), any(Integer.class))).thenCallRealMethod();
when(environment.getStringEnvVariable(any(String.class), any(String.class))).thenCallRealMethod();
DockerSeleniumStarterRemoteProxy.setEnv(environment);
try {
ObjectName objectName = new ObjectName("org.seleniumhq.grid:type=RemoteProxy,node=\"http://localhost:30000\"");
new JMXHelper().unregister(objectName);
} finally {
DockerSeleniumStarterRemoteProxy.getNewInstance(request, registry);
}
Assert.assertEquals(DockerSeleniumStarterRemoteProxy.DEFAULT_AMOUNT_DESIRED_CONTAINERS, DockerSeleniumStarterRemoteProxy.getDesiredContainersOnStartup());
Assert.assertEquals(DockerSeleniumStarterRemoteProxy.DEFAULT_AMOUNT_DOCKER_SELENIUM_CONTAINERS_RUNNING, DockerSeleniumStarterRemoteProxy.getMaxDockerSeleniumContainers());
Assert.assertEquals(DockerSeleniumStarterRemoteProxy.DEFAULT_SCREEN_SIZE.getHeight(), DockerSeleniumStarterRemoteProxy.getConfiguredScreenSize().getHeight());
Assert.assertEquals(DockerSeleniumStarterRemoteProxy.DEFAULT_SCREEN_SIZE.getWidth(), DockerSeleniumStarterRemoteProxy.getConfiguredScreenSize().getWidth());
Assert.assertEquals(DockerSeleniumStarterRemoteProxy.DEFAULT_TZ.getID(), DockerSeleniumStarterRemoteProxy.getConfiguredTimeZone().getID());
}
use of org.openqa.selenium.remote.server.jmx.JMXHelper in project zalenium by zalando.
the class DockerSeleniumStarterRemoteProxyTest method afterMethod.
@After
public void afterMethod() throws MalformedObjectNameException {
ObjectName objectName = new ObjectName("org.seleniumhq.grid:type=RemoteProxy,node=\"http://localhost:30000\"");
new JMXHelper().unregister(objectName);
registry.removeIfPresent(spyProxy);
DockerSeleniumStarterRemoteProxy.setSleepIntervalMultiplier(1000);
DockerSeleniumStarterRemoteProxy.restoreEnvironment();
DockerSeleniumStarterRemoteProxy.processedCapabilitiesList.clear();
ContainerFactory.setContainerClientGenerator(originalDockerContainerClient);
ContainerFactory.setIsKubernetes(originalIsKubernetesValue);
ContainerFactory.setKubernetesContainerClient(originalKubernetesContainerClient);
}
Aggregations