assertNull(lyrics3);
assertTrue(filename != null);
assertFalse(filename.hasFrame("TIT2"));
lyrics3 = new Lyrics3v2();
try {
((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
} catch (TagException ex) {
fail(ex.getMessage());
}
mp3file.setLyrics3Tag(lyrics3);
assertEquals(3, mp3file.getFrameAcrossTags("TIT2").size());
filename.setFrame(frame);
assertEquals(4, mp3file.getFrameAcrossTags("TIT2").size());
mp3file.setFilenameTag(null);
assertEquals(3, mp3file.getFrameAcrossTags("TIT2").size());
mp3file.setID3v2Tag(null);
assertEquals(2, mp3file.getFrameAcrossTags("TIT2").size());
mp3file.setID3v1Tag(null);
assertEquals(1, mp3file.getFrameAcrossTags("TIT2").size());
mp3file.setLyrics3Tag(null);
assertEquals(0, mp3file.getFrameAcrossTags("TIT2").size());
// test nulls
assertNull(mp3file.getFrameAcrossTags(null));
assertNull(mp3file.getFrameAcrossTags(""));
// test all different fields
List frameList;
final String testString = "Test String";
mp3file = new MP3File();
frame = new ID3v2_4Frame(new FrameBodyTIT2((byte) 0, testString));
id3v1 = new ID3v1_1();
id3v2 = new ID3v2_4();
lyrics3 = new Lyrics3v2();
filename = FilenameTagBuilder.createEmptyFilenameTag();
id3v1.setTitle(testString);
id3v2.setFrame(frame);
try {
((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
} catch (TagException ex) {
fail("This should not happen. " + ex.getMessage());
}
filename.setFrame(frame);
// different nulls
mp3file = new MP3File();
mp3file.setID3v1Tag(null);
mp3file.setID3v2Tag(null);
mp3file.setLyrics3Tag(null);
mp3file.setFilenameTag(null);
frameList = mp3file.getFrameAcrossTags("TIT2");
assertEquals(0, frameList.size());
mp3file = new MP3File();
mp3file.setID3v1Tag(id3v1);
mp3file.setID3v2Tag(null);
mp3file.setLyrics3Tag(null);
mp3file.setFilenameTag(null);
frameList = mp3file.getFrameAcrossTags("TIT2");
assertEquals(1, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
mp3file = new MP3File();
mp3file.setID3v1Tag(null);
mp3file.setID3v2Tag(id3v2);
mp3file.setLyrics3Tag(null);
mp3file.setFilenameTag(null);
frameList = mp3file.getFrameAcrossTags("TIT2");
assertEquals(1, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
mp3file = new MP3File();
mp3file.setID3v1Tag(null);
mp3file.setID3v2Tag(null);
mp3file.setLyrics3Tag(lyrics3);
mp3file.setFilenameTag(null);
frameList = mp3file.getFrameAcrossTags("TIT2");
assertEquals(1, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
mp3file = new MP3File();
mp3file.setID3v1Tag(null);
mp3file.setID3v2Tag(null);
mp3file.setLyrics3Tag(null);
mp3file.setFilenameTag(filename);
frameList = mp3file.getFrameAcrossTags("TIT2");
assertEquals(1, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
mp3file = new MP3File();
mp3file.setID3v1Tag(id3v1);
mp3file.setID3v2Tag(id3v2);
mp3file.setLyrics3Tag(null);
mp3file.setFilenameTag(null);
frameList = mp3file.getFrameAcrossTags("TIT2");
assertEquals(2, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
mp3file = new MP3File();
mp3file.setID3v1Tag(id3v1);
mp3file.setID3v2Tag(null);
mp3file.setLyrics3Tag(lyrics3);
mp3file.setFilenameTag(null);
frameList = mp3file.getFrameAcrossTags("TIT2");
assertEquals(2, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
mp3file = new MP3File();
mp3file.setID3v1Tag(id3v1);
mp3file.setID3v2Tag(null);
mp3file.setLyrics3Tag(null);
mp3file.setFilenameTag(filename);
frameList = mp3file.getFrameAcrossTags("TIT2");
assertEquals(2, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
mp3file = new MP3File();
mp3file.setID3v1Tag(null);
mp3file.setID3v2Tag(id3v2);
mp3file.setLyrics3Tag(lyrics3);
mp3file.setFilenameTag(null);
frameList = mp3file.getFrameAcrossTags("TIT2");
assertEquals(2, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
mp3file = new MP3File();
mp3file.setID3v1Tag(null);
mp3file.setID3v2Tag(id3v2);
mp3file.setLyrics3Tag(null);
mp3file.setFilenameTag(filename);
frameList = mp3file.getFrameAcrossTags("TIT2");
assertEquals(2, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
mp3file = new MP3File();
mp3file.setID3v1Tag(null);
mp3file.setID3v2Tag(null);
mp3file.setLyrics3Tag(lyrics3);
mp3file.setFilenameTag(filename);
frameList = mp3file.getFrameAcrossTags("TIT2");
assertEquals(2, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
mp3file = new MP3File();
mp3file.setID3v1Tag(id3v1);
mp3file.setID3v2Tag(id3v2);
mp3file.setLyrics3Tag(lyrics3);
mp3file.setFilenameTag(null);
frameList = mp3file.getFrameAcrossTags("TIT2");
assertEquals(3, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
mp3file = new MP3File();
mp3file.setID3v1Tag(id3v1);
mp3file.setID3v2Tag(id3v2);
mp3file.setLyrics3Tag(null);
mp3file.setFilenameTag(filename);
frameList = mp3file.getFrameAcrossTags("TIT2");
assertEquals(3, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
mp3file = new MP3File();
mp3file.setID3v1Tag(id3v1);
mp3file.setID3v2Tag(null);
mp3file.setLyrics3Tag(lyrics3);
mp3file.setFilenameTag(filename);
frameList = mp3file.getFrameAcrossTags("TIT2");
assertEquals(3, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
mp3file = new MP3File();
mp3file.setID3v1Tag(null);
mp3file.setID3v2Tag(id3v2);
mp3file.setLyrics3Tag(lyrics3);
mp3file.setFilenameTag(filename);
frameList = mp3file.getFrameAcrossTags("TIT2");
assertEquals(3, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
// TEST each frame
// TIT1
mp3file = new MP3File();
mp3file.setID3v1Tag(id3v1);
mp3file.setID3v2Tag(id3v2);
mp3file.setLyrics3Tag(lyrics3);
mp3file.setFilenameTag(filename);
frameList = mp3file.getFrameAcrossTags("TIT2");
assertEquals(4, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
// TPE1
mp3file = new MP3File();
id3v1 = new ID3v1_1();
id3v2 = new ID3v2_4();
lyrics3 = new Lyrics3v2();
filename = FilenameTagBuilder.createEmptyFilenameTag();
frame = new ID3v2_4Frame(new FrameBodyTPE1((byte) 0, testString));
id3v1.setArtist(testString);
id3v2.setFrame(frame);
try {
((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
} catch (TagException ex) {
fail("This should not happen. " + ex.getMessage());
}
filename.setFrame(frame);
mp3file.setID3v1Tag(id3v1);
mp3file.setID3v2Tag(id3v2);
mp3file.setLyrics3Tag(lyrics3);
mp3file.setFilenameTag(filename);
frameList = mp3file.getFrameAcrossTags("TPE1");
assertEquals(4, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
// TALB
mp3file = new MP3File();
id3v1 = new ID3v1_1();
id3v2 = new ID3v2_4();
lyrics3 = new Lyrics3v2();
filename = FilenameTagBuilder.createEmptyFilenameTag();
frame = new ID3v2_4Frame(new FrameBodyTALB((byte) 0, testString));
id3v1.setAlbum(testString);
id3v2.setFrame(frame);
try {
((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
} catch (TagException ex) {
fail("This should not happen. " + ex.getMessage());
}
filename.setFrame(frame);
mp3file.setID3v1Tag(id3v1);
mp3file.setID3v2Tag(id3v2);
mp3file.setLyrics3Tag(lyrics3);
mp3file.setFilenameTag(filename);
frameList = mp3file.getFrameAcrossTags("TALB");
assertEquals(4, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
// TDRC
mp3file = new MP3File();
id3v1 = new ID3v1_1();
id3v2 = new ID3v2_4();
lyrics3 = new Lyrics3v2();
filename = FilenameTagBuilder.createEmptyFilenameTag();
frame = new ID3v2_4Frame(new FrameBodyTDRC((byte) 0, "1992"));
id3v1.setYear("1992");
id3v2.setFrame(frame);
try {
((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
fail("Somehow created a TDRC (year) Lyrics3v2 Field");
} catch (TagException ex) {
// correct behavior
}
filename.setFrame(frame);
mp3file.setID3v1Tag(id3v1);
mp3file.setID3v2Tag(id3v2);
mp3file.setLyrics3Tag(lyrics3);
mp3file.setFilenameTag(filename);
frameList = mp3file.getFrameAcrossTags("TDRC");
assertEquals(3, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
// COMM
mp3file = new MP3File();
id3v1 = new ID3v1_1();
id3v2 = new ID3v2_4();
lyrics3 = new Lyrics3v2();
filename = FilenameTagBuilder.createEmptyFilenameTag();
frame = new ID3v2_4Frame(new FrameBodyCOMM((byte) 0, "ENG", "", testString));
id3v1.setComment(testString);
id3v2.setFrame(frame);
try {
((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
} catch (TagException ex) {
fail("This should not happen. " + ex.getMessage());
}
filename.setFrame(frame);
mp3file.setID3v1Tag(id3v1);
mp3file.setID3v2Tag(id3v2);
mp3file.setLyrics3Tag(lyrics3);
mp3file.setFilenameTag(filename);
frameList = mp3file.getFrameAcrossTags("COMM");
assertEquals(4, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
// TCON
mp3file = new MP3File();
id3v1 = new ID3v1_1();
id3v2 = new ID3v2_4();
lyrics3 = new Lyrics3v2();
filename = FilenameTagBuilder.createEmptyFilenameTag();
frame = new ID3v2_4Frame(new FrameBodyTCON((byte) 0, "(42) Soul"));
id3v1.setGenre((byte) 42);
id3v2.setFrame(frame);
try {
((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
fail("Somehow created a TCON (genre) Lyrics3v2 Field");
} catch (TagException ex) {
// correct behavior
}
filename.setFrame(frame);
mp3file.setID3v1Tag(id3v1);
mp3file.setID3v2Tag(id3v2);
mp3file.setLyrics3Tag(lyrics3);
mp3file.setFilenameTag(filename);
frameList = mp3file.getFrameAcrossTags("TCON");
assertEquals(3, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
// TRCK
mp3file = new MP3File();
id3v1 = new ID3v1_1();
id3v2 = new ID3v2_4();
lyrics3 = new Lyrics3v2();
filename = FilenameTagBuilder.createEmptyFilenameTag();
frame = new ID3v2_4Frame(new FrameBodyTRCK((byte) 0, "42"));
((ID3v1_1) id3v1).setTrack((byte) 42);
id3v2.setFrame(frame);
try {
((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
fail("Somehow created a TRCK (track) Lyrics3v2 Field");
} catch (TagException ex) {
// correct behavior
}
filename.setFrame(frame);
mp3file.setID3v1Tag(id3v1);
mp3file.setID3v2Tag(id3v2);
mp3file.setLyrics3Tag(lyrics3);
mp3file.setFilenameTag(filename);
frameList = mp3file.getFrameAcrossTags("TRCK");
assertEquals(3, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
// SYLT
mp3file = new MP3File();
id3v1 = new ID3v1_1();
id3v2 = new ID3v2_4();
lyrics3 = new Lyrics3v2();
filename = FilenameTagBuilder.createEmptyFilenameTag();
frame = new ID3v2_4Frame(new FrameBodySYLT((byte) 0, "ENG", (byte) 0, (byte) 0, "description"));
((FrameBodySYLT) frame.getBody()).addLyric(0, testString);
id3v2.setFrame(frame);
try {
((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
} catch (TagException ex) {
fail("This should not happen. " + ex.getMessage());
}
filename.setFrame(frame);
mp3file.setID3v1Tag(id3v1);
mp3file.setID3v2Tag(id3v2);
mp3file.setLyrics3Tag(lyrics3);
mp3file.setFilenameTag(filename);
frameList = mp3file.getFrameAcrossTags("SYLT");
assertEquals(3, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
// USLT
mp3file = new MP3File();
id3v1 = new ID3v1_1();
id3v2 = new ID3v2_4();
lyrics3 = new Lyrics3v2();
filename = FilenameTagBuilder.createEmptyFilenameTag();
frame = new ID3v2_4Frame(new FrameBodyUSLT((byte) 0, "ENG", "", testString));
id3v2.setFrame(frame);
try {
((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
} catch (TagException ex) {
fail("This should not happen. " + ex.getMessage());
}
filename.setFrame(frame);
mp3file.setID3v1Tag(id3v1);
mp3file.setID3v2Tag(id3v2);
mp3file.setLyrics3Tag(lyrics3);
mp3file.setFilenameTag(filename);
frameList = mp3file.getFrameAcrossTags("USLT");
assertEquals(3, frameList.size());
for (int i = 0; i < frameList.size(); i++) {
assertEquals(frame, frameList.get(i));
}
// TCOM
mp3file = new MP3File();
id3v1 = new ID3v1_1();
id3v2 = new ID3v2_4();
lyrics3 = new Lyrics3v2();
filename = FilenameTagBuilder.createEmptyFilenameTag();
frame = new ID3v2_4Frame(new FrameBodyTCOM((byte) 0, testString));
id3v2.setFrame(frame);
try {
((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
} catch (TagException ex) {
fail("This should not happen. " + ex.getMessage());
}
filename.setFrame(frame);
mp3file.setID3v1Tag(id3v1);