Using code snippets from the Lookup interface
authorJaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 09:51:12 +0200
changeset 27699c5a4f0fab
parent 26 913d1d0a7bdf
child 28 26d443dac030
Using code snippets from the Lookup interface
samples/consistency/src-test/api/ArithmeticaTest.java
samples/consistency/src-test/api/FactorialTest.java
     1.1 --- a/samples/consistency/src-test/api/ArithmeticaTest.java	Sat Jun 14 09:51:12 2008 +0200
     1.2 +++ b/samples/consistency/src-test/api/ArithmeticaTest.java	Sat Jun 14 09:51:12 2008 +0200
     1.3 @@ -22,22 +22,4 @@
     1.4          super.tearDown();
     1.5      }
     1.6  
     1.7 -    //BEGIN: design.composition.arith.test
     1.8 -    public void testSumTwo() {
     1.9 -        Arithmetica instance = new Arithmetica();
    1.10 -        assertEquals("+", 5, instance.sumTwo(3, 2));
    1.11 -    }
    1.12 -
    1.13 -    public void testSumAll() {
    1.14 -        Arithmetica instance = new Arithmetica();
    1.15 -        assertEquals("+", 6, instance.sumAll(3, 2, 1));
    1.16 -    }
    1.17 -
    1.18 -    public void testSumRange() {
    1.19 -        Arithmetica instance = new Arithmetica();
    1.20 -        assertEquals("+", 6, instance.sumRange(1, 3));
    1.21 -        assertEquals("10", 55, instance.sumRange(1, 10));
    1.22 -    }
    1.23 -    //END: design.composition.arith.test
    1.24 -
    1.25  }
     2.1 --- a/samples/consistency/src-test/api/FactorialTest.java	Sat Jun 14 09:51:12 2008 +0200
     2.2 +++ b/samples/consistency/src-test/api/FactorialTest.java	Sat Jun 14 09:51:12 2008 +0200
     2.3 @@ -16,44 +16,5 @@
     2.4      public FactorialTest(String testName) {
     2.5          super(testName);
     2.6      }            
     2.7 -
     2.8 -    @Override
     2.9 -    protected void setUp() throws Exception {
    2.10 -        super.setUp();
    2.11 -    }
    2.12 -
    2.13 -    @Override
    2.14 -    protected void tearDown() throws Exception {
    2.15 -        super.tearDown();
    2.16 -    }
    2.17 -    
    2.18 -    public void testFactorial3() {
    2.19 -        assertEquals(6, Factorial.factorial(3));
    2.20 -    }
    2.21 -    
    2.22 -    public void testFactorial4() {
    2.23 -        assertEquals(24, Factorial.factorial(4));
    2.24 -    }
    2.25 -    
    2.26 -    public void testFactorial5() {
    2.27 -        assertEquals(120, Factorial.factorial(5));
    2.28 -    }
    2.29 -
    2.30 -    /** Class showing inventive, non-expected use of 
    2.31 -     * Arithmetica methods to do multiplication instead of
    2.32 -     * addition.
    2.33 -     */
    2.34 -    //BEGIN: design.composition.arith.factorial
    2.35 -    public static final class Factorial extends Arithmetica {
    2.36 -        public static int factorial(int n) {
    2.37 -            return new Factorial().sumRange(1, n);
    2.38 -        }
    2.39 -        @Override
    2.40 -        public int sumTwo(int one, int second) {
    2.41 -            return one * second;
    2.42 -        }
    2.43 -    }
    2.44 -    //END: design.composition.arith.factorial
    2.45 -
    2.46      
    2.47  }