blob: 90736d16bbe8fe948af8da3c4c3500a94d9770ab [file] [log] [blame]
Ray Milkey540b2ce2015-02-04 17:50:20 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Ray Milkey540b2ce2015-02-04 17:50:20 -08003 *
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);
Ray Milkey6d7968e2015-07-06 14:30:02 -070040 assertThatClassIsImmutable(EncodeConstraintCodecHelper.class);
41 assertThatClassIsImmutable(DecodeConstraintCodecHelper.class);
Ray Milkey540b2ce2015-02-04 17:50:20 -080042 assertThatClassIsImmutable(CriterionCodec.class);
Ray Milkey6d7968e2015-07-06 14:30:02 -070043 assertThatClassIsImmutable(EncodeCriterionCodecHelper.class);
44 assertThatClassIsImmutable(DecodeCriterionCodecHelper.class);
Ray Milkey540b2ce2015-02-04 17:50:20 -080045 assertThatClassIsImmutable(DeviceCodec.class);
46 assertThatClassIsImmutable(EthernetCodec.class);
47 assertThatClassIsImmutable(FlowEntryCodec.class);
48 assertThatClassIsImmutable(HostCodec.class);
49 assertThatClassIsImmutable(HostLocationCodec.class);
50 assertThatClassIsImmutable(HostToHostIntentCodec.class);
51 assertThatClassIsImmutable(InstructionCodec.class);
Ray Milkey6d7968e2015-07-06 14:30:02 -070052 assertThatClassIsImmutable(EncodeInstructionCodecHelper.class);
53 assertThatClassIsImmutable(DecodeInstructionCodecHelper.class);
Ray Milkey540b2ce2015-02-04 17:50:20 -080054 assertThatClassIsImmutable(IntentCodec.class);
55 assertThatClassIsImmutable(LinkCodec.class);
56 assertThatClassIsImmutable(PathCodec.class);
57 assertThatClassIsImmutable(PointToPointIntentCodec.class);
58 assertThatClassIsImmutable(PortCodec.class);
59 assertThatClassIsImmutable(TopologyClusterCodec.class);
60 assertThatClassIsImmutable(TopologyCodec.class);
61 assertThatClassIsImmutable(TrafficSelectorCodec.class);
62 assertThatClassIsImmutable(TrafficTreatmentCodec.class);
Ray Milkeyd43fe452015-05-29 09:35:12 -070063 assertThatClassIsImmutable(FlowRuleCodec.class);
Ray Milkey540b2ce2015-02-04 17:50:20 -080064 }
65}