File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed
main/java/com/aspose/barcode/cloud
test/java/com/aspose/barcode/cloud/test Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -938,12 +938,13 @@ public void requestToken() throws ApiException {
938938 .build ();
939939
940940 Response response = httpClient .newCall (request ).execute ();
941+ String responseBody = response .body ().string ();
941942 if (response .isSuccessful ()) {
942943 GetAccessTokenResult result =
943- json .deserialize (response . body (). string () , GetAccessTokenResult .class );
944+ json .deserialize (responseBody , GetAccessTokenResult .class );
944945 setAccessToken (result .access_token );
945946 } else {
946- throw new ApiException (response . body (). string () );
947+ throw new ApiException (responseBody );
947948 }
948949 } catch (Exception ex ) {
949950 throw new ApiException (ex );
Original file line number Diff line number Diff line change 11package com .aspose .barcode .cloud .test ;
22
3- import static org .junit .Assert .assertEquals ;
4- import static org .junit .Assert .assertTrue ;
5-
63import com .aspose .barcode .cloud .ApiException ;
74import com .aspose .barcode .cloud .api .GenerateApi ;
85import com .aspose .barcode .cloud .model .EncodeBarcodeType ;
118import org .junit .BeforeClass ;
129import org .junit .Test ;
1310
11+ import static org .junit .Assert .*;
12+
1413public class ExceptionTest extends TestBase {
1514
1615 private static GenerateApi api ;
@@ -24,12 +23,11 @@ public static void oneTimeSetUp() {
2423 public void ExceptionMessageParsed () {
2524 GenerateRequestWrapper request = new GenerateRequestWrapper (EncodeBarcodeType .QR , "" );
2625
27- boolean thrown = false ;
26+ ApiException thrownE = null ;
2827 try {
2928 api .generate (request );
3029 } catch (ApiException e ) {
31- thrown = true ;
32- System .err .println (e );
30+ thrownE = e ;
3331 assertEquals (400 , e .getHttpCode ());
3432 assertEquals ("com.aspose.barcode.cloud.ApiException: Bad Request" , e .toString ());
3533 assertEquals (
@@ -38,6 +36,6 @@ public void ExceptionMessageParsed() {
3836 e .getDetails ().replace ("\r " , "" ));
3937 }
4038
41- assertTrue ( thrown );
39+ assertNotNull ( thrownE );
4240 }
4341}
You can’t perform that action at this time.
0 commit comments