blob: 3915c8da0934a939227df0da9811acca0127762a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/*-
* ============LICENSE_START=======================================================
* openECOMP : APP-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.openecomp.appc;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.openecomp.appc.provider.AppcProvider;
/**
* Defines a unit test class which tests the provider. This class leverages the AbstractDataBrokerTest class which
* starts a real MD-SAL implementation to use inside of your unit tests. This is not an exhaustive test, but rather is
* used to illustrate how one can leverage the AbstractDataBrokerTest to test MD-SAL providers/listeners.
*/
public class AppcProviderTest extends AbstractDataBrokerTest {
private ExecutorService threadPool = Executors.newSingleThreadExecutor();
private AppcProvider provider;
private DataBroker dataBroker;
/**
* The @Before annotation is defined in the AbstractDataBrokerTest class. The method setupWithDataBroker is invoked
* from inside the @Before method and is used to initialize the databroker with objects for a test runs. In our case
* we use this oportunity to create an instance of our provider and initialize it (which registers it as a listener
* etc). This method runs before every @Test method below.
*/
@Override
protected void setupWithDataBroker(DataBroker dataBroker) {
super.setupWithDataBroker(dataBroker);
this.dataBroker = dataBroker;
NotificationProviderService nps = null;
RpcProviderRegistry registry = null;
provider = new AppcProvider(dataBroker, nps, registry);
}
/**
* Shuts down our provider, testing close code. @After runs after every @Test method below.
*/
@After
public void stop() throws Exception {
if (provider != null) {
provider.close();
}
}
/**
* This validates that when a task is created, the run count is initialized to 0
*/
@Ignore
@Test
public void sampleUnitTest() {
// This is where you add your unit testing. You can access "DataBroker" as
// needed to create items etc.
// This a "Real" data broker.
}
}
|