sysmodelmgr/com.symbian.pde.test.utils/src/com/symbian/pde/test/utils/PDETestResultsCollector.java
changeset 0 522a326673b6
equal deleted inserted replaced
-1:000000000000 0:522a326673b6
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 package com.symbian.pde.test.utils;
       
    16 
       
    17 import org.eclipse.jdt.internal.junit.model.ITestRunListener2;
       
    18 import org.eclipse.jdt.internal.junit.model.RemoteTestRunnerClient;
       
    19 
       
    20 public final class PDETestResultsCollector {
       
    21     private static PDETestListener pdeTestListener;
       
    22 
       
    23     private String suiteName;
       
    24 
       
    25     private PDETestResultsCollector(String suite) {
       
    26         suiteName = suite;
       
    27     }
       
    28 
       
    29     private void run(int port) throws InterruptedException {
       
    30         pdeTestListener = new PDETestListener(this, suiteName);
       
    31         new RemoteTestRunnerClient().startListening(new ITestRunListener2[] {pdeTestListener}, port);
       
    32         System.out.println("Listening on port " + port + " for test suite " + suiteName + " results ...");
       
    33         synchronized (this) {
       
    34             wait();
       
    35         }
       
    36     }
       
    37 
       
    38     public static void main(String[] args) {
       
    39         if (args.length != 2) {
       
    40             System.out.println("usage: PDETestResultsCollector <test suite name> <port number>");
       
    41             System.exit(0);
       
    42         }
       
    43 
       
    44         try {
       
    45             new PDETestResultsCollector(args[0]).run(Integer.parseInt(args[1]));
       
    46         } catch (Throwable th) {
       
    47             th.printStackTrace();
       
    48         }
       
    49 
       
    50         if (pdeTestListener != null && pdeTestListener.failed()) {
       
    51             System.exit(1);
       
    52         }
       
    53     }
       
    54 }