KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > math > FunctionEvaluationExceptionTest


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

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

24 public class FunctionEvaluationExceptionTest extends TestCase {
25     
26     public void testConstructor(){
27         FunctionEvaluationException ex = new FunctionEvaluationException(0.0);
28         assertNull(ex.getCause());
29         assertNotNull(ex.getMessage());
30         assertEquals(0.0, ex.getArgument(), 0);
31     }
32     
33     public void testConstructorMessage(){
34         String JavaDoc msg = "message";
35         FunctionEvaluationException ex = new FunctionEvaluationException(0.0, msg);
36         assertNull(ex.getCause());
37         assertTrue(ex.getMessage().startsWith(msg));
38         assertTrue(ex.getMessage().indexOf("0") > 0);
39         assertEquals(0.0, ex.getArgument(), 0);
40     }
41     
42     public void testConstructorMessageCause(){
43         String JavaDoc outMsg = "outer message";
44         String JavaDoc inMsg = "inner message";
45         Exception JavaDoc cause = new Exception JavaDoc(inMsg);
46         FunctionEvaluationException ex = new FunctionEvaluationException(0, outMsg, cause);
47         assertTrue(ex.getMessage().startsWith(outMsg));
48         assertTrue(ex.getMessage().indexOf("0") > 0);
49         assertEquals(cause, ex.getCause());
50         assertEquals(0.0, ex.getArgument(), 0);
51     }
52 }
53
Popular Tags