66import com .qiniu .qvs .model .Device ;
77import com .qiniu .qvs .model .PatchOperation ;
88import com .qiniu .util .Auth ;
9+ import org .junit .Assert ;
910import org .junit .Before ;
1011import org .junit .Test ;
1112import test .com .qiniu .TestConfig ;
@@ -14,8 +15,9 @@ public class DeviceManagerTest {
1415 Auth auth = TestConfig .testAuth ;
1516 private DeviceManager deviceManager ;
1617 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" };
1921
2022
2123 @ Before
@@ -30,8 +32,10 @@ public void testCreateDevice() {
3032 device .setPassword ("QQQNNN111" );
3133 try {
3234 res = deviceManager .createDevice (namespaceId , device );
35+ Assert .assertNotNull (res );
3336 System .out .println (res .bodyString ());
3437 } catch (QiniuException e ) {
38+ Assert .assertEquals ("401" , res .statusCode );
3539 e .printStackTrace ();
3640 } finally {
3741 if (res != null ) {
@@ -44,8 +48,10 @@ public void testCreateDevice() {
4448 public void testQueryDevice () {
4549 try {
4650 res = deviceManager .queryDevice (namespaceId , gbId );
51+ Assert .assertNotNull (res );
4752 System .out .println (res .bodyString ());
4853 } catch (QiniuException e ) {
54+ Assert .assertEquals ("401" , res .statusCode );
4955 e .printStackTrace ();
5056 } finally {
5157 if (res != null ) {
@@ -59,8 +65,10 @@ public void testUpdateDevice() {
5965 PatchOperation [] patchOperation = {new PatchOperation ("replace" , "name" , "GBTEST" )};
6066 try {
6167 res = deviceManager .updateDevice (namespaceId , gbId , patchOperation );
68+ Assert .assertNotNull (res );
6269 System .out .println (res .bodyString ());
6370 } catch (QiniuException e ) {
71+ Assert .assertEquals ("401" , res .statusCode );
6472 e .printStackTrace ();
6573 } finally {
6674 if (res != null ) {
@@ -78,8 +86,10 @@ public void testListDevice() {
7886 String state = "notReg" ;
7987 try {
8088 res = deviceManager .listDevice (namespaceId , offset , line , prefix , state , qtype );
89+ Assert .assertNotNull (res );
8190 System .out .println (res .bodyString ());
8291 } catch (QiniuException e ) {
92+ Assert .assertEquals ("401" , res .statusCode );
8393 e .printStackTrace ();
8494 } finally {
8595 if (res != null ) {
@@ -93,6 +103,7 @@ public void testListChannels() {
93103 String prefix = "310" ;
94104 try {
95105 res = deviceManager .listChannels (namespaceId , gbId , prefix );
106+ Assert .assertNotNull (res );
96107 System .out .println (res .bodyString ());
97108 } catch (QiniuException e ) {
98109 e .printStackTrace ();
@@ -106,7 +117,8 @@ public void testListChannels() {
106117 @ Test
107118 public void testStartDevice () {
108119 try {
109- res = deviceManager .startDevice (namespaceId , gbId , "31011500991320000056" );
120+ res = deviceManager .startDevice (namespaceId , gbId , channels );
121+ Assert .assertNotNull (res );
110122 System .out .println (res .bodyString ());
111123 } catch (QiniuException e ) {
112124 e .printStackTrace ();
@@ -120,7 +132,8 @@ public void testStartDevice() {
120132 @ Test
121133 public void testStopDevice () {
122134 try {
123- res = deviceManager .stopDevice (namespaceId , gbId , "31011500991320000056" );
135+ res = deviceManager .stopDevice (namespaceId , gbId , channels );
136+ Assert .assertNotNull (res );
124137 System .out .println (res .bodyString ());
125138 } catch (QiniuException e ) {
126139 e .printStackTrace ();
@@ -135,8 +148,10 @@ public void testStopDevice() {
135148 public void testDeleteDevice () {
136149 try {
137150 res = deviceManager .deleteDevice (namespaceId , gbId );
151+ Assert .assertNotNull (res );
138152 System .out .println (res .bodyString ());
139153 } catch (QiniuException e ) {
154+ Assert .assertEquals ("401" , res .statusCode );
140155 e .printStackTrace ();
141156 } finally {
142157 if (res != null ) {
0 commit comments