tmf: enable and fix o.e.tc.tmf.ui.tests.trace test cases
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui.tests / src / org / eclipse / tracecompass / tmf / ui / tests / trace / CustomXmlTraceInvalidTest.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2015 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.tmf.ui.tests.trace;
14
15 import static org.junit.Assert.fail;
16
17 import java.io.File;
18 import java.util.ArrayList;
19 import java.util.Collection;
20
21 import org.eclipse.core.runtime.IStatus;
22 import org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus;
23 import org.junit.Test;
24 import org.junit.runner.RunWith;
25 import org.junit.runners.Parameterized;
26 import org.junit.runners.Parameterized.Parameters;
27
28 /**
29 * Invalid Xml files, random errors
30 *
31 * @author Matthew Khouzam
32 *
33 */
34 @RunWith(Parameterized.class)
35 public class CustomXmlTraceInvalidTest extends CustomXmlTraceTest{
36
37 private final static String pathname = "tracesets/xml/invalid";
38
39 /**
40 * This should create the parameters to launch the project
41 *
42 * @return the path of the parameters
43 */
44 @Parameters(name = "{index}: path {0}")
45 public static Collection<Object[]> getFiles() {
46 File[] invalidFiles = (new File(pathname)).listFiles();
47 Collection<Object[]> params = new ArrayList<>();
48 for (File f : invalidFiles) {
49 Object[] arr = new Object[] { f.getAbsolutePath() };
50 params.add(arr);
51 }
52 return params;
53 }
54
55 /**
56 * ctor
57 *
58 * @param filePath
59 * the path
60 */
61 public CustomXmlTraceInvalidTest(String filePath) {
62 setPath(filePath);
63 }
64
65 /**
66 * Test all the invalid xml files
67 */
68 @Test
69 public void testInvalid() {
70 IStatus invalid = getTrace().validate(null, getPath());
71
72 // Validation doesn't check for syntax errors. It returns a confidence
73 // of 0 and status OK if it is a text file for invalid xml files.
74 if ((IStatus.ERROR == invalid.getSeverity() ||
75 ((IStatus.OK == invalid.getSeverity() && (invalid instanceof TraceValidationStatus) && ((TraceValidationStatus) invalid).getConfidence() == 0)))) {
76 return;
77 }
78
79 fail(getPath());
80 }
81
82 }
This page took 0.054952 seconds and 5 git commands to generate.