Make minimum set of API methods in JNI layer to support encoding/decoding#563
Make minimum set of API methods in JNI layer to support encoding/decoding#563hrosa merged 8 commits intogithub-107from
Conversation
| #include <stdlib.h> | ||
| #include <string.h> | ||
|
|
||
| #define FRAME_SIZE 480 |
There was a problem hiding this comment.
Open ticket to make these variables configurable in the future.
There was a problem hiding this comment.
The hardcoded values will be substituted by configurable values in task #551
|
|
||
| try { | ||
| FileInputStream inputStream = new FileInputStream("src\\main\\jni\\test_sound_mono_48.pcm"); | ||
| FileOutputStream outputStream = new FileOutputStream("src\\main\\jni\\test_sound_mono_48_decoded.pcm", false); |
There was a problem hiding this comment.
Create temporary file instead and make sure we delete it after the test.
Example: Path tempFile = Files.createTempFile("tempfiles", ".tmp");
| opus.closeNative(); | ||
| } | ||
| } catch (IOException exc) { | ||
| System.out.println("IOException: " + exc.getMessage()); |
There was a problem hiding this comment.
Use log4j instead with ERROR threshold
| } | ||
| } catch (IOException exc) { | ||
| System.out.println("IOException: " + exc.getMessage()); | ||
| return; |
There was a problem hiding this comment.
Fail the test instead of silently ignoring the error.
| @@ -71,9 +79,36 @@ public void tearDown() throws Exception { | |||
| */ | |||
| @Test | |||
| public void testCodec() { | |||
| opus.sayHelloNative(); | ||
|
|
||
| try { | ||
| FileInputStream inputStream = new FileInputStream("src\\main\\jni\\test_sound_mono_48.pcm"); |
There was a problem hiding this comment.
Move resource to src/test/resources/...
|
@hrosa It is ready to be merged. |
| FileOutputStream outputStream = new FileOutputStream(outputFile, false); | ||
|
|
||
| OpusJni opus = new OpusJni(); | ||
| opus.setOpusObserverNative(this); |
There was a problem hiding this comment.
Create a Mockito.mock for OpusJni.Observer instead of using this reference
| @@ -42,6 +50,9 @@ | |||
| * | |||
| */ | |||
| public class OpusCodecTest implements OpusJni.Observer { | |||
There was a problem hiding this comment.
Test class should not implement OpusJni.Observer
| } | ||
|
|
||
| @Override | ||
| public void onHello() { |
| } | ||
|
|
||
| assertTrue(testPassed); | ||
|
|
There was a problem hiding this comment.
Mockito.verify(opusObserver).onHello()
|
|
||
| boolean testPassed = false; | ||
|
|
||
| try { |
There was a problem hiding this comment.
For safety, use try-with-resources for any closeable resource used (inputStream, outputStream).
https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html
No description provided.