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

« back to all changes in this revision

Viewing changes to srctest/org/jaudiotagger/tag/id3/FileClosingTest.java

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath, Damien Raude-Morvan, Varun Hiremath
  • Date: 2009-04-01 19:17:56 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090401191756-bygniim270guy7o1
Tags: 1.0.9-1
[ Damien Raude-Morvan ]
* New upstream release
* debian/watch: Use java.net repository (which contains new releases!)
* debian/control:
  - Build-Depends on default-jdk-builddep
  - Bump Standards-Version to 3.8.1 (no changes needed)
  - Change section to "java"
* debian/rules: use default-java as JAVA_HOME
* debina/orig-tar.{sh|excludes}: strip audio and others binary files from ZIP
* debian/build.xml:
  - compile with "nowarn" to keep build log readable
  - exclude LogFormatter from build (use com.sun classes)
* debian/ant.properties: new source directory is "src" in orig.tar.gz
* Add myself as Uploaders

[ Varun Hiremath ]
* Accept changes made by Damien Raude-Morvan (Closes: #522130)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.jaudiotagger.tag.id3;
 
2
 
 
3
import org.jaudiotagger.AbstractTestCase;
 
4
import org.jaudiotagger.audio.mp3.MP3File;
 
5
 
 
6
import java.io.File;
 
7
 
 
8
/**
 
9
 * testing of reading compressed frames
 
10
 */
 
11
public class FileClosingTest extends AbstractTestCase
 
12
{
 
13
    /**
 
14
     * This tests checks files are closed after reading attempt
 
15
     */
 
16
    public void testClosingFileAfterFailedRead()
 
17
    {
 
18
        Exception exception = null;
 
19
        File testFile = AbstractTestCase.copyAudioToTmp("corrupt.mp3");
 
20
 
 
21
        //Try and Read
 
22
        try
 
23
        {
 
24
            MP3File mp3File = new MP3File(testFile);
 
25
        }
 
26
        catch (Exception e)
 
27
        {
 
28
            exception = e;
 
29
        }
 
30
 
 
31
        //Error Should have occured
 
32
        assertTrue(exception != null);
 
33
 
 
34
        //Should be able to delete
 
35
        boolean deleted = testFile.delete();
 
36
        assertTrue(deleted);
 
37
    }
 
38
 
 
39
    /**
 
40
     * This tests checks files are closed after succesful reading attempt
 
41
     */
 
42
    public void testClosingFileAfterSuccessfulRead()
 
43
    {
 
44
        Exception exception = null;
 
45
        File testFile = AbstractTestCase.copyAudioToTmp("testV1.mp3");
 
46
 
 
47
        //Try and Read
 
48
        try
 
49
        {
 
50
            MP3File mp3File = new MP3File(testFile);
 
51
        }
 
52
        catch (Exception e)
 
53
        {
 
54
            exception = e;
 
55
        }
 
56
 
 
57
        //No Error Should have occured
 
58
        assertTrue(exception == null);
 
59
 
 
60
        //Should be able to delete
 
61
        boolean deleted = testFile.delete();
 
62
        assertTrue(deleted);
 
63
    }
 
64
 
 
65
    /**
 
66
     * This tests checks files are closed after failed reading attempt (read only)
 
67
     */
 
68
    public void testClosingFileAfterFailedReadOnly()
 
69
    {
 
70
        Exception exception = null;
 
71
        File testFile = AbstractTestCase.copyAudioToTmp("testV1.mp3");
 
72
 
 
73
        boolean readonly = testFile.setReadOnly();
 
74
        assertTrue(readonly);
 
75
 
 
76
        //Try and Read
 
77
        try
 
78
        {
 
79
            MP3File mp3File = new MP3File(testFile);
 
80
        }
 
81
        catch (Exception e)
 
82
        {
 
83
            exception = e;
 
84
        }
 
85
 
 
86
        //Error Should have occured
 
87
        assertTrue(exception != null);
 
88
 
 
89
        //Should be able to delete
 
90
        boolean deleted = testFile.delete();
 
91
        assertTrue(deleted);
 
92
    }
 
93
 
 
94
}