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.FrameBodyTSOC;
6
import org.jaudiotagger.tag.id3.framebody.FrameBodyTSOCTest;
7
import org.jaudiotagger.tag.id3.valuepair.TextEncoding;
14
public class FrameTSOCTest extends AbstractTestCase
16
public static ID3v24Frame getV24InitialisedFrame()
18
ID3v24Frame frame = new ID3v24Frame(ID3v24Frames.FRAME_ID_COMPOSER_SORT_ORDER_ITUNES);
19
FrameBodyTSOC fb = FrameBodyTSOCTest.getInitialisedBody();
24
public static ID3v23Frame getV23InitialisedFrame()
26
ID3v23Frame frame = new ID3v23Frame(ID3v23Frames.FRAME_ID_V3_COMPOSER_SORT_ORDER_ITUNES);
27
FrameBodyTSOC fb = FrameBodyTSOCTest.getInitialisedBody();
32
public static ID3v22Frame getV22InitialisedFrame()
34
ID3v22Frame frame = new ID3v22Frame(ID3v22Frames.FRAME_ID_V2_COMPOSER_SORT_ORDER_ITUNES);
35
FrameBodyTSOC fb = FrameBodyTSOCTest.getInitialisedBody();
40
public void testCreateID3v24Frame()
42
Exception exceptionCaught = null;
43
ID3v24Frame frame = null;
46
frame = getV24InitialisedFrame();
53
assertNull(exceptionCaught);
54
assertEquals(ID3v24Frames.FRAME_ID_COMPOSER_SORT_ORDER_ITUNES, frame.getIdentifier());
55
assertEquals(TextEncoding.ISO_8859_1, frame.getBody().getTextEncoding());
56
assertTrue(ID3v24Frames.getInstanceOf().isExtensionFrames(frame.getIdentifier()));
57
assertFalse(ID3v24Frames.getInstanceOf().isSupportedFrames(frame.getIdentifier()));
58
assertEquals(FrameBodyTSOCTest.COMPOSER_SORT, ((FrameBodyTSOC) frame.getBody()).getText());
63
public void testCreateID3v23Frame()
65
Exception exceptionCaught = null;
66
ID3v23Frame frame = null;
70
frame = getV23InitialisedFrame();
77
assertNull(exceptionCaught);
78
assertEquals(ID3v23Frames.FRAME_ID_V3_COMPOSER_SORT_ORDER_ITUNES, frame.getIdentifier());
79
assertEquals(TextEncoding.ISO_8859_1, frame.getBody().getTextEncoding());
80
assertTrue(ID3v23Frames.getInstanceOf().isExtensionFrames(frame.getIdentifier()));
81
assertFalse(ID3v23Frames.getInstanceOf().isSupportedFrames(frame.getIdentifier()));
82
assertEquals(FrameBodyTSOCTest.COMPOSER_SORT, ((FrameBodyTSOC) frame.getBody()).getText());
86
public void testCreateID3v22Frame()
88
Exception exceptionCaught = null;
89
ID3v22Frame frame = null;
93
frame = getV22InitialisedFrame();
100
assertNull(exceptionCaught);
101
assertEquals(ID3v22Frames.FRAME_ID_V2_COMPOSER_SORT_ORDER_ITUNES, frame.getIdentifier());
102
assertEquals(TextEncoding.ISO_8859_1, frame.getBody().getTextEncoding());
103
assertTrue(ID3v22Frames.getInstanceOf().isExtensionFrames(frame.getIdentifier()));
104
assertFalse(ID3v22Frames.getInstanceOf().isSupportedFrames(frame.getIdentifier()));
105
assertEquals(FrameBodyTSOCTest.COMPOSER_SORT, ((FrameBodyTSOC) frame.getBody()).getText());
110
public void testSaveToFile() throws Exception
112
File testFile = AbstractTestCase.copyAudioToTmp("testV1.mp3");
113
MP3File mp3File = new MP3File(testFile);
116
ID3v24Tag tag = new ID3v24Tag();
117
tag.setFrame(getV24InitialisedFrame());
118
mp3File.setID3v2Tag(tag);
122
mp3File = new MP3File(testFile);
123
ID3v24Frame frame = (ID3v24Frame) mp3File.getID3v2Tag().getFrame(ID3v24Frames.FRAME_ID_COMPOSER_SORT_ORDER_ITUNES);
124
FrameBodyTSOC body = (FrameBodyTSOC) frame.getBody();
125
assertEquals(TextEncoding.ISO_8859_1, body.getTextEncoding());
129
public void testConvertV24ToV23() throws Exception
131
File testFile = AbstractTestCase.copyAudioToTmp("testV1.mp3");
132
MP3File mp3File = new MP3File(testFile);
135
ID3v24Tag tag = new ID3v24Tag();
136
tag.setFrame(getV24InitialisedFrame());
138
mp3File.setID3v2Tag(tag);
141
//Reload and convert to v23 and save
142
mp3File = new MP3File(testFile);
143
mp3File.setID3v2TagOnly(new ID3v23Tag(mp3File.getID3v2TagAsv24()));
147
mp3File = new MP3File(testFile);
148
ID3v23Frame frame = (ID3v23Frame) mp3File.getID3v2Tag().getFrame(ID3v23Frames.FRAME_ID_V3_COMPOSER_SORT_ORDER_ITUNES);
149
FrameBodyTSOC body = (FrameBodyTSOC) frame.getBody();
150
assertEquals(TextEncoding.ISO_8859_1, body.getTextEncoding());
151
assertEquals(FrameBodyTSOCTest.COMPOSER_SORT, body.getText());
154
public void testConvertV24ToV22() throws Exception
156
File testFile = AbstractTestCase.copyAudioToTmp("testV1.mp3");
157
MP3File mp3File = new MP3File(testFile);
160
ID3v24Tag tag = new ID3v24Tag();
161
tag.setFrame(FrameTSOCTest.getV24InitialisedFrame());
163
mp3File.setID3v2Tag(tag);
166
//Reload and convert to v22 and save
167
mp3File = new MP3File(testFile);
168
mp3File.setID3v2TagOnly(new ID3v22Tag(mp3File.getID3v2TagAsv24()));
172
mp3File = new MP3File(testFile);
173
ID3v22Frame frame = (ID3v22Frame) mp3File.getID3v2Tag().getFrame(ID3v22Frames.FRAME_ID_V2_COMPOSER_SORT_ORDER_ITUNES);
174
FrameBodyTSOC body = (FrameBodyTSOC) frame.getBody();
175
assertEquals(TextEncoding.ISO_8859_1, body.getTextEncoding());
176
assertEquals(FrameBodyTSOCTest.COMPOSER_SORT, body.getText());
179
public void testConvertV23ToV22() throws Exception
181
File testFile = AbstractTestCase.copyAudioToTmp("testV1.mp3");
182
MP3File mp3File = new MP3File(testFile);
185
ID3v23Tag tag = new ID3v23Tag();
186
tag.setFrame(FrameTSOCTest.getV23InitialisedFrame());
188
mp3File.setID3v2TagOnly((ID3v23Tag) tag);
191
//Reload and convert from v23 to v22 and save
192
mp3File = new MP3File(testFile);
193
mp3File.setID3v2TagOnly(new ID3v22Tag(mp3File.getID3v2Tag()));
197
mp3File = new MP3File(testFile);
198
ID3v22Frame frame = (ID3v22Frame) mp3File.getID3v2Tag().getFrame(ID3v22Frames.FRAME_ID_V2_COMPOSER_SORT_ORDER_ITUNES);
199
FrameBodyTSOC body = (FrameBodyTSOC) frame.getBody();
200
assertEquals(TextEncoding.ISO_8859_1, body.getTextEncoding());
201
assertEquals(FrameBodyTSOCTest.COMPOSER_SORT, body.getText());
205
public void testConvertV22ToV24() throws Exception
207
File testFile = AbstractTestCase.copyAudioToTmp("testV1.mp3");
208
MP3File mp3File = new MP3File(testFile);
211
ID3v22Tag tag = new ID3v22Tag();
213
//..Notes (uses v22Frame but frame body will be the v23/24 version)
214
ID3v22Frame id3v22frame = new ID3v22Frame(ID3v22Frames.FRAME_ID_V2_COMPOSER_SORT_ORDER_ITUNES);
215
((FrameBodyTSOC) id3v22frame.getBody()).setText(FrameBodyTSOCTest.COMPOSER_SORT);
216
tag.setFrame(id3v22frame);
218
mp3File.setID3v2TagOnly((ID3v22Tag) tag);
221
//Reload and convert from v22 to v24 and save
222
mp3File = new MP3File(testFile);
223
mp3File.setID3v2TagOnly(new ID3v24Tag(mp3File.getID3v2Tag()));
227
mp3File = new MP3File(testFile);
228
ID3v24Frame frame = (ID3v24Frame) mp3File.getID3v2Tag().getFrame(ID3v24Frames.FRAME_ID_COMPOSER_SORT_ORDER_ITUNES);
229
FrameBodyTSOC body = (FrameBodyTSOC) frame.getBody();
230
assertEquals(TextEncoding.ISO_8859_1, body.getTextEncoding());
231
assertEquals(FrameBodyTSOCTest.COMPOSER_SORT, body.getText());
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.FrameBodyTSOC;
6
import org.jaudiotagger.tag.id3.framebody.FrameBodyTSOCTest;
7
import org.jaudiotagger.tag.id3.valuepair.TextEncoding;
14
public class FrameTSOCTest extends AbstractTestCase
16
public static ID3v24Frame getV24InitialisedFrame()
18
ID3v24Frame frame = new ID3v24Frame(ID3v24Frames.FRAME_ID_COMPOSER_SORT_ORDER_ITUNES);
19
FrameBodyTSOC fb = FrameBodyTSOCTest.getInitialisedBody();
24
public static ID3v23Frame getV23InitialisedFrame()
26
ID3v23Frame frame = new ID3v23Frame(ID3v23Frames.FRAME_ID_V3_COMPOSER_SORT_ORDER_ITUNES);
27
FrameBodyTSOC fb = FrameBodyTSOCTest.getInitialisedBody();
32
public static ID3v22Frame getV22InitialisedFrame()
34
ID3v22Frame frame = new ID3v22Frame(ID3v22Frames.FRAME_ID_V2_COMPOSER_SORT_ORDER_ITUNES);
35
FrameBodyTSOC fb = FrameBodyTSOCTest.getInitialisedBody();
40
public void testCreateID3v24Frame()
42
Exception exceptionCaught = null;
43
ID3v24Frame frame = null;
46
frame = getV24InitialisedFrame();
53
assertNull(exceptionCaught);
54
assertEquals(ID3v24Frames.FRAME_ID_COMPOSER_SORT_ORDER_ITUNES, frame.getIdentifier());
55
assertEquals(TextEncoding.ISO_8859_1, frame.getBody().getTextEncoding());
56
assertTrue(ID3v24Frames.getInstanceOf().isExtensionFrames(frame.getIdentifier()));
57
assertFalse(ID3v24Frames.getInstanceOf().isSupportedFrames(frame.getIdentifier()));
58
assertEquals(FrameBodyTSOCTest.COMPOSER_SORT, ((FrameBodyTSOC) frame.getBody()).getText());
63
public void testCreateID3v23Frame()
65
Exception exceptionCaught = null;
66
ID3v23Frame frame = null;
70
frame = getV23InitialisedFrame();
77
assertNull(exceptionCaught);
78
assertEquals(ID3v23Frames.FRAME_ID_V3_COMPOSER_SORT_ORDER_ITUNES, frame.getIdentifier());
79
assertEquals(TextEncoding.ISO_8859_1, frame.getBody().getTextEncoding());
80
assertTrue(ID3v23Frames.getInstanceOf().isExtensionFrames(frame.getIdentifier()));
81
assertFalse(ID3v23Frames.getInstanceOf().isSupportedFrames(frame.getIdentifier()));
82
assertEquals(FrameBodyTSOCTest.COMPOSER_SORT, ((FrameBodyTSOC) frame.getBody()).getText());
86
public void testCreateID3v22Frame()
88
Exception exceptionCaught = null;
89
ID3v22Frame frame = null;
93
frame = getV22InitialisedFrame();
100
assertNull(exceptionCaught);
101
assertEquals(ID3v22Frames.FRAME_ID_V2_COMPOSER_SORT_ORDER_ITUNES, frame.getIdentifier());
102
assertEquals(TextEncoding.ISO_8859_1, frame.getBody().getTextEncoding());
103
assertTrue(ID3v22Frames.getInstanceOf().isExtensionFrames(frame.getIdentifier()));
104
assertFalse(ID3v22Frames.getInstanceOf().isSupportedFrames(frame.getIdentifier()));
105
assertEquals(FrameBodyTSOCTest.COMPOSER_SORT, ((FrameBodyTSOC) frame.getBody()).getText());
110
public void testSaveToFile() throws Exception
112
File testFile = AbstractTestCase.copyAudioToTmp("testV1.mp3");
113
MP3File mp3File = new MP3File(testFile);
116
ID3v24Tag tag = new ID3v24Tag();
117
tag.setFrame(getV24InitialisedFrame());
118
mp3File.setID3v2Tag(tag);
122
mp3File = new MP3File(testFile);
123
ID3v24Frame frame = (ID3v24Frame) mp3File.getID3v2Tag().getFrame(ID3v24Frames.FRAME_ID_COMPOSER_SORT_ORDER_ITUNES);
124
FrameBodyTSOC body = (FrameBodyTSOC) frame.getBody();
125
assertEquals(TextEncoding.ISO_8859_1, body.getTextEncoding());
129
public void testConvertV24ToV23() throws Exception
131
File testFile = AbstractTestCase.copyAudioToTmp("testV1.mp3");
132
MP3File mp3File = new MP3File(testFile);
135
ID3v24Tag tag = new ID3v24Tag();
136
tag.setFrame(getV24InitialisedFrame());
138
mp3File.setID3v2Tag(tag);
141
//Reload and convert to v23 and save
142
mp3File = new MP3File(testFile);
143
mp3File.setID3v2TagOnly(new ID3v23Tag(mp3File.getID3v2TagAsv24()));
147
mp3File = new MP3File(testFile);
148
ID3v23Frame frame = (ID3v23Frame) mp3File.getID3v2Tag().getFrame(ID3v23Frames.FRAME_ID_V3_COMPOSER_SORT_ORDER_ITUNES);
149
FrameBodyTSOC body = (FrameBodyTSOC) frame.getBody();
150
assertEquals(TextEncoding.ISO_8859_1, body.getTextEncoding());
151
assertEquals(FrameBodyTSOCTest.COMPOSER_SORT, body.getText());
154
public void testConvertV24ToV22() throws Exception
156
File testFile = AbstractTestCase.copyAudioToTmp("testV1.mp3");
157
MP3File mp3File = new MP3File(testFile);
160
ID3v24Tag tag = new ID3v24Tag();
161
tag.setFrame(FrameTSOCTest.getV24InitialisedFrame());
163
mp3File.setID3v2Tag(tag);
166
//Reload and convert to v22 and save
167
mp3File = new MP3File(testFile);
168
mp3File.setID3v2TagOnly(new ID3v22Tag(mp3File.getID3v2TagAsv24()));
172
mp3File = new MP3File(testFile);
173
ID3v22Frame frame = (ID3v22Frame) mp3File.getID3v2Tag().getFrame(ID3v22Frames.FRAME_ID_V2_COMPOSER_SORT_ORDER_ITUNES);
174
FrameBodyTSOC body = (FrameBodyTSOC) frame.getBody();
175
assertEquals(TextEncoding.ISO_8859_1, body.getTextEncoding());
176
assertEquals(FrameBodyTSOCTest.COMPOSER_SORT, body.getText());
179
public void testConvertV23ToV22() throws Exception
181
File testFile = AbstractTestCase.copyAudioToTmp("testV1.mp3");
182
MP3File mp3File = new MP3File(testFile);
185
ID3v23Tag tag = new ID3v23Tag();
186
tag.setFrame(FrameTSOCTest.getV23InitialisedFrame());
188
mp3File.setID3v2TagOnly((ID3v23Tag) tag);
191
//Reload and convert from v23 to v22 and save
192
mp3File = new MP3File(testFile);
193
mp3File.setID3v2TagOnly(new ID3v22Tag(mp3File.getID3v2Tag()));
197
mp3File = new MP3File(testFile);
198
ID3v22Frame frame = (ID3v22Frame) mp3File.getID3v2Tag().getFrame(ID3v22Frames.FRAME_ID_V2_COMPOSER_SORT_ORDER_ITUNES);
199
FrameBodyTSOC body = (FrameBodyTSOC) frame.getBody();
200
assertEquals(TextEncoding.ISO_8859_1, body.getTextEncoding());
201
assertEquals(FrameBodyTSOCTest.COMPOSER_SORT, body.getText());
205
public void testConvertV22ToV24() throws Exception
207
File testFile = AbstractTestCase.copyAudioToTmp("testV1.mp3");
208
MP3File mp3File = new MP3File(testFile);
211
ID3v22Tag tag = new ID3v22Tag();
213
//..Notes (uses v22Frame but frame body will be the v23/24 version)
214
ID3v22Frame id3v22frame = new ID3v22Frame(ID3v22Frames.FRAME_ID_V2_COMPOSER_SORT_ORDER_ITUNES);
215
((FrameBodyTSOC) id3v22frame.getBody()).setText(FrameBodyTSOCTest.COMPOSER_SORT);
216
tag.setFrame(id3v22frame);
218
mp3File.setID3v2TagOnly((ID3v22Tag) tag);
221
//Reload and convert from v22 to v24 and save
222
mp3File = new MP3File(testFile);
223
mp3File.setID3v2TagOnly(new ID3v24Tag(mp3File.getID3v2Tag()));
227
mp3File = new MP3File(testFile);
228
ID3v24Frame frame = (ID3v24Frame) mp3File.getID3v2Tag().getFrame(ID3v24Frames.FRAME_ID_COMPOSER_SORT_ORDER_ITUNES);
229
FrameBodyTSOC body = (FrameBodyTSOC) frame.getBody();
230
assertEquals(TextEncoding.ISO_8859_1, body.getTextEncoding());
231
assertEquals(FrameBodyTSOCTest.COMPOSER_SORT, body.getText());