Commit | Line | Data |
---|---|---|
f9a76cac | 1 | /******************************************************************************* |
60ae41e1 | 2 | * Copyright (c) 2013, 2014 Ericsson |
f9a76cac AM |
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 | * Alexandre Montplaisir - Initial API and implementation | |
6a769f6a | 11 | * Bernd Hufmann - Use state system analysis module instead of factory |
f9a76cac AM |
12 | ******************************************************************************/ |
13 | ||
9bc60be7 | 14 | package org.eclipse.tracecompass.lttng2.kernel.core.tests.stateprovider; |
f9a76cac | 15 | |
6a769f6a BH |
16 | import static org.junit.Assert.assertTrue; |
17 | import static org.junit.Assert.fail; | |
92ba8466 | 18 | |
9bc60be7 | 19 | import org.eclipse.tracecompass.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider; |
e894a508 | 20 | import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; |
2bdf0193 AM |
21 | import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException; |
22 | import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider; | |
23 | import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule; | |
24 | import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; | |
9722e5d7 | 25 | import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace; |
58ba027e | 26 | import org.junit.After; |
f9a76cac AM |
27 | |
28 | /** | |
29 | * State system tests using the in-memory back-end. | |
30 | * | |
31 | * @author Alexandre Montplaisir | |
32 | */ | |
33 | public class StateSystemInMemoryTest extends StateSystemTest { | |
34 | ||
58ba027e | 35 | private TestLttngKernelAnalysisModule module; |
bd64ee73 | 36 | |
edbdb7ea AM |
37 | @Override |
38 | protected ITmfStateSystem initialize() { | |
bd64ee73 | 39 | module = new TestLttngKernelAnalysisModule(); |
6a769f6a BH |
40 | try { |
41 | module.setTrace(testTrace.getTrace()); | |
42 | } catch (TmfAnalysisException e) { | |
43 | fail(); | |
44 | } | |
45 | module.schedule(); | |
7d6122fc | 46 | assertTrue(module.waitForCompletion()); |
edbdb7ea | 47 | return module.getStateSystem(); |
6a769f6a BH |
48 | } |
49 | ||
bd64ee73 AM |
50 | /** |
51 | * Class cleanup | |
52 | */ | |
58ba027e | 53 | @After |
edbdb7ea AM |
54 | public void cleanup() { |
55 | if (module != null) { | |
03f0b0b1 | 56 | module.dispose(); |
edbdb7ea | 57 | } |
bd64ee73 AM |
58 | } |
59 | ||
6a769f6a BH |
60 | private static class TestLttngKernelAnalysisModule extends TmfStateSystemAnalysisModule { |
61 | ||
62 | /** | |
63 | * Constructor adding the views to the analysis | |
64 | */ | |
65 | public TestLttngKernelAnalysisModule() { | |
66 | super(); | |
67 | } | |
68 | ||
69 | @Override | |
70 | public void setTrace(ITmfTrace trace) throws TmfAnalysisException { | |
71 | if (!(trace instanceof CtfTmfTrace)) { | |
72 | throw new IllegalStateException("TestLttngKernelAnalysisModule: trace should be of type CtfTmfTrace"); //$NON-NLS-1$ | |
73 | } | |
74 | super.setTrace(trace); | |
75 | } | |
76 | ||
77 | @Override | |
78 | protected ITmfStateProvider createStateProvider() { | |
1887c91b | 79 | return new LttngKernelStateProvider(getTrace()); |
6a769f6a BH |
80 | } |
81 | ||
82 | @Override | |
83 | protected StateSystemBackendType getBackendType() { | |
a3b864c0 | 84 | return StateSystemBackendType.INMEM; |
6a769f6a | 85 | } |
f9a76cac AM |
86 | } |
87 | } |