c4ff243de39ed36520521efbbf5caa221a581c1b
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / messages / CloseTransactionChainTest.java
1 /*
2  * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.datastore.messages;
9
10 import static org.junit.Assert.assertEquals;
11 import java.io.Serializable;
12 import org.apache.commons.lang.SerializationUtils;
13 import org.junit.Test;
14 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
15
16 /**
17  * Unit tests for CloseTransactionChain.
18  *
19  * @author Thomas Pantelis
20  */
21 public class CloseTransactionChainTest {
22
23     @Test
24     public void testSerialization() {
25         CloseTransactionChain expected = new CloseTransactionChain("txId", DataStoreVersions.CURRENT_VERSION);
26
27         Object serialized = expected.toSerializable();
28         assertEquals("Serialized type", CloseTransactionChain.class, serialized.getClass());
29
30         CloseTransactionChain actual = CloseTransactionChain.fromSerializable(
31                 SerializationUtils.clone((Serializable) serialized));
32         assertEquals("getTransactionChainId", expected.getTransactionChainId(), actual.getTransactionChainId());
33         assertEquals("getVersion", DataStoreVersions.CURRENT_VERSION, actual.getVersion());
34     }
35
36     @Test
37     public void testIsSerializedType() {
38         assertEquals("isSerializedType", true, CloseTransactionChain.isSerializedType(new CloseTransactionChain()));
39         assertEquals("isSerializedType", false, CloseTransactionChain.isSerializedType(new Object()));
40     }
41 }