608N/A/*
608N/A * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
608N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
608N/A *
608N/A * This code is free software; you can redistribute it and/or modify it
608N/A * under the terms of the GNU General Public License version 2 only, as
608N/A * published by the Free Software Foundation. Oracle designates this
608N/A * particular file as subject to the "Classpath" exception as provided
608N/A * by Oracle in the LICENSE file that accompanied this code.
608N/A *
608N/A * This code is distributed in the hope that it will be useful, but WITHOUT
608N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
608N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
608N/A * version 2 for more details (a copy is included in the LICENSE file that
608N/A * accompanied this code).
608N/A *
608N/A * You should have received a copy of the GNU General Public License version
608N/A * 2 along with this work; if not, write to the Free Software Foundation,
608N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
608N/A *
608N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
608N/A * or visit www.oracle.com if you need additional information or have any
608N/A * questions.
608N/A */
608N/A
608N/A/* @test
608N/A @summary Test RiffReader getFilePointer method */
608N/A
608N/Aimport java.io.File;
608N/Aimport java.io.FileInputStream;
608N/A
608N/Aimport javax.sound.sampled.*;
608N/A
608N/Aimport com.sun.media.sound.*;
608N/A
608N/Apublic class GetFilePointer {
608N/A
608N/A private static void assertEquals(Object a, Object b) throws Exception
608N/A {
608N/A if(!a.equals(b))
608N/A throw new RuntimeException("assertEquals fails!");
608N/A }
608N/A
608N/A public static void main(String[] args) throws Exception {
608N/A RIFFWriter writer = null;
608N/A RIFFReader reader = null;
608N/A File tempfile = File.createTempFile("test",".riff");
608N/A try
608N/A {
608N/A writer = new RIFFWriter(tempfile, "TEST");
608N/A RIFFWriter chunk = writer.writeChunk("TSCH");
608N/A chunk.writeByte(10);
608N/A writer.close();
608N/A writer = null;
608N/A FileInputStream fis = new FileInputStream(tempfile);
608N/A reader = new RIFFReader(fis);
608N/A RIFFReader readchunk = reader.nextChunk();
608N/A long p = readchunk.getFilePointer();
608N/A readchunk.readByte();
608N/A assertEquals(p+1,readchunk.getFilePointer());
608N/A fis.close();
608N/A reader = null;
608N/A
608N/A
608N/A }
608N/A finally
608N/A {
608N/A if(writer != null)
608N/A writer.close();
608N/A if(reader != null)
608N/A reader.close();
608N/A
608N/A if(tempfile.exists())
608N/A if(!tempfile.delete())
608N/A tempfile.deleteOnExit();
608N/A }
608N/A }
608N/A}
608N/A