public class DefaultRemoteProxy extends BaseRemoteProxy implements TimeoutListener, SelfHealingProxy, CommandListener, TestSessionListener
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_DOWN_POLLING_LIMIT |
static int |
DEFAULT_POLLING_INTERVAL |
static int |
DEFAULT_UNREGISTER_DELAY |
remoteHost
Constructor and Description |
---|
DefaultRemoteProxy(RegistrationRequest request,
Registry registry) |
Modifier and Type | Method and Description |
---|---|
void |
addNewEvent(RemoteException event)
Allow to record when something important about the remote state is detected.
|
void |
afterCommand(TestSession session,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Executed just before the forwards returns.
|
void |
afterSession(TestSession session)
Will be run after the last command is forwarded, but before the proxy slot is released.
|
void |
beforeCommand(TestSession session,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Executed before the hub forwards the request.
|
void |
beforeRelease(TestSession session)
Gives a chance to clean the resources on the remote when the session has timed out.
|
void |
beforeSession(TestSession session)
The client shouldn't have to care where firefox is installed as long as the correct version is
launched, however with webdriver the binary location is specified in the desiredCapability,
making it the responsibility of the person running the test.
|
HtmlRenderer |
getHtmlRender()
Returns the object responsible for rendering any information about the proxy in a Web application.
|
TestSession |
getNewSession(Map<String,Object> requestedCapability)
overwrites the session allocation to discard the proxy that are down.
|
boolean |
isAlive() |
boolean |
isDown() |
void |
onEvent(List<RemoteException> events,
RemoteException lastInserted)
Allow to process the list of all the events that were detected on this Remote so far.
|
void |
startPolling()
start/restart the polling for the remote proxy.
|
void |
stopPolling()
put the polling on hold.
|
void |
teardown()
If the RemoteProxy implementation also implements TimeoutListener, then this method
will stop the thread used to monitor timeouts.
|
compareTo, equals, forceSlotCleanerRun, getCapabilityHelper, getConfig, getHttpClientFactory, getId, getMaxNumberOfConcurrentTestSessions, getNewInstance, getOriginalRegistrationRequest, getRegistry, getRemoteHost, getResourceUsageInPercent, getStatus, getTestSlots, getTimeOut, getTotalUsed, hasCapability, hashCode, isBusy, setupTimeoutListener, toString
public static final int DEFAULT_POLLING_INTERVAL
public static final int DEFAULT_UNREGISTER_DELAY
public static final int DEFAULT_DOWN_POLLING_LIMIT
public DefaultRemoteProxy(RegistrationRequest request, Registry registry)
public void beforeRelease(TestSession session)
TimeoutListener
Is executed before the session is released to the hub. If an exception is thrown, the slot that was associated with the session is considered corrupted and won't be released for future use.
You can check session.getInternalKey before timing out. internalkey==null usually means the initial POST /session hasn't been completed yet.For instance if you use web driver, that means the browser is in the process of being started. During that state, you can't really clean the resources properly.
beforeRelease
in interface TimeoutListener
session
- sessionpublic void afterCommand(TestSession session, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
CommandListener
Throwing an exception will result in an error for the client.
afterCommand
in interface CommandListener
session
- sessionrequest
- requestresponse
- responsepublic void beforeCommand(TestSession session, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
CommandListener
Throwing an exception will prevent the forward to the remote.
beforeCommand
in interface CommandListener
session
- sessionrequest
- requestresponse
- responsepublic HtmlRenderer getHtmlRender()
RemoteProxy
getHtmlRender
in interface RemoteProxy
getHtmlRender
in class BaseRemoteProxy
public boolean isAlive()
public void startPolling()
SelfHealingProxy
startPolling
in interface SelfHealingProxy
public void stopPolling()
SelfHealingProxy
stopPolling
in interface SelfHealingProxy
public void addNewEvent(RemoteException event)
SelfHealingProxy
addNewEvent
in interface SelfHealingProxy
event
- RemoteException event to be called when something happenspublic void onEvent(List<RemoteException> events, RemoteException lastInserted)
SelfHealingProxy
onEvent
in interface SelfHealingProxy
events
- list of RemoteExceptions occurredlastInserted
- last event that occurredpublic TestSession getNewSession(Map<String,Object> requestedCapability)
getNewSession
in interface RemoteProxy
getNewSession
in class BaseRemoteProxy
requestedCapability
- the type of test the client is interested in performing.null
otherwisepublic boolean isDown()
public void beforeSession(TestSession session)
For instance if a node registers: {"browserName":"firefox","version":"7.0","firefox_binary":"/home/ff7"} and later on a client requests {"browserName":"firefox","version":"7.0"} , the hub will automatically append the correct binary path to the desiredCapability before it's forwarded to the server. That way the version / install location mapping is done only once at the node level.
beforeSession
in interface TestSessionListener
session
- sessionif the setup applies to all the tests.
public void afterSession(TestSession session)
TestSessionListener
If the test crashes before a session is provided by the remote, session.externalKey will be null.
WARNING : after session should NOT throw exception. If an exception is thrown, the resources will NOT be released, as it could mean the remote is now corrupted.
afterSession
in interface TestSessionListener
session
- sessionpublic void teardown()
RemoteProxy
teardown
in interface RemoteProxy
teardown
in class BaseRemoteProxy
Copyright © 2015. All rights reserved.