Ray Milkey | 540b2ce | 2015-02-04 17:50:20 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Ray Milkey | 540b2ce | 2015-02-04 17:50:20 -0800 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.codec.impl; |
| 17 | |
| 18 | import org.junit.Test; |
| 19 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 20 | import 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 | */ |
| 26 | public 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 Milkey | 6d7968e | 2015-07-06 14:30:02 -0700 | [diff] [blame] | 40 | assertThatClassIsImmutable(EncodeConstraintCodecHelper.class); |
| 41 | assertThatClassIsImmutable(DecodeConstraintCodecHelper.class); |
Ray Milkey | 540b2ce | 2015-02-04 17:50:20 -0800 | [diff] [blame] | 42 | assertThatClassIsImmutable(CriterionCodec.class); |
Ray Milkey | 6d7968e | 2015-07-06 14:30:02 -0700 | [diff] [blame] | 43 | assertThatClassIsImmutable(EncodeCriterionCodecHelper.class); |
| 44 | assertThatClassIsImmutable(DecodeCriterionCodecHelper.class); |
Ray Milkey | 540b2ce | 2015-02-04 17:50:20 -0800 | [diff] [blame] | 45 | 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 Milkey | 6d7968e | 2015-07-06 14:30:02 -0700 | [diff] [blame] | 52 | assertThatClassIsImmutable(EncodeInstructionCodecHelper.class); |
| 53 | assertThatClassIsImmutable(DecodeInstructionCodecHelper.class); |
Ray Milkey | 540b2ce | 2015-02-04 17:50:20 -0800 | [diff] [blame] | 54 | 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 Milkey | d43fe45 | 2015-05-29 09:35:12 -0700 | [diff] [blame] | 63 | assertThatClassIsImmutable(FlowRuleCodec.class); |
Ray Milkey | 540b2ce | 2015-02-04 17:50:20 -0800 | [diff] [blame] | 64 | } |
| 65 | } |