2 * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.access.commands;
10 import org.apache.commons.lang.SerializationUtils;
11 import org.junit.Assert;
12 import org.junit.Test;
13 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
14 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
15 import org.opendaylight.controller.cluster.access.concepts.FrontendType;
16 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
17 import org.opendaylight.controller.cluster.access.concepts.MemberName;
18 import org.opendaylight.controller.cluster.access.concepts.RequestSuccess;
20 public abstract class AbstractRequestSuccessTest<T extends RequestSuccess<?, T>> {
22 private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
23 MemberName.forName("test"), FrontendType.forName("one"));
24 protected static final ClientIdentifier CLIENT_IDENTIFIER = ClientIdentifier.create(FRONTEND_IDENTIFIER, 0);
25 protected static final LocalHistoryIdentifier HISTORY_IDENTIFIER = new LocalHistoryIdentifier(
26 CLIENT_IDENTIFIER, 0);
28 protected abstract T object();
30 @SuppressWarnings("unchecked")
32 public void serializationTest() {
33 final Object deserialize = SerializationUtils.clone(object());
35 Assert.assertEquals(object().getTarget(), ((T) deserialize).getTarget());
36 Assert.assertEquals(object().getVersion(), ((T) deserialize).getVersion());
37 Assert.assertEquals(object().getSequence(), ((T) deserialize).getSequence());
38 doAdditionalAssertions(deserialize);
41 protected abstract void doAdditionalAssertions(Object deserialize);