Revert "ss: Add serialization logic to state values"
[deliverable/tracecompass.git] / statesystem / org.eclipse.tracecompass.statesystem.core.tests / src / org / eclipse / tracecompass / statesystem / core / tests / statevalue / StateValueTestBase.java
1 /*******************************************************************************
2 * Copyright (c) 2016 EfficiOS Inc., Alexandre Montplaisir
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
9
10 package org.eclipse.tracecompass.statesystem.core.tests.statevalue;
11
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertFalse;
14
15 import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
16 import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
17 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
18 import org.junit.Test;
19
20 /**
21 * Base class for state value tests.
22 *
23 * By default, it is assumed the state value is *not* null, and throws an
24 * exception for every unbox*() method. Subclasses should override the
25 * appropriate tests to represent their actual behaviour.
26 *
27 * @author Alexandre Montplaisir
28 */
29 public abstract class StateValueTestBase {
30
31 /**
32 * @return The state value fixture
33 */
34 protected abstract ITmfStateValue getStateValueFixture();
35
36 /**
37 * @return The expected type of the state value
38 */
39 protected abstract ITmfStateValue.Type getStateValueType();
40
41 /**
42 * Test the {@link TmfStateValue#getType()} method
43 */
44 @Test
45 public final void testGetType() {
46 assertEquals(getStateValueType(), getStateValueFixture().getType());
47 }
48
49 /**
50 * Test the {@link TmfStateValue#unboxInt()} method
51 */
52 @Test(expected=StateValueTypeException.class)
53 public void testUnboxInt() {
54 getStateValueFixture().unboxInt();
55 }
56
57 /**
58 * Test the {@link TmfStateValue#unboxLong()} method
59 */
60 @Test(expected=StateValueTypeException.class)
61 public void testUnboxLong() {
62 getStateValueFixture().unboxLong();
63 }
64
65 /**
66 * Test the {@link TmfStateValue#unboxDouble()} method
67 */
68 @Test(expected=StateValueTypeException.class)
69 public void testUnboxDouble() {
70 getStateValueFixture().unboxDouble();
71 }
72
73 /**
74 * Test the {@link TmfStateValue#unboxStr()} method
75 */
76 @Test(expected=StateValueTypeException.class)
77 public void testUnboxStr() {
78 getStateValueFixture().unboxStr();
79 }
80
81 /**
82 * Test the {@link TmfStateValue#isNull()} method
83 */
84 @Test
85 public void testIsNull() {
86 assertFalse(getStateValueFixture().isNull());
87 }
88 }
This page took 0.036682 seconds and 5 git commands to generate.