1
package org.jaudiotagger.audio.asf.data;
3
import org.jaudiotagger.logging.ErrorMessage;
5
import java.math.BigInteger;
6
import java.util.ArrayList;
10
* Tests the content description container.
12
* @author Christian Laireiter
14
public class ContentDescriptionTest extends
15
AbstractMetadataContainer<ContentDescription> {
21
protected ContentDescription createChunk(long pos, BigInteger size) {
22
return new ContentDescription(pos, size);
29
protected MetadataDescriptor[] createSupportedDescriptors(
30
ContentDescription container) {
31
final List<MetadataDescriptor> result = new ArrayList<MetadataDescriptor>();
32
MetadataDescriptor desc = new MetadataDescriptor(
33
ContentDescription.KEY_AUTHOR);
34
desc.setStringValue("author");
36
desc = new MetadataDescriptor(ContentDescription.KEY_COPYRIGHT);
37
desc.setStringValue("copyright");
39
desc = new MetadataDescriptor(ContentDescription.KEY_DESCRIPTION);
40
desc.setStringValue("description");
42
desc = new MetadataDescriptor(ContentDescription.KEY_RATING);
43
desc.setStringValue("rating");
45
desc = new MetadataDescriptor(ContentDescription.KEY_TITLE);
46
desc.setStringValue("title");
48
return result.toArray(new MetadataDescriptor[result.size()]);
55
protected ContentDescription[] createTestContainers() {
56
return new ContentDescription[] { new ContentDescription() };
61
* {@link org.jaudiotagger.audio.asf.data.ContentDescription#setAuthor(java.lang.String)}
64
public void testSetAuthor() {
65
final ContentDescription chunk = createChunk(0, BigInteger.ZERO);
66
assertTrue(chunk.isEmpty());
67
assertEquals("", chunk.getAuthor());
69
assertTrue(chunk.isEmpty());
70
chunk.setAuthor("author");
71
assertEquals("author", chunk.getAuthor());
72
assertFalse(chunk.isEmpty());
74
chunk.setAuthor(AbstractChunk
75
.createAString(MetadataDescriptor.WORD_MAXVALUE + 1));
76
fail("Exception expected");
77
} catch (IllegalArgumentException iae) {
78
assertErrorMessage(ErrorMessage.WMA_LENGTH_OF_DATA_IS_TOO_LARGE,
85
* {@link org.jaudiotagger.audio.asf.data.ContentDescription#setComment(java.lang.String)}
88
public void testSetComment() {
89
final ContentDescription chunk = createChunk(0, BigInteger.ZERO);
90
assertTrue(chunk.isEmpty());
91
assertEquals("", chunk.getComment());
93
assertTrue(chunk.isEmpty());
94
chunk.setComment("comment");
95
assertEquals("comment", chunk.getComment());
96
assertFalse(chunk.isEmpty());
98
chunk.setComment(AbstractChunk
99
.createAString(MetadataDescriptor.WORD_MAXVALUE + 1));
100
fail("Exception expected");
101
} catch (IllegalArgumentException iae) {
102
assertErrorMessage(ErrorMessage.WMA_LENGTH_OF_DATA_IS_TOO_LARGE,
109
* {@link org.jaudiotagger.audio.asf.data.ContentDescription#setCopyright(java.lang.String)}
112
public void testSetCopyRight() {
113
final ContentDescription chunk = createChunk(0, BigInteger.ZERO);
114
assertTrue(chunk.isEmpty());
115
assertEquals("", chunk.getCopyRight());
116
chunk.setCopyright("");
117
assertTrue(chunk.isEmpty());
118
chunk.setCopyright("copyright");
119
assertEquals("copyright", chunk.getCopyRight());
120
assertFalse(chunk.isEmpty());
122
chunk.setCopyright(AbstractChunk
123
.createAString(MetadataDescriptor.WORD_MAXVALUE + 1));
124
fail("Exception expected");
125
} catch (IllegalArgumentException iae) {
126
assertErrorMessage(ErrorMessage.WMA_LENGTH_OF_DATA_IS_TOO_LARGE,
133
* {@link org.jaudiotagger.audio.asf.data.ContentDescription#setRating(java.lang.String)}
136
public void testSetRating() {
137
final ContentDescription chunk = createChunk(0, BigInteger.ZERO);
138
assertTrue(chunk.isEmpty());
139
assertEquals("", chunk.getRating());
141
assertTrue(chunk.isEmpty());
142
chunk.setRating("rating");
143
assertEquals("rating", chunk.getRating());
144
assertFalse(chunk.isEmpty());
146
chunk.setRating(AbstractChunk
147
.createAString(MetadataDescriptor.WORD_MAXVALUE + 1));
148
fail("Exception expected");
149
} catch (IllegalArgumentException iae) {
150
assertErrorMessage(ErrorMessage.WMA_LENGTH_OF_DATA_IS_TOO_LARGE,
157
* {@link org.jaudiotagger.audio.asf.data.ContentDescription#setTitle(java.lang.String)}
160
public void testSetTitle() {
161
final ContentDescription chunk = createChunk(0, BigInteger.ZERO);
162
assertTrue(chunk.isEmpty());
163
assertEquals("", chunk.getTitle());
165
assertTrue(chunk.isEmpty());
166
chunk.setTitle("title");
167
assertEquals("title", chunk.getTitle());
168
assertFalse(chunk.isEmpty());
170
chunk.setTitle(AbstractChunk
171
.createAString(MetadataDescriptor.WORD_MAXVALUE + 1));
172
fail("Exception expected");
173
} catch (IllegalArgumentException iae) {
174
assertErrorMessage(ErrorMessage.WMA_LENGTH_OF_DATA_IS_TOO_LARGE,