tmf: Null-annotate state system API classes
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.kernel.core.tests / src / org / eclipse / tracecompass / lttng2 / kernel / core / tests / analysis / kernel / statesystem / StateSystemInMemoryTest.java
CommitLineData
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
42d5b5f2 14package org.eclipse.tracecompass.lttng2.kernel.core.tests.analysis.kernel.statesystem;
f9a76cac 15
d0c7e4ba 16import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
6a769f6a
BH
17import static org.junit.Assert.assertTrue;
18import static org.junit.Assert.fail;
92ba8466 19
7411cd67 20import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.LttngEventLayout;
42d5b5f2 21import org.eclipse.tracecompass.lttng2.kernel.core.analysis.kernel.LttngKernelStateProvider;
2bdf0193
AM
22import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
23import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
24import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
25import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
9722e5d7 26import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
392bf486
AM
27import org.junit.AfterClass;
28import org.junit.BeforeClass;
f9a76cac
AM
29
30/**
31 * State system tests using the in-memory back-end.
32 *
33 * @author Alexandre Montplaisir
34 */
35public class StateSystemInMemoryTest extends StateSystemTest {
36
392bf486
AM
37 private static TestLttngKernelAnalysisModule module;
38
39 /**
40 * Test class setup
41 */
42 @BeforeClass
43 public static void initialize() {
44 if (!testTrace.exists()) {
45 traceIsPresent = false;
46 return;
47 }
48 traceIsPresent = true;
bd64ee73 49
bd64ee73 50 module = new TestLttngKernelAnalysisModule();
6a769f6a
BH
51 try {
52 module.setTrace(testTrace.getTrace());
53 } catch (TmfAnalysisException e) {
54 fail();
55 }
56 module.schedule();
7d6122fc 57 assertTrue(module.waitForCompletion());
392bf486
AM
58
59 fixture = module.getStateSystem();
6a769f6a
BH
60 }
61
bd64ee73
AM
62 /**
63 * Class cleanup
64 */
392bf486
AM
65 @AfterClass
66 public static void cleanup() {
edbdb7ea 67 if (module != null) {
03f0b0b1 68 module.dispose();
edbdb7ea 69 }
392bf486
AM
70 if (fixture != null) {
71 fixture.dispose();
72 }
73 module = null;
74 fixture = null;
bd64ee73
AM
75 }
76
6a769f6a
BH
77 private static class TestLttngKernelAnalysisModule extends TmfStateSystemAnalysisModule {
78
79 /**
80 * Constructor adding the views to the analysis
81 */
82 public TestLttngKernelAnalysisModule() {
83 super();
84 }
85
86 @Override
87 public void setTrace(ITmfTrace trace) throws TmfAnalysisException {
88 if (!(trace instanceof CtfTmfTrace)) {
89 throw new IllegalStateException("TestLttngKernelAnalysisModule: trace should be of type CtfTmfTrace"); //$NON-NLS-1$
90 }
91 super.setTrace(trace);
92 }
93
94 @Override
95 protected ITmfStateProvider createStateProvider() {
d0c7e4ba 96 return new LttngKernelStateProvider(checkNotNull(getTrace()), LttngEventLayout.getInstance());
6a769f6a
BH
97 }
98
99 @Override
100 protected StateSystemBackendType getBackendType() {
a3b864c0 101 return StateSystemBackendType.INMEM;
6a769f6a 102 }
f9a76cac
AM
103 }
104}
This page took 0.066642 seconds and 5 git commands to generate.