1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
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
10 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.btf
.core
.tests
.utils
;
16 import java
.io
.IOException
;
17 import java
.net
.URISyntaxException
;
20 import org
.eclipse
.core
.runtime
.FileLocator
;
21 import org
.eclipse
.core
.runtime
.Path
;
22 import org
.eclipse
.linuxtools
.btf
.core
.tests
.BtfTestPlugin
;
23 import org
.eclipse
.linuxtools
.btf
.core
.trace
.BtfTrace
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfTraceException
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
26 import org
.osgi
.framework
.Bundle
;
29 * Wrapper like CtfTestTrace but for BTF, the best trace format
30 * @author Matthew Khouzam
32 public enum BtfTestTrace
{
35 BTF_TEST("20140219-123819.btf");
37 private final String fPath
;
38 private final String fDirectory
= "testfiles";
39 private BtfTrace fTrace
= null;
41 private BtfTestTrace(String file
) {
46 * Get the path of the trace
48 * @return The path of this trace
50 public String
getPath() {
55 * Get the full path of the trace
57 * @return The full path of the trace
59 public String
getFullPath() {
60 return fDirectory
+ File
.separator
+ fPath
;
64 * Return a ITmfTrace object of this test trace. It will be already
65 * initTrace()'ed. This method will always return a new trace and dispose of
68 * After being used by unit tests, traces must be properly disposed of by
69 * calling the {@link BtfTestTrace#dispose()} method.
71 * @return A {@link ITmfTrace} reference to this trace
73 public BtfTrace
getTrace() {
77 Bundle bundle
= BtfTestPlugin
.getBundle();
78 Path path
= new Path(fDirectory
+ File
.separator
+ fPath
);
79 final URL location
= FileLocator
.find(bundle
,path
, null);
82 test
= new File(FileLocator
.toFileURL(location
).toURI());
83 fTrace
= new BtfTrace();
84 fTrace
.initTrace(null, test
.getAbsolutePath(), null);
85 } catch (URISyntaxException
| IOException
| TmfTraceException e
) {
86 throw new RuntimeException(e
);
92 * Dispose of the trace
94 public void dispose() {
This page took 0.064921 seconds and 5 git commands to generate.