[LIB-4] Extend copyright for 2019 year
[hespiff.git] / src / test / java / org / hedgecode / xml / xspf / XSPFTest.java
1 /*
2  * Copyright (c) 2015-2019. Developed by Hedgecode.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.hedgecode.xml.xspf;
18
19 import java.io.File;
20
21 import org.junit.Assert;
22 import org.junit.Test;
23 import org.junit.runner.RunWith;
24 import org.junit.runners.JUnit4;
25
26 /**
27  * Tests for {@link XSPF}.
28  *
29  * @author Dmitry Samoshin aka gotty
30  */
31 @RunWith(JUnit4.class)
32 public class XSPFTest extends Assert {
33
34     private static final String XSPF_FILE_DIR = "/";
35     private static final String XSPF_PLAYLIST_FILE = "playlist.xspf";
36     private static final String XSPF_TORRENT_FILE = "torrent-tv.ru.xspf";
37
38     @Test
39     public void testBind() throws Exception {
40
41         File xspfFile = new File(
42                 XSPFTest.class.getResource(
43                         XSPF_FILE_DIR + XSPF_PLAYLIST_FILE
44                 ).toURI()
45         );
46
47
48         Playlist playlist = XSPF.create(xspfFile);
49
50         playlist.write(
51                 new File("test.xspf")
52         );
53     }
54
55     @Test
56     public void testCreate() throws Exception {
57
58         Playlist playlist = XSPF.create(XSPFConstants.Format.XSD);
59         playlist.setTitle("Title");
60         playlist.setLocation("Location");
61         XSPF.addTrack(playlist, "a.mp3", "First MP3");
62         XSPF.addTrack(playlist, "b.mp3", "Second MP3");
63         XSPF.addTrack(playlist, "c.mp3", "Third MP3");
64         playlist.write(
65                 new File("test2.xspf")
66         );
67     }
68
69 }