@Override public void run() { try { if (fDebug) System.out.println("Creating server socket " + fServerPort); // $NON-NLS-1$ fServerSocket = new ServerSocket(fServerPort); fSocket = fServerSocket.accept(); try { fPushbackReader = new PushbackReader( new BufferedReader( new InputStreamReader(fSocket.getInputStream(), "UTF-8"))); // $NON-NLS-1$ } catch (UnsupportedEncodingException e) { fPushbackReader = new PushbackReader( new BufferedReader(new InputStreamReader(fSocket.getInputStream()))); } try { fWriter = new PrintWriter( new OutputStreamWriter(fSocket.getOutputStream(), "UTF-8"), true); // $NON-NLS-1$ } catch (UnsupportedEncodingException e1) { fWriter = new PrintWriter(new OutputStreamWriter(fSocket.getOutputStream()), true); } String message; while (fPushbackReader != null && (message = readMessage(fPushbackReader)) != null) receiveMessage(message); } catch (SocketException e) { notifyTestRunTerminated(); } catch (IOException e) { JUnitCorePlugin.log(e); // fall through } shutDown(); }
private void notifyTestRunStarted(final int count) { if (JUnitCorePlugin.isStopped()) return; for (int i = 0; i < fListeners.length; i++) { final ITestRunListener2 listener = fListeners[i]; SafeRunner.run( new ListenerSafeRunnable() { @Override public void run() { listener.testRunStarted(count); } }); } }
private void testRunEnded(final long elapsedTime) { if (JUnitCorePlugin.isStopped()) return; for (int i = 0; i < fListeners.length; i++) { final ITestRunListener2 listener = fListeners[i]; SafeRunner.run( new ListenerSafeRunnable() { @Override public void run() { listener.testRunEnded(elapsedTime); } }); } }
private void notifyTestRunTerminated() { // fix for 77771 RemoteTestRunnerClient doing work after junit shutdown [JUnit] if (JUnitCorePlugin.isStopped()) return; for (int i = 0; i < fListeners.length; i++) { final ITestRunListener2 listener = fListeners[i]; SafeRunner.run( new ListenerSafeRunnable() { @Override public void run() { listener.testRunTerminated(); } }); } }
private void notifyTestStarted(final String test) { if (JUnitCorePlugin.isStopped()) return; for (int i = 0; i < fListeners.length; i++) { final ITestRunListener2 listener = fListeners[i]; SafeRunner.run( new ListenerSafeRunnable() { @Override public void run() { String s[] = extractTestId(test); listener.testStarted(s[0], s[1]); } }); } }
private void notifyTestFailed() { if (JUnitCorePlugin.isStopped()) return; for (int i = 0; i < fListeners.length; i++) { final ITestRunListener2 listener = fListeners[i]; SafeRunner.run( new ListenerSafeRunnable() { @Override public void run() { listener.testFailed( fFailureKind, fFailedTestId, fFailedTest, fFailedTrace.toString(), nullifyEmpty(fExpectedResult), nullifyEmpty(fActualResult)); } }); } }
@Override public void handleException(Throwable exception) { JUnitCorePlugin.log(exception); }
private Object[] getListeners() { return JUnitCorePlugin.getDefault().getNewTestRunListeners().getListeners(); }