当前位置: 首页>>代码示例>>Java>>正文


Java TestSession类代码示例

本文整理汇总了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;
}
 
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:22,代码来源:GhostProxy.java

示例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);
}
 
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:21,代码来源:GhostProxy.java

示例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();
    }
}
 
开发者ID:pojosontheweb,项目名称:selenium-utils,代码行数:21,代码来源:NodeProxy.java

示例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();
    }
}
 
开发者ID:pojosontheweb,项目名称:selenium-utils,代码行数:21,代码来源:NodeProxy.java

示例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;
}
 
开发者ID:RetailMeNot,项目名称:SeleniumGridScaler,代码行数:19,代码来源:AutomationRequestMatcher.java

示例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()));
        }
    }
}
 
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:12,代码来源:GhostProxy.java

示例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);
    }
}
 
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:16,代码来源:GhostProxy.java

示例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);
    }
}
 
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:10,代码来源:GhostProxy.java

示例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;
}
 
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:16,代码来源:SpawnedServer.java

示例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);
    }
}
 
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:12,代码来源:DockerBasedSeleniumServer.java

示例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);
    }
}
 
开发者ID:RationaleEmotions,项目名称:just-ask,代码行数:16,代码来源:JvmBasedSeleniumServer.java

示例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());
		}
	}
}
 
开发者ID:bharathkumar-gopalan,项目名称:grid-video-recorder,代码行数:16,代码来源:ScreenRecordingProxy.java

示例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);
}
 
开发者ID:sterodium,项目名称:selenium-grid-extensions,代码行数:9,代码来源:SeleniumSessions.java

示例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);
        }
    }
}
 
开发者ID:sterodium,项目名称:selenium-grid-extensions,代码行数:8,代码来源:SeleniumSessions.java

示例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));
}
 
开发者ID:sterodium,项目名称:selenium-grid-extensions,代码行数:10,代码来源:SeleniumSessionsTest.java


注:本文中的org.openqa.grid.internal.TestSession类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。