|
19 | 19 | import java.util.Map; |
20 | 20 |
|
21 | 21 | import org.eclipse.jdt.annotation.NonNullByDefault; |
22 | | -import org.eclipse.jetty.client.HttpClient; |
23 | | -import org.junit.jupiter.api.AfterAll; |
24 | | -import org.junit.jupiter.api.AfterEach; |
25 | | -import org.junit.jupiter.api.BeforeAll; |
26 | 22 | import org.junit.jupiter.api.BeforeEach; |
27 | 23 | import org.openhab.binding.avmfritz.internal.AVMFritzDynamicCommandDescriptionProvider; |
28 | 24 | import org.openhab.core.config.core.Configuration; |
29 | 25 | import org.openhab.core.test.java.JavaOSGiTest; |
30 | | -import org.openhab.core.test.storage.VolatileStorageService; |
31 | 26 | import org.openhab.core.thing.Bridge; |
32 | | -import org.openhab.core.thing.ManagedThingProvider; |
33 | | -import org.openhab.core.thing.ThingProvider; |
34 | | -import org.openhab.core.thing.binding.ThingHandler; |
35 | 27 | import org.openhab.core.thing.binding.ThingHandlerCallback; |
36 | 28 | import org.openhab.core.thing.binding.builder.BridgeBuilder; |
37 | 29 |
|
|
43 | 35 | @NonNullByDefault |
44 | 36 | public abstract class AVMFritzThingHandlerOSGiTest extends JavaOSGiTest { |
45 | 37 |
|
46 | | - private static HttpClient httpClient = new HttpClient(); |
47 | | - |
48 | | - private VolatileStorageService volatileStorageService = new VolatileStorageService(); |
49 | | - private @NonNullByDefault({}) ManagedThingProvider managedThingProvider; |
50 | | - |
51 | 38 | protected @NonNullByDefault({}) Bridge bridge; |
52 | 39 | protected @NonNullByDefault({}) BoxHandler bridgeHandler; |
53 | 40 |
|
54 | | - @BeforeAll |
55 | | - public static void setUpClass() throws Exception { |
56 | | - httpClient.start(); |
57 | | - } |
58 | | - |
59 | 41 | @BeforeEach |
60 | 42 | public void setUp() { |
61 | | - registerService(volatileStorageService); |
62 | | - |
63 | | - managedThingProvider = getService(ThingProvider.class, ManagedThingProvider.class); |
64 | | - assertNotNull(managedThingProvider, "Could not get ManagedThingProvider"); |
65 | | - |
66 | 43 | bridge = buildBridge(); |
67 | 44 | assertNotNull(bridge.getConfiguration()); |
68 | 45 |
|
69 | | - managedThingProvider.add(bridge); |
70 | | - |
71 | 46 | ThingHandlerCallback callback = mock(ThingHandlerCallback.class); |
72 | 47 |
|
73 | | - bridgeHandler = new BoxHandler(bridge, httpClient, mock(AVMFritzDynamicCommandDescriptionProvider.class)); |
| 48 | + bridgeHandler = new BoxHandler(bridge, mock(), mock(AVMFritzDynamicCommandDescriptionProvider.class)); |
74 | 49 | assertNotNull(bridgeHandler); |
75 | 50 |
|
76 | 51 | bridgeHandler.setCallback(callback); |
77 | | - |
78 | | - ThingHandler oldHandler = bridge.getHandler(); |
79 | | - if (oldHandler != null) { |
80 | | - oldHandler.dispose(); |
81 | | - } |
82 | 52 | bridge.setHandler(bridgeHandler); |
83 | 53 | assertNotNull(bridge.getHandler()); |
84 | 54 |
|
85 | | - bridgeHandler.initialize(); |
86 | | - } |
87 | | - |
88 | | - @AfterEach |
89 | | - public void tearDown() { |
90 | | - if (bridge != null) { |
91 | | - managedThingProvider.remove(bridge.getUID()); |
92 | | - } |
93 | | - |
94 | | - unregisterService(volatileStorageService); |
95 | | - } |
96 | | - |
97 | | - @AfterAll |
98 | | - public static void tearDownClass() throws Exception { |
99 | | - httpClient.stop(); |
| 55 | + // Discovery tests only need the handler's type and UID mapping. Initializing it would authenticate against |
| 56 | + // the configured host and make these tests depend on the network. |
100 | 57 | } |
101 | 58 |
|
102 | 59 | private Bridge buildBridge() { |
|
0 commit comments