1 package com.melloware.jukes.file.tag;
2
3 import com.melloware.jukes.AbstractTestCase;
4 import com.melloware.jukes.exception.MusicTagException;
5
6
7
8
9
10
11
12
13
14 public class MusicTagTest
15 extends AbstractTestCase {
16
17 private MusicTag tag = null;
18
19
20
21
22
23 public MusicTagTest(String arg0) {
24 super(arg0);
25
26 }
27
28 public static void main(String[] args) {
29 junit.textui.TestRunner.run(MusicTagTest.class);
30 }
31
32
33
34
35 public void testExtractTitleFromFilename() {
36 assertNotNull(tag.extractTitleFromFilename());
37 }
38
39
40
41
42 public void testGetDisc() {
43 assertEquals("Disc", tag.getDisc());
44 }
45
46
47
48
49 public void testGetArtist() {
50 assertEquals("Artist", tag.getArtist());
51 }
52
53
54
55
56 public void testGetComment() {
57 assertEquals("Comment", tag.getComment());
58 }
59
60
61
62
63 public void testGetEncodedBy() {
64 assertEquals("Junit", tag.getEncodedBy());
65 }
66
67
68
69
70 public void testGetGenre() {
71 assertEquals("Rock", tag.getGenre());
72 }
73
74
75
76
77 public void testGetHeaderInfo() {
78 assertNotNull(tag.getHeaderInfo());
79 }
80
81
82
83
84 public void testGetTitle() {
85 assertEquals("Title", tag.getTitle());
86 }
87
88
89
90
91 public void testGetTrack() {
92 assertEquals("01", tag.getTrack());
93 }
94
95
96
97
98 public void testGetYear() {
99 assertEquals("2006", tag.getYear());
100 }
101
102
103
104
105 public void testHashCode() {
106 assertTrue(tag.hashCode() != 0);
107 }
108
109
110
111
112 public void testRemoveTags() {
113 try {
114 tag.removeTags();
115 } catch (MusicTagException ex) {
116 fail("MusicTagException: Could not remove tags.");
117 }
118 }
119
120
121
122
123 public void testSave() {
124 try {
125 tag.save();
126 } catch (MusicTagException ex) {
127 fail("MusicTagException: Could not save tags.");
128 }
129 }
130
131
132
133
134 public void testSetDisc() {
135 tag.setDisc("test");
136 assertEquals("test", tag.getDisc());
137 }
138
139
140
141
142 public void testSetArtist() {
143 tag.setArtist("test");
144 assertEquals("test", tag.getArtist());
145 }
146
147
148
149
150 public void testSetComment() {
151 tag.setComment("test");
152 assertEquals("test", tag.getComment());
153 }
154
155
156
157
158 public void testSetEncodedBy() {
159 tag.setEncodedBy("test");
160 assertEquals("test", tag.getEncodedBy());
161 }
162
163
164
165
166 public void testSetGenre() {
167 tag.setGenre("test");
168 assertEquals("test", tag.getGenre());
169 }
170
171
172
173
174 public void testSetTitle() {
175 tag.setTitle("test");
176 assertEquals("test", tag.getTitle());
177 }
178
179
180
181
182 public void testSetTrack() {
183 tag.setTrack("2");
184 assertEquals("02", tag.getTrack());
185 }
186
187
188
189
190 public void testSetYear() {
191 tag.setYear("1870");
192 assertEquals("1870", tag.getYear());
193 }
194
195
196
197
198 public void testToString() {
199 assertNotNull(tag.toString());
200 }
201
202
203
204
205 protected void setUp()
206 throws Exception {
207 super.setUp();
208
209 try {
210 tag = TagFactory.getTag("C:/dev/melloware/jukes/trunk/src/test/java/com/melloware/jukes/file/01 - Test.mp3");
211 tag.setDisc("Disc");
212 tag.setArtist("Artist");
213 tag.setComment("Comment");
214 tag.setEncodedBy("Junit");
215 tag.setGenre("Rock");
216 tag.setTitle("Title");
217 tag.setTrack("1");
218 tag.setYear("2006");
219 } catch (MusicTagException ex) {
220 fail("Tag could not be created");
221 }
222 }
223
224
225
226
227 protected void tearDown()
228 throws Exception {
229 super.tearDown();
230 if (tag != null) {
231 tag = null;
232 }
233 }
234
235 }