FileDocCategorySizeDatePackage
ID3Test.javaAPI Docjid3 0.468707Sun Feb 06 18:11:27 GMT 2005org.blinkenlights.jid3.test

ID3Test

public class ID3Test extends Object
author
paul Run all JUnit tests.

Fields Summary
Constructors Summary
Methods Summary
private static voidcopy(java.lang.String sSource, java.lang.String sDestination)

        File oInputFile = new File(sSource);
        File oOutputFile = new File(sDestination);

        FileInputStream oFIS = new FileInputStream(oInputFile);
        FileOutputStream oFOS = new FileOutputStream(oOutputFile);
        int c;

        while ((c = oFIS.read()) != -1)
           oFOS.write(c);

        oFIS.close();
        oFOS.close();
    
public static voidmain(java.lang.String[] args)

        //testWriteSomething();
        if (false) { return; }
        
        testWriteV1_0Tag();
        
        testWriteV1_1Tag();
        
        testReadV1_0Tag();
        
        testReadV1_1Tag();
    
private static voidprintTags(ID3Tag[] aoID3Tag)

        System.out.println("Number of tag sets: " + aoID3Tag.length);
        for (int i=0; i < aoID3Tag.length; i++)
        {
            if (aoID3Tag[i] instanceof ID3V1_0Tag)
            {
                System.out.println("ID3V1_0Tag:");
                System.out.println(aoID3Tag[i].toString());
            }
            else if (aoID3Tag[i] instanceof ID3V1_1Tag)
            {
                System.out.println("ID3V1_1Tag:");
                System.out.println(aoID3Tag[i].toString());
            }
            else if (aoID3Tag[i] instanceof ID3V2_3_0Tag)
            {
                System.out.println("ID3V2_3_0Tag:");
                System.out.println(aoID3Tag[i].toString());
            }
        }
    
private static voidtestReadV1_0Tag()

        System.out.println("\n--- testReadV1_0Tag ---");

        File oSourceFile = new File(AllTests.s_RootPath + "v1_0tags.mp3");
        MediaFile oMediaFile = new MP3File(oSourceFile);
        
        ID3Tag[] aoID3Tag = oMediaFile.getTags();
        printTags(aoID3Tag);
    
private static voidtestReadV1_1Tag()

        System.out.println("\n--- testReadV1_1Tag ---");
        
        File oSourceFile = new File(AllTests.s_RootPath + "v1_1tags.mp3");
        MediaFile oMediaFile = new MP3File(oSourceFile);
        
        ID3Tag[] aoID3Tag = oMediaFile.getTags();
        printTags(aoID3Tag);
    
static voidtestWriteV1_0Tag()

        System.out.println("\n--- testWriteV1_0Tag ---");

        copy(AllTests.s_RootPath + "notags.mp3", AllTests.s_RootPath + "id3_v1_0_testresult.mp3");
        File oSourceFile = new File(AllTests.s_RootPath + "id3_v1_0_testresult.mp3");
        MediaFile oMediaFile = new MP3File(oSourceFile);

        // test v1.0 tags
        ID3V1_0Tag oID3V1_0Tag = new ID3V1_0Tag();
        oID3V1_0Tag.setAlbum("Album");
        oID3V1_0Tag.setArtist("Artist");
        oID3V1_0Tag.setComment("Comment");
        oID3V1_0Tag.setGenre(ID3V1Tag.Genre.Dance);
        oID3V1_0Tag.setTitle("Title");
        oID3V1_0Tag.setYear("1999");
        
        System.out.println(oID3V1_0Tag.toString());
        
        oMediaFile.setID3Tag(oID3V1_0Tag);
        oMediaFile.sync();
    
static voidtestWriteV1_1Tag()

        System.out.println("\n--- testWriteV1_1Tag ---");

        copy(AllTests.s_RootPath + "notags.mp3", AllTests.s_RootPath + "id3_v1_1_testresult.mp3");
        File oSourceFile = new File(AllTests.s_RootPath + "id3_v1_1_testresult.mp3");
        MediaFile oMediaFile = new MP3File(oSourceFile);
        
        // test v1.1 tags
        ID3V1_1Tag oID3V1_1Tag = new ID3V1_1Tag();
        oID3V1_1Tag.setAlbum("Album");
        oID3V1_1Tag.setArtist("Artist");
        oID3V1_1Tag.setComment("Comment");
        oID3V1_1Tag.setGenre(ID3V1Tag.Genre.Dance);
        oID3V1_1Tag.setTitle("Title");
        oID3V1_1Tag.setYear("1999");
        oID3V1_1Tag.setAlbumTrack(7);
        
        System.out.println(oID3V1_1Tag.toString());
        
        oMediaFile.setID3Tag(oID3V1_1Tag);
        oMediaFile.sync();