class JVoiceXmlDocumentServer implements DocumentServer {

    @Override
    public URI storeAudio(final AudioInputStream in) throws BadFetchError {
        try {
            final File directory = getRecordingsDirectory();
            final File file = File.createTempFile("rec-", ".wav", directory);
            AudioSystem.write(in, AudioFileFormat.Type.WAVE, file);
            LOGGER.info("recorded to file '" + file.toURI() + "'");
            return file.toURI();
        } catch (IOException ex) {
            throw new BadFetchError(ex.getMessage(), ex);
        }
    }

}

class TestJVoiceXmlDocumentServer {

    private DocumentMap map;
    private JVoiceXmlDocumentServer server;

    @Test
    public void testStoreAudio() throws Exception, JVoiceXMLEvent {

        final URL file = this.getClass().getResource("/test.wav");
        final AudioInputStream ain = AudioSystem.getAudioInputStream(file);
        final URI result = server.storeAudio(ain);
        Assert.assertNotNull(result);
        final File rec = new File(result);
        Assert.assertTrue("expexcted file exists", rec.exists());
    }

}