There's no elegant way of doing this.
Here's a dirty hack using which you can get this done.
- Create a new marker interface (lets call it as
Registrable
)
- Create a new class whose contents duplicate the contents of
org.openqa.grid.selenium.proxy.DefaultRemoteProxy
(I like to call this approach as CLASSPATH overriding but am sure there's a much more elegant name for this ) such that this new class also is called DefaultRemoteProxy
and it resides in the same package org.openqa.grid.selenium.proxy
but in your test project.
- Now inside the constructor add an edit check as shown below.
- Now create an uber jar out of this project so that it can be used to spin off the Hub.
Here's how Registrable
would look like
public interface Registrable {}
Here's how the modified constructor of DefaultRemoteProxy
would look like :
public DefaultRemoteProxy(RegistrationRequest request, Registry registry) {
super(request, registry);
if (!(this instanceof Registrable)) {
throw new UnsupportedOperationException("Cannot proceed further");
}
pollingInterval = config.nodePolling != null ? config.nodePolling : DEFAULT_POLLING_INTERVAL;
unregisterDelay = config.unregisterIfStillDownAfter != null ? config.unregisterIfStillDownAfter : DEFAULT_UNREGISTER_DELAY;
downPollingLimit = config.downPollingLimit != null ? config.downPollingLimit : DEFAULT_DOWN_POLLING_LIMIT;
}
Now you can tweak your custom proxy such that it implements the Registrable
interface. So anyone trying to register their node using DefaultRemoteProxy
would constantly fail because DefaultRemoteProxy
doesn't implement Registrable
interface.
Would this work for you ?