~ubuntu-branches/ubuntu/trusty/libjaudiotagger-java/trusty

« back to all changes in this revision

Viewing changes to srctest/org/jaudiotagger/audio/asf/data/ChunkTest.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.audio.asf.data;
2
 
 
3
 
import java.math.BigInteger;
4
 
 
5
 
/**
6
 
 * Test for simple {@link Chunk}.
7
 
 * 
8
 
 * @author Christian Laireiter
9
 
 */
10
 
public class ChunkTest extends AbstractChunk<Chunk> {
11
 
 
12
 
    /**
13
 
     * Creates a chunk instance.
14
 
     * 
15
 
     * @param chunkGUID
16
 
     *            GUID
17
 
     * @param pos
18
 
     *            position of chunk
19
 
     * @param chunkLength
20
 
     *            length of chunk
21
 
     * @return chunk instance.
22
 
     */
23
 
    protected Chunk createChunk(final GUID chunkGUID, final long pos,
24
 
            final BigInteger chunkLength) {
25
 
        return new Chunk(chunkGUID, pos, chunkLength);
26
 
    }
27
 
 
28
 
    /**
29
 
     * {@inheritDoc}
30
 
     */
31
 
    @Override
32
 
    protected Chunk createChunk(long pos, BigInteger size) {
33
 
        return new Chunk(GUID.GUID_UNSPECIFIED, pos, size);
34
 
    }
35
 
 
36
 
    /**
37
 
     * Tests the creation of chunks and should fail.<br>
38
 
     * 
39
 
     * @param chunkGUID
40
 
     *            GUID.
41
 
     * @param pos
42
 
     *            position of the chunk
43
 
     * @param chunkLength
44
 
     *            chunk size.
45
 
     * @return The occurred exception on
46
 
     *         {@link #createChunk(GUID,long, BigInteger)}.
47
 
     */
48
 
    public Exception failOn(final GUID chunkGUID, final long pos,
49
 
            final BigInteger chunkLength) {
50
 
        Exception result = null;
51
 
        try {
52
 
            createChunk(chunkGUID, pos, chunkLength);
53
 
        } catch (Exception e) {
54
 
            result = e;
55
 
        }
56
 
        return result;
57
 
    }
58
 
 
59
 
    /**
60
 
     * Test method for
61
 
     * {@link org.jaudiotagger.audio.asf.data.Chunk#Chunk(GUID, BigInteger)}.
62
 
     */
63
 
    public void testChunk() {
64
 
        assertTrue("IllegalArgumentException expected",
65
 
                failOn(null, 0, null) instanceof IllegalArgumentException);
66
 
        assertTrue(
67
 
                "IllegalArgumentException expected",
68
 
                failOn(GUID.GUID_UNSPECIFIED, 0, null) instanceof IllegalArgumentException);
69
 
        assertTrue("IllegalArgumentException expected", failOn(
70
 
                GUID.GUID_UNSPECIFIED, 0, BigInteger.TEN.multiply(BigInteger
71
 
                        .valueOf(-1))) instanceof IllegalArgumentException);
72
 
        assertNull("Should have worked fine", failOn(GUID.GUID_UNSPECIFIED, 0,
73
 
                BigInteger.TEN));
74
 
        assertNull("Should have worked fine", failOn(GUID.GUID_UNSPECIFIED, 0,
75
 
                BigInteger.ZERO));
76
 
    }
77
 
 
78
 
}
 
1
package org.jaudiotagger.audio.asf.data;
 
2
 
 
3
import java.math.BigInteger;
 
4
 
 
5
/**
 
6
 * Test for simple {@link Chunk}.
 
7
 * 
 
8
 * @author Christian Laireiter
 
9
 */
 
10
public class ChunkTest extends AbstractChunk<Chunk> {
 
11
 
 
12
    /**
 
13
     * Creates a chunk instance.
 
14
     * 
 
15
     * @param chunkGUID
 
16
     *            GUID
 
17
     * @param pos
 
18
     *            position of chunk
 
19
     * @param chunkLength
 
20
     *            length of chunk
 
21
     * @return chunk instance.
 
22
     */
 
23
    protected Chunk createChunk(final GUID chunkGUID, final long pos,
 
24
            final BigInteger chunkLength) {
 
25
        return new Chunk(chunkGUID, pos, chunkLength);
 
26
    }
 
27
 
 
28
    /**
 
29
     * {@inheritDoc}
 
30
     */
 
31
    @Override
 
32
    protected Chunk createChunk(long pos, BigInteger size) {
 
33
        return new Chunk(GUID.GUID_UNSPECIFIED, pos, size);
 
34
    }
 
35
 
 
36
    /**
 
37
     * Tests the creation of chunks and should fail.<br>
 
38
     * 
 
39
     * @param chunkGUID
 
40
     *            GUID.
 
41
     * @param pos
 
42
     *            position of the chunk
 
43
     * @param chunkLength
 
44
     *            chunk size.
 
45
     * @return The occurred exception on
 
46
     *         {@link #createChunk(GUID,long, BigInteger)}.
 
47
     */
 
48
    public Exception failOn(final GUID chunkGUID, final long pos,
 
49
            final BigInteger chunkLength) {
 
50
        Exception result = null;
 
51
        try {
 
52
            createChunk(chunkGUID, pos, chunkLength);
 
53
        } catch (Exception e) {
 
54
            result = e;
 
55
        }
 
56
        return result;
 
57
    }
 
58
 
 
59
    /**
 
60
     * Test method for
 
61
     * {@link org.jaudiotagger.audio.asf.data.Chunk#Chunk(GUID, BigInteger)}.
 
62
     */
 
63
    public void testChunk() {
 
64
        assertTrue("IllegalArgumentException expected",
 
65
                failOn(null, 0, null) instanceof IllegalArgumentException);
 
66
        assertTrue(
 
67
                "IllegalArgumentException expected",
 
68
                failOn(GUID.GUID_UNSPECIFIED, 0, null) instanceof IllegalArgumentException);
 
69
        assertTrue("IllegalArgumentException expected", failOn(
 
70
                GUID.GUID_UNSPECIFIED, 0, BigInteger.TEN.multiply(BigInteger
 
71
                        .valueOf(-1))) instanceof IllegalArgumentException);
 
72
        assertNull("Should have worked fine", failOn(GUID.GUID_UNSPECIFIED, 0,
 
73
                BigInteger.TEN));
 
74
        assertNull("Should have worked fine", failOn(GUID.GUID_UNSPECIFIED, 0,
 
75
                BigInteger.ZERO));
 
76
    }
 
77
 
 
78
}