View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  
16  package org.fourthline.cling.test.data;
17  
18  import org.fourthline.cling.model.resource.DeviceDescriptorResource;
19  import org.fourthline.cling.model.resource.IconResource;
20  import org.fourthline.cling.model.resource.ServiceControlResource;
21  import org.fourthline.cling.model.resource.ServiceDescriptorResource;
22  import org.fourthline.cling.model.resource.ServiceEventSubscriptionResource;
23  import org.fourthline.cling.model.resource.Resource;
24  import org.fourthline.cling.model.meta.Device;
25  import org.fourthline.cling.model.meta.DeviceIdentity;
26  import org.fourthline.cling.model.meta.LocalService;
27  
28  import java.net.URI;
29  
30  import static org.testng.Assert.assertEquals;
31  
32  /**
33   * @author Christian Bauer
34   */
35  public class SampleDeviceRootLocal extends SampleDeviceRoot {
36  
37      public SampleDeviceRootLocal(DeviceIdentity identity, LocalService service, Device embeddedDevice) {
38          super(identity, service, embeddedDevice);
39      }
40  
41      public static void assertLocalResourcesMatch(Resource[] resources){
42          assertEquals(
43                  getLocalResource(resources, URI.create("/dev/MY-DEVICE-123/desc")).getClass(),
44                  DeviceDescriptorResource.class
45          );
46          assertEquals(
47                  getLocalResource(resources, URI.create("/dev/MY-DEVICE-123/icon.png")).getClass(),
48                  IconResource.class
49          );
50          assertEquals(
51                  getLocalResource(resources, URI.create("/dev/MY-DEVICE-123/icon2.png")).getClass(),
52                  IconResource.class
53          );
54          assertEquals(
55                  getLocalResource(resources, URI.create("/dev/MY-DEVICE-123/svc/upnp-org/MY-SERVICE-123/desc")).getClass(),
56                  ServiceDescriptorResource.class
57          );
58          assertEquals(
59                  getLocalResource(resources, URI.create("/dev/MY-DEVICE-123/svc/upnp-org/MY-SERVICE-123/action")).getClass(),
60                  ServiceControlResource.class
61          );
62          assertEquals(
63                  getLocalResource(resources, URI.create("/dev/MY-DEVICE-123/svc/upnp-org/MY-SERVICE-123/event")).getClass(),
64                  ServiceEventSubscriptionResource.class
65          );
66          assertEquals(
67                  getLocalResource(resources, URI.create("/dev/MY-DEVICE-456/icon3.png")).getClass(),
68                  IconResource.class
69          );
70          assertEquals(
71                  getLocalResource(resources, URI.create("/dev/MY-DEVICE-456/svc/upnp-org/MY-SERVICE-456/desc")).getClass(),
72                  ServiceDescriptorResource.class
73          );
74          assertEquals(
75                  getLocalResource(resources, URI.create("/dev/MY-DEVICE-456/svc/upnp-org/MY-SERVICE-456/action")).getClass(),
76                  ServiceControlResource.class
77          );
78          assertEquals(
79                  getLocalResource(resources, URI.create("/dev/MY-DEVICE-456/svc/upnp-org/MY-SERVICE-456/event")).getClass(),
80                  ServiceEventSubscriptionResource.class
81          );
82          assertEquals(
83                  getLocalResource(resources, URI.create("/dev/MY-DEVICE-789/svc/upnp-org/MY-SERVICE-789/desc")).getClass(),
84                  ServiceDescriptorResource.class
85          );
86          assertEquals(
87                  getLocalResource(resources, URI.create("/dev/MY-DEVICE-789/svc/upnp-org/MY-SERVICE-789/action")).getClass(),
88                  ServiceControlResource.class
89          );
90          assertEquals(
91                  getLocalResource(resources, URI.create("/dev/MY-DEVICE-789/svc/upnp-org/MY-SERVICE-789/event")).getClass(),
92                  ServiceEventSubscriptionResource.class
93          );
94  
95      }
96  
97  }