tmf: Remove equals()/hashCode() from TmfEventRequest
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui.swtbot.tests / src / org / eclipse / tracecompass / tmf / ui / swtbot / tests / AbstractCustomParserWizard.java
CommitLineData
41a0d150
MK
1/*******************************************************************************
2 * Copyright (c) 2014 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
2bdf0193 13package org.eclipse.tracecompass.tmf.ui.swtbot.tests;
41a0d150
MK
14
15import java.io.File;
16import java.io.FileNotFoundException;
17import java.io.IOException;
18import java.io.RandomAccessFile;
19
20import org.apache.log4j.ConsoleAppender;
21import org.apache.log4j.Logger;
22import org.apache.log4j.SimpleLayout;
23import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
24import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
25import org.junit.BeforeClass;
26
27/**
28 * Abstract custom parser
29 * @author Matthew Khouzam
30 *
31 */
32public class AbstractCustomParserWizard {
33
34 /** The Log4j logger instance. */
35 static final Logger fLogger = Logger.getRootLogger();
36
37 /**
38 * The SWTBot running the test
39 */
40 protected static SWTWorkbenchBot fBot;
41
42 /** Test Class setup */
43 @BeforeClass
44 public static void init() {
45 SWTBotUtil.failIfUIThread();
46 Thread.currentThread().setName("SWTBot Thread"); // for the debugger
47 /* set up for swtbot */
48 SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
49 fLogger.addAppender(new ConsoleAppender(new SimpleLayout()));
50 fBot = new SWTWorkbenchBot();
51
52 SWTBotUtil.closeView("welcome", fBot);
53
54 SWTBotUtil.switchToTracingPerspective();
55 /* finish waiting for eclipse to load */
56 SWTBotUtil.waitForJobs();
57
58 }
59
60 /**
61 * Extract test XML file
62 *
63 * @param xmlFile
64 * the XML file to open
65 * @param category
66 * the category of the parser
67 * @param definitionName
68 * the name of the definition
69 * @return an XML string of the definition
70 * @throws IOException
71 * Error reading the file
72 * @throws FileNotFoundException
73 * File is not found
74 */
75 protected static String extractTestXml(File xmlFile, String category, String definitionName) throws IOException, FileNotFoundException {
76 StringBuilder xmlPart = new StringBuilder();
77 boolean started = false;
78 try (RandomAccessFile raf = new RandomAccessFile(xmlFile, "r");) {
79 String s = raf.readLine();
80 while (s != null) {
81 if (s.equals("<Definition category=\"" + category + "\" name=\"" + definitionName + "\">")) {
82 started = true;
83 }
84 if (started) {
85 if (s.equals("</Definition>")) {
86 break;
87 }
88 xmlPart.append(s);
89 xmlPart.append('\n');
90 }
91 s = raf.readLine();
92 }
93 }
94 return xmlPart.toString();
95 }
96}
This page took 0.036559 seconds and 5 git commands to generate.