2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
6 package org.apidesign.codeinjection;
8 import org.apidesign.codeinjection.spi.CountDownExtender;
10 import org.netbeans.junit.MockServices;
11 import static org.junit.Assert.*;
13 /** Final count down test.
15 * @author Jaroslav Tulach <jtulach@netbeans.org>
17 public class Version20Test {
19 public Version20Test() {
22 /** creates version 2.0 */
23 private static CountDown create(int value) {
24 return new CountDownImplV2(value);
28 public void testDecrementFourTimes() {
29 MockServices.setServices();
30 CountDown counter = create(4);
31 assertFalse("Not down yet", counter.isDown()); counter.down();
32 assertFalse("Not down yet", counter.isDown()); counter.down();
33 assertFalse("Not down yet", counter.isDown()); counter.down();
34 assertFalse("Not down yet", counter.isDown()); counter.down();
35 assertTrue("Down now", counter.isDown());
39 public void testDecrementTwoTimesEnough() {
40 MockServices.setServices(DecrementByTwo.class);
41 CountDown counter = create(4);
42 assertFalse("Not down yet", counter.isDown()); counter.down();
43 assertFalse("Not down yet", counter.isDown()); counter.down();
44 assertTrue("Two Down is enough", counter.isDown());
47 public static final class DecrementByTwo implements CountDownExtender {
48 public int decrement(int value) {