tmf: Don't use .deleteOnExit() in unit tests
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.core.tests / src / org / eclipse / linuxtools / lttng2 / kernel / core / tests / stateprovider / StateSystemFullHistoryTest.java
1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 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 * Alexandre Montplaisir - Initial API and implementation
11 ******************************************************************************/
12
13 package org.eclipse.linuxtools.lttng2.kernel.core.tests.stateprovider;
14
15 import static org.junit.Assert.assertEquals;
16 import static org.junit.Assert.assertNotNull;
17 import static org.junit.Assert.fail;
18 import static org.junit.Assume.assumeTrue;
19
20 import java.io.File;
21 import java.io.IOException;
22
23 import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
24 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
25 import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
26 import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
27 import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory;
28 import org.junit.AfterClass;
29 import org.junit.BeforeClass;
30 import org.junit.Test;
31
32 /**
33 * State system tests using a full history back-end and the LTTng kernel state
34 * input.
35 *
36 * @author Alexandre Montplaisir
37 */
38 public class StateSystemFullHistoryTest extends StateSystemTest {
39
40 private static File stateFile;
41 private static File stateFileBenchmark;
42
43 /**
44 * Initialize the test cases (build the history file once for all tests).
45 */
46 @BeforeClass
47 public static void initialize() {
48 assumeTrue(testTrace.exists());
49 try {
50 stateFile = File.createTempFile("test", ".ht");
51 stateFileBenchmark = File.createTempFile("test", ".ht.benchmark");
52
53 input = new LttngKernelStateProvider(testTrace.getTrace());
54 ssq = TmfStateSystemFactory.newFullHistory(stateFile, input, true);
55 } catch (IOException e) {
56 fail();
57 } catch (TmfTraceException e) {
58 fail();
59 }
60 }
61
62 /**
63 * Clean-up
64 */
65 @AfterClass
66 public static void tearDownClass() {
67 stateFile.delete();
68 stateFileBenchmark.delete();
69 }
70
71 // ------------------------------------------------------------------------
72 // Tests specific to a full-history
73 // ------------------------------------------------------------------------
74
75 /**
76 * Rebuild independently so we can benchmark it. Too bad JUnit doesn't allow
77 * us to @Test the @BeforeClass...
78 */
79 @Test
80 public void testBuild() {
81 try {
82 ITmfStateProvider input2 = new LttngKernelStateProvider(testTrace.getTrace());
83 ITmfStateSystem ssb2 = TmfStateSystemFactory.newFullHistory(stateFileBenchmark, input2, true);
84
85 assertEquals(startTime, ssb2.getStartTime());
86 assertEquals(endTime, ssb2.getCurrentEndTime());
87
88 } catch (TmfTraceException e) {
89 fail();
90 }
91 }
92
93 /**
94 * Test re-opening the existing file.
95 */
96 @Test
97 public void testOpenExistingStateFile() {
98 try {
99 /* 'newStateFile' should have already been created */
100 ITmfStateSystem ssb2 = TmfStateSystemFactory.newFullHistory(stateFile, null, true);
101
102 assertNotNull(ssb2);
103 assertEquals(startTime, ssb2.getStartTime());
104 assertEquals(endTime, ssb2.getCurrentEndTime());
105
106 } catch (TmfTraceException e) {
107 fail();
108 }
109 }
110
111 }
This page took 0.036702 seconds and 6 git commands to generate.