1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.fourthline.cling.test.gena;
17
18 import org.fourthline.cling.binding.annotations.AnnotationLocalServiceBinder;
19 import org.fourthline.cling.binding.annotations.UpnpAction;
20 import org.fourthline.cling.binding.annotations.UpnpInputArgument;
21 import org.fourthline.cling.binding.annotations.UpnpOutputArgument;
22 import org.fourthline.cling.binding.annotations.UpnpServiceId;
23 import org.fourthline.cling.binding.annotations.UpnpServiceType;
24 import org.fourthline.cling.binding.annotations.UpnpStateVariable;
25 import org.fourthline.cling.model.meta.DeviceDetails;
26 import org.fourthline.cling.model.meta.LocalDevice;
27 import org.fourthline.cling.model.meta.LocalService;
28 import org.fourthline.cling.model.types.UDADeviceType;
29 import org.fourthline.cling.test.data.SampleData;
30
31
32
33
34 public class GenaSampleData {
35
36 public static LocalDevice createTestDevice() throws Exception {
37 return createTestDevice(LocalTestService.class);
38 }
39
40 public static LocalDevice createTestDevice(Class<?> clazz) throws Exception {
41 return createTestDevice(
42 SampleData.readService(
43 new AnnotationLocalServiceBinder(),
44 clazz
45 )
46 );
47 }
48
49 public static LocalDevice createTestDevice(LocalService service) throws Exception {
50 return new LocalDevice(
51 SampleData.createLocalDeviceIdentity(),
52 new UDADeviceType("BinaryLight", 1),
53 new DeviceDetails("Example Binary Light"),
54 service
55 );
56 }
57
58 @org.fourthline.cling.binding.annotations.UpnpService(
59 serviceId = @UpnpServiceId("SwitchPower"),
60 serviceType = @UpnpServiceType(value = "SwitchPower", version = 1)
61 )
62 public static class LocalTestService {
63
64 @UpnpStateVariable(sendEvents = false)
65 private boolean target = false;
66
67 @UpnpStateVariable
68 private boolean status = false;
69
70 @UpnpStateVariable(defaultValue = "foo")
71 Foo someVar;
72
73 @UpnpAction
74 public void setTarget(@UpnpInputArgument(name = "NewTargetValue") boolean newTargetValue) {
75 target = newTargetValue;
76 status = newTargetValue;
77 }
78
79 @UpnpAction(out = @UpnpOutputArgument(name = "RetTargetValue"))
80 public boolean getTarget() {
81 return target;
82 }
83
84 @UpnpAction(name = "GetStatus", out = @UpnpOutputArgument(name = "ResultStatus", getterName = "getStatus"))
85 public void dummyStatus() {
86
87 }
88
89 public boolean getStatus() {
90 return status;
91 }
92 }
93
94 public static enum Foo {
95 foo, bar
96 }
97
98 }