-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPureJavaMp3DecoderTest.java
More file actions
36 lines (27 loc) · 1.2 KB
/
Copy pathPureJavaMp3DecoderTest.java
File metadata and controls
36 lines (27 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package me.tamkungz.codecmedia.internal.audio.mp3;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.io.InputStream;
import org.junit.jupiter.api.Test;
import me.tamkungz.codecmedia.CodecMediaException;
class PureJavaMp3DecoderTest {
@Test
void shouldFailClosedUntilRealPureJavaLayer3DecoderExists() throws Exception {
byte[] encoded = readResource("c-major-scale_test_web-convert_mono.mp3");
CodecMediaException error = assertThrows(
CodecMediaException.class,
() -> PureJavaMp3Decoder.decodeToPcm(encoded)
);
assertTrue(error.getMessage().contains("not a real MP3 decoder yet"));
assertTrue(error.getMessage().contains("decoder=javasound"));
}
private static byte[] readResource(String resourceName) throws IOException {
try (InputStream in = PureJavaMp3DecoderTest.class.getClassLoader().getResourceAsStream(resourceName)) {
if (in == null) {
throw new IOException("Missing test resource: " + resourceName);
}
return in.readAllBytes();
}
}
}