22
33import android .content .Context ;
44import android .net .Uri ;
5+ import android .support .test .runner .AndroidJUnit4 ;
56
6- import com .smartdevicelink .AndroidTestCase2 ;
77import com .smartdevicelink .managers .BaseSubManager ;
88import com .smartdevicelink .managers .CompletionListener ;
99import com .smartdevicelink .managers .file .filetypes .SdlArtwork ;
2323import com .smartdevicelink .proxy .rpc .listeners .OnMultipleRequestListener ;
2424import com .smartdevicelink .test .Test ;
2525
26+ import org .junit .Before ;
27+ import org .junit .runner .RunWith ;
2628import org .mockito .invocation .InvocationOnMock ;
2729import org .mockito .stubbing .Answer ;
2830
2931import java .util .ArrayList ;
3032import java .util .List ;
3133import java .util .Map ;
3234
35+ import static android .support .test .InstrumentationRegistry .getContext ;
36+ import static junit .framework .TestCase .assertTrue ;
37+ import static org .junit .Assert .assertEquals ;
38+ import static org .junit .Assert .assertFalse ;
39+ import static org .junit .Assert .assertNull ;
3340import static org .mockito .ArgumentMatchers .any ;
3441import static org .mockito .Mockito .doAnswer ;
3542import static org .mockito .Mockito .mock ;
4047 * This is a unit test class for the SmartDeviceLink library manager class :
4148 * {@link FileManager}
4249 */
43- public class FileManagerTests extends AndroidTestCase2 {
50+ @ RunWith (AndroidJUnit4 .class )
51+ public class FileManagerTests {
4452 public static final String TAG = "FileManagerTests" ;
4553 private Context mTestContext ;
4654 private SdlFile validFile ;
4755
4856 // SETUP / HELPERS
4957
50- @ Override
58+ @ Before
5159 public void setUp () throws Exception {
52- super .setUp ();
53- mTestContext = this .getContext ();
60+ mTestContext = getContext ();
5461 validFile = new SdlFile ();
5562 validFile .setName (Test .GENERAL_STRING );
5663 validFile .setFileData (Test .GENERAL_BYTE_ARRAY );
5764 validFile .setPersistent (false );
5865 }
5966
60- @ Override
61- public void tearDown () throws Exception {
62- super .tearDown ();
63- }
64-
6567 private Answer <Void > onPutFileFailureOnError = new Answer <Void >() {
6668 @ Override
6769 public Void answer (InvocationOnMock invocation ) throws Throwable {
@@ -242,6 +244,7 @@ public Void answer(InvocationOnMock invocation) throws Throwable {
242244 /**
243245 * Test deleting list of files, success
244246 */
247+ @ org .junit .Test
245248 public void testDeleteRemoteFilesWithNamesSuccess (){
246249 final ISdl internalInterface = mock (ISdl .class );
247250
@@ -273,6 +276,7 @@ public void onComplete(Map<String, String> errors) {
273276 /**
274277 * Test deleting list of files, fail
275278 */
279+ @ org .junit .Test
276280 public void testDeleteRemoteFilesWithNamesFail (){
277281 final ISdl internalInterface = mock (ISdl .class );
278282
@@ -304,6 +308,7 @@ public void onComplete(Map<String, String> errors) {
304308 /**
305309 * Test reUploading failed file
306310 */
311+ @ org .junit .Test
307312 public void testFileUploadRetry (){
308313 final ISdl internalInterface = mock (ISdl .class );
309314
@@ -335,6 +340,7 @@ public void onComplete(boolean success) {
335340 /**
336341 * Test reUploading failed Artwork
337342 */
343+ @ org .junit .Test
338344 public void testArtworkUploadRetry (){
339345 final ISdl internalInterface = mock (ISdl .class );
340346
@@ -393,6 +399,7 @@ public void onComplete(boolean success) {
393399 /**
394400 * Test retry uploading failed list of files
395401 */
402+ @ org .junit .Test
396403 public void testListFilesUploadRetry (){
397404 final ISdl internalInterface = mock (ISdl .class );
398405
@@ -434,6 +441,7 @@ public void onComplete(Map<String, String> errors) {
434441 /**
435442 * Testing the initialization of FileManager
436443 */
444+ @ org .junit .Test
437445 public void testInitializationSuccess () {
438446 ISdl internalInterface = mock (ISdl .class );
439447
@@ -455,6 +463,7 @@ public void onComplete(boolean success) {
455463 /**
456464 * Test file upload, success
457465 */
466+ @ org .junit .Test
458467 public void testFileUploadSuccess () {
459468 ISdl internalInterface = mock (ISdl .class );
460469
@@ -484,6 +493,7 @@ public void onComplete(boolean success) {
484493 /**
485494 * Testing failed file upload.
486495 */
496+ @ org .junit .Test
487497 public void testFileUploadFailure () {
488498 ISdl internalInterface = mock (ISdl .class );
489499
@@ -511,6 +521,7 @@ public void onComplete(boolean success) {
511521 /**
512522 * Testing uploadFile for a staticIcon, verifying that it doesn't actually upload.
513523 */
524+ @ org .junit .Test
514525 public void testFileUploadForStaticIcon () {
515526 ISdl internalInterface = mock (ISdl .class );
516527
@@ -537,6 +548,7 @@ public void onComplete(boolean success) {
537548 /**
538549 * Testing uploadFiles for staticIcons, verifying that it doesn't actually upload.
539550 */
551+ @ org .junit .Test
540552 public void testMultipleFileUploadsForStaticIcon () {
541553 ISdl internalInterface = mock (ISdl .class );
542554
@@ -568,6 +580,7 @@ public void onComplete(Map<String, String> errors) {
568580 /**
569581 * Testing uploadFiles for static icons and nonStatic icons in the same list.
570582 */
583+ @ org .junit .Test
571584 public void testMultipleFileUploadsForPartialStaticIcon () {
572585 ISdl internalInterface = mock (ISdl .class );
573586
@@ -600,6 +613,7 @@ public void onComplete(Map<String, String> errors) {
600613 /**
601614 * Test to make sure you cannot upload an SdlFile with invalid data
602615 */
616+ @ org .junit .Test
603617 public void testInvalidSdlFileInput () {
604618 ISdl internalInterface = mock (ISdl .class );
605619
@@ -662,6 +676,7 @@ public void onComplete(boolean success) {}
662676 * Test Invalid SdlArtWork FileTypes
663677 * SdlArtwork FileTypes can only be: GRAPHIC_BMP, GRAPHIC_PNG or GRAPHIC_JPEG
664678 */
679+ @ org .junit .Test
665680 public void testInvalidSdlArtworkInput (){
666681 SdlArtwork sdlArtwork = new SdlArtwork ();
667682 // Set invalid type
@@ -683,6 +698,7 @@ public void testInvalidSdlArtworkInput(){
683698 /**
684699 * Test Multiple File Uploads, success
685700 */
701+ @ org .junit .Test
686702 public void testMultipleFileUpload () {
687703 ISdl internalInterface = mock (ISdl .class );
688704
@@ -719,6 +735,7 @@ public void onComplete(Map<String, String> errors) {
719735 /**
720736 * Testing uploading multiple files with some failing.
721737 */
738+ @ org .junit .Test
722739 public void testMultipleFileUploadPartialFailure () {
723740 ISdl internalInterface = mock (ISdl .class );
724741
@@ -767,6 +784,7 @@ public void onComplete(Map<String, String> errors) {
767784 /**
768785 * Testing uploading multiple SdlArtwork files.
769786 */
787+ @ org .junit .Test
770788 public void testMultipleArtworkUploadSuccess (){
771789 ISdl internalInterface = mock (ISdl .class );
772790
@@ -813,6 +831,7 @@ public void onComplete(Map<String, String> errors) {
813831 /**
814832 * Testing uploading persistent SdlFile
815833 */
834+ @ org .junit .Test
816835 public void testPersistentFileUploaded (){
817836 ISdl internalInterface = mock (ISdl .class );
818837
@@ -835,6 +854,7 @@ public void onComplete(boolean success) {
835854 /**
836855 * Test FileManagerConfig
837856 */
857+ @ org .junit .Test
838858 public void testFileManagerConfig () {
839859 FileManagerConfig fileManagerConfig = new FileManagerConfig ();
840860 fileManagerConfig .setFileRetryCount (2 );
@@ -847,6 +867,7 @@ public void testFileManagerConfig() {
847867 * Tests overwrite property for uploading a file.
848868 * Checks to make sure file does not overwrite itself if overwrite property is set to false
849869 */
870+ @ org .junit .Test
850871 public void testOverwriteFileProperty () {
851872 ISdl internalInterface = mock (ISdl .class );
852873
@@ -883,6 +904,7 @@ public void onComplete(boolean success) {
883904 * Tests overwrite property for uploading a list of files.
884905 * Checks to make sure files do not overwrite themselves if overwrite property is set to false.
885906 */
907+ @ org .junit .Test
886908 public void testOverWriteFilePropertyListFiles () {
887909 final ISdl internalInterface = mock (ISdl .class );
888910
@@ -929,6 +951,7 @@ public void onComplete(Map<String, String> errors) {
929951 /**
930952 * Test custom overridden SdlFile equals method
931953 */
954+ @ org .junit .Test
932955 public void testSdlFileEquals () {
933956 // Case 1: object is null, assertFalse
934957 SdlFile artwork1 = new SdlFile ("image1" , FileType .GRAPHIC_PNG , 1 , true );
0 commit comments