1 package example.binarylight;
2
3 import org.fourthline.cling.mock.MockUpnpService;
4 import org.fourthline.cling.model.meta.LocalDevice;
5 import org.fourthline.cling.model.meta.LocalService;
6 import org.testng.annotations.Test;
7
8 import static org.testng.Assert.assertEquals;
9
10
11
12
13 public class BinaryLightTest {
14
15 @Test
16 public void testServer() throws Exception {
17 LocalDevice binaryLight = new BinaryLightServer().createDevice();
18 assertEquals(binaryLight.getServices()[0].getAction("SetTarget").getName(), "SetTarget");
19 }
20
21 @Test
22 public void testClient() throws Exception {
23
24
25 MockUpnpService upnpService = new MockUpnpService();
26
27 BinaryLightClient client = new BinaryLightClient();
28 LocalDevice binaryLight = new BinaryLightServer().createDevice();
29
30 LocalService<SwitchPower> service = binaryLight.getServices()[0];
31 client.executeAction(upnpService, binaryLight.getServices()[0]);
32 Thread.sleep(100);
33 assertEquals(service.getManager().getImplementation().getStatus(), true);
34 }
35
36 }