blob: 4187569523f5e40acbebd76193cf5086839a2461 [file] [log] [blame]
Jonathan Hart679d24d2016-05-13 13:29:53 -07001package org.onosproject.store.serializers;
2
3import org.junit.Test;
4import org.onlab.util.KryoNamespace;
5
6import static org.junit.Assert.assertTrue;
7
8/**
9 * Tests pre-defined Kryo namespaces to catch basic errors such as someone
10 * adding too many registrations which may flow into another namespace.
11 */
12public class KryoNamespacesTest {
13
14 /**
15 * Verifies that the BASIC namespace has not exceeded its allocated size.
16 */
17 @Test
18 public void basicNamespaceSizeTest() {
19 testNamespaceSize(KryoNamespaces.BASIC, KryoNamespaces.BASIC_MAX_SIZE);
20 }
21
22 /**
23 * Verifies that the MISC namespace has not exceeded its allocated size.
24 */
25 @Test
26 public void miscNamespaceSizeTest() {
27 testNamespaceSize(KryoNamespaces.MISC, KryoNamespaces.MISC_MAX_SIZE);
28 }
29
30 /**
31 * Verifies that the API namespace has not exceeded its allocated size.
32 */
33 @Test
34 public void apiNamespaceSizeTest() {
35 testNamespaceSize(KryoNamespaces.API, KryoNamespaces.API_MAX_SIZE);
36 }
37
38 private void testNamespaceSize(KryoNamespace namespace, int maxSize) {
39 assertTrue("Kryo namespace has exceeded its allocated size",
40 namespace.size() < maxSize);
41 }
42}