Skip.java revision 8729:0242fce0f717
1228753Smm/* 2228753Smm * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. 3228753Smm * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4228753Smm * 5228753Smm * This code is free software; you can redistribute it and/or modify it 6228753Smm * under the terms of the GNU General Public License version 2 only, as 7228753Smm * published by the Free Software Foundation. 8228753Smm * 9228753Smm * This code is distributed in the hope that it will be useful, but WITHOUT 10228753Smm * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11228753Smm * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12228753Smm * version 2 for more details (a copy is included in the LICENSE file that 13228753Smm * accompanied this code). 14228753Smm * 15228753Smm * You should have received a copy of the GNU General Public License version 16228753Smm * 2 along with this work; if not, write to the Free Software Foundation, 17228753Smm * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18228753Smm * 19228753Smm * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20228753Smm * or visit www.oracle.com if you need additional information or have any 21228753Smm * questions. 22228753Smm */ 23228753Smm 24228753Smm/* @test 25228753Smm @summary Test RiffReader skip method */ 26228753Smm 27228753Smmimport java.io.File; 28228753Smmimport java.io.FileInputStream; 29228753Smm 30228753Smmimport javax.sound.sampled.*; 31228753Smm 32228753Smmimport com.sun.media.sound.*; 33228753Smm 34228753Smmpublic class Skip { 35228753Smm 36228753Smm private static void assertEquals(Object a, Object b) throws Exception 37228753Smm { 38228753Smm if(!a.equals(b)) 39228753Smm throw new RuntimeException("assertEquals fails!"); 40228753Smm } 41228753Smm 42228753Smm public static void main(String[] args) throws Exception { 43228753Smm RIFFWriter writer = null; 44228753Smm RIFFReader reader = null; 45228753Smm File tempfile = File.createTempFile("test",".riff"); 46228753Smm try 47228753Smm { 48228753Smm writer = new RIFFWriter(tempfile, "TEST"); 49228753Smm RIFFWriter chunk = writer.writeChunk("TSCH"); 50228753Smm chunk.write((byte)33); 51228753Smm chunk.write((byte)44); 52228753Smm writer.close(); 53228753Smm writer = null; 54228753Smm FileInputStream fis = new FileInputStream(tempfile); 55228753Smm reader = new RIFFReader(fis); 56228753Smm RIFFReader readchunk = reader.nextChunk(); 57228753Smm reader.skip(1); 58228753Smm assertEquals(readchunk.read(), 44); 59228753Smm fis.close(); 60228753Smm reader = null; 61228753Smm 62228753Smm 63228753Smm } 64228753Smm finally 65228753Smm { 66228753Smm if(writer != null) 67228753Smm writer.close(); 68228753Smm if(reader != null) 69228753Smm reader.close(); 70228753Smm 71228753Smm if(tempfile.exists()) 72228753Smm if(!tempfile.delete()) 73228753Smm tempfile.deleteOnExit(); 74228753Smm } 75228753Smm } 76228753Smm} 77228753Smm