Java Code Examples for javax.sound.midi.Synthesizer#isOpen()

The following examples show how to use javax.sound.midi.Synthesizer#isOpen() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImplicitOpenClose.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Field f = SoftSynthesizer.class.getDeclaredField("testline");
    f.setAccessible(true);
    f.set(null, new DummySourceDataLine());

    Synthesizer synth = new SoftSynthesizer();

    ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth;

    // Test single open/close cycle

    Receiver recv = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test using 2 receiver cycle

    Receiver recv1 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    Receiver recv2 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");

    recv2.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    recv1.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for explicit,implicit conflict

    synth.open();
    Receiver recv3 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for implicit,explicit conflict

    recv3 = rcd.getReceiverReferenceCounting();
    synth.open();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

}
 
Example 2
Source File: ImplicitOpenClose.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Field f = SoftSynthesizer.class.getDeclaredField("testline");
    f.setAccessible(true);
    f.set(null, new DummySourceDataLine());

    Synthesizer synth = new SoftSynthesizer();

    ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth;

    // Test single open/close cycle

    Receiver recv = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test using 2 receiver cycle

    Receiver recv1 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    Receiver recv2 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");

    recv2.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    recv1.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for explicit,implicit conflict

    synth.open();
    Receiver recv3 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for implicit,explicit conflict

    recv3 = rcd.getReceiverReferenceCounting();
    synth.open();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

}
 
Example 3
Source File: ImplicitOpenClose.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Field f = SoftSynthesizer.class.getDeclaredField("testline");
    f.setAccessible(true);
    f.set(null, new DummySourceDataLine());

    Synthesizer synth = new SoftSynthesizer();

    ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth;

    // Test single open/close cycle

    Receiver recv = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test using 2 receiver cycle

    Receiver recv1 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    Receiver recv2 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");

    recv2.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    recv1.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for explicit,implicit conflict

    synth.open();
    Receiver recv3 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for implicit,explicit conflict

    recv3 = rcd.getReceiverReferenceCounting();
    synth.open();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

}
 
Example 4
Source File: ImplicitOpenClose.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Field f = SoftSynthesizer.class.getDeclaredField("testline");
    f.setAccessible(true);
    f.set(null, new DummySourceDataLine());

    Synthesizer synth = new SoftSynthesizer();

    ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth;

    // Test single open/close cycle

    Receiver recv = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test using 2 receiver cycle

    Receiver recv1 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    Receiver recv2 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");

    recv2.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    recv1.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for explicit,implicit conflict

    synth.open();
    Receiver recv3 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for implicit,explicit conflict

    recv3 = rcd.getReceiverReferenceCounting();
    synth.open();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

}
 
Example 5
Source File: ImplicitOpenClose.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Field f = SoftSynthesizer.class.getDeclaredField("testline");
    f.setAccessible(true);
    f.set(null, new DummySourceDataLine());

    Synthesizer synth = new SoftSynthesizer();

    ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth;

    // Test single open/close cycle

    Receiver recv = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test using 2 receiver cycle

    Receiver recv1 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    Receiver recv2 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");

    recv2.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    recv1.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for explicit,implicit conflict

    synth.open();
    Receiver recv3 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for implicit,explicit conflict

    recv3 = rcd.getReceiverReferenceCounting();
    synth.open();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

}
 
Example 6
Source File: ImplicitOpenClose.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Field f = SoftSynthesizer.class.getDeclaredField("testline");
    f.setAccessible(true);
    f.set(null, new DummySourceDataLine());

    Synthesizer synth = new SoftSynthesizer();

    ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth;

    // Test single open/close cycle

    Receiver recv = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test using 2 receiver cycle

    Receiver recv1 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    Receiver recv2 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");

    recv2.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    recv1.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for explicit,implicit conflict

    synth.open();
    Receiver recv3 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for implicit,explicit conflict

    recv3 = rcd.getReceiverReferenceCounting();
    synth.open();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

}
 
Example 7
Source File: ImplicitOpenClose.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Field f = SoftSynthesizer.class.getDeclaredField("testline");
    f.setAccessible(true);
    f.set(null, new DummySourceDataLine());

    Synthesizer synth = new SoftSynthesizer();

    ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth;

    // Test single open/close cycle

    Receiver recv = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test using 2 receiver cycle

    Receiver recv1 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    Receiver recv2 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");

    recv2.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    recv1.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for explicit,implicit conflict

    synth.open();
    Receiver recv3 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for implicit,explicit conflict

    recv3 = rcd.getReceiverReferenceCounting();
    synth.open();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

}
 
Example 8
Source File: ImplicitOpenClose.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Field f = SoftSynthesizer.class.getDeclaredField("testline");
    f.setAccessible(true);
    f.set(null, new DummySourceDataLine());

    Synthesizer synth = new SoftSynthesizer();

    ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth;

    // Test single open/close cycle

    Receiver recv = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test using 2 receiver cycle

    Receiver recv1 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    Receiver recv2 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");

    recv2.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    recv1.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for explicit,implicit conflict

    synth.open();
    Receiver recv3 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for implicit,explicit conflict

    recv3 = rcd.getReceiverReferenceCounting();
    synth.open();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

}
 
Example 9
Source File: ImplicitOpenClose.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Field f = SoftSynthesizer.class.getDeclaredField("testline");
    f.setAccessible(true);
    f.set(null, new DummySourceDataLine());

    Synthesizer synth = new SoftSynthesizer();

    ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth;

    // Test single open/close cycle

    Receiver recv = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test using 2 receiver cycle

    Receiver recv1 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    Receiver recv2 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");

    recv2.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    recv1.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for explicit,implicit conflict

    synth.open();
    Receiver recv3 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for implicit,explicit conflict

    recv3 = rcd.getReceiverReferenceCounting();
    synth.open();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

}
 
Example 10
Source File: ImplicitOpenClose.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Field f = SoftSynthesizer.class.getDeclaredField("testline");
    f.setAccessible(true);
    f.set(null, new DummySourceDataLine());

    Synthesizer synth = new SoftSynthesizer();

    ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth;

    // Test single open/close cycle

    Receiver recv = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test using 2 receiver cycle

    Receiver recv1 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    Receiver recv2 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");

    recv2.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    recv1.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for explicit,implicit conflict

    synth.open();
    Receiver recv3 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for implicit,explicit conflict

    recv3 = rcd.getReceiverReferenceCounting();
    synth.open();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

}
 
Example 11
Source File: ImplicitOpenClose.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Field f = SoftSynthesizer.class.getDeclaredField("testline");
    f.setAccessible(true);
    f.set(null, new DummySourceDataLine());

    Synthesizer synth = new SoftSynthesizer();

    ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth;

    // Test single open/close cycle

    Receiver recv = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test using 2 receiver cycle

    Receiver recv1 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    Receiver recv2 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");

    recv2.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    recv1.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for explicit,implicit conflict

    synth.open();
    Receiver recv3 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for implicit,explicit conflict

    recv3 = rcd.getReceiverReferenceCounting();
    synth.open();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

}
 
Example 12
Source File: ImplicitOpenClose.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Field f = SoftSynthesizer.class.getDeclaredField("testline");
    f.setAccessible(true);
    f.set(null, new DummySourceDataLine());

    Synthesizer synth = new SoftSynthesizer();

    ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth;

    // Test single open/close cycle

    Receiver recv = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test using 2 receiver cycle

    Receiver recv1 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    Receiver recv2 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");

    recv2.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    recv1.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for explicit,implicit conflict

    synth.open();
    Receiver recv3 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for implicit,explicit conflict

    recv3 = rcd.getReceiverReferenceCounting();
    synth.open();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

}
 
Example 13
Source File: ImplicitOpenClose.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Field f = SoftSynthesizer.class.getDeclaredField("testline");
    f.setAccessible(true);
    f.set(null, new DummySourceDataLine());

    Synthesizer synth = new SoftSynthesizer();

    ReferenceCountingDevice rcd = (ReferenceCountingDevice)synth;

    // Test single open/close cycle

    Receiver recv = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test using 2 receiver cycle

    Receiver recv1 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    Receiver recv2 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");

    recv2.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    recv1.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for explicit,implicit conflict

    synth.open();
    Receiver recv3 = rcd.getReceiverReferenceCounting();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

    // Test for implicit,explicit conflict

    recv3 = rcd.getReceiverReferenceCounting();
    synth.open();
    if(!synth.isOpen())
        throw new Exception("Synthesizer not open!");
    recv3.close();
    if(!synth.isOpen())
        throw new Exception("Synthesizer was closed!");
    synth.close();
    if(synth.isOpen())
        throw new Exception("Synthesizer not closed!");

}