blob: 717cda2ed5921a024c3b1d8ea0421258b2353ef1 [file] [log] [blame]
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.net.driver;
17
18import com.google.common.collect.ImmutableMap;
19import org.junit.Before;
20import org.junit.Test;
21
22import static org.junit.Assert.assertSame;
23import static org.junit.Assert.assertTrue;
24
25public class DefaultDriverHandlerTest {
26
27 DefaultDriver ddc;
28 DefaultDriverData data;
29 DefaultDriverHandler handler;
30
31 @Before
32 public void setUp() {
Thomas Vachuska635c2d72015-05-08 14:32:13 -070033 ddc = new DefaultDriver("foo.bar", null, "Circus", "lux", "1.2a",
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080034 ImmutableMap.of(TestBehaviour.class,
35 TestBehaviourImpl.class,
36 TestBehaviourTwo.class,
37 TestBehaviourTwoImpl.class),
38 ImmutableMap.of("foo", "bar"));
Thomas Vachuska80b0a802015-07-17 08:43:30 -070039 data = new DefaultDriverData(ddc, DefaultDriverDataTest.DEVICE_ID);
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080040 handler = new DefaultDriverHandler(data);
41 }
42
43 @Test
44 public void basics() {
45 assertSame("incorrect data", data, handler.data());
46 assertTrue("incorrect toString", handler.toString().contains("1.2a"));
47 }
48
49 @Test
50 public void behaviour() {
51 TestBehaviourTwo behaviour = handler.behaviour(TestBehaviourTwo.class);
52 assertTrue("incorrect behaviour", behaviour instanceof TestBehaviourTwoImpl);
53 }
54
55}