~ubuntu-branches/ubuntu/utopic/libjaudiotagger-java/utopic

« back to all changes in this revision

Viewing changes to srctest/org/jaudiotagger/issues/Issue307Test.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2011-04-28 23:52:43 UTC
  • mfrom: (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110428235243-pzalvw6lncis3ukf
Tags: 2.0.3-1
* d/control: Drop Depends on default-jre per Debian Java Policy as its
  a library package.
* d/watch: Fix to directly monitor SVN tags.
* Switch to 3.0 (quilt) format.
* Bump Standards-Version to 3.9.2 (no changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.jaudiotagger.issues;
2
 
 
3
 
import org.jaudiotagger.AbstractTestCase;
4
 
import org.jaudiotagger.audio.mp3.MP3File;
5
 
import org.jaudiotagger.tag.id3.ID3v23Frame;
6
 
import org.jaudiotagger.tag.id3.ID3v23Tag;
7
 
import org.jaudiotagger.tag.id3.framebody.FrameBodyIPLS;
8
 
 
9
 
import java.io.File;
10
 
 
11
 
/**
12
 
 * Test Reading dodgy IPLS frame shouldnt cause file not to be loaded
13
 
 */
14
 
public class Issue307Test extends AbstractTestCase
15
 
{
16
 
    public static int countExceptions =0;
17
 
 
18
 
    public void testMultiThreadedMP3HeaderAccess() throws Exception
19
 
    {
20
 
        File orig = new File("testdata", "test71.mp3");
21
 
        if (!orig.isFile())
22
 
        {
23
 
            System.err.println("Unable to test file - not available");
24
 
            return;
25
 
        }
26
 
 
27
 
        Exception e=null;
28
 
        MP3File mp3File = null;
29
 
        try
30
 
        {
31
 
            final File testFile = AbstractTestCase.copyAudioToTmp("test71.mp3");
32
 
            if (!testFile.isFile())
33
 
            {
34
 
                System.err.println("Unable to test file - not available");
35
 
                return;
36
 
            }
37
 
            mp3File = new MP3File(testFile);
38
 
        }
39
 
        catch(Exception ex)
40
 
        {
41
 
            e=ex;
42
 
            ex.printStackTrace();
43
 
        }
44
 
        assertNull(e);
45
 
        FrameBodyIPLS frameBody = (FrameBodyIPLS)(((ID3v23Frame)((ID3v23Tag)mp3File.getTag()).getFirstField("IPLS")).getBody());
46
 
        assertEquals(3,frameBody.getNumberOfPairs());
47
 
        assertEquals(7,frameBody.getNumberOfValues());
48
 
        assertEquals("producer",frameBody.getValueAtIndex(0));
49
 
        assertEquals("Tom Wilson",frameBody.getValueAtIndex(1));
50
 
        assertEquals("producer",frameBody.getValueAtIndex(2));
51
 
        assertEquals("John H. Hammond",frameBody.getValueAtIndex(3));
52
 
        assertEquals("lead vocal",frameBody.getValueAtIndex(4));
53
 
        //assertEquals("l",frameBody.getValueAtIndex(5));
54
 
        //assertEquals("",frameBody.getValueAtIndex(6));
55
 
 
56
 
 
57
 
    }
 
1
package org.jaudiotagger.issues;
 
2
 
 
3
import org.jaudiotagger.AbstractTestCase;
 
4
import org.jaudiotagger.audio.mp3.MP3File;
 
5
import org.jaudiotagger.tag.id3.ID3v23Frame;
 
6
import org.jaudiotagger.tag.id3.ID3v23Tag;
 
7
import org.jaudiotagger.tag.id3.framebody.FrameBodyIPLS;
 
8
 
 
9
import java.io.File;
 
10
 
 
11
/**
 
12
 * Test Reading dodgy IPLS frame shouldnt cause file not to be loaded
 
13
 */
 
14
public class Issue307Test extends AbstractTestCase
 
15
{
 
16
    public static int countExceptions =0;
 
17
 
 
18
    public void testMultiThreadedMP3HeaderAccess() throws Exception
 
19
    {
 
20
        File orig = new File("testdata", "test71.mp3");
 
21
        if (!orig.isFile())
 
22
        {
 
23
            System.err.println("Unable to test file - not available");
 
24
            return;
 
25
        }
 
26
 
 
27
        Exception e=null;
 
28
        MP3File mp3File = null;
 
29
        try
 
30
        {
 
31
            final File testFile = AbstractTestCase.copyAudioToTmp("test71.mp3");
 
32
            if (!testFile.isFile())
 
33
            {
 
34
                System.err.println("Unable to test file - not available");
 
35
                return;
 
36
            }
 
37
            mp3File = new MP3File(testFile);
 
38
        }
 
39
        catch(Exception ex)
 
40
        {
 
41
            e=ex;
 
42
            ex.printStackTrace();
 
43
        }
 
44
        assertNull(e);
 
45
        FrameBodyIPLS frameBody = (FrameBodyIPLS)(((ID3v23Frame)((ID3v23Tag)mp3File.getTag()).getFirstField("IPLS")).getBody());
 
46
        assertEquals(3,frameBody.getNumberOfPairs());
 
47
        assertEquals("producer",frameBody.getKeyAtIndex(0));
 
48
        assertEquals("Tom Wilson",frameBody.getValueAtIndex(0));
 
49
        assertEquals("producer",frameBody.getKeyAtIndex(1));
 
50
        assertEquals("John H. Hammond",frameBody.getValueAtIndex(1));
 
51
 
 
52
 
 
53
    }
58
54
}
 
 
b'\\ No newline at end of file'