harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r424630 [2/2] - in /incubator/harmony/enhanced/classlib/trunk/modules/sound: ./ .settings/ META-INF/ make/ src/ src/main/ src/main/java/ src/main/java/javax/ src/main/java/javax/sound/ src/main/java/javax/sound/midi/ src/test/ src/test/java...
Date Sat, 22 Jul 2006 21:05:06 GMT
Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/MetaMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/MetaMessageTest.java?rev=424630&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/MetaMessageTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/MetaMessageTest.java Sat Jul 22 14:05:04 2006
@@ -0,0 +1,477 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.sound.tests.javax.sound.midi;
+
+import javax.sound.midi.MetaMessage;
+import javax.sound.midi.InvalidMidiDataException;
+import junit.framework.TestCase;
+
+public class MetaMessageTest extends TestCase {
+    /**
+     * Test constructors of class MetaMessage
+     * with parameters and without its.
+     */
+    public void test_constructor_MetaMessage() throws Exception {
+        MetaMessage meta = new MetaMessage();
+        assertEquals(2, meta.getLength());
+        assertEquals(255, meta.getStatus());
+        assertEquals(0, meta.getType());
+        assertEquals(2, meta.getMessage().length);
+        assertEquals(-1, meta.getMessage()[0]);
+        assertEquals(0, meta.getMessage()[1]);
+        assertEquals(0, meta.getData().length);
+
+        /**
+         * the condition of the object must be the same
+         * after throw out exception
+         */
+        try {
+            meta = new MetaMessage1(null);
+            fail("NullPointerException expected");
+        } catch (NullPointerException e) {
+        }
+
+        assertEquals(2, meta.getLength());
+        assertEquals(255, meta.getStatus());
+        assertEquals(0, meta.getType());
+        assertEquals(2, meta.getMessage().length);
+        assertEquals(-1, meta.getMessage()[0]);
+        assertEquals(0, meta.getMessage()[1]);
+        assertEquals(0, meta.getData().length);
+
+        MetaMessage1 meta3 = new MetaMessage1(new byte[] { -87, 19, 4 });
+        assertEquals(3, meta3.getLength());
+        assertEquals(169, meta3.getStatus());
+        assertEquals(19, meta3.getType());
+        assertEquals(3, meta3.getMessage().length);
+        assertEquals(-87, meta3.getMessage()[0]);
+        assertEquals(19, meta3.getMessage()[1]);
+        assertEquals(4, meta3.getMessage()[2]);
+        assertEquals(0, meta3.getData().length);
+
+        MetaMessage1 meta1 = new MetaMessage1(new byte[] { 17, -9, 23, 45, 56 });
+        assertEquals(5, meta1.getLength());
+        assertEquals(17, meta1.getStatus());
+        assertEquals(247, meta1.getType());
+        assertEquals(5, meta1.getMessage().length);
+        assertEquals(17, meta1.getMessage()[0]);
+        assertEquals(-9, meta1.getMessage()[1]);
+        assertEquals(23, meta1.getMessage()[2]);
+        assertEquals(45, meta1.getMessage()[3]);
+        assertEquals(56, meta1.getMessage()[4]);
+        assertEquals(2, meta1.getData().length);
+        assertEquals(45, meta1.getData()[0]);
+        assertEquals(56, meta1.getData()[1]);
+
+        meta.setMessage(10, new byte[100000], 16385);
+
+        meta1 = new MetaMessage1(meta.getMessage());
+        assertEquals(16390, meta1.getLength());
+        assertEquals(255, meta1.getStatus());
+        assertEquals(10, meta1.getType());
+        assertEquals(16390, meta1.getMessage().length);
+        assertEquals(-1, meta1.getMessage()[0]);
+        assertEquals(10, meta1.getMessage()[1]);
+        assertEquals(-127, meta1.getMessage()[2]);
+        assertEquals(-128, meta1.getMessage()[3]);
+        assertEquals(1, meta1.getMessage()[4]);
+        assertEquals(16385, meta1.getData().length);
+        assertEquals(0, meta1.getData()[0]);
+        assertEquals(0, meta1.getData()[1]);
+
+    }
+
+    /**
+     * Test constant
+     */
+    public void test_constants() {
+        assertEquals("Value of META", 255, MetaMessage.META);
+    }
+
+    /**
+     * Test method setMessage( int, byte[], int ) of 
+     * class MetaMessage with parameters and without its.
+     * Class was created using constructor MetaMessage()
+     */
+    public void test_setMessage1() throws Exception {
+        MetaMessage meta = new MetaMessage();
+        try {
+            meta.setMessage(10, new byte[] { 1, 2, 3 }, 4);
+            fail("InvalidMidiDataException expected");
+        } catch (InvalidMidiDataException e) {
+        }
+
+        try {
+            meta.setMessage(10, new byte[] { 1, 2, 3 }, -5);
+            fail("InvalidMidiDataException expected");
+        } catch (InvalidMidiDataException e) {
+        }
+
+        try {
+            meta.setMessage(-1, new byte[] { 1, 2, 3 }, 3);
+            fail("InvalidMidiDataException expected");
+        } catch (InvalidMidiDataException e) {
+        }
+
+        try {
+            meta.setMessage(128, new byte[] { 1, 2, 3 }, 3);
+            fail("InvalidMidiDataException expected");
+        } catch (InvalidMidiDataException e) {
+        }
+
+        meta.setMessage(18, new byte[] { 1, 2, 3 }, 0);
+
+        assertEquals(meta.getLength(), 3);
+        assertEquals(meta.getMessage().length, 3);
+        assertEquals(meta.getMessage()[0], -1);
+        assertEquals(meta.getMessage()[1], 18);
+        assertEquals(meta.getMessage()[2], 0);
+        assertEquals(meta.getData().length, 0);
+
+        meta.setMessage(10, new byte[100000], 65535);
+        assertEquals(meta.getLength(), 65540);
+        assertEquals(meta.getMessage().length, 65540);
+        assertEquals(meta.getMessage()[0], -1);
+        assertEquals(meta.getMessage()[1], 10);
+        assertEquals(meta.getMessage()[2], -125);
+        assertEquals(meta.getMessage()[3], -1);
+        assertEquals(meta.getMessage()[4], 127);
+
+        meta.setMessage(10, new byte[100000], 16385);
+        assertEquals(meta.getLength(), 16390);
+        assertEquals(meta.getMessage().length, 16390);
+        assertEquals(meta.getMessage()[0], -1);
+        assertEquals(meta.getMessage()[1], 10);
+        assertEquals(meta.getMessage()[2], -127);
+        assertEquals(meta.getMessage()[3], -128);
+        assertEquals(meta.getMessage()[4], 1);
+
+        meta.setMessage(10, new byte[] { 1, 2, 3, 4 }, 4);
+        assertEquals(meta.getLength(), 7);
+        assertEquals(meta.getStatus(), 255);
+        assertEquals(meta.getType(), 10);
+        assertEquals(meta.getData().length, 4);
+        assertEquals(meta.getData()[0], 1);
+        assertEquals(meta.getData()[1], 2);
+        assertEquals(meta.getData()[2], 3);
+        assertEquals(meta.getData()[3], 4);
+        assertEquals(meta.getMessage().length, 7);
+        assertEquals(meta.getMessage()[0], -1);
+        assertEquals(meta.getMessage()[1], 10);
+        assertEquals(meta.getMessage()[2], 4);
+        assertEquals(meta.getMessage()[3], 1);
+        assertEquals(meta.getMessage()[4], 2);
+        assertEquals(meta.getMessage()[5], 3);
+        assertEquals(meta.getMessage()[6], 4);
+
+        meta.setMessage(12, null, 0);
+
+        assertEquals(meta.getLength(), 3);
+        assertEquals(meta.getStatus(), 255);
+        assertEquals(meta.getType(), 12);
+        assertEquals(meta.getData().length, 0);
+        assertEquals(meta.getMessage().length, 3);
+        assertEquals(meta.getMessage()[0], -1);
+        assertEquals(meta.getMessage()[1], 12);
+        assertEquals(meta.getMessage()[2], 0);
+
+        /**
+         * I will testing this condition after throw out exception;
+         * it must be the same after it 
+         */
+        try {
+            meta.setMessage(10, new byte[] { 1, 2, 3, 4 }, 4);
+        } catch (InvalidMidiDataException e) {
+        }
+
+        try {
+            meta.setMessage(12, new byte[0], 9);
+            fail("InvalidMidiDataException expected");
+        } catch (InvalidMidiDataException e) {
+        }
+        assertEquals(meta.getLength(), 7);
+        assertEquals(meta.getStatus(), 255);
+        assertEquals(meta.getType(), 10);
+        assertEquals(meta.getData().length, 4);
+        assertEquals(meta.getData()[0], 1);
+        assertEquals(meta.getData()[1], 2);
+        assertEquals(meta.getData()[2], 3);
+        assertEquals(meta.getData()[3], 4);
+        assertEquals(meta.getMessage().length, 7);
+        assertEquals(meta.getMessage()[0], -1);
+        assertEquals(meta.getMessage()[1], 10);
+        assertEquals(meta.getMessage()[2], 4);
+        assertEquals(meta.getMessage()[3], 1);
+        assertEquals(meta.getMessage()[4], 2);
+        assertEquals(meta.getMessage()[5], 3);
+        assertEquals(meta.getMessage()[6], 4);
+
+        try {
+            meta.setMessage(12, null, 9);
+            fail("NullPointerException expected");
+        } catch (NullPointerException e) {
+        }
+        assertEquals(meta.getLength(), 7);
+        assertEquals(meta.getStatus(), 255);
+        assertEquals(meta.getType(), 10);
+        assertEquals(meta.getData().length, 4);
+        assertEquals(meta.getData()[0], 1);
+        assertEquals(meta.getData()[1], 2);
+        assertEquals(meta.getData()[2], 3);
+        assertEquals(meta.getData()[3], 4);
+        assertEquals(meta.getMessage().length, 7);
+        assertEquals(meta.getMessage()[0], -1);
+        assertEquals(meta.getMessage()[1], 10);
+        assertEquals(meta.getMessage()[2], 4);
+        assertEquals(meta.getMessage()[3], 1);
+        assertEquals(meta.getMessage()[4], 2);
+        assertEquals(meta.getMessage()[5], 3);
+        assertEquals(meta.getMessage()[6], 4);
+
+        try {
+            meta.setMessage(12, null, -9);
+            fail("InvalidMidiDataException expected");
+        } catch (InvalidMidiDataException e) {
+        }
+        assertEquals(meta.getLength(), 7);
+        assertEquals(meta.getStatus(), 255);
+        assertEquals(meta.getType(), 10);
+        assertEquals(meta.getData().length, 4);
+        assertEquals(meta.getData()[0], 1);
+        assertEquals(meta.getData()[1], 2);
+        assertEquals(meta.getData()[2], 3);
+        assertEquals(meta.getData()[3], 4);
+        assertEquals(meta.getMessage().length, 7);
+        assertEquals(meta.getMessage()[0], -1);
+        assertEquals(meta.getMessage()[1], 10);
+        assertEquals(meta.getMessage()[2], 4);
+        assertEquals(meta.getMessage()[3], 1);
+        assertEquals(meta.getMessage()[4], 2);
+        assertEquals(meta.getMessage()[5], 3);
+        assertEquals(meta.getMessage()[6], 4);
+    }
+
+    /**
+     * Test method setMessage( int, byte[], int ) of 
+     * class MetaMessage with parameters and without its.
+     * Class was created using constructor MetaMessage( byte[] )
+     */
+    public void test_setMessage2() throws Exception {
+        MetaMessage1 meta = new MetaMessage1(new byte[] { -23, 18, 87, 34, -90 });
+        try {
+            meta.setMessage(10, new byte[] { 1, 2, 3 }, 4);
+            fail("InvalidMidiDataException expected");
+        } catch (InvalidMidiDataException e) {
+        }
+
+        try {
+            meta.setMessage(10, new byte[] { 1, 2, 3 }, -5);
+            fail("InvalidMidiDataException expected");
+        } catch (InvalidMidiDataException e) {
+        }
+
+        try {
+            meta.setMessage(-1, new byte[] { 1, 2, 3 }, 3);
+            fail("InvalidMidiDataException expected");
+        } catch (InvalidMidiDataException e) {
+        }
+
+        try {
+            meta.setMessage(128, new byte[] { 1, 2, 3 }, 3);
+            fail("InvalidMidiDataException expected");
+        } catch (InvalidMidiDataException e) {
+        }
+
+        meta.setMessage(10, new byte[] { 1, 2, 3, 4 }, 4);
+
+        assertEquals(meta.getLength(), 7);
+        assertEquals(meta.getStatus(), 255);
+        assertEquals(meta.getType(), 10);
+        assertEquals(meta.getData().length, 4);
+        assertEquals(meta.getData()[0], 1);
+        assertEquals(meta.getData()[1], 2);
+        assertEquals(meta.getData()[2], 3);
+        assertEquals(meta.getData()[3], 4);
+        assertEquals(meta.getMessage().length, 7);
+        assertEquals(meta.getMessage()[0], -1);
+        assertEquals(meta.getMessage()[1], 10);
+        assertEquals(meta.getMessage()[2], 4);
+        assertEquals(meta.getMessage()[3], 1);
+        assertEquals(meta.getMessage()[4], 2);
+        assertEquals(meta.getMessage()[5], 3);
+        assertEquals(meta.getMessage()[6], 4);
+
+        meta.setMessage(10, new byte[] { 1, 2, 3, 4 }, 2);
+
+        assertEquals(meta.getLength(), 5);
+        assertEquals(meta.getStatus(), 255);
+        assertEquals(meta.getType(), 10);
+        assertEquals(meta.getData().length, 2);
+        assertEquals(meta.getData()[0], 1);
+        assertEquals(meta.getData()[1], 2);
+        assertEquals(meta.getMessage().length, 5);
+        assertEquals(meta.getMessage()[0], -1);
+        assertEquals(meta.getMessage()[1], 10);
+        assertEquals(meta.getMessage()[2], 2);
+        assertEquals(meta.getMessage()[3], 1);
+        assertEquals(meta.getMessage()[4], 2);
+
+        meta.setMessage(12, null, 0);
+        assertEquals(meta.getLength(), 3);
+        assertEquals(meta.getStatus(), 255);
+        assertEquals(meta.getType(), 12);
+        assertEquals(meta.getData().length, 0);
+        assertEquals(meta.getMessage().length, 3);
+        assertEquals(meta.getMessage()[0], -1);
+        assertEquals(meta.getMessage()[1], 12);
+        assertEquals(meta.getMessage()[2], 0);
+
+    }
+
+    /**
+     * Test method getType() of class MetaMessage
+     * 
+     */
+    public void test_getType() throws Exception {
+        MetaMessage meta = new MetaMessage();
+        assertEquals(meta.getType(), 0);
+
+        MetaMessage1 meta2 = new MetaMessage1(new byte[] { 9, -4, 34, 18 });
+        assertEquals(meta2.getType(), 252);
+
+        meta.setMessage(10, new byte[] { 1, 2, 3, 4 }, 4);
+        assertEquals(meta.getType(), 10);
+
+        meta.setMessage(27, null, 0);
+        assertEquals(meta.getType(), 27);
+    }
+
+    /**
+     * Test method getData() of class MetaMessage
+     *
+     */
+    public void test_getData() throws Exception {
+        MetaMessage meta = new MetaMessage();
+        assertEquals(0, meta.getData().length);
+
+        MetaMessage1 meta1 = new MetaMessage1(new byte[] { 18, 43, 27, -90, 4 });
+        assertEquals(2, meta1.getData().length);
+        assertEquals(-90, meta1.getData()[0]);
+        assertEquals(4, meta1.getData()[1]);
+
+        MetaMessage1 meta2 = new MetaMessage1(new byte[] { 18, 43, 27 });
+        assertEquals(0, meta2.getData().length);
+
+        meta.setMessage(10, new byte[] { 1, 2, 3, 4 }, 4);
+        assertEquals(4, meta.getData().length);
+        assertEquals(1, meta.getData()[0]);
+        assertEquals(2, meta.getData()[1]);
+        assertEquals(3, meta.getData()[2]);
+        assertEquals(4, meta.getData()[3]);
+
+        meta.setMessage(12, null, 0);
+        assertNotNull(meta.getData());
+        assertEquals(0, meta.getData().length);
+    }
+
+    /**
+     * Test method clone() of class MetaMessage.
+     */
+    public void test_clone1() {
+        MetaMessage meta = new MetaMessage();
+        assertTrue(meta.clone() != meta);
+        assertEquals(meta.clone().getClass(), meta.getClass());
+        MetaMessage tmeta;
+        tmeta = (MetaMessage) meta.clone();
+        assertEquals(meta.getLength(), tmeta.getLength());
+        assertEquals(meta.getMessage().length, tmeta.getMessage().length);
+        assertEquals(meta.getData().length, tmeta.getData().length);
+        if (meta.getData().length != 0) {
+            for (int i = 0; i < meta.getData().length; i++) {
+                assertEquals(meta.getData()[i], tmeta.getData()[i]);
+            }
+        }
+        if (meta.getMessage().length != 0) {
+            for (int i = 0; i < meta.getMessage().length; i++) {
+                assertEquals(meta.getMessage()[i], tmeta.getMessage()[i]);
+            }
+        }
+    }
+
+    /**
+     * Test method clone() of class MetaMessage.
+     */
+    public void test_clone2() throws Exception {
+        MetaMessage meta = new MetaMessage();
+
+        meta.setMessage(23, new byte[] { 23, 45, -90 }, 2);
+
+        assertTrue(meta.clone() != meta);
+        assertEquals(meta.clone().getClass(), meta.getClass());
+        MetaMessage tmeta;
+        tmeta = (MetaMessage) meta.clone();
+        assertEquals(meta.getLength(), tmeta.getLength());
+        assertEquals(meta.getMessage().length, tmeta.getMessage().length);
+        assertEquals(meta.getData().length, tmeta.getData().length);
+        if (meta.getData().length != 0) {
+            for (int i = 0; i < meta.getData().length; i++) {
+                assertEquals(meta.getData()[i], tmeta.getData()[i]);
+            }
+        }
+        if (meta.getMessage().length != 0) {
+            for (int i = 0; i < meta.getMessage().length; i++) {
+                assertEquals(meta.getMessage()[i], tmeta.getMessage()[i]);
+            }
+        }
+    }
+
+    /**
+     * Test method clone() of class MetaMessage.
+     */
+    public void test_clone3() throws Exception {
+        MetaMessage meta = new MetaMessage();
+        meta.setMessage(23, null, 0);
+
+        assertTrue(meta.clone() != meta);
+        assertEquals(meta.clone().getClass(), meta.getClass());
+        MetaMessage tmeta;
+        tmeta = (MetaMessage) meta.clone();
+        assertEquals(meta.getLength(), tmeta.getLength());
+        assertEquals(meta.getMessage().length, tmeta.getMessage().length);
+        assertEquals(meta.getData().length, tmeta.getData().length);
+        if (meta.getData().length != 0) {
+            for (int i = 0; i < meta.getData().length; i++) {
+                assertEquals(meta.getData()[i], tmeta.getData()[i]);
+            }
+        }
+        if (meta.getMessage().length != 0) {
+            for (int i = 0; i < meta.getMessage().length; i++) {
+                assertEquals(meta.getMessage()[i], tmeta.getMessage()[i]);
+            }
+        }
+    }
+
+    /**
+     * Subsidiary class in order to testing constructor
+     * of class Instrument, because it declared as protected
+     */
+    static class MetaMessage1 extends MetaMessage {
+        MetaMessage1(byte[] data) {
+            super(data);
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/MetaMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/MidiMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/MidiMessageTest.java?rev=424630&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/MidiMessageTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/MidiMessageTest.java Sat Jul 22 14:05:04 2006
@@ -0,0 +1,233 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.sound.tests.javax.sound.midi;
+
+import junit.framework.TestCase;
+
+import javax.sound.midi.InvalidMidiDataException;
+import javax.sound.midi.MidiMessage;
+
+
+public class MidiMessageTest extends TestCase
+{   
+    /**
+     * test constructor of class MidiMessage
+     *
+     */
+    public void test_constructor_MidiMessage()
+    {
+        MidiMessage1 midi = new MidiMessage1( new byte[] { 1, 2, 3, -5 } );
+        assertTrue( midi.getLength() == 4 );
+        assertTrue( midi.getStatus() == 1 );
+        assertTrue( midi.getMessage().length == 4 );
+        assertTrue( midi.getMessage()[0] == 1 ); 
+        assertTrue( midi.getMessage()[1] == 2 );
+        assertTrue( midi.getMessage()[2] == 3 );
+        assertTrue( midi.getMessage()[3] == -5 );
+        
+        MidiMessage1 midi1 = new MidiMessage1( new byte[] { 0, -2 } );
+        assertTrue( midi1.getLength() == 2 );
+        assertTrue( midi1.getStatus() == 0 );
+        assertTrue( midi1.getMessage().length == 2 );
+        assertTrue( midi1.getMessage()[0] == 0 ); 
+        assertTrue( midi1.getMessage()[1] == -2 );
+        
+        MidiMessage1 midi2 = new MidiMessage1( new byte[] { -1, 87, 19 } );
+        assertTrue( midi2.getLength() == 3 );
+        assertTrue( midi2.getStatus() == 255 );
+        assertTrue( midi2.getMessage().length == 3 );
+        assertTrue( midi2.getMessage()[0] == -1 );
+        assertTrue( midi2.getMessage()[1] == 87 );
+        assertTrue( midi2.getMessage()[2] == 19 );
+        
+        MidiMessage1 midi3 = new MidiMessage1( null );
+        assertTrue( midi3.getLength() == 0 );
+        assertTrue( midi3.getStatus() == 0 );
+        try {
+            midi3.getMessage();
+            fail( "NullPointerExcepiton expect" );
+        } catch( NullPointerException e ) { }
+        
+    }
+    
+    /**
+     * test method getMessage() of class MidiMessage
+     *
+     */
+    public void test_getMessage()
+    {
+        MidiMessage1 midi = new MidiMessage1( new byte[] { 1, 2, 3 } );
+        assertTrue( midi.getMessage()[0] == 1 );
+        assertTrue( midi.getMessage()[1] == 2 );
+        assertTrue( midi.getMessage()[2] == 3 );
+        
+        MidiMessage1 midi1 = new MidiMessage1( new byte[] { 1 } );
+        assertTrue( midi1.getMessage()[0] == 1 );
+        try {
+            int i = midi1.getMessage()[1];
+            fail( "IndexOutOfBoundsException expected" );
+        } catch( IndexOutOfBoundsException e ) { };
+        
+        MidiMessage1 midi2 = new MidiMessage1( null );
+        try {
+            int i = midi2.getMessage()[0];
+            fail( "NullPointerException expected" );
+        } catch( NullPointerException e ) { }
+        
+        try {
+            midi2.setMessage( new byte[] { 90, 84 } , 2 );
+        } catch( InvalidMidiDataException e ) { };
+        assertTrue( midi2.getMessage().length == 2 );
+        assertTrue( midi2.getMessage()[0] == 90 );
+        assertTrue( midi2.getMessage()[1] == 84 );
+        
+        try {
+            midi1.setMessage( new byte[] { -54, 84, -9 } , 1 );
+        } catch( InvalidMidiDataException e ) { };
+        assertTrue( midi1.getMessage().length == 1 );
+        assertTrue( midi1.getMessage()[0] == -54 );
+        
+        try {
+            midi.setMessage( new byte[] { -90, -7, 4 } , 0 );
+        } catch( InvalidMidiDataException e ) { };
+        assertTrue( midi.getMessage().length == 0 );
+        try {
+            int i = midi.getMessage()[0];
+            fail( "ArrayIndexOutOfBoundsException expected" );
+        } catch( ArrayIndexOutOfBoundsException e ) { };
+        
+    }
+    
+    /**
+     * test method getStatus() of class MidiMessage
+     *
+     */
+    public void test_getStatus()
+    {
+        MidiMessage1 midi = new MidiMessage1( new byte[] { 1, 2, 3 } );
+        assertTrue( midi.getStatus() == 1 );
+        
+        MidiMessage1 midi1 = new MidiMessage1( new byte[] { -91, 2, 3 } );
+        assertTrue( midi1.getStatus() == 165 );
+        
+        MidiMessage1 midi2 = new MidiMessage1( new byte[] { 1 } );
+        assertTrue( midi2.getStatus() == 1 );
+        
+        MidiMessage1 midi3 = new MidiMessage1( null );
+        assertTrue( midi3.getStatus() == 0 );
+        
+        try {
+            midi2.setMessage( new byte[] { 90, 84 } , 2 );
+        } catch( InvalidMidiDataException e ) { };
+        assertTrue( midi2.getStatus() == 90 );
+        
+        try {
+            midi1.setMessage( new byte[] { -54, 84, -9 } , 1 );
+        } catch( InvalidMidiDataException e ) { };
+        assertTrue( midi1.getStatus() == 202 );
+        
+        try {
+            midi.setMessage( new byte[] { -90, -7, 4 } , 0 );
+        } catch( InvalidMidiDataException e ) { };
+        assertTrue( midi.getStatus() == 0 );
+    }
+    
+    /**
+     * test method getLength() of class MidiMessage
+     *
+     */
+    public void test_getLength()
+    {
+        MidiMessage1 midi = new MidiMessage1( new byte[] { 1, 2, 3 } );
+        assertTrue( midi.getLength() == 3 );
+        
+        MidiMessage1 midi1 = new MidiMessage1( null );
+        assertTrue( midi1.getLength() == 0 );
+        
+        MidiMessage1 midi2 = new MidiMessage1( new byte[] { -71, 2, 3, -90 } );
+        assertTrue( midi2.getLength() == 4 );
+        
+        try {
+            midi2.setMessage( new byte[] { 90, 84 } , 2 );
+        } catch( InvalidMidiDataException e ) { };
+        assertTrue( midi2.getLength() == 2 );
+        
+        try {
+            midi1.setMessage( new byte[] { 90, 84, -9 } , 2 );
+        } catch( InvalidMidiDataException e ) { };
+        assertTrue( midi1.getLength() == 2 );
+        
+        try {
+            midi.setMessage( new byte[] { -90, -7, 4 } , 0 );
+        } catch( InvalidMidiDataException e ) { };
+        assertTrue( midi.getLength() == 0 );
+    }
+    
+    /**
+     * test method setMessage( byte[], int ) of class MidiMessage
+     *
+     */
+    public void test_setMessage()
+    {
+        MidiMessage1 midi = new MidiMessage1( new byte[] { 18, 34, 48, -56, 12 } );
+        MidiMessage1 midi1 = new MidiMessage1( new byte[] { 18 } );
+        MidiMessage1 midi2 = new MidiMessage1( null );
+        try {
+            midi2.setMessage( new byte[] { 90, 84 } , 2 );
+        } catch( InvalidMidiDataException e ) { };
+        assertTrue( midi2.getMessage().length == 2 );
+        assertTrue( midi2.getMessage()[0] == 90 );
+        assertTrue( midi2.getMessage()[1] == 84 );
+        
+        try {
+            midi1.setMessage( new byte[] { -54, 84, -9 } , 1 );
+        } catch( InvalidMidiDataException e ) { };
+        assertTrue( midi1.getMessage().length == 1 );
+        assertTrue( midi1.getMessage()[0] == -54 );
+        
+        try {
+            midi.setMessage( new byte[] { -90, -7, 4 } , 0 );
+        } catch( InvalidMidiDataException e ) { };
+        assertTrue( midi.getMessage().length == 0 );
+        try {
+            int i = midi.getMessage()[0];
+            fail( "ArrayIndexOutOfBoundsException expected" );
+        } catch( ArrayIndexOutOfBoundsException e ) { };
+    }
+    /**
+     * Subsidiary class in order to testing constructor
+     * and method setMessage( byte[], int ) of class Instrument, 
+     * because its declared as protected
+     */
+    static class MidiMessage1 extends MidiMessage
+    {
+        MidiMessage1( byte[] data )
+        {
+            super( data );
+        }
+        public Object clone()
+        {
+            return null;
+        }
+        
+        public void setMessage( byte[] data, int length ) 
+                throws InvalidMidiDataException
+        {   
+            super.setMessage( data, length );
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/MidiMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/PatchTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/PatchTest.java?rev=424630&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/PatchTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/PatchTest.java Sat Jul 22 14:05:04 2006
@@ -0,0 +1,77 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Evgeny S. Sidorenko
+ */
+
+package org.apache.harmony.sound.tests.javax.sound.midi;
+
+import junit.framework.TestCase;
+
+import javax.sound.midi.Patch;
+
+public class PatchTest extends TestCase
+{
+    /**
+     * test constructor of class Patch
+     *
+     */
+    public void test_constructor()
+    {
+        Patch patch = new Patch( 34, 68 );
+        assertTrue( patch.getBank() == 34 );
+        assertTrue( patch.getProgram() == 68 );
+        
+        Patch patch2 = new Patch( -4, 567 );
+        assertTrue( patch2.getBank() == -4 );
+        assertTrue( patch2.getProgram() == 567 );
+    }
+    
+    /**
+     * test method getBank() of class Patch
+     *
+     */
+    public void test_getBank()
+    {
+        Patch patch = new Patch( 45, 78 );
+        assertTrue( patch.getBank() == 45 );
+        
+        Patch patch1 = new Patch( -78, 78 );
+        assertTrue( patch1.getBank() == -78 );
+        
+        Patch patch2 = new Patch( 16400, 78 );
+        assertTrue( patch2.getBank() == 16400 );
+        
+    }
+    
+    /**
+     * test method getProgram() of class Patch
+     *
+     */
+    public void test_getProgram()
+    {
+        Patch patch = new Patch( 45, 78 );
+        assertTrue( patch.getProgram() == 78 );
+        
+        Patch patch1 = new Patch( -78, -5 );
+        assertTrue( patch1.getProgram() == -5 );
+        
+        Patch patch2 = new Patch( 16400, 216 );
+        assertTrue( patch2.getProgram() == 216 );
+        
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/PatchTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/ShortMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/ShortMessageTest.java?rev=424630&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/ShortMessageTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/ShortMessageTest.java Sat Jul 22 14:05:04 2006
@@ -0,0 +1,467 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Evgeny S. Sidorenko
+ */
+
+package org.apache.harmony.sound.tests.javax.sound.midi;
+
+import javax.sound.midi.InvalidMidiDataException;
+import javax.sound.midi.ShortMessage;
+
+import junit.framework.TestCase;
+
+public class ShortMessageTest extends TestCase
+{
+    /**
+     * test constants
+     *
+     */
+    public void test_constants()
+    {
+        assertTrue( ShortMessage.ACTIVE_SENSING == 254 );
+        assertTrue( ShortMessage.CHANNEL_PRESSURE == 208 );
+        assertTrue( ShortMessage.CONTINUE == 251 );
+        assertTrue( ShortMessage.CONTROL_CHANGE == 176 );
+        assertTrue( ShortMessage.END_OF_EXCLUSIVE == 247 );
+        assertTrue( ShortMessage.MIDI_TIME_CODE == 241 );
+        assertTrue( ShortMessage.NOTE_OFF == 128 );
+        assertTrue( ShortMessage.NOTE_ON == 144 );
+        assertTrue( ShortMessage.PITCH_BEND == 224 );
+        assertTrue( ShortMessage.POLY_PRESSURE == 160 );
+        assertTrue( ShortMessage.PROGRAM_CHANGE == 192 );
+        assertTrue( ShortMessage.SONG_POSITION_POINTER == 242 );
+        assertTrue( ShortMessage.SONG_SELECT == 243 );
+        assertTrue( ShortMessage.START == 250 );
+        assertTrue( ShortMessage.STOP == 252 );
+        assertTrue( ShortMessage.SYSTEM_RESET == 255 );
+        assertTrue( ShortMessage.TIMING_CLOCK == 248 );
+        assertTrue( ShortMessage.TUNE_REQUEST == 246 );
+    }
+    
+    /**
+     * test constructors
+     *
+     */
+    public void test_constructor_ShortMessage1()
+    {
+        ShortMessage1 message = new ShortMessage1();
+        assertTrue( message.getChannel() == 0 );
+        assertTrue( message.getCommand() == 144 );
+        assertTrue( message.getData1() == 64 );
+        assertTrue( message.getData2() == 127 );
+        assertTrue( message.getLength() == 3 );
+        assertTrue( message.getStatus() == 144 );
+        assertTrue( message.getMessage().length == 3 );
+        assertTrue( message.getMessage()[0] == -112 );
+        assertTrue( message.getMessage()[1] == 64 );
+        assertTrue( message.getMessage()[2] == 127 );
+                
+        ShortMessage1 message1 = new ShortMessage1( new byte[] { 95, -5, 9, 56, -18 } );
+        assertTrue( message1.getChannel() == 15 );
+        assertTrue( message1.getCommand() == 80 );
+        assertTrue( message1.getData1() == 251 );
+        assertTrue( message1.getData2() == 9 );
+        assertTrue( message1.getLength() == 5 );
+        assertTrue( message1.getStatus() == 95 );
+        assertTrue( message1.getMessage().length == 5 );
+        
+        ShortMessage1 message2 = new ShortMessage1( new byte[] { 95, 14 } );
+        assertTrue( message2.getChannel() == 15 );
+        assertTrue( message2.getCommand() == 80 );
+        assertTrue( message2.getData1() == 14 );
+        assertTrue( message2.getData2() == 0 );
+        assertTrue( message2.getLength() == 2 );
+        assertTrue( message2.getStatus() == 95 );
+        assertTrue( message2.getMessage().length == 2 );
+        
+        ShortMessage1 message3 = new ShortMessage1( null );
+        assertTrue( message3.getChannel() == 0 );
+        assertTrue( message3.getCommand() == 0 );
+        assertTrue( message3.getData1() == 0 );
+        assertTrue( message3.getData2() == 0 );
+        assertTrue( message3.getLength() == 0 );
+        assertTrue( message3.getStatus() == 0 );
+    }
+    
+    /**
+     * test method setMessage( int ) of class ShortMessage
+     */
+    public void test_setMessage1()
+    {
+        ShortMessage1 message = new ShortMessage1();
+        /**
+         * value of variable status is more or equals 246 and
+         * less or equals 255
+         */
+        try {
+            message.setMessage( 245 );
+            fail( "InvalidMidiDataException expected" );
+        } catch( InvalidMidiDataException e ) { }
+        try {
+            message.setMessage( 256 );
+            fail( "InvalidMidiDataException expected" );
+        } catch( InvalidMidiDataException e ) { }
+        try {
+            message.setMessage( 250 );
+        } catch( InvalidMidiDataException e ) { }
+        /**
+         * channel change from 0 up to 15, and
+         * channel + command == status, so
+         * the value of command divisible by 16
+         */
+        assertTrue( message.getChannel() == 10 );
+        assertTrue( message.getCommand() == 240 );
+        assertTrue( message.getData1() == 0 );
+        assertTrue( message.getData2() == 0 );
+        assertTrue( message.getLength() == 1 );
+        assertTrue( message.getStatus() == 250 );
+        assertTrue( message.getMessage().length == 1 );
+    }
+    
+    /**
+     * test method setMessage( int, int, int ) of 
+     * class ShortMessage
+     */
+    public void test_setMessage2()
+    {
+        ShortMessage1 message = new ShortMessage1();
+        /**
+         * value of variable status is more or equals 246 and
+         * less or equals 255
+         */
+        try {
+            message.setMessage( 245, 34, 56 );
+            fail( "InvalidMidiDataException expected" );
+        } catch( InvalidMidiDataException e ) { }
+        try {
+            message.setMessage( 256, 34, 56 );
+            fail( "InvalidMidiDataException expected" );
+        } catch( InvalidMidiDataException e ) { }
+        try {
+            message.setMessage( 250, 34, 56 );
+        } catch( InvalidMidiDataException e ) { }
+        /**
+         * channel change from 0 up to 15, and
+         * channel + command == status, so
+         * the value of command divisible by 16.
+         */
+        assertTrue( message.getChannel() == 10 );
+        assertTrue( message.getCommand() == 240 );
+        assertTrue( message.getData1() == 0 );
+        assertTrue( message.getData2() == 0 );
+        assertTrue( message.getLength() == 1 );
+        assertTrue( message.getStatus() == 250 );
+        assertTrue( message.getMessage().length == 1 );
+    }
+    
+    /**
+     * test method setMessage( int, int, int ) of 
+     * class ShortMessage
+     */
+    public void test_setMessage3()
+    {
+        ShortMessage1 message = new ShortMessage1();
+        /**
+         * value of variable command is more or equals 128 and
+         * less or equals 239
+         */
+        try {
+            message.setMessage( 127, 10, 34, 56 );
+            fail( "InvalidMidiDataException expected" );
+        } catch( InvalidMidiDataException e ) { }
+        try {
+            message.setMessage( 240, 34, 56 );
+            fail( "InvalidMidiDataException expected" );
+        } catch( InvalidMidiDataException e ) { }
+        
+        /**
+         * value of variable channel is more or equals 0 and 
+         * less or equals 15
+         */
+        try {
+            message.setMessage( 200, -1, 34, 56 );
+            fail( "InvalidMidiDataException expected" );
+        } catch( InvalidMidiDataException e ) { }
+        try {
+            message.setMessage( 200, 16, 34, 56 );
+            fail( "InvalidMidiDataException expected" );
+        } catch( InvalidMidiDataException e ) { }
+  
+        /**
+         * value of data1 and data2 is more or equals 0 and
+         * less or equals 127, but when command more or
+         * equals 192 and less or equals 224 the second data,
+         * data2, is unused
+         */
+        try {
+            message.setMessage( 200, 12, -1, 56 );
+            fail( "InvalidMidiDataException expected" );
+        } catch( InvalidMidiDataException e ) { }
+        try {
+            message.setMessage( 225, 8, 34, 456 );
+            fail( "InvalidMidiDataException expected" );
+        } catch( InvalidMidiDataException e ) { }
+        try {
+            message.setMessage( 200, 8, 34, 456 );
+        } catch( InvalidMidiDataException e ) { }
+                
+        try {
+            message.setMessage( 200, 9, 34, 56 );
+        } catch( InvalidMidiDataException e ) { }
+        /**
+         * channel change from 0 up to 15;
+         * 
+         * command must to divisible by 16, and so it less or 
+         * equals parameter command;
+         * 
+         * status is sum of channel and command
+         */
+        assertTrue( message.getChannel() == 9 );
+        assertTrue( message.getCommand() == 192 );
+        assertTrue( message.getData1() == 34 );
+        assertTrue( message.getData2() == 0 );
+        assertTrue( message.getLength() == 2 );
+        assertTrue( message.getStatus() == 201 );
+        assertTrue( message.getMessage().length == 2 );
+        
+        try {
+            message.setMessage( 148, 9, 34, 56 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getChannel() == 9 );
+        assertTrue( message.getCommand() == 144 );
+        assertTrue( message.getData1() == 34 );
+        assertTrue( message.getData2() == 56 );
+        assertTrue( message.getLength() == 3 );
+        assertTrue( message.getStatus() == 153 );
+        assertTrue( message.getMessage().length == 3 );
+    }
+    
+    /**
+     * test method getChannel() of class ShortMessage
+     *
+     */
+    public void test_getChannel()
+    {
+        ShortMessage message = new ShortMessage();
+        assertTrue( message.getChannel() == 0 );
+        
+        ShortMessage1 message1 = new ShortMessage1( new byte[] { 23, 16, 35 } );
+        assertTrue( message1.getChannel() == 7 );
+        
+        ShortMessage1 message2 = new ShortMessage1( null );
+        assertTrue( message2.getChannel() == 0 );
+        
+        try {
+            message.setMessage( 249 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getChannel() == 9 );
+        
+        try {
+            message.setMessage( 250, 14, 62 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getChannel() == 10 );
+        
+        try {
+            message.setMessage( 234, 15, 14, 62 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getChannel() == 15 );
+        
+    }
+    
+    /**
+     * test method getCommand() of class ShortMessage
+     *
+     */
+    public void test_getCommand()
+    {
+        ShortMessage message = new ShortMessage();
+        assertTrue( message.getCommand() == 144 );
+        
+        ShortMessage1 message1 = new ShortMessage1( new byte[] { 23, 16, 35 } );
+        assertTrue( message1.getCommand() == 16 );
+        
+        ShortMessage1 message2 = new ShortMessage1( null );
+        assertTrue( message2.getCommand() == 0 );
+        
+        try {
+            message.setMessage( 249 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getCommand() == 240 );
+        
+        try {
+            message.setMessage( 250, 14, 62 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getCommand() == 240 );
+        
+        try {
+            message.setMessage( 234, 15, 14, 62 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getCommand() == 224 );
+    }
+    
+    /**
+     * test method getLength() of class ShortMessage
+     *
+     */
+    public void test_getLength()
+    {
+        ShortMessage message = new ShortMessage();
+        assertTrue( message.getLength() == 3 );
+        
+        ShortMessage1 message1 = new ShortMessage1( new byte[] { 23, 16, 35 } );
+        assertTrue( message1.getLength() == 3 );
+        
+        ShortMessage1 message2 = new ShortMessage1( null );
+        assertTrue( message2.getLength() == 0 );
+        
+        try {
+            message.setMessage( 249 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getLength() == 1 );
+        
+        try {
+            message.setMessage( 250, 14, 62 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getLength() == 1 );
+        
+        try {
+            message.setMessage( 234, 15, 14, 62 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getLength() == 3 );
+        
+        try {
+            message.setMessage( 214, 15, 14, 62 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getLength() == 2 );
+    }
+    
+    /**
+     * test method getStatus() of class ShortMessage
+     *
+     */
+    public void test_getStatus()
+    {
+        ShortMessage message = new ShortMessage();
+        assertTrue( message.getStatus() == 144 );
+        
+        ShortMessage1 message1 = new ShortMessage1( new byte[] { 23, 16, 35 } );
+        assertTrue( message1.getStatus() == 23 );
+        
+        ShortMessage1 message2 = new ShortMessage1( null );
+        assertTrue( message2.getStatus() == 0 );
+        
+        try {
+            message.setMessage( 249 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getStatus() == 249 );
+        
+        try {
+            message.setMessage( 250, 14, 62 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getStatus() == 250 );
+        
+        try {
+            message.setMessage( 234, 15, 14, 62 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getStatus() == 239 );
+    }
+    
+    /**
+     * test methods getData1() and getData2() of 
+     * class ShortMessage
+     *
+     */
+    public void test_getData1_2()
+    {
+        ShortMessage message = new ShortMessage();
+        assertTrue( message.getData1() == 64 );
+        assertTrue( message.getData2() == 127 );
+        
+        ShortMessage1 message1 = new ShortMessage1( new byte[] { 23, 16, 35 } );
+        assertTrue( message1.getData1() == 16 );
+        assertTrue( message1.getData2() == 35 );
+        
+        ShortMessage1 message11 = new ShortMessage1( new byte[] { 23, 16 } );
+        assertTrue( message11.getData1() == 16 );
+        assertTrue( message11.getData2() == 0 );
+        
+        ShortMessage1 message12 = new ShortMessage1( new byte[] { 23 } );
+        assertTrue( message12.getData1() == 0 );
+        assertTrue( message12.getData2() == 0 );
+        
+        ShortMessage1 message2 = new ShortMessage1( null );
+        assertTrue( message2.getData1() == 0 );
+        assertTrue( message2.getData2() == 0 );
+        
+        try {
+            message.setMessage( 249 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getData1() == 0 );
+        assertTrue( message.getData2() == 0 );
+        
+        try {
+            message.setMessage( 250, 14, 62 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getData1() == 0 );
+        assertTrue( message.getData2() == 0 );
+        
+        try {
+            message.setMessage( 234, 15, 14, 62 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getData1() == 14 );
+        assertTrue( message.getData2() == 62 );
+        
+        try {
+            message.setMessage( 198, 15, 14, 62 );
+        } catch( InvalidMidiDataException e ) { }
+        assertTrue( message.getData1() == 14 );
+        assertTrue( message.getData2() == 0 );
+    }
+    
+    /**
+     * test method getDataLength() of class ShortMessage
+     *
+     */
+    public void test_getDataLentgth()
+    {
+        //TODO
+    }
+    
+    /**
+     * Subsidiary class in order to use constructor
+     * and method getDataLength( int ) of class Instrument, 
+     * because its declared as protected
+     */
+    static class ShortMessage1 extends ShortMessage
+    {
+        ShortMessage1()
+        {
+            super();
+        }
+        ShortMessage1( byte[] data )
+        {
+            super( data );
+        }
+        
+        public int getDataLength1( int status )
+                throws InvalidMidiDataException
+        {
+            return super.getDataLength( status );
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/ShortMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/SoundbankResourceTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/SoundbankResourceTest.java?rev=424630&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/SoundbankResourceTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/SoundbankResourceTest.java Sat Jul 22 14:05:04 2006
@@ -0,0 +1,70 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Evgeny S. Sidorenko
+ */
+
+package org.apache.harmony.sound.tests.javax.sound.midi;
+
+import javax.sound.midi.Soundbank;
+import javax.sound.midi.SoundbankResource;
+
+import junit.framework.TestCase;
+
+public class SoundbankResourceTest extends TestCase
+{
+    /**
+     * test method getName() of class SoundbankResource
+     *
+     */
+    public void test_getName()
+    {
+        
+        SoundbankResource1 sound = new SoundbankResource1( null, null, null );
+        assertTrue( sound.getName() == null );
+        
+        SoundbankResource1 sound1 = new SoundbankResource1( null, "Test", null );
+        assertTrue( sound1.getName().equals( "Test" ) );
+    }
+    
+    /**
+     * test method getDataClass() of class SoundbankResource
+     *
+     */
+    public void test_getDataClass()
+    {
+        SoundbankResource1 sound = new SoundbankResource1( null, null, null );
+        assertTrue( sound.getDataClass() == null );
+    }
+    
+    /**
+     * Subsidiary class in order to use constructor
+     * of class Instrument, because it declared as protected
+     */
+    static class SoundbankResource1 extends SoundbankResource
+    {
+        SoundbankResource1( Soundbank soundbank, String name, Class<?> dataClass )
+        {
+            super( soundbank, name, dataClass );
+        }
+        
+        public Object getData()
+        {
+            return null;
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/midi/SoundbankResourceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message