Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  bug6416024.java   Sprache: JAVA

 
/*
 * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */


import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MetaMessage;
import javax.sound.midi.MidiEvent;
import javax.sound.midi.Sequence;
import javax.sound.midi.Track;

/**
 * @test
 * @bug 6416024
 * @summary Tests that sequence correctly handle removing of EndOfTrack event
 * @run main bug6416024
 */

public class bug6416024 {

    boolean test() {
        Sequence sequence = null;
        Track track = null;
        MidiEvent event = null;

        log("creating sequence...");
        try {
            sequence = new Sequence(Sequence.PPQ, 10);
            log(" - OK: " + sequence);
        } catch(InvalidMidiDataException e ) {
            log(" - FAILED: got exception");
            e.printStackTrace(System.out);
            return false;
        }

        log("creating track...");
        track = sequence.createTrack();
        log(" - OK: " + track);
        log("initial track size=" + track.size());

        log("removing all track events...");
        while (track.size() > 0) {
            try {
                event = track.get(0);
                log(" ..removing event " + event);
                track.remove(event);
                log(" - OK, track size=" + track.size());
            } catch (Exception e) {
                log(" - FAILED: got exception");
                e.printStackTrace(System.out);
                return false;
            }
        }

        MetaMessage newMsg = new MetaMessage();
        MidiEvent newEvent = new MidiEvent(newMsg, 10);
        log("adding new event...");
        try {
            if (!track.add(newEvent)) {
                log("event hasn't been added");
                return false;
            }
            log(" - OK, track size=" + track.size());
        } catch (Exception e) {
            log(" - FAILED: got exception");
            e.printStackTrace(System.out);
            return false;
        }

        return true;
    }

    public static void main(String args[]) throws Exception {
        bug6416024 This = new bug6416024();
        if (This.test()) {
            log("Test passed sucessfully.");
        } else {
            log("Test FAILED!");
            delay(1000);
            throw new RuntimeException("Test failed!");
        }
    }

    // helper routines
    static long startTime = currentTimeMillis();
    static long currentTimeMillis() {
        //return System.nanoTime() / 1000000L;
        return System.currentTimeMillis();
    }
    static void log(String s) {
        long time = currentTimeMillis() - startTime;
        long ms = time % 1000;
        time /= 1000;
        long sec = time % 60;
        time /= 60;
        long min = time % 60;
        time /= 60;
        System.out.println(""
                + (time < 10 ? "0" : "") + time
                + ":" + (min < 10 ? "0" : "") + min
                + ":" + (sec < 10 ? "0" : "") + sec
                + "." + (ms < 10 ? "00" : (ms < 100 ? "0" : "")) + ms
                + " (" + Thread.currentThread().getName() + ") " + s);
    }
    static void delay(int millis) {
        try {
            Thread.sleep(millis);
        } catch (InterruptedException e) {}
    }
}

Messung V0.5
C=95 H=85 G=90

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge