b83cbe8829ac541fee5f726ba679b565b46993aa
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core.tests / src / org / eclipse / tracecompass / tmf / core / tests / trace / indexer / checkpoint / TmfBTreeIndexTest.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2014 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 * Francois Chouinard - Initial API and implementation
11 * Francois Chouinard - Adapted for TMF Trace Model 1.0
12 * Alexandre Montplaisir - Port to JUnit4
13 * Marc-Andre Laperle - Adapted to BTree indexer from TmfCheckpointIndexTest
14 *******************************************************************************/
15
16 package org.eclipse.tracecompass.tmf.core.tests.trace.indexer.checkpoint;
17
18 import static org.junit.Assert.assertFalse;
19
20 import org.eclipse.tracecompass.tmf.core.trace.indexer.TmfBTreeTraceIndexer;
21 import org.eclipse.tracecompass.tmf.core.trace.indexer.checkpoint.ITmfCheckpointIndex;
22 import org.junit.Test;
23
24 /**
25 * Test suite for the TmfBTreeTraceIndexer class.
26 *
27 * @author Marc-Andre Laperle
28 */
29 public class TmfBTreeIndexTest extends AbstractIndexTest {
30
31 /**
32 * Create the indexer for testing
33 *
34 * @param trace
35 * the trace
36 * @return the indexer for testing
37 */
38 @Override
39 protected ITestIndexer createTestIndexer(TestTrace trace) {
40 return new TestBTreeIndexer(trace);
41 }
42
43 private static class TestBTreeIndexer extends TmfBTreeTraceIndexer implements ITestIndexer {
44 public TestBTreeIndexer(TestTrace testTrace) {
45 super(testTrace, BLOCK_SIZE);
46 }
47
48 @Override
49 public ITmfCheckpointIndex getCheckpoints() {
50 return getTraceIndex();
51 }
52 }
53
54 /**
55 * Test that a fully built index has the same content when reloaded from disk
56 *
57 * @throws Exception when error occurs
58 */
59 @Test
60 public void testReopenIndex() throws Exception {
61 fTrace.dispose();
62 fTrace = createTrace(getTracePath());
63 assertFalse(fTrace.getIndexer().getCheckpoints().isCreatedFromScratch());
64 fTrace.indexTrace(true);
65
66 verifyIndexContent();
67 }
68
69 }
This page took 0.033006 seconds and 4 git commands to generate.