1
package org.jaudiotagger.tag.id3;
3
import org.jaudiotagger.AbstractTestCase;
4
import org.jaudiotagger.audio.mp3.MP3File;
5
import org.jaudiotagger.tag.id3.framebody.FrameBodyCOMM;
12
public class FrameCOMMTest extends AbstractTestCase
15
* Should run without throwing Runtime excception, although COMMFrame wont be loaded and will
16
* throwe invalid size exception
18
public void testReadFileContainingInvalidSizeCOMMFrame() throws Exception
23
File testFile = AbstractTestCase.copyAudioToTmp("Issue77.id3", "testV1.mp3");
24
MP3File mp3File = new MP3File(testFile);
34
* Should run without throwing Runtime excception, although COMMFrame wont be loaded and will
35
* throwe invalid datatype exception
37
public void testReadFileContainingInvalidTextEncodingCOMMFrame() throws Exception
42
File testFile = AbstractTestCase.copyAudioToTmp("Issue80.id3", "testV1.mp3");
43
MP3File mp3File = new MP3File(testFile);
53
* Can read file containing a language code that does not actually map to a code , and write it back
54
* In this real example the language code has been held as three space characters
56
public void testreadFrameContainingInvalidlanguageCodeCOMMFrame() throws Exception
58
final String INVALID_LANG_CODE = " ";
62
File testFile = AbstractTestCase.copyAudioToTmp("Issue108.id3", "testV1.mp3");
63
MP3File mp3File = new MP3File(testFile);
65
assertTrue(mp3File.getID3v2Tag().hasFrame("COMM"));
67
ID3v24Frame commFrame = (ID3v24Frame) mp3File.getID3v2Tag().getFrame("COMM");
68
FrameBodyCOMM frameBody = (FrameBodyCOMM) commFrame.getBody();
70
assertEquals(INVALID_LANG_CODE, frameBody.getLanguage());
81
* Can write file containing a COMM Frame with null language code
83
public void testsaveFileContainingNullLanguageCodeCOMMFrame() throws Exception
85
final String SAFE_LANG_CODE = " ";
86
final String SAFE_LONGER_LANG_CODE = "aa ";
87
final String SAFE_SHORTER_LANG_CODE = "aaa";
92
File testFile = AbstractTestCase.copyAudioToTmp("Issue108.id3", "testV1.mp3");
93
MP3File mp3File = new MP3File(testFile);
94
ID3v24Frame commFrame = (ID3v24Frame) mp3File.getID3v2Tag().getFrame("COMM");
95
FrameBodyCOMM frameBody = (FrameBodyCOMM) commFrame.getBody();
97
//Set language to null, this is common problem for new frames might null lang codes
98
frameBody.setLanguage(null);
100
mp3File = new MP3File(testFile);
101
commFrame = (ID3v24Frame) mp3File.getID3v2Tag().getFrame("COMM");
102
frameBody = (FrameBodyCOMM) commFrame.getBody();
103
assertEquals(SAFE_LANG_CODE, frameBody.getLanguage());
105
//Set language to too short a value
106
frameBody.setLanguage("aa");
108
mp3File = new MP3File(testFile);
109
commFrame = (ID3v24Frame) mp3File.getID3v2Tag().getFrame("COMM");
110
frameBody = (FrameBodyCOMM) commFrame.getBody();
111
assertEquals(SAFE_LONGER_LANG_CODE, frameBody.getLanguage());
113
//Set language to too long a value
114
frameBody.setLanguage("aaaaaaa");
116
mp3File = new MP3File(testFile);
117
commFrame = (ID3v24Frame) mp3File.getID3v2Tag().getFrame("COMM");
118
frameBody = (FrameBodyCOMM) commFrame.getBody();
119
assertEquals(SAFE_SHORTER_LANG_CODE, frameBody.getLanguage());
124
ie.printStackTrace();
1
package org.jaudiotagger.tag.id3;
3
import org.jaudiotagger.AbstractTestCase;
4
import org.jaudiotagger.audio.mp3.MP3File;
5
import org.jaudiotagger.tag.id3.framebody.FrameBodyCOMM;
12
public class FrameCOMMTest extends AbstractTestCase
15
* Should run without throwing Runtime excception, although COMMFrame wont be loaded and will
16
* throwe invalid size exception
18
public void testReadFileContainingInvalidSizeCOMMFrame() throws Exception
23
File testFile = AbstractTestCase.copyAudioToTmp("Issue77.id3", "testV1.mp3");
24
MP3File mp3File = new MP3File(testFile);
34
* Should run without throwing Runtime excception, although COMMFrame wont be loaded and will
35
* throwe invalid datatype exception
37
public void testReadFileContainingInvalidTextEncodingCOMMFrame() throws Exception
42
File testFile = AbstractTestCase.copyAudioToTmp("Issue80.id3", "testV1.mp3");
43
MP3File mp3File = new MP3File(testFile);
53
* Can read file containing a language code that does not actually map to a code , and write it back
54
* In this real example the language code has been held as three space characters
56
public void testreadFrameContainingInvalidlanguageCodeCOMMFrame() throws Exception
58
final String INVALID_LANG_CODE = " ";
62
File testFile = AbstractTestCase.copyAudioToTmp("Issue108.id3", "testV1.mp3");
63
MP3File mp3File = new MP3File(testFile);
65
assertTrue(mp3File.getID3v2Tag().hasFrame("COMM"));
67
ID3v24Frame commFrame = (ID3v24Frame) mp3File.getID3v2Tag().getFrame("COMM");
68
FrameBodyCOMM frameBody = (FrameBodyCOMM) commFrame.getBody();
70
assertEquals(INVALID_LANG_CODE, frameBody.getLanguage());
81
* Can write file containing a COMM Frame with null language code
83
public void testsaveFileContainingNullLanguageCodeCOMMFrame() throws Exception
85
final String SAFE_LANG_CODE = " ";
86
final String SAFE_LONGER_LANG_CODE = "aa ";
87
final String SAFE_SHORTER_LANG_CODE = "aaa";
92
File testFile = AbstractTestCase.copyAudioToTmp("Issue108.id3", "testV1.mp3");
93
MP3File mp3File = new MP3File(testFile);
94
ID3v24Frame commFrame = (ID3v24Frame) mp3File.getID3v2Tag().getFrame("COMM");
95
FrameBodyCOMM frameBody = (FrameBodyCOMM) commFrame.getBody();
97
//Set language to null, this is common problem for new frames might null lang codes
98
frameBody.setLanguage(null);
100
mp3File = new MP3File(testFile);
101
commFrame = (ID3v24Frame) mp3File.getID3v2Tag().getFrame("COMM");
102
frameBody = (FrameBodyCOMM) commFrame.getBody();
103
assertEquals(SAFE_LANG_CODE, frameBody.getLanguage());
105
//Set language to too short a value
106
frameBody.setLanguage("aa");
108
mp3File = new MP3File(testFile);
109
commFrame = (ID3v24Frame) mp3File.getID3v2Tag().getFrame("COMM");
110
frameBody = (FrameBodyCOMM) commFrame.getBody();
111
assertEquals(SAFE_LONGER_LANG_CODE, frameBody.getLanguage());
113
//Set language to too long a value
114
frameBody.setLanguage("aaaaaaa");
116
mp3File = new MP3File(testFile);
117
commFrame = (ID3v24Frame) mp3File.getID3v2Tag().getFrame("COMM");
118
frameBody = (FrameBodyCOMM) commFrame.getBody();
119
assertEquals(SAFE_SHORTER_LANG_CODE, frameBody.getLanguage());
124
ie.printStackTrace();