FileDocCategorySizeDatePackage
AllTests.javaAPI Docjid3 0.4616229Tue Apr 26 17:55:34 BST 2005org.blinkenlights.jid3.test

AllTests

public class AllTests extends TestCase
author
paul To change the template for this generated type comment go to Window>Preferences>Java>Code Generation>Code and Comments

Fields Summary
public static String
s_RootPath
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)


        
    
        junit.swingui.TestRunner.run(AllTests.class);
    
public static junit.framework.Testsuite()

        TestSuite suite = new TestSuite("Test for org.blinkenlights.id3.test");
        //$JUnit-BEGIN$
        suite.addTest(new TestSuite(ID3V1Test.class));
        suite.addTest(new TestSuite(ID3V2Test.class));
        suite.addTest(new TestSuite(AllTests.class));
        //$JUnit-END$
        return suite;
    
public voidtestRemoveTags()

        try
        {
            // get a copy of an unmodified file to edit
            ID3Util.copy(AllTests.s_RootPath + "notags.mp3", AllTests.s_RootPath + "id3_v2_3_0_tagtest.mp3");

            File oSourceFile = new File(AllTests.s_RootPath + "id3_v2_3_0_tagtest.mp3");
            MediaFile oMediaFile = new MP3File(oSourceFile);
            
            // write v1.1 tag to file
            ID3V1_1Tag oID3V1_1Tag = new ID3V1_1Tag();
            oID3V1_1Tag.setArtist("Artist");
            oID3V1_1Tag.setTitle("Song Title");
            oID3V1_1Tag.setAlbum("Album");
            oID3V1_1Tag.setYear("2004");
            oID3V1_1Tag.setAlbumTrack(3);
            oID3V1_1Tag.setGenre(ID3V1Tag.Genre.Blues);
            oMediaFile.setID3Tag(oID3V1_1Tag);
        
            // write v2.3.0 tag to file
            ID3V2Tag oID3V2Tag = new ID3V2_3_0Tag();
            oID3V2Tag.setArtist("Artist");
            oID3V2Tag.setTitle("Song Title");
            oID3V2Tag.setAlbum("Album");
            oID3V2Tag.setYear(2004);
            oID3V2Tag.setTrackNumber(3, 9);
            oID3V2Tag.setGenre("Blues");
            oMediaFile.setID3Tag(oID3V2Tag);

            oMediaFile.sync();
            
            // remove those tags
            oMediaFile.removeTags();
            
            // read file back
            oMediaFile = new MP3File(oSourceFile);
            
            // make sure the tags aren't there
            if (oMediaFile.getID3V1Tag() != null)
            {
                fail("The remove tag operation failed to remove v1 tag.");
            }
            if (oMediaFile.getID3V2Tag() != null)
            {
                fail("The remove tag operation failed to remove v2 tag.");
            }
        }
        catch (Exception e)
        {
            fail(ID3Exception.getStackTrace(e));
        }
    
public voidtestVisitor()

        try
        {
            File oSourceFile = new File(AllTests.s_RootPath + "v2_3_0tags.mp3");
            MP3File oMP3File = new MP3File(oSourceFile);
            
            ID3Tag[] aoID3Tag = oMP3File.getTags();

            AllTests.TestID3Visitor oTestID3Visitor = new AllTests.TestID3Visitor();
            
            // visit each tag (which also results in each v2 frame being visited)
            for (int i=0; i < aoID3Tag.length; i++)
            {
                aoID3Tag[i].accept(oTestID3Visitor);
            }
            
            // a 'visit list' was created by our visitor, recording which frames were visited, so we can compare
            if ( ! oTestID3Visitor.getVisitList().equals("3=DS+uw_PsKMr(VT$ICBUtvNyEzRL)W[QJO6*-"))
            {
                fail("Unexpected resulting visit list: " + oTestID3Visitor.getVisitList());
            }
        }
        catch (Exception e)
        {
            fail(ID3Exception.getStackTrace(e));
        }