@@ -45,11 +45,15 @@ public static void setUpClass() throws IOException {
4545 public static void tearDownClass () {
4646 Api api = new Cloudinary ().api ();
4747 try {
48- api .deleteResourcesByTag (ARCHIVE_TAG , ObjectUtils .emptyMap ());
48+ api .deleteResourcesByTag (UPLOADER_TAG , ObjectUtils .emptyMap ());
4949 } catch (Exception ignored ) {
5050 }
5151 try {
52- api .deleteResourcesByTag (UPLOADER_TAG , ObjectUtils .emptyMap ());
52+ api .deleteResourcesByTag (UPLOADER_TAG , ObjectUtils .asMap ("resource_type" , "video" ));
53+ } catch (Exception ignored ) {
54+ }
55+ try {
56+ api .deleteResourcesByTag (UPLOADER_TAG , ObjectUtils .asMap ("resource_type" , "raw" ));
5357 } catch (Exception ignored ) {
5458 }
5559 }
@@ -144,11 +148,11 @@ public void testRename() throws Exception {
144148 assertNotNull (cloudinary .api ().resource (publicId2 , ObjectUtils .emptyMap ()));
145149
146150 Map result2 = cloudinary .uploader ().upload ("../cloudinary-test-common/src/main/resources/favicon.ico" , asMap ("tags" , Arrays .asList (SDK_TEST_TAG , UPLOADER_TAG )));
147- boolean error_found = false ;
151+ boolean error_found = false ;
148152 try {
149- cloudinary .uploader ().rename ((String ) result2 .get ("public_id" ), publicId2 , asMap ("tags" , Arrays .asList (SDK_TEST_TAG , UPLOADER_TAG )));
150- } catch (Exception e ) {
151- error_found = true ;
153+ cloudinary .uploader ().rename ((String ) result2 .get ("public_id" ), publicId2 , asMap ("tags" , Arrays .asList (SDK_TEST_TAG , UPLOADER_TAG )));
154+ } catch (Exception e ) {
155+ error_found = true ;
152156 }
153157 assertTrue (error_found );
154158 cloudinary .uploader ().rename ((String ) result2 .get ("public_id" ), publicId2 , asMap ("overwrite" , true , "tags" , Arrays .asList (SDK_TEST_TAG , UPLOADER_TAG )));
@@ -180,7 +184,7 @@ public void testEager() throws IOException {
180184 @ Test
181185 public void testUploadAsync () throws IOException {
182186 Map result = cloudinary .uploader ().upload (SRC_TEST_IMAGE , asMap ("transformation" , new Transformation ().crop ("scale" ).width (2.0 ), "async" , true ));
183- assertEquals ((String )result .get ("status" ), "pending" );
187+ assertEquals ((String ) result .get ("status" ), "pending" );
184188 }
185189
186190 @ Test
@@ -209,9 +213,9 @@ public void testImageUploadTag() {
209213
210214 @ Test
211215 public void testSprite () throws IOException {
212- final String sprite_test_tag = String .format ("sprite_test_tag_%d" , new java .util .Date ().getTime ()) ;
213- cloudinary .uploader ().upload (SRC_TEST_IMAGE , asMap ("tags" , new String [] {sprite_test_tag , SDK_TEST_TAG , UPLOADER_TAG }, "public_id" , "sprite_test_tag_1" + SUFFIX ));
214- cloudinary .uploader ().upload (SRC_TEST_IMAGE , asMap ("tags" , new String [] {sprite_test_tag , SDK_TEST_TAG , UPLOADER_TAG }, "public_id" , "sprite_test_tag_2" + SUFFIX ));
216+ final String sprite_test_tag = String .format ("sprite_test_tag_%d" , new java .util .Date ().getTime ());
217+ cloudinary .uploader ().upload (SRC_TEST_IMAGE , asMap ("tags" , new String [] {sprite_test_tag , SDK_TEST_TAG , UPLOADER_TAG }, "public_id" , "sprite_test_tag_1" + SUFFIX ));
218+ cloudinary .uploader ().upload (SRC_TEST_IMAGE , asMap ("tags" , new String [] {sprite_test_tag , SDK_TEST_TAG , UPLOADER_TAG }, "public_id" , "sprite_test_tag_2" + SUFFIX ));
215219 Map result = cloudinary .uploader ().generateSprite (sprite_test_tag , asMap ("tags" , Arrays .asList (SDK_TEST_TAG , UPLOADER_TAG )));
216220 assertEquals (2 , ((Map ) result .get ("image_infos" )).size ());
217221 result = cloudinary .uploader ().generateSprite (sprite_test_tag , asMap ("transformation" , "w_100" ));
@@ -227,7 +231,7 @@ public void testMulti() throws IOException {
227231 cloudinary .uploader ().upload (SRC_TEST_IMAGE , options );
228232 cloudinary .uploader ().upload (SRC_TEST_IMAGE , options );
229233 List <String > ids = new ArrayList <String >();
230- Map result = cloudinary .uploader ().multi (MULTI_TEST_TAG , asMap ("transformation" , "c_crop,w_0.5" ));
234+ Map result = cloudinary .uploader ().multi (MULTI_TEST_TAG , asMap ("transformation" , "c_crop,w_0.5" ));
231235 ids .add ((String ) result .get ("public_id" ));
232236 Map pdfResult = cloudinary .uploader ().multi (MULTI_TEST_TAG , asMap ("transformation" , new Transformation ().width (111 ), "format" , "pdf" ));
233237 ids .add ((String ) pdfResult .get ("public_id" ));
@@ -428,7 +432,7 @@ public void testUploadLarge() throws Exception {
428432 out .close ();
429433 assertEquals (5880138 , temp .length ());
430434
431- String [] tags = new String [] { "upload_large_tag" , SDK_TEST_TAG , UPLOADER_TAG };
435+ String [] tags = new String []{ "upload_large_tag_" + SUFFIX , SDK_TEST_TAG , UPLOADER_TAG };
432436
433437 Map resource = cloudinary .uploader ().uploadLarge (temp , asMap ("resource_type" , "raw" , "chunk_size" , 5243000 , "tags" , tags ));
434438 assertArrayEquals (tags , ((java .util .ArrayList ) resource .get ("tags" )).toArray ());
@@ -442,7 +446,7 @@ public void testUploadLarge() throws Exception {
442446 assertEquals (1400 , resource .get ("height" ));
443447
444448 resource = cloudinary .uploader ().uploadLarge (temp , asMap ("chunk_size" , 5880138 , "tags" , tags ));
445- assertArrayEquals (tags , ((java .util .ArrayList ) resource .get ("tags" )).toArray ());
449+ assertArrayEquals (tags , ((java .util .ArrayList ) resource .get ("tags" )).toArray ());
446450 assertEquals ("image" , resource .get ("resource_type" ));
447451 assertEquals (1400 , resource .get ("width" ));
448452 assertEquals (1400 , resource .get ("height" ));
@@ -480,7 +484,7 @@ public void testResponsiveBreakpoints() throws Exception {
480484 java .util .ArrayList breakpointsResponse = (java .util .ArrayList ) result .get ("responsive_breakpoints" );
481485 java .util .ArrayList breakpoints = (java .util .ArrayList ) ((Map ) breakpointsResponse .get (0 )).get ("breakpoints" );
482486 assertEquals (2 , breakpoints .size ());
483- assertTrue (((Map )breakpoints .get (0 )).get ("url" ).toString ().endsWith ("gif" ));
487+ assertTrue (((Map ) breakpoints .get (0 )).get ("url" ).toString ().endsWith ("gif" ));
484488
485489 // an array of breakpoints
486490 result = cloudinary .uploader ().upload (SRC_TEST_IMAGE , asMap ("responsive_breakpoints" ,
@@ -532,12 +536,12 @@ public void testDownloadArchive() throws Exception {
532536 }
533537 assertEquals (2 , files );
534538 }
535-
539+
536540 public void testUploadInvalidUrl () {
537541 try {
538542 cloudinary .uploader ().upload (REMOTE_TEST_IMAGE + "\n " , asMap ("return_error" , true ));
539543 fail ("Expected exception was not thrown" );
540- } catch (IOException e ) {
544+ } catch (IOException e ) {
541545 assertEquals (e .getMessage (), "File not found or unreadable: " + REMOTE_TEST_IMAGE + "\n " );
542546 }
543547 }
0 commit comments