6
6
import com .qiniu .qvs .model .Device ;
7
7
import com .qiniu .qvs .model .PatchOperation ;
8
8
import com .qiniu .util .Auth ;
9
+ import org .junit .Assert ;
9
10
import org .junit .Before ;
10
11
import org .junit .Test ;
11
12
import test .com .qiniu .TestConfig ;
@@ -14,8 +15,9 @@ public class DeviceManagerTest {
14
15
Auth auth = TestConfig .testAuth ;
15
16
private DeviceManager deviceManager ;
16
17
private Response res = null ;
17
- private String namespaceId = "3nm4x0v0h6vjr" ;
18
- private String gbId = "31011500991320000056" ;
18
+ private String namespaceId = "2xenzw3lpzpdz" ;
19
+ private String gbId = "31011500991320000126" ;
20
+ private String [] channels = {"31011500991320000126" };
19
21
20
22
21
23
@ Before
@@ -30,8 +32,10 @@ public void testCreateDevice() {
30
32
device .setPassword ("QQQNNN111" );
31
33
try {
32
34
res = deviceManager .createDevice (namespaceId , device );
35
+ Assert .assertNotNull (res );
33
36
System .out .println (res .bodyString ());
34
37
} catch (QiniuException e ) {
38
+ Assert .assertEquals ("401" , res .statusCode );
35
39
e .printStackTrace ();
36
40
} finally {
37
41
if (res != null ) {
@@ -44,8 +48,10 @@ public void testCreateDevice() {
44
48
public void testQueryDevice () {
45
49
try {
46
50
res = deviceManager .queryDevice (namespaceId , gbId );
51
+ Assert .assertNotNull (res );
47
52
System .out .println (res .bodyString ());
48
53
} catch (QiniuException e ) {
54
+ Assert .assertEquals ("401" , res .statusCode );
49
55
e .printStackTrace ();
50
56
} finally {
51
57
if (res != null ) {
@@ -59,8 +65,10 @@ public void testUpdateDevice() {
59
65
PatchOperation [] patchOperation = {new PatchOperation ("replace" , "name" , "GBTEST" )};
60
66
try {
61
67
res = deviceManager .updateDevice (namespaceId , gbId , patchOperation );
68
+ Assert .assertNotNull (res );
62
69
System .out .println (res .bodyString ());
63
70
} catch (QiniuException e ) {
71
+ Assert .assertEquals ("401" , res .statusCode );
64
72
e .printStackTrace ();
65
73
} finally {
66
74
if (res != null ) {
@@ -78,8 +86,10 @@ public void testListDevice() {
78
86
String state = "notReg" ;
79
87
try {
80
88
res = deviceManager .listDevice (namespaceId , offset , line , prefix , state , qtype );
89
+ Assert .assertNotNull (res );
81
90
System .out .println (res .bodyString ());
82
91
} catch (QiniuException e ) {
92
+ Assert .assertEquals ("401" , res .statusCode );
83
93
e .printStackTrace ();
84
94
} finally {
85
95
if (res != null ) {
@@ -93,6 +103,7 @@ public void testListChannels() {
93
103
String prefix = "310" ;
94
104
try {
95
105
res = deviceManager .listChannels (namespaceId , gbId , prefix );
106
+ Assert .assertNotNull (res );
96
107
System .out .println (res .bodyString ());
97
108
} catch (QiniuException e ) {
98
109
e .printStackTrace ();
@@ -106,7 +117,8 @@ public void testListChannels() {
106
117
@ Test
107
118
public void testStartDevice () {
108
119
try {
109
- res = deviceManager .startDevice (namespaceId , gbId , "31011500991320000056" );
120
+ res = deviceManager .startDevice (namespaceId , gbId , channels );
121
+ Assert .assertNotNull (res );
110
122
System .out .println (res .bodyString ());
111
123
} catch (QiniuException e ) {
112
124
e .printStackTrace ();
@@ -120,7 +132,8 @@ public void testStartDevice() {
120
132
@ Test
121
133
public void testStopDevice () {
122
134
try {
123
- res = deviceManager .stopDevice (namespaceId , gbId , "31011500991320000056" );
135
+ res = deviceManager .stopDevice (namespaceId , gbId , channels );
136
+ Assert .assertNotNull (res );
124
137
System .out .println (res .bodyString ());
125
138
} catch (QiniuException e ) {
126
139
e .printStackTrace ();
@@ -135,8 +148,10 @@ public void testStopDevice() {
135
148
public void testDeleteDevice () {
136
149
try {
137
150
res = deviceManager .deleteDevice (namespaceId , gbId );
151
+ Assert .assertNotNull (res );
138
152
System .out .println (res .bodyString ());
139
153
} catch (QiniuException e ) {
154
+ Assert .assertEquals ("401" , res .statusCode );
140
155
e .printStackTrace ();
141
156
} finally {
142
157
if (res != null ) {
0 commit comments