Commit | Line | Data |
---|---|---|
13201b83 MK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2013 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 | ||
eb8ea213 MK |
13 | package org.eclipse.linuxtools.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.junit.Test; | |
23 | import org.junit.runner.RunWith; | |
24 | import org.junit.runners.Parameterized; | |
25 | import org.junit.runners.Parameterized.Parameters; | |
26 | ||
27 | /** | |
28 | * Malformed xml test, dangerous errors | |
29 | * @author Matthew Khouzam | |
30 | * | |
31 | */ | |
32 | @RunWith(Parameterized.class) | |
33 | public class CustomXmlTraceBadlyFormedTest extends CustomXmlTraceTest { | |
34 | ||
35 | private final static String pathname = "tracesets/xml/malformed"; | |
36 | ||
37 | /** | |
38 | * This should create the parameters to launch the project | |
39 | * | |
40 | * @return the path of the parameters | |
41 | */ | |
42 | @Parameters(name = "{index}: path {0}") | |
43 | public static Collection<Object[]> getFiles() { | |
44 | File[] malformedFiles = (new File(pathname)).listFiles(); | |
ab410d88 | 45 | Collection<Object[]> params = new ArrayList<>(); |
eb8ea213 MK |
46 | for (File f : malformedFiles) { |
47 | Object[] arr = new Object[] { f.getAbsolutePath() }; | |
48 | params.add(arr); | |
49 | } | |
50 | return params; | |
51 | } | |
52 | ||
53 | /** | |
54 | * Test all the invalid xml files | |
55 | */ | |
56 | @Test | |
57 | public void testBadlyFormed() { | |
58 | IStatus valid = getTrace().validate(null, getPath()); | |
59 | if (IStatus.ERROR != valid.getSeverity()) { | |
60 | fail(valid.toString()); | |
61 | } | |
62 | } | |
63 | ||
64 | /** | |
65 | * ctor | |
66 | * | |
67 | * @param filePath | |
68 | * the path | |
69 | */ | |
70 | public CustomXmlTraceBadlyFormedTest(String filePath) { | |
71 | this.setPath(filePath); | |
72 | } | |
73 | ||
74 | } |