SetName.java revision 8729:0242fce0f717
1239675Srwatson/* 2239675Srwatson * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. 3239675Srwatson * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4239675Srwatson * 5239675Srwatson * This code is free software; you can redistribute it and/or modify it 6239675Srwatson * under the terms of the GNU General Public License version 2 only, as 7239675Srwatson * published by the Free Software Foundation. 8239675Srwatson * 9239675Srwatson * This code is distributed in the hope that it will be useful, but WITHOUT 10239675Srwatson * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11239675Srwatson * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12239675Srwatson * version 2 for more details (a copy is included in the LICENSE file that 13239675Srwatson * accompanied this code). 14239675Srwatson * 15239675Srwatson * You should have received a copy of the GNU General Public License version 16239675Srwatson * 2 along with this work; if not, write to the Free Software Foundation, 17239675Srwatson * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18239675Srwatson * 19239675Srwatson * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20239675Srwatson * or visit www.oracle.com if you need additional information or have any 21239675Srwatson * questions. 22239675Srwatson */ 23239675Srwatson 24239675Srwatson/* @test 25239675Srwatson @summary Test SimpleInstrument setName(String) method */ 26239675Srwatson 27239675Srwatsonimport javax.sound.sampled.*; 28239675Srwatson 29239675Srwatsonimport com.sun.media.sound.*; 30239675Srwatson 31239675Srwatsonpublic class SetName { 32239675Srwatson 33239675Srwatson private static void assertEquals(Object a, Object b) throws Exception 34239675Srwatson { 35239675Srwatson if(!a.equals(b)) 36239675Srwatson throw new RuntimeException("assertEquals fails!"); 37239675Srwatson } 38239675Srwatson 39239675Srwatson public static void main(String[] args) throws Exception { 40239675Srwatson 41239675Srwatson SimpleInstrument instrument = new SimpleInstrument(); 42239675Srwatson 43239675Srwatson ModelPerformer[] performers = new ModelPerformer[2]; 44239675Srwatson 45239675Srwatson performers[0] = new ModelPerformer(); 46239675Srwatson performers[0].setExclusiveClass(1); 47239675Srwatson performers[0].setKeyFrom(36); 48239675Srwatson performers[0].setKeyTo(48); 49239675Srwatson performers[0].setVelFrom(16); 50239675Srwatson performers[0].setVelTo(80); 51239675Srwatson performers[0].setSelfNonExclusive(true); 52239675Srwatson performers[0].setDefaultConnectionsEnabled(false); 53239675Srwatson performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); 54239675Srwatson performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); 55239675Srwatson 56239675Srwatson performers[1] = new ModelPerformer(); 57239675Srwatson performers[1].setExclusiveClass(0); 58239675Srwatson performers[1].setKeyFrom(12); 59239675Srwatson performers[1].setKeyTo(24); 60239675Srwatson performers[1].setVelFrom(20); 61239675Srwatson performers[1].setVelTo(90); 62239675Srwatson performers[1].setSelfNonExclusive(false); 63239675Srwatson performers[0].setDefaultConnectionsEnabled(true); 64239675Srwatson performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); 65239675Srwatson performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); 66239675Srwatson 67239675Srwatson instrument.setName("hello"); 68239675Srwatson assertEquals(instrument.getName(), "hello"); 69239675Srwatson } 70239675Srwatson} 71239675Srwatson