@@ -0,0 +1,2666 @@
+/*%0A * Copyright (c) 2009, Julian Gosnell%0A * All rights reserved.%0A *%0A * Redistribution and use in source and binary forms, with or without%0A * modification, are permitted provided that the following conditions are%0A * met:%0A *%0A *     * Redistributions of source code must retain the above copyright%0A *     notice, this list of conditions and the following disclaimer.%0A *%0A *     * Redistributions in binary form must reproduce the above%0A *     copyright notice, this list of conditions and the following%0A *     disclaimer in the documentation and/or other materials provided%0A *     with the distribution.%0A *%0A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS%0A * %22AS IS%22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT%0A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR%0A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT%0A * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,%0A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT%0A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,%0A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY%0A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT%0A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE%0A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.%0A */%0Apackage org.dada.core;%0A%0Aimport java.util.concurrent.TimeUnit;%0Aimport java.util.concurrent.locks.Lock;%0A%0Aimport org.jmock.Expectations;%0Aimport org.jmock.integration.junit3.MockObjectTestCase;%0A%0Aimport EDU.oswego.cs.dl.util.concurrent.Sync;%0A%0Apublic class SyncLockTestCase extends MockObjectTestCase %7B%0A%0A%09public void test() throws Exception %7B%0A%09%09final Sync sync = mock(Sync.class);%0A%09%09Lock lock = new SyncLock(sync);%0A%09%09%0A%09%09// unsuccessful sync acquisition...%0A%0A%09%09checking(new Expectations()%7B%7B%0A%09%09%09one(sync).acquire();%0A            will(throwException(new InterruptedException()));%0A        %7D%7D);%0A%09%09%0A%09%09try %7Block.lock();fail();%7D catch (Exception e) %7B%7D%0A%09%09%0A%09%09// successful lock acquisition%0A%09%09%0A%09%09checking(new Expectations()%7B%7B%0A%09%09%09one(sync).acquire();%0A        %7D%7D);%0A%0A%09%09lock.lock();%0A%09%09%0A%09%09// successful lock release%0A%0A%09%09checking(new Expectations()%7B%7B%0A%09%09%09one(sync).release();%0A        %7D%7D);%0A%0A%09%09lock.unlock();%0A%0A%09%09// NYI%0A%09%09%0A%09%09try %7Block.lockInterruptibly();        fail();%7D catch (UnsupportedOperationException e) %7B%7D;%0A%09%09try %7Block.newCondition();             fail();%7D catch (UnsupportedOperationException e) %7B%7D;%0A%09%09try %7Block.tryLock();                  fail();%7D catch (UnsupportedOperationException e) %7B%7D;%0A%09%09try %7Block.tryLock(1, TimeUnit.HOURS); fail();%7D catch (UnsupportedOperationException e) %7B%7D;%0A%09%7D%0A%7D%0A

add coverage for SyncLock