/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
+ * Copyright (c) 2012, 2014 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
package org.eclipse.linuxtools.tmf.core.tests.statistics;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
-import java.io.File;
-import java.io.IOException;
-
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
+import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
import org.eclipse.linuxtools.tmf.core.statistics.TmfStateStatistics;
+import org.eclipse.linuxtools.tmf.core.statistics.TmfStatisticsEventTypesModule;
+import org.eclipse.linuxtools.tmf.core.statistics.TmfStatisticsTotalsModule;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.junit.After;
+import org.junit.Before;
import org.junit.BeforeClass;
/**
*/
public class TmfStateStatisticsTest extends TmfStatisticsTest {
+ private ITmfTrace fTrace;
+
/**
- * Set up the fixture (build the state history, etc.) once for all tests.
+ * Class setup
*/
@BeforeClass
public static void setUpClass() {
assumeTrue(testTrace.exists());
+ }
+
+ /**
+ * Test setup
+ */
+ @Before
+ public void setUp() {
+ fTrace = testTrace.getTrace();
+
+ /* Prepare the two analysis-backed state systems */
+ TmfStatisticsTotalsModule totalsMod = new TmfStatisticsTotalsModule();
+ TmfStatisticsEventTypesModule eventTypesMod = new TmfStatisticsEventTypesModule();
try {
- File htFile = File.createTempFile("stats-test", ".ht");
- htFile.deleteOnExit();
- backend = new TmfStateStatistics(testTrace.getTrace(), htFile);
- } catch (TmfTraceException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
+ totalsMod.setTrace(fTrace);
+ eventTypesMod.setTrace(fTrace);
+ } catch (TmfAnalysisException e) {
+ fail();
}
+
+ totalsMod.schedule();
+ eventTypesMod.schedule();
+ assertTrue(totalsMod.waitForCompletion());
+ assertTrue(eventTypesMod.waitForCompletion());
+
+ ITmfStateSystem totalsSS = totalsMod.getStateSystem();
+ ITmfStateSystem eventTypesSS = eventTypesMod.getStateSystem();
+ assertNotNull(totalsSS);
+ assertNotNull(eventTypesSS);
+
+ backend = new TmfStateStatistics(totalsSS, eventTypesSS);
+ }
+
+ /**
+ * Test cleanup
+ */
+ @After
+ public void tearDown() {
+ fTrace.dispose();
}
}