|
Lines 14-19
Link Here
|
| 14 |
import java.io.File; |
14 |
import java.io.File; |
| 15 |
import java.io.FileOutputStream; |
15 |
import java.io.FileOutputStream; |
| 16 |
import java.io.IOException; |
16 |
import java.io.IOException; |
|
|
17 |
import java.io.InputStream; |
| 17 |
import java.io.OutputStream; |
18 |
import java.io.OutputStream; |
| 18 |
import java.util.ArrayList; |
19 |
import java.util.ArrayList; |
| 19 |
import java.util.HashSet; |
20 |
import java.util.HashSet; |
|
Lines 389-394
Link Here
|
| 389 |
} |
390 |
} |
| 390 |
|
391 |
|
| 391 |
/** |
392 |
/** |
|
|
393 |
* Imports a test run session from the given input stream. |
| 394 |
* |
| 395 |
* @param contents an input stream containing a test run session transcript |
| 396 |
* @param absoluteFileName absolute location of the file being imported |
| 397 |
* @return the imported test run session |
| 398 |
* @throws CoreException if the import failed |
| 399 |
*/ |
| 400 |
public static TestRunSession importTestRunSession(InputStream contents, String absoluteFileName) throws CoreException { |
| 401 |
try { |
| 402 |
SAXParserFactory parserFactory= SAXParserFactory.newInstance(); |
| 403 |
// parserFactory.setValidating(true); // TODO: add DTD and debug flag |
| 404 |
SAXParser parser= parserFactory.newSAXParser(); |
| 405 |
TestRunHandler handler= new TestRunHandler(); |
| 406 |
parser.parse(contents, handler); |
| 407 |
TestRunSession session= handler.getTestRunSession(); |
| 408 |
JUnitPlugin.getModel().addTestRunSession(session); |
| 409 |
return session; |
| 410 |
} catch (ParserConfigurationException e) { |
| 411 |
throwImportError(absoluteFileName, e); |
| 412 |
} catch (SAXException e) { |
| 413 |
throwImportError(absoluteFileName, e); |
| 414 |
} catch (IOException e) { |
| 415 |
throwImportError(absoluteFileName, e); |
| 416 |
} |
| 417 |
return null; // does not happen |
| 418 |
} |
| 419 |
|
| 420 |
/** |
| 392 |
* Imports a test run session from the given file. |
421 |
* Imports a test run session from the given file. |
| 393 |
* |
422 |
* |
| 394 |
* @param file a file containing a test run session transcript |
423 |
* @param file a file containing a test run session transcript |
|
Lines 493-501
Link Here
|
| 493 |
} |
522 |
} |
| 494 |
|
523 |
|
| 495 |
private static void throwImportError(File file, Exception e) throws CoreException { |
524 |
private static void throwImportError(File file, Exception e) throws CoreException { |
|
|
525 |
throwImportError(file.getAbsolutePath(), e); |
| 526 |
} |
| 527 |
|
| 528 |
private static void throwImportError(String absoluteFileName, Exception e) throws CoreException { |
| 496 |
throw new CoreException(new org.eclipse.core.runtime.Status(IStatus.ERROR, |
529 |
throw new CoreException(new org.eclipse.core.runtime.Status(IStatus.ERROR, |
| 497 |
JUnitPlugin.getPluginId(), |
530 |
JUnitPlugin.getPluginId(), |
| 498 |
Messages.format(ModelMessages.JUnitModel_could_not_read, file.getAbsolutePath()), |
531 |
Messages.format(ModelMessages.JUnitModel_could_not_read, absoluteFileName), |
| 499 |
e)); |
532 |
e)); |
| 500 |
} |
533 |
} |
| 501 |
|
534 |
|