KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > BaseRateCalculatorTest


1 /*
2  * This file is part of JGAP.
3  *
4  * JGAP offers a dual license model containing the LGPL as well as the MPL.
5  *
6  * For licencing information please see the file license.txt included with JGAP
7  * or have a look at the top of class org.jgap.Chromosome which representatively
8  * includes the JGAP license policy applicable for any file delivered with JGAP.
9  */

10 package org.jgap;
11
12 import junit.framework.*;
13
14 /**
15  * Tests the BaseRateCalculator class.
16  *
17  * @author Klaus Meffert
18  * @since 3.0
19  */

20 public class BaseRateCalculatorTest
21     extends JGAPTestCase {
22   /** String containing the CVS revision. Read out via reflection!*/
23   private final static String JavaDoc CVS_REVISION = "$Revision: 1.1 $";
24
25   public static Test suite() {
26     TestSuite suite = new TestSuite(BaseRateCalculatorTest.class);
27     return suite;
28   }
29
30   /**
31    * Following should be possible without exception.
32    * @throws Exception
33    *
34    * @author Klaus Meffert
35    * @since 3.0
36    */

37   public void testConstruct_0()
38       throws Exception JavaDoc {
39     assertNotNull(new BaseRateCalculatorImpl(conf));
40   }
41
42   /**
43    * @throws Exception
44    *
45    * @author Klaus Meffert
46    * @since 3.0
47    */

48   public void testConstruct_1()
49       throws Exception JavaDoc {
50     try {
51       new BaseRateCalculatorImpl(null);
52       fail();
53     }
54     catch (InvalidConfigurationException iex) {
55       ; //this is OK
56
}
57   }
58
59   /**
60    * @throws Exception
61    *
62    * @author Klaus Meffert
63    * @since 3.0
64    */

65   public void testGetConfiguration_0()
66       throws Exception JavaDoc {
67     BaseRateCalculator calc = new BaseRateCalculatorImpl(conf);
68     assertSame(conf, calc.getConfiguration());
69   }
70
71   /**
72    * Test implementation of Gene interface extending abstract BaseRateCalculator
73    * class.
74    *
75    * @author Klaus Meffert
76    * @since 3.0
77    */

78   class BaseRateCalculatorImpl
79       extends BaseRateCalculator {
80     public BaseRateCalculatorImpl(final Configuration a_config)
81         throws InvalidConfigurationException {
82       super(a_config);
83     }
84
85     public int calculateCurrentRate() {
86       return 0;
87     }
88
89     public boolean toBePermutated(IChromosome a_chrom, int a_geneIndex) {
90       return true;
91     }
92   }
93   class AppDataForTest
94       implements IApplicationData {
95     public int compareTo(Object JavaDoc o2) {
96       return 0;
97     }
98
99     public Object JavaDoc clone()
100         throws CloneNotSupportedException JavaDoc {
101       return null;
102     }
103   }
104 }
105
Popular Tags