本文整理汇总了Java中org.openqa.grid.internal.TestSession类的典型用法代码示例。如果您正苦于以下问题:Java TestSession类的具体用法?Java TestSession怎么用?Java TestSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestSession类属于org.openqa.grid.internal包,在下文中一共展示了TestSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNewSession
import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Override
public TestSession getNewSession(Map<String, Object> requestedCapability) {
if (counter.get() > ConfigReader.getInstance().getMaxSession()) {
LOG.info("Waiting for remote nodes to be available");
return null;
}
if (LOG.isLoggable(Level.FINE)) {
LOG.fine(String.format("Trying to create a new session on node %s", this));
}
// any slot left for the given app ?
for (TestSlot testslot : getTestSlots()) {
TestSession session = testslot.getNewSession(requestedCapability);
if (session != null) {
return session;
}
}
return null;
}
示例2: beforeCommand
import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Override
public void beforeCommand(TestSession session, HttpServletRequest request, HttpServletResponse response) {
RequestType type = identifyRequestType(request);
if (type == START_SESSION) {
try {
if (processTestSession(session)) {
startServerForTestSession(session);
} else {
String msg = "Missing target mapping. Available mappings are " +
ConfigReader.getInstance().getMapping();
throw new IllegalStateException(msg);
}
} catch (Exception e) {
getRegistry().terminate(session, SessionTerminationReason.CREATIONFAILED);
LOG.severe("Failed creating a session. Root cause :" + e.getMessage());
throw e;
}
}
super.beforeCommand(session, request, response);
}
示例3: beforeSession
import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Override
public void beforeSession(TestSession session) {
super.beforeSession(session);
HttpPost r = new HttpPost(serviceUrl + "?command=start");
try {
HttpResponse response = client.execute(remoteHost, r);
if(response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
log.warning("Could not start video reporting: " + EntityUtils.toString(response.getEntity()));
return;
}
log.info("Started recording for new session on node: " + getId());
} catch (Exception e) {
log.warning("Could not start video reporting due to exception: " + e.getMessage());
e.printStackTrace();
}
finally {
r.releaseConnection();
}
}
示例4: afterSession
import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Override
public void afterSession(TestSession session) {
super.afterSession(session);
HttpPost r = new HttpPost(serviceUrl + "?command=stop");
try {
HttpResponse response = client.execute(remoteHost, r);
if(response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
log.warning("Could not stop video reporting: " + EntityUtils.toString(response.getEntity()));
return;
}
log.info("Stopped recording for new session on node: " + getId());
} catch (Exception e) {
log.warning("Could not stop video reporting due to exception: " + e.getMessage());
e.printStackTrace();
}
finally {
r.releaseConnection();
}
}
示例5: getNumInProgressTests
import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public int getNumInProgressTests(ProxySet proxySet, AutomationRunRequest runRequest) {
int inProgressTests = 0;
for(RemoteProxy proxy : proxySet) {
for(TestSlot testSlot : proxy.getTestSlots() ) {
TestSession session = testSlot.getSession();
if(session != null) {
if(runRequest.matchesCapabilities(session.getRequestedCapabilities())) {
inProgressTests++;
}
}
}
}
return inProgressTests;
}
示例6: afterCommand
import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Override
public void afterCommand(TestSession session, HttpServletRequest request, HttpServletResponse response) {
super.afterCommand(session, request, response);
RequestType type = identifyRequestType(request);
if (type == STOP_SESSION) {
stopServerForTestSession(session);
if (LOG.isLoggable(Level.INFO)) {
LOG.info(String.format("Counter value after decrementing : %d", counter.decrementAndGet()));
}
}
}
示例7: startServerForTestSession
import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
private void startServerForTestSession(TestSession session) {
try {
SpawnedServer server = SpawnedServer.spawnInstance(session);
String key = "http://" + server.getHost() + ":" + server.getPort();
URL url = new URL(key);
servers.put(key, server);
((ProxiedTestSlot) session.getSlot()).setRemoteURL(url);
if (LOG.isLoggable(Level.INFO)) {
LOG.info(String.format("Forwarding session to :%s", session.getSlot().getRemoteURL()));
LOG.info(String.format("Counter value after incrementing : %d", counter.incrementAndGet()));
}
} catch (Exception e) {
throw new GridException(e.getMessage(), e);
}
}
示例8: stopServerForTestSession
import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
private void stopServerForTestSession(TestSession session) {
URL url = session.getSlot().getRemoteURL();
String key = String.format("%s://%s:%d", url.getProtocol(), url.getHost(), url.getPort());
SpawnedServer localServer = servers.get(key);
if (localServer != null) {
localServer.shutdown();
servers.remove(key);
}
}
示例9: spawnInstance
import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
public static SpawnedServer spawnInstance(TestSession session) throws Exception {
SpawnedServer server = new SpawnedServer();
AtomicInteger attempts = new AtomicInteger(0);
String browser = (String) session.getRequestedCapabilities().get(CapabilityType.BROWSER_NAME);
server.server = newInstance(browser);
int port = server.server.startServer(session);
do {
TimeUnit.SECONDS.sleep(2);
} while (!server.server.isServerRunning() && attempts.incrementAndGet() <= 5);
if (LOG.isLoggable(Level.WARNING)) {
LOG.warning(String.format("***Server started on [%d]****", port));
}
return server;
}
示例10: startServer
import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Override
public int startServer(TestSession session) throws ServerException {
try {
String browser = (String) session.getRequestedCapabilities().get(CapabilityType.BROWSER_NAME);
String image = ConfigReader.getInstance().getMapping().get(browser).getTarget();
containerInfo = DockerHelper.startContainerFor(image, isPrivileged(), getDeviceInfos());
return containerInfo.getPort();
} catch (DockerException | InterruptedException e) {
throw new ServerException(e.getMessage(), e);
}
}
示例11: startServer
import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Override
public int startServer(TestSession session) throws ServerException {
port = PortProber.findFreePort();
String[] args = getArgs(port);
if (LOG.isLoggable(Level.INFO)) {
LOG.info(String.format("Spawning a Selenium server using the arguments [%s]", Arrays.toString(args)));
}
ProcessBuilder pb = new ProcessBuilder(getArgs(port));
try {
this.process = pb.start();
return port;
} catch (Exception e) {
throw new ServerException(e.getMessage(), e);
}
}
示例12: afterSession
import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
public void afterSession(TestSession session) {
if (this.hasRecordingStarted == true) {
final String key = session.getInternalKey();
HttpGetHelper helper = new HttpGetHelper(String.format(
STOP_RECORDING_STRING, nodeUrl, key));
try {
helper.execute();
hasRecordingStarted = false;
} catch (Exception err) {
System.out
.println("Error occurred while stopping the recording "
+ err.getMessage());
}
}
}
示例13: getRemoteHostForSession
import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
public URL getRemoteHostForSession(String sessionId) {
for (TestSession activeSession : registry.getActiveSessions()) {
if (sessionId.equals(activeSession.getExternalKey().getKey())) {
return activeSession.getSlot().getProxy().getRemoteHost();
}
}
throw new IllegalArgumentException("Invalid sessionId. No active session is present for id:" + sessionId);
}
示例14: refreshTimeout
import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
public void refreshTimeout(String sessionId) {
for (TestSession activeSession : registry.getActiveSessions()) {
if (sessionId.equals(activeSession.getExternalKey().getKey())) {
refreshTimeout(activeSession);
}
}
}
示例15: setUp
import org.openqa.grid.internal.TestSession; //导入依赖的package包/类
@Before
public void setUp() {
seleniumSessions = new SeleniumSessions(registry);
activeSession = spy(new TestSession(null, null, Clock.systemDefaultZone()));
when(activeSession.getExternalKey()).thenReturn(externalSessionKey);
when(externalSessionKey.getKey()).thenReturn("sessionId");
when(registry.getActiveSessions()).thenReturn(Sets.newHashSet(activeSession));
}