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 com.google.common.base.MoreObjects;
11 import org.junit.Assert;
12 import org.junit.Test;
13 import org.opendaylight.controller.cluster.access.ABIVersion;
14 import org.opendaylight.controller.cluster.access.concepts.AbstractRequestProxy;
15 import org.opendaylight.controller.cluster.access.concepts.AbstractRequestTest;
16 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
17 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
18 import org.opendaylight.controller.cluster.access.concepts.FrontendType;
19 import org.opendaylight.controller.cluster.access.concepts.MemberName;
20 import org.opendaylight.controller.cluster.access.concepts.RequestException;
22 public class ConnectClientRequestTest extends AbstractRequestTest<ConnectClientRequest> {
23 private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
24 MemberName.forName("member"), FrontendType.forName("frontend"));
25 private static final ClientIdentifier CLIENT_IDENTIFIER = ClientIdentifier.create(FRONTEND_IDENTIFIER, 0);
27 private static final ABIVersion MIN_VERSION = ABIVersion.TEST_PAST_VERSION;
28 private static final ABIVersion MAX_VERSION = ABIVersion.TEST_FUTURE_VERSION;
30 private static final ConnectClientRequest OBJECT = new ConnectClientRequest(
31 CLIENT_IDENTIFIER, 0, ACTOR_REF, MIN_VERSION, MAX_VERSION);
34 protected ConnectClientRequest object() {
39 public void getMinVersion() throws Exception {
40 Assert.assertEquals(MIN_VERSION, OBJECT.getMinVersion());
44 public void getMaxVersion() throws Exception {
45 Assert.assertEquals(MAX_VERSION, OBJECT.getMaxVersion());
49 public void toRequestFailure() throws Exception {
50 final RequestException exception = new DeadTransactionException(0);
51 final ConnectClientFailure failure = OBJECT.toRequestFailure(exception);
52 Assert.assertNotNull(failure);
56 public void externalizableProxy() throws Exception {
57 final AbstractRequestProxy<ClientIdentifier, ConnectClientRequest> proxy = OBJECT.externalizableProxy(
58 ABIVersion.current());
59 Assert.assertNotNull(proxy);
63 public void cloneAsVersion() throws Exception {
64 final ConnectClientRequest clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
65 Assert.assertNotNull(clone);
66 Assert.assertEquals(ABIVersion.BORON, clone.getVersion());
70 public void addToStringAttributes() throws Exception {
71 final MoreObjects.ToStringHelper result = OBJECT.addToStringAttributes(MoreObjects.toStringHelper(OBJECT));
72 Assert.assertTrue(result.toString().contains("minVersion=" + MIN_VERSION));
73 Assert.assertTrue(result.toString().contains("maxVersion=" + MAX_VERSION));