blob: 744248aa6fffcc4e056f0daeb2b1d4b453dfc3c1 [file] [log] [blame]
Ray Milkey540b2ce2015-02-04 17:50:20 -08001/*
2 * Copyright 2015 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 */
16package org.onosproject.codec.impl;
17
18import org.junit.Test;
19import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
20import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutableBaseClass;
21
22/**
23 * Tests to assure that the codec classes follow the contract of having
24 * no local context.
25 */
26public class ImmutableCodecsTest {
27
28 /**
29 * Checks that the codec classes adhere to the contract that there cannot
30 * be any local context in a codec.
31 */
32 @Test
33 public void checkImmutability() {
34 assertThatClassIsImmutableBaseClass(AnnotatedCodec.class);
35 assertThatClassIsImmutable(AnnotationsCodec.class);
36 assertThatClassIsImmutable(ApplicationCodec.class);
37 assertThatClassIsImmutable(ConnectivityIntentCodec.class);
38 assertThatClassIsImmutable(ConnectPointCodec.class);
39 assertThatClassIsImmutable(ConstraintCodec.class);
40 assertThatClassIsImmutable(CriterionCodec.class);
Ray Milkeyd43fe452015-05-29 09:35:12 -070041 assertThatClassIsImmutable(EncodeCriterionCodec.class);
42 assertThatClassIsImmutable(DecodeCriterionCodec.class);
Ray Milkey540b2ce2015-02-04 17:50:20 -080043 assertThatClassIsImmutable(DeviceCodec.class);
44 assertThatClassIsImmutable(EthernetCodec.class);
45 assertThatClassIsImmutable(FlowEntryCodec.class);
46 assertThatClassIsImmutable(HostCodec.class);
47 assertThatClassIsImmutable(HostLocationCodec.class);
48 assertThatClassIsImmutable(HostToHostIntentCodec.class);
49 assertThatClassIsImmutable(InstructionCodec.class);
Ray Milkeyd43fe452015-05-29 09:35:12 -070050 assertThatClassIsImmutable(EncodeInstructionCodec.class);
51 assertThatClassIsImmutable(DecodeInstructionCodec.class);
Ray Milkey540b2ce2015-02-04 17:50:20 -080052 assertThatClassIsImmutable(IntentCodec.class);
53 assertThatClassIsImmutable(LinkCodec.class);
54 assertThatClassIsImmutable(PathCodec.class);
55 assertThatClassIsImmutable(PointToPointIntentCodec.class);
56 assertThatClassIsImmutable(PortCodec.class);
57 assertThatClassIsImmutable(TopologyClusterCodec.class);
58 assertThatClassIsImmutable(TopologyCodec.class);
59 assertThatClassIsImmutable(TrafficSelectorCodec.class);
60 assertThatClassIsImmutable(TrafficTreatmentCodec.class);
Ray Milkeyd43fe452015-05-29 09:35:12 -070061 assertThatClassIsImmutable(FlowRuleCodec.class);
Ray Milkey540b2ce2015-02-04 17:50:20 -080062 }
63}