@Override public void exceptionOccurred(Exception e) { ExecutionLog log = client.getExecutionLog(); log.addException(e); try { client.kill(); } finally { testSystemStopped(log, e); } }
@Override public void runTests(TestPage pageToTest) throws IOException, InterruptedException { processingQueue.addLast(pageToTest); String html = pageToTest.getHtml(); try { if (html.length() == 0) client.send(EMPTY_PAGE_CONTENT); else client.send(html); } catch (InterruptedException e) { exceptionOccurred(e); throw e; } catch (IOException e) { exceptionOccurred(e); throw e; } }
@Override public void exceptionOccurred(Throwable t) { try { client.kill(); } finally { testSystemStopped(t); } }
@Override public void run() { try { Thread.sleep(1000); // next waitFor() can finish too quickly on Linux! commandRunner.waitForCommandToFinish(); synchronized (fitClient) { if (!fitClient.isConnectionEstablished()) { fitClient.notify(); Exception e = new Exception( "FitClient: external process terminated before a connection could be established."); commandRunner.exceptionOccurred(e); fitClient.exceptionOccurred(e); } } } catch (InterruptedException e) { Thread.currentThread().interrupt(); // remember interrupted } }
@Override public void kill() { client.kill(); }
@Override public void bye() throws IOException, InterruptedException { client.done(); client.join(); testSystemStopped(null); }
@Override public void start() throws IOException { // TODO: start a server socket (thread) here client.start(); testSystemStarted(this); }
public FitTestSystem(String testSystemName, CommandRunningFitClient fitClient) { this.testSystemListener = new CompositeTestSystemListener(); this.testSystemName = testSystemName; this.client = fitClient; client.addFitClientListener(this); }
@Override public boolean isSuccessfullyStarted() { return client.isSuccessfullyStarted(); }
@Override public void kill() { client.kill(); testSystemStopped(client.getExecutionLog(), null); }
@Override public void runTests(TestPage pageToTest) throws IOException, InterruptedException { String html = pageToTest.getDecoratedData().getHtml(); if (html.length() == 0) client.send(EMPTY_PAGE_CONTENT); else client.send(html); }
@Override public void start() { client.start(); testSystemStarted(this, descriptor.getTestSystemName(), descriptor.getTestRunner()); }