2 * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.datastore.messages;
10 import static org.junit.Assert.assertEquals;
12 import java.io.Serializable;
13 import org.apache.commons.lang.SerializationUtils;
14 import org.junit.Test;
15 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
16 import org.opendaylight.controller.cluster.datastore.MockIdentifiers;
19 * Unit tests for AbortTransaction.
21 * @author Thomas Pantelis
23 public class AbortTransactionTest {
26 public void testSerialization() {
27 AbortTransaction expected = new AbortTransaction(
28 MockIdentifiers.transactionIdentifier(AbortTransactionTest.class, "mock"),
29 DataStoreVersions.CURRENT_VERSION);
31 Object serialized = expected.toSerializable();
32 assertEquals("Serialized type", AbortTransaction.class, serialized.getClass());
34 AbortTransaction actual = AbortTransaction.fromSerializable(
35 SerializationUtils.clone((Serializable) serialized));
36 assertEquals("getTransactionID", expected.getTransactionId(), actual.getTransactionId());
37 assertEquals("getVersion", DataStoreVersions.CURRENT_VERSION, actual.getVersion());
41 public void testIsSerializedType() {
42 assertEquals("isSerializedType", true, AbortTransaction.isSerializedType(new AbortTransaction()));
43 assertEquals("isSerializedType", false, AbortTransaction.isSerializedType(new Object()));