blob: 02b8d641e278ca78837740b190ba0733418bb58f [file] [log] [blame]
Ray Milkey85267002016-11-16 11:06:35 -08001/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Jonathan Hart679d24d2016-05-13 13:29:53 -070016package org.onosproject.store.serializers;
17
18import org.junit.Test;
19import org.onlab.util.KryoNamespace;
20
21import static org.junit.Assert.assertTrue;
22
23/**
24 * Tests pre-defined Kryo namespaces to catch basic errors such as someone
25 * adding too many registrations which may flow into another namespace.
26 */
27public class KryoNamespacesTest {
28
29 /**
30 * Verifies that the BASIC namespace has not exceeded its allocated size.
31 */
32 @Test
33 public void basicNamespaceSizeTest() {
34 testNamespaceSize(KryoNamespaces.BASIC, KryoNamespaces.BASIC_MAX_SIZE);
35 }
36
37 /**
38 * Verifies that the MISC namespace has not exceeded its allocated size.
39 */
40 @Test
41 public void miscNamespaceSizeTest() {
42 testNamespaceSize(KryoNamespaces.MISC, KryoNamespaces.MISC_MAX_SIZE);
43 }
44
45 /**
46 * Verifies that the API namespace has not exceeded its allocated size.
47 */
48 @Test
49 public void apiNamespaceSizeTest() {
50 testNamespaceSize(KryoNamespaces.API, KryoNamespaces.API_MAX_SIZE);
51 }
52
53 private void testNamespaceSize(KryoNamespace namespace, int maxSize) {
54 assertTrue("Kryo namespace has exceeded its allocated size",
55 namespace.size() < maxSize);
56 }
57}