ss: Add a package-info file to backend unit tests
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Mon, 7 Mar 2016 17:19:20 +0000 (12:19 -0500)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Mon, 21 Mar 2016 01:32:57 +0000 (21:32 -0400)
Change-Id: I29b2b13cb32468fa4c4484c89360eb0eaf08076f
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/68096
Reviewed-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Tested-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Reviewed-by: Hudson CI
statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/HistoryTreeBackendTest.java
statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/InMemoryBackendTest.java
statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/StateHistoryBackendTestBase.java
statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/package-info.java [new file with mode: 0644]

index 9ab003d5d309e607db8767f81b545afce1d090e8..1ffb8700a8648e6f1b130fdf26101e26f89f7f00 100644 (file)
@@ -18,7 +18,6 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.internal.statesystem.core.backend.historytree.HistoryTreeBackend;
 import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend;
 import org.junit.After;
@@ -36,7 +35,7 @@ import org.junit.runners.Parameterized.Parameters;
 public class HistoryTreeBackendTest extends StateHistoryBackendTestBase {
 
     /** State system ID */
-    protected static final @NonNull String SSID = "test";
+    protected static final String SSID = "test";
     /** Provider version */
     protected static final int PROVIDER_VERSION = 0;
 
index 82cd87e43b9ae1830dcf817c1701614cd942d90a..6785c488d71cfa689a93f2ad990ddf30558d22b3 100644 (file)
@@ -21,7 +21,6 @@ import static org.junit.Assert.fail;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.statesystem.core.backend.IStateHistoryBackend;
 import org.eclipse.tracecompass.statesystem.core.backend.StateHistoryBackendFactory;
@@ -42,24 +41,25 @@ import org.junit.Test;
  */
 public class InMemoryBackendTest extends StateHistoryBackendTestBase {
 
-    private static final @NonNull String SSID = "test-ss";
+    private static final String SSID = "test-ss";
     private static final int NUMBER_OF_ATTRIBUTES = 10;
-    private static IStateHistoryBackend fixture;
+
+    private static @Nullable IStateHistoryBackend fixture;
 
     /**
      * Test setup. make a state system that is moderately large
      */
     @BeforeClass
     public static void init() {
-        fixture = StateHistoryBackendFactory.createInMemoryBackend(SSID, 0);
+        IStateHistoryBackend backend = StateHistoryBackendFactory.createInMemoryBackend(SSID, 0);
         for (int attribute = 0; attribute < NUMBER_OF_ATTRIBUTES; attribute++) {
             for (int timeStart = 0; timeStart < 1000; timeStart++) {
                 try {
                     final int stateEndTime = (timeStart * 100) + 90 + attribute;
                     final int stateStartTime = timeStart * 100 + attribute;
-                    fixture.insertPastState(stateStartTime, stateEndTime, attribute, TmfStateValue.newValueInt(timeStart % 100));
+                    backend.insertPastState(stateStartTime, stateEndTime, attribute, TmfStateValue.newValueInt(timeStart % 100));
                     if (timeStart != 999) {
-                        fixture.insertPastState(stateEndTime + 1, stateEndTime + 9, attribute, TmfStateValue.nullValue());
+                        backend.insertPastState(stateEndTime + 1, stateEndTime + 9, attribute, TmfStateValue.nullValue());
                     }
                 } catch (TimeRangeException e) {
                     /* Should not happen here */
@@ -67,9 +67,10 @@ public class InMemoryBackendTest extends StateHistoryBackendTestBase {
                 }
             }
         }
+        fixture = backend;
     }
 
-    private static void testInterval(ITmfStateInterval interval, int startTime,
+    private static void testInterval(@Nullable ITmfStateInterval interval, int startTime,
             int endTime, int value) {
         assertNotNull(interval);
         assertEquals(startTime, interval.getStartTime());
@@ -91,7 +92,9 @@ public class InMemoryBackendTest extends StateHistoryBackendTestBase {
      */
     @Test
     public void testStartTime() {
-        assertEquals(0, fixture.getStartTime());
+        IStateHistoryBackend backend = fixture;
+        assertNotNull(backend);
+        assertEquals(0, backend.getStartTime());
     }
 
     /**
@@ -99,7 +102,9 @@ public class InMemoryBackendTest extends StateHistoryBackendTestBase {
      */
     @Test
     public void testEndTime() {
-        assertEquals(99999, fixture.getEndTime());
+        IStateHistoryBackend backend = fixture;
+        assertNotNull(backend);
+        assertEquals(99999, backend.getEndTime());
     }
 
     /**
@@ -111,8 +116,10 @@ public class InMemoryBackendTest extends StateHistoryBackendTestBase {
         for (int i = 0; i < NUMBER_OF_ATTRIBUTES; i++) {
             interval.add(null);
         }
+        IStateHistoryBackend backend = fixture;
+        assertNotNull(backend);
         try {
-            fixture.doQuery(interval, 950);
+            backend.doQuery(interval, 950);
         } catch (TimeRangeException | StateSystemDisposedException e) {
             fail(e.getMessage());
         }
@@ -137,9 +144,11 @@ public class InMemoryBackendTest extends StateHistoryBackendTestBase {
     @Test
     public void testQueryAttribute() {
         try {
+            IStateHistoryBackend backend = fixture;
+            assertNotNull(backend);
             ITmfStateInterval interval[] = new TmfStateInterval[10];
             for (int i = 0; i < 10; i++) {
-                interval[i] = fixture.doSingularQuery(950, i);
+                interval[i] = backend.doSingularQuery(950, i);
             }
 
             testInterval(interval[0], 900, 990, 9);
@@ -158,7 +167,7 @@ public class InMemoryBackendTest extends StateHistoryBackendTestBase {
                 intervalQuery.add(null);
             }
 
-            fixture.doQuery(intervalQuery, 950);
+            backend.doQuery(intervalQuery, 950);
             ITmfStateInterval ref[] = intervalQuery.toArray(new ITmfStateInterval[0]);
             assertArrayEquals(ref, interval);
 
@@ -173,7 +182,9 @@ public class InMemoryBackendTest extends StateHistoryBackendTestBase {
     @Test
     public void testQueryAttributeEmpty() {
         try {
-            ITmfStateInterval interval = fixture.doSingularQuery(999, 0);
+            IStateHistoryBackend backend = fixture;
+            assertNotNull(backend);
+            ITmfStateInterval interval = backend.doSingularQuery(999, 0);
             assertEquals(TmfStateValue.nullValue(), interval.getStateValue());
 
         } catch (TimeRangeException | AttributeNotFoundException | StateSystemDisposedException e) {
@@ -187,7 +198,9 @@ public class InMemoryBackendTest extends StateHistoryBackendTestBase {
     @Test
     public void testBegin() {
         try {
-            ITmfStateInterval interval = fixture.doSingularQuery(0, 0);
+            IStateHistoryBackend backend = fixture;
+            assertNotNull(backend);
+            ITmfStateInterval interval = backend.doSingularQuery(0, 0);
             assertEquals(0, interval.getStartTime());
             assertEquals(90, interval.getEndTime());
             assertEquals(0, interval.getStateValue().unboxInt());
@@ -203,7 +216,9 @@ public class InMemoryBackendTest extends StateHistoryBackendTestBase {
     @Test
     public void testEnd() {
         try {
-            ITmfStateInterval interval = fixture.doSingularQuery(99998, 9);
+            IStateHistoryBackend backend = fixture;
+            assertNotNull(backend);
+            ITmfStateInterval interval = backend.doSingularQuery(99998, 9);
             testInterval(interval, 99909, 99999, 99);
 
         } catch (TimeRangeException | AttributeNotFoundException | StateSystemDisposedException e) {
@@ -220,7 +235,9 @@ public class InMemoryBackendTest extends StateHistoryBackendTestBase {
     @Test(expected = TimeRangeException.class)
     public void testOutOfRange_1() throws TimeRangeException {
         try {
-            ITmfStateInterval interval = fixture.doSingularQuery(-1, 0);
+            IStateHistoryBackend backend = fixture;
+            assertNotNull(backend);
+            ITmfStateInterval interval = backend.doSingularQuery(-1, 0);
             assertNull(interval);
 
         } catch (AttributeNotFoundException | StateSystemDisposedException e) {
@@ -237,7 +254,9 @@ public class InMemoryBackendTest extends StateHistoryBackendTestBase {
     @Test(expected = TimeRangeException.class)
     public void testOutOfRange_2() throws TimeRangeException {
         try {
-            ITmfStateInterval interval = fixture.doSingularQuery(100000, 0);
+            IStateHistoryBackend backend = fixture;
+            assertNotNull(backend);
+            ITmfStateInterval interval = backend.doSingularQuery(100000, 0);
             assertNull(interval);
 
         } catch (AttributeNotFoundException | StateSystemDisposedException e) {
index 83c60c0807d4f20ca34e116870ef63c6f6e7bf0b..5fd83ec968e61f93738c2036b105316d78439e16 100644 (file)
@@ -10,6 +10,7 @@
 package org.eclipse.tracecompass.statesystem.core.tests.backend;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -75,7 +76,7 @@ public abstract class StateHistoryBackendTestBase {
      *            The intervals to insert in the history backend
      * @return The backend to be used for querying.
      */
-    protected final IStateHistoryBackend prepareBackend(long startTime, long endTime,
+    protected final @Nullable IStateHistoryBackend prepareBackend(long startTime, long endTime,
             List<ITmfStateInterval> intervals) {
 
         try {
@@ -128,6 +129,7 @@ public abstract class StateHistoryBackendTestBase {
     protected final IStateHistoryBackend buildAndQueryFullRange(long startTime, long endTime, int nbAttr, List<ITmfStateInterval> intervals, boolean allowNull) {
 
         final IStateHistoryBackend backend = prepareBackend(startTime, endTime, intervals);
+        assertNotNull(backend);
 
         try {
             /*
@@ -155,7 +157,6 @@ public abstract class StateHistoryBackendTestBase {
             assertEquals(endTime, backend.getEndTime());
         } catch (StateSystemDisposedException e) {
             fail(e.getMessage());
-            return null;
         }
         return backend;
     }
diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/package-info.java b/statesystem/org.eclipse.tracecompass.statesystem.core.tests/src/org/eclipse/tracecompass/statesystem/core/tests/backend/package-info.java
new file mode 100644 (file)
index 0000000..be79b27
--- /dev/null
@@ -0,0 +1,11 @@
+/*******************************************************************************
+ * Copyright (c) 2016 École Polytechnique de Montréal
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+@org.eclipse.jdt.annotation.NonNullByDefault
+package org.eclipse.tracecompass.statesystem.core.tests.backend;
This page took 0.028906 seconds and 5 git commands to generate.