Fix warnings in sal-akka-raft test classes
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / test / java / org / opendaylight / controller / cluster / raft / DefaultConfigParamsImplTest.java
1 /*
2  * Copyright (c) 2015 Cisco 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.raft;
9
10 import static org.junit.Assert.assertEquals;
11
12 import org.junit.Test;
13 import org.opendaylight.controller.cluster.raft.policy.DefaultRaftPolicy;
14 import org.opendaylight.controller.cluster.raft.policy.RaftPolicy;
15 import org.opendaylight.controller.cluster.raft.policy.TestRaftPolicy;
16
17 public class DefaultConfigParamsImplTest {
18
19     @Test
20     public void testGetRaftPolicyWithDefault() {
21         DefaultConfigParamsImpl params = new DefaultConfigParamsImpl();
22
23         assertEquals("Default instance", DefaultRaftPolicy.INSTANCE, params.getRaftPolicy());
24     }
25
26     @Test
27     public void testGetRaftPolicyInvalidClassName() {
28         DefaultConfigParamsImpl params = new DefaultConfigParamsImpl();
29         params.setCustomRaftPolicyImplementationClass("foobar");
30
31         assertEquals("Default instance", DefaultRaftPolicy.INSTANCE, params.getRaftPolicy());
32     }
33
34     @Test
35     public void testGetRaftPolicyValidClassNameButInvalidType() {
36         DefaultConfigParamsImpl params = new DefaultConfigParamsImpl();
37         params.setCustomRaftPolicyImplementationClass("java.lang.String");
38
39         assertEquals("Default instance", DefaultRaftPolicy.INSTANCE, params.getRaftPolicy());
40     }
41
42     @Test
43     public void testGetRaftPolicyValidClass() {
44         DefaultConfigParamsImpl params1 = new DefaultConfigParamsImpl();
45         params1.setCustomRaftPolicyImplementationClass(
46                 "org.opendaylight.controller.cluster.raft.policy.TestRaftPolicy");
47         RaftPolicy behavior1 = params1.getRaftPolicy();
48
49         assertEquals("TestCustomBehavior", TestRaftPolicy.class, behavior1.getClass());
50         assertEquals("Same instance returned", behavior1, params1.getRaftPolicy());
51
52         DefaultConfigParamsImpl params2 = new DefaultConfigParamsImpl();
53         RaftPolicy behavior2 = params2.getRaftPolicy();
54         params1.setCustomRaftPolicyImplementationClass(
55                 "org.opendaylight.controller.cluster.raft.policy.TestRaftPolicy");
56
57         assertEquals("Default instance", DefaultRaftPolicy.INSTANCE, behavior2);
58         assertEquals("Default instance", DefaultRaftPolicy.INSTANCE, params2.getRaftPolicy());
59
60     }
61
62
63 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.