1 | /** |
2 | * |
3 | */ |
4 | package de.uka.ipd.sdq.tcfmoop.tests; |
5 | |
6 | import static org.junit.Assert.*; |
7 | |
8 | import org.junit.Before; |
9 | import org.junit.Test; |
10 | |
11 | import de.uka.ipd.sdq.tcfmoop.config.MaxGenerationNumberConfig; |
12 | import de.uka.ipd.sdq.tcfmoop.terminationcriteria.MaxGenerationNumber; |
13 | |
14 | /** |
15 | * @author Atanas Dimitrov |
16 | * |
17 | */ |
18 | public class MaximumGenerationNumberCriterionTest { |
19 | MaxGenerationNumberConfig mgnconf; |
20 | MaxGenerationNumber mgncrit; |
21 | |
22 | /** |
23 | * @throws java.lang.Exception |
24 | */ |
25 | @Before |
26 | public void setUp() throws Exception { |
27 | mgnconf = new MaxGenerationNumberConfig(); |
28 | mgnconf.setMaximumNumberOfIterations(5); |
29 | if(!mgnconf.validateConfiguration()){ |
30 | throw new Exception(); |
31 | } |
32 | mgncrit = new MaxGenerationNumber(mgnconf, null, null); |
33 | |
34 | } |
35 | |
36 | /** |
37 | * Test method for {@link de.uka.ipd.sdq.tcfmoop.terminationcriteria.AbstractTerminationCriterion#getEvaluationResult()}. |
38 | */ |
39 | @Test |
40 | public void testMaximumNotReached() { |
41 | mgncrit.evaluate(4, 0); |
42 | assertFalse(mgncrit.getEvaluationResult()); |
43 | } |
44 | |
45 | /** |
46 | * Test method for {@link de.uka.ipd.sdq.tcfmoop.terminationcriteria.AbstractTerminationCriterion#getEvaluationResult()}. |
47 | */ |
48 | @Test |
49 | public void testMaximumReached() { |
50 | mgncrit.evaluate(5, 0); |
51 | assertTrue(mgncrit.getEvaluationResult()); |
52 | } |
53 | |
54 | /** |
55 | * Test method for {@link de.uka.ipd.sdq.tcfmoop.terminationcriteria.AbstractTerminationCriterion#getEvaluationResult()}. |
56 | */ |
57 | @Test |
58 | public void testMaximumSurpassed() { |
59 | mgncrit.evaluate(6, 0); |
60 | assertTrue(mgncrit.getEvaluationResult()); |
61 | } |
62 | |
63 | } |