org.openqa.grid.internal
Class TestSession

java.lang.Object
  extended by org.openqa.grid.internal.TestSession

public class TestSession
extends Object

Represent a running test for the hub/registry. A test session is created when a TestSlot becomes available for a test. The session is destroyed when the test ends ( ended by the client or timed out)


Method Summary
 boolean equals(Object obj)
           
 void forward(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Forward the request to the remote, execute the TestSessionListeners if applicable.
 String forward(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String content, boolean interceptResponseBody)
          Forward the request to the remote.
 Object get(String key)
          Allow you to retrieve an object previously stored on the test session.
 String getExternalKey()
          Get the session key from the remote.
 long getInactivityTime()
          give the time in milliseconds since the last access to this test session, or 0 is ignore time out has been set to true.
 String getInternalKey()
           
 Map<String,Object> getRequestedCapabilities()
          the capabilities the client requested.
 TestSlot getSlot()
           
 int hashCode()
           
 void put(String key, Object value)
          Allows you to store an object on the test session.
 boolean sendDeleteSessionRequest()
          Sends a DELETE session command to the remote, following web driver protocol.
 boolean sendSelenium1TestComplete(TestSession session)
          Sends a cmd=testComplete command to the remote, following selenium1 protocol.
 void setExternalKey(String externalKey)
          associate this session to the session provided by the remote.
 void setIgnoreTimeout(boolean ignore)
          allow to bypass time out for this session. ignore = true => the session will not time out. setIgnoreTimeout(true) also update the lastActivity to now.
 void terminate()
          Ends this test session for the hub, releasing the resources in the hub / registry.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getInternalKey

public String getInternalKey()

getRequestedCapabilities

public Map<String,Object> getRequestedCapabilities()
the capabilities the client requested. It will match the TestSlot capabilities, but is not equals.

Returns:

getExternalKey

public String getExternalKey()
Get the session key from the remote. It's up to the remote to guarantee the key is unique. If 2 remotes return the same session key, the tests will overwrite each other.

Returns:
the key that was provided by the remote when the POST /session command was sent.

setExternalKey

public void setExternalKey(String externalKey)
associate this session to the session provided by the remote.

Parameters:
externalKey -

getInactivityTime

public long getInactivityTime()
give the time in milliseconds since the last access to this test session, or 0 is ignore time out has been set to true.

Returns:
time in millis
See Also:
setIgnoreTimeout(boolean)

getSlot

public TestSlot getSlot()
Returns:
the TestSlot this session is executed against.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

forward

public void forward(javax.servlet.http.HttpServletRequest request,
                    javax.servlet.http.HttpServletResponse response)
             throws IOException
Forward the request to the remote, execute the TestSessionListeners if applicable.

Parameters:
request -
response -
Throws:
IOException

forward

public String forward(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response,
                      String content,
                      boolean interceptResponseBody)
               throws IOException
Forward the request to the remote.

Parameters:
request -
response -
content - Overwrite the body. Useful when the body of the request was already read.
interceptResponseBody - for selenium1 protocol, you need to read the content of the response to find the session.
Returns:
the content of the response if interceptResponseBody=true. null otherwise
Throws:
IOException

get

public Object get(String key)
Allow you to retrieve an object previously stored on the test session.

Parameters:
key -
Returns:
the object you stored

put

public void put(String key,
                Object value)
Allows you to store an object on the test session.

Parameters:
key -
value -

terminate

public void terminate()
Ends this test session for the hub, releasing the resources in the hub / registry. It does not release anything on the remote. The resources are released in a separate thread, so the call returns immediatly. It allows release with long duration not to block the test while the hub is releasing the resource.


sendDeleteSessionRequest

public boolean sendDeleteSessionRequest()
Sends a DELETE session command to the remote, following web driver protocol.

Returns:
true is the remote replied successfully to the request.

sendSelenium1TestComplete

public boolean sendSelenium1TestComplete(TestSession session)
                                  throws org.apache.http.client.ClientProtocolException,
                                         IOException
Sends a cmd=testComplete command to the remote, following selenium1 protocol.

Returns:
true is the remote replied successfully to the request.
Throws:
org.apache.http.client.ClientProtocolException
IOException

setIgnoreTimeout

public void setIgnoreTimeout(boolean ignore)
allow to bypass time out for this session. ignore = true => the session will not time out. setIgnoreTimeout(true) also update the lastActivity to now.

Parameters:
ignore -


Copyright © 2011. All Rights Reserved.