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 / CustomXmlTraceBadlyFormedTest.java
CommitLineData
13201b83 1/*******************************************************************************
13c60668 2 * Copyright (c) 2013, 2015 Ericsson
13201b83
MK
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
2bdf0193 13package org.eclipse.tracecompass.tmf.ui.tests.trace;
eb8ea213
MK
14
15import static org.junit.Assert.fail;
16
17import java.io.File;
18import java.util.ArrayList;
19import java.util.Collection;
20
21import org.eclipse.core.runtime.IStatus;
13c60668 22import org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus;
eb8ea213
MK
23import org.junit.Test;
24import org.junit.runner.RunWith;
25import org.junit.runners.Parameterized;
26import org.junit.runners.Parameterized.Parameters;
27
28/**
29 * Malformed xml test, dangerous errors
30 * @author Matthew Khouzam
31 *
32 */
33@RunWith(Parameterized.class)
34public class CustomXmlTraceBadlyFormedTest extends CustomXmlTraceTest {
35
36 private final static String pathname = "tracesets/xml/malformed";
37
38 /**
39 * This should create the parameters to launch the project
40 *
41 * @return the path of the parameters
42 */
43 @Parameters(name = "{index}: path {0}")
44 public static Collection<Object[]> getFiles() {
45 File[] malformedFiles = (new File(pathname)).listFiles();
ab410d88 46 Collection<Object[]> params = new ArrayList<>();
eb8ea213
MK
47 for (File f : malformedFiles) {
48 Object[] arr = new Object[] { f.getAbsolutePath() };
49 params.add(arr);
50 }
51 return params;
52 }
53
54 /**
55 * Test all the invalid xml files
56 */
57 @Test
58 public void testBadlyFormed() {
13c60668
BH
59 IStatus invalid = getTrace().validate(null, getPath());
60 // Validation doesn't check for syntax errors. It returns a confidence
61 // of 0 and status OK if it is a text file for malformed xml files.
62 if ((IStatus.ERROR == invalid.getSeverity() ||
63 ((IStatus.OK == invalid.getSeverity() && (invalid instanceof TraceValidationStatus) && ((TraceValidationStatus) invalid).getConfidence() == 0)))) {
64 return;
eb8ea213 65 }
13c60668 66 fail(getPath());
eb8ea213
MK
67 }
68
69 /**
70 * ctor
71 *
72 * @param filePath
73 * the path
74 */
75 public CustomXmlTraceBadlyFormedTest(String filePath) {
76 this.setPath(filePath);
77 }
78
79}
This page took 0.067096 seconds and 5 git commands to generate.