1 /*******************************************************************************
2 * Copyright (c) 2013 École Polytechnique de Montréal
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 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.core
.tests
.shared
;
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
.tmf
.core
.exceptions
.TmfTraceException
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalManager
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.tests
.TmfCoreTestPlugin
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
26 import org
.eclipse
.linuxtools
.tmf
.tests
.stubs
.trace
.TmfTraceStub
;
27 import org
.eclipse
.linuxtools
.tmf
.tests
.stubs
.trace
.TmfTraceStub2
;
30 * Generic TMF test traces
32 * @author Geneviève Bastien
34 public enum TmfTestTrace
{
36 A_TEST_10K("A-Test-10K"),
38 A_TEST_10K2("A-Test-10K-2"),
40 E_TEST_10K("E-Test-10K"),
42 O_TEST_10K("O-Test-10K"),
43 /** And oh! a fifth trace */
44 R_TEST_10K("R-Test-10K");
46 private final String fPath
;
47 private final String fDirectory
= "../org.eclipse.linuxtools.tmf.core.tests/testfiles";
48 private ITmfTrace fTrace
= null;
50 private TmfTestTrace(String file
) {
55 * Get the path of the trace
57 * @return The path of this trace
59 public String
getPath() {
64 * Get the full path of the trace
66 * @return The full path of the trace
68 public String
getFullPath() {
69 return fDirectory
+ File
.separator
+ fPath
;
73 * Return a ITmfTrace object of this test trace. It will be already
74 * initTrace()'ed. This method will always return a new trace and dispose of
77 * After being used by unit tests, traces must be properly disposed of by
78 * calling the {@link TmfTestTrace#dispose()} method.
80 * @return A {@link ITmfTrace} reference to this trace
82 public ITmfTrace
getTrace() {
86 final URL location
= FileLocator
.find(TmfCoreTestPlugin
.getDefault().getBundle(), new Path(fDirectory
+ File
.separator
+ fPath
), null);
88 File test
= new File(FileLocator
.toFileURL(location
).toURI());
89 fTrace
= new TmfTraceStub(test
.toURI().getPath(), ITmfTrace
.DEFAULT_TRACE_CACHE_SIZE
, false, null);
91 } catch (URISyntaxException
| IOException
| TmfTraceException e
) {
92 throw new IllegalStateException(e
);
98 * Return a ITmfTrace object that is of type {@link TmfTraceStub2}. It
99 * will be already initTrace()'ed. But the trace will be deregistered from
100 * signal managers and will need to be manually disposed of by the caller.
102 * @return a {@link ITmfTrace} reference to this trace
104 public ITmfTrace
getTraceAsStub2() {
105 ITmfTrace trace
= null;
106 final URL location
= FileLocator
.find(TmfCoreTestPlugin
.getDefault().getBundle(), new Path(fDirectory
+ File
.separator
+ fPath
), null);
108 File test
= new File(FileLocator
.toFileURL(location
).toURI());
109 trace
= new TmfTraceStub2(test
.toURI().getPath(), ITmfTrace
.DEFAULT_TRACE_CACHE_SIZE
, false, null);
110 TmfSignalManager
.deregister(trace
);
112 } catch (URISyntaxException
| IOException
| TmfTraceException e
) {
113 throw new IllegalStateException(e
);
119 * Dispose of the trace
121 public void dispose() {
122 if (fTrace
!= null) {
This page took 0.0427 seconds and 6 git commands to generate.