Search in sources :

Example 21 with CountingInputStream

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());
}
Also used : CountingInputStream(org.apache.commons.io.input.CountingInputStream) Chapter(de.danoeh.antennapod.model.feed.Chapter) Test(org.junit.Test)

Example 22 with CountingInputStream

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());
}
Also used : CountingInputStream(org.apache.commons.io.input.CountingInputStream) Chapter(de.danoeh.antennapod.model.feed.Chapter) Test(org.junit.Test)

Example 23 with CountingInputStream

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);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) CountingInputStream(org.apache.commons.io.input.CountingInputStream) Test(org.junit.Test)

Example 24 with CountingInputStream

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));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) CountingInputStream(org.apache.commons.io.input.CountingInputStream) Test(org.junit.Test)

Example 25 with CountingInputStream

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));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) CountingInputStream(org.apache.commons.io.input.CountingInputStream) Test(org.junit.Test)

Aggregations

CountingInputStream (org.apache.commons.io.input.CountingInputStream)31 Test (org.junit.Test)17 ByteArrayInputStream (java.io.ByteArrayInputStream)15 InputStream (java.io.InputStream)8 Chapter (de.danoeh.antennapod.model.feed.Chapter)7 IOException (java.io.IOException)7 FrameHeader (de.danoeh.antennapod.parser.media.id3.model.FrameHeader)4 BufferedInputStream (java.io.BufferedInputStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 GZIPInputStream (java.util.zip.GZIPInputStream)3 ZipInputStream (java.util.zip.ZipInputStream)3 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 RsrcSection (org.phoenicis.win32.pe.rsrc.RsrcSection)2 Logger (org.slf4j.Logger)2 NodeStatisticsMessage (com.sedmelluq.discord.lavaplayer.remote.message.NodeStatisticsMessage)1 RemoteMessage (com.sedmelluq.discord.lavaplayer.remote.message.RemoteMessage)1 TrackExceptionMessage (com.sedmelluq.discord.lavaplayer.remote.message.TrackExceptionMessage)1 TrackFrameDataMessage (com.sedmelluq.discord.lavaplayer.remote.message.TrackFrameDataMessage)1 TrackStartResponseMessage (com.sedmelluq.discord.lavaplayer.remote.message.TrackStartResponseMessage)1