@Test
public void testPcmWavConversion()throws IOException{

    final String pcmFilePath=Environment.getExternalStorageDirectory().getAbsolutePath()+File.separator+"Test"+ File.separator+"Test.pcm";
    createPCMFile(pcmFilePath);
    final String wavFilePath=pcmFilePath.replace(".pcm", ".wav");
    PcmWavConverter.convertPCMToWav(waveHeader, pcmFilePath, wavFilePath);
    final DataInputStream dataInputStream=new DataInputStream(new BufferedInputStream(new FileInputStream(wavFilePath)));
    //header
    byte[] expectedByteArray=new byte["RIFF".getBytes().length];
    dataInputStream.read(expectedByteArray);
    assertArrayEquals("RIFF is not there or in correct position.", "RIFF".getBytes(), expectedByteArray);
    Assert.assertEquals("File length is not there or in correct position", Integer.reverseBytes(36 + (int) new File(pcmFilePath).length()), dataInputStream.readInt());
    expectedByteArray=new byte["WAVE".getBytes().length];
    dataInputStream.read(expectedByteArray);
    assertArrayEquals("WAVE is not there or in correct position.", "WAVE".getBytes(), expectedByteArray);
    expectedByteArray=new byte["fmt ".getBytes().length];
    dataInputStream.read(expectedByteArray);
    assertArrayEquals("fmt  is not there or in correct position.", "fmt ".getBytes(), expectedByteArray);
    Assert.assertEquals("16 is not there or in correct position.", Integer.reverseBytes(16), dataInputStream.readInt());
    Assert.assertEquals("PCM format is not there or in correct position.", Short.reverseBytes((short) 1), dataInputStream.readShort());
    Assert.assertEquals("Channel num is not there or in correct position.", Short.reverseBytes(waveHeader.getChannelNum()), dataInputStream.readShort());
    Assert.assertEquals("Sample rate is not there or in correct position.",Integer.reverseBytes(waveHeader.getSampleRateInHertz()),dataInputStream.readInt());
    Assert.assertEquals("Data calculation is not there or in correct position.",Integer.reverseBytes(waveHeader.getChannelNum() * waveHeader.getSampleRateInHertz() * waveHeader.getBitRate() / 8),dataInputStream.readInt());
    Assert.assertEquals("Channel num and bit rate calculation is not there or in correct position.", Short.reverseBytes((short) (waveHeader.getChannelNum() * waveHeader.getBitRate() / 8)),dataInputStream.readShort());
    Assert.assertEquals("Bit rate is not there or in correct position",Short.reverseBytes(waveHeader.getBitRate()),dataInputStream.readShort());
    expectedByteArray=new byte["data".getBytes().length];
    dataInputStream.read(expectedByteArray);
    assertArrayEquals("data is not there or in correct position.", "data".getBytes(), expectedByteArray);
    Assert.assertEquals("File size is not there or in correct position.",Integer.reverseBytes((int) new File(pcmFilePath).length()),dataInputStream.readInt());
    //PCM data
    int i=0;
    while (dataInputStream.available()>0) {
        ByteBuffer bb = ByteBuffer.allocate(2);
        bb.order(ByteOrder.LITTLE_ENDIAN);
        bb.put(dataInputStream.readByte());
        bb.put(dataInputStream.readByte());
        Assert.assertEquals(pcmDataSample[i++],bb.getShort(0));
    }
}