KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > math > analysis > UnivariateRealSolverFactoryImplTest


1 /*
2  *
3  * Copyright 2004 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.commons.math.analysis;
19
20 import junit.framework.TestCase;
21
22 /**
23  * @version $Revision$ $Date: 2005-02-26 05:11:52 -0800 (Sat, 26 Feb 2005) $
24  */

25 public class UnivariateRealSolverFactoryImplTest extends TestCase {
26     
27     /** solver factory */
28     private UnivariateRealSolverFactory factory;
29     
30     /** function */
31     private DifferentiableUnivariateRealFunction function;
32     /**
33      * @throws java.lang.Exception
34      * @see junit.framework.TestCase#tearDown()
35      */

36     protected void setUp() throws Exception JavaDoc {
37         super.setUp();
38         factory = new UnivariateRealSolverFactoryImpl();
39         function = new SinFunction();
40     }
41     
42     /**
43      * @throws java.lang.Exception
44      * @see junit.framework.TestCase#tearDown()
45      */

46     protected void tearDown() throws Exception JavaDoc {
47         factory = null;
48         function = null;
49         super.tearDown();
50     }
51
52     public void testNewBisectionSolverNull() {
53         try {
54             UnivariateRealSolver solver = factory.newBisectionSolver(null);
55             fail();
56         } catch(IllegalArgumentException JavaDoc ex) {
57             // success
58
}
59     }
60
61     public void testNewBisectionSolverValid() {
62         UnivariateRealSolver solver = factory.newBisectionSolver(function);
63         assertNotNull(solver);
64         assertTrue(solver instanceof BisectionSolver);
65     }
66
67     public void testNewNewtonSolverNull() {
68         try {
69             UnivariateRealSolver solver = factory.newNewtonSolver(null);
70             fail();
71         } catch(IllegalArgumentException JavaDoc ex) {
72             // success
73
}
74     }
75
76     public void testNewNewtonSolverValid() {
77         UnivariateRealSolver solver = factory.newNewtonSolver(function);
78         assertNotNull(solver);
79         assertTrue(solver instanceof NewtonSolver);
80     }
81
82     public void testNewBrentSolverNull() {
83         try {
84             UnivariateRealSolver solver = factory.newBrentSolver(null);
85             fail();
86         } catch(IllegalArgumentException JavaDoc ex) {
87             // success
88
}
89     }
90
91     public void testNewBrentSolverValid() {
92         UnivariateRealSolver solver = factory.newBrentSolver(function);
93         assertNotNull(solver);
94         assertTrue(solver instanceof BrentSolver);
95     }
96
97     public void testNewSecantSolverNull() {
98         try {
99             UnivariateRealSolver solver = factory.newSecantSolver(null);
100             fail();
101         } catch(IllegalArgumentException JavaDoc ex) {
102             // success
103
}
104     }
105
106     public void testNewSecantSolverValid() {
107         UnivariateRealSolver solver = factory.newSecantSolver(function);
108         assertNotNull(solver);
109         assertTrue(solver instanceof SecantSolver);
110     }
111 }
112
Popular Tags