use of org.openqa.selenium.remote.server.jmx.JMXHelper in project zalenium by zalando.
the class BrowserStackRemoteProxyTest method setUp.
@SuppressWarnings("ConstantConditions")
@Before
public void setUp() {
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(30002, BrowserStackRemoteProxy.class.getCanonicalName());
CommonProxyUtilities commonProxyUtilities = mock(CommonProxyUtilities.class);
when(commonProxyUtilities.readJSONFromUrl(anyString(), anyString(), anyString())).thenReturn(null);
BrowserStackRemoteProxy.setCommonProxyUtilities(commonProxyUtilities);
browserStackProxy = BrowserStackRemoteProxy.getNewInstance(request, registry);
// we need to register a DockerSeleniumStarter proxy to have a proper functioning BrowserStackProxy
request = TestUtils.getRegistrationRequestForTesting(30000, DockerSeleniumStarterRemoteProxy.class.getCanonicalName());
DockerSeleniumStarterRemoteProxy dsStarterProxy = DockerSeleniumStarterRemoteProxy.getNewInstance(request, registry);
// We add both nodes to the registry
registry.add(browserStackProxy);
registry.add(dsStarterProxy);
}
use of org.openqa.selenium.remote.server.jmx.JMXHelper in project zalenium by zalando.
the class BrowserStackRemoteProxyTest method tearDown.
@After
public void tearDown() throws MalformedObjectNameException {
ObjectName objectName = new ObjectName("org.seleniumhq.grid:type=RemoteProxy,node=\"http://hub-cloud.browserstack.com:80\"");
new JMXHelper().unregister(objectName);
objectName = new ObjectName("org.seleniumhq.grid:type=RemoteProxy,node=\"http://localhost:30000\"");
new JMXHelper().unregister(objectName);
BrowserStackRemoteProxy.restoreCommonProxyUtilities();
BrowserStackRemoteProxy.restoreGa();
BrowserStackRemoteProxy.restoreEnvironment();
}
Aggregations