use of org.apache.commons.io.input.CountingInputStream in project AntennaPod by AntennaPod.
the class ChapterReaderTest method testRealFileMp3chapsPy.
@Test
public void testRealFileMp3chapsPy() throws IOException, ID3ReaderException {
CountingInputStream inputStream = new CountingInputStream(getClass().getClassLoader().getResource("mp3chaps-py.mp3").openStream());
ChapterReader reader = new ChapterReader(inputStream);
reader.readInputStream();
List<Chapter> chapters = reader.getChapters();
assertEquals(4, chapters.size());
assertEquals(0, chapters.get(0).getStart());
assertEquals(7000, chapters.get(1).getStart());
assertEquals(9000, chapters.get(2).getStart());
assertEquals(11000, chapters.get(3).getStart());
assertEquals("Start", chapters.get(0).getTitle());
assertEquals("Chapter 1", chapters.get(1).getTitle());
assertEquals("Chapter 2", chapters.get(2).getTitle());
assertEquals("Chapter 3", chapters.get(3).getTitle());
}
use of org.apache.commons.io.input.CountingInputStream in project AntennaPod by AntennaPod.
the class ChapterReaderTest method testRealFileUltraschall.
@Test
public void testRealFileUltraschall() throws IOException, ID3ReaderException {
CountingInputStream inputStream = new CountingInputStream(getClass().getClassLoader().getResource("ultraschall5.mp3").openStream());
ChapterReader reader = new ChapterReader(inputStream);
reader.readInputStream();
List<Chapter> chapters = reader.getChapters();
assertEquals(3, chapters.size());
assertEquals(0, chapters.get(0).getStart());
assertEquals(4004, chapters.get(1).getStart());
assertEquals(7999, chapters.get(2).getStart());
assertEquals("Marke 1", chapters.get(0).getTitle());
assertEquals("Marke 2", chapters.get(1).getTitle());
assertEquals("Marke 3", chapters.get(2).getTitle());
assertEquals("https://example.com", chapters.get(0).getLink());
assertEquals("https://example.com", chapters.get(1).getLink());
assertEquals("https://example.com", chapters.get(2).getLink());
assertEquals(EmbeddedChapterImage.makeUrl(16073, 2750569), chapters.get(0).getImageUrl());
assertEquals(EmbeddedChapterImage.makeUrl(2766765, 15740), chapters.get(1).getImageUrl());
assertEquals(EmbeddedChapterImage.makeUrl(2782628, 2750569), chapters.get(2).getImageUrl());
}
use of org.apache.commons.io.input.CountingInputStream in project AntennaPod by AntennaPod.
the class Id3ReaderTest method testReadString.
@Test
public void testReadString() throws IOException {
byte[] data = { ID3Reader.ENCODING_ISO, 'T', 'e', 's', 't', // Null-terminated
0 };
CountingInputStream inputStream = new CountingInputStream(new ByteArrayInputStream(data));
String string = new ID3Reader(inputStream).readEncodingAndString(1000);
assertEquals("Test", string);
}
use of org.apache.commons.io.input.CountingInputStream in project AntennaPod by AntennaPod.
the class Id3ReaderTest method testReadMultipleStrings.
@Test
public void testReadMultipleStrings() throws IOException {
byte[] data = { ID3Reader.ENCODING_ISO, 'F', 'o', 'o', // Null-terminated
0, ID3Reader.ENCODING_ISO, 'B', 'a', 'r', // Null-terminated
0 };
CountingInputStream inputStream = new CountingInputStream(new ByteArrayInputStream(data));
ID3Reader reader = new ID3Reader(inputStream);
assertEquals("Foo", reader.readEncodingAndString(1000));
assertEquals("Bar", reader.readEncodingAndString(1000));
}
use of org.apache.commons.io.input.CountingInputStream in project AntennaPod by AntennaPod.
the class Id3ReaderTest method testReadUtf16RespectsBom.
@Test
public void testReadUtf16RespectsBom() throws IOException {
byte[] data = { ID3Reader.ENCODING_UTF16_WITH_BOM, // BOM: Little-endian
(byte) 0xff, // BOM: Little-endian
(byte) 0xfe, 'A', 0, 'B', 0, 'C', 0, // Null-terminated
0, // Null-terminated
0, ID3Reader.ENCODING_UTF16_WITH_BOM, // BOM: Big-endian
(byte) 0xfe, // BOM: Big-endian
(byte) 0xff, 0, 'D', 0, 'E', 0, 'F', // Null-terminated
0, // Null-terminated
0 };
CountingInputStream inputStream = new CountingInputStream(new ByteArrayInputStream(data));
ID3Reader reader = new ID3Reader(inputStream);
assertEquals("ABC", reader.readEncodingAndString(1000));
assertEquals("DEF", reader.readEncodingAndString(1000));
}
Aggregations