}
@Test
public void testFlushPacket()
{
IContainer container = IContainer.make();
// now, try opening a container.
int retval = container.open("file:"+this.getClass().getName()+"_"+this.getName()+".flv",
IContainer.Type.WRITE, null);
assertTrue("could not open file for writing", retval >= 0);
// add a stream
IStream stream = container.addNewStream(0);
IStreamCoder coder = stream.getStreamCoder();
coder.setCodec(ICodec.ID.CODEC_ID_MP3);
coder.setChannels(1);
coder.setSampleRate(22050);
retval = coder.open();
assertTrue("could not open audio codec", retval >= 0);
retval = container.writeHeader();
assertTrue("could not write header", retval >= 0);
// Try a flush
retval = container.flushPackets();
assertTrue("could not flush packets", retval >= 0);
// Now, this should fail; in previous versions it would work but could crash the JVM
retval = container.writeTrailer();
assertTrue("this should fail", retval >=0);
// now close the codec
retval = coder.close();
assertTrue("could not close audio codec", retval >= 0);
retval = container.close();
assertTrue("could not close file", retval >= 0);
}