KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > test > notification > node > EvaluationResultTest


1 package org.jacorb.test.notification.node;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1999-2003 Gerald Brose
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  */

23
24 import junit.framework.Test;
25 import junit.framework.TestCase;
26 import junit.framework.TestSuite;
27 import org.jacorb.notification.filter.EvaluationResult;
28
29 /**
30  * Unit Test for class EvaluationResult
31  *
32  * @author Alphonse Bendt
33  */

34
35 public class EvaluationResultTest extends TestCase
36 {
37
38     private EvaluationResult objectUnderTest_;
39
40     public void setUp() throws Exception JavaDoc
41     {
42         objectUnderTest_ = new EvaluationResult();
43     }
44
45     public void testPlus() throws Exception JavaDoc
46     {
47         EvaluationResult a, b;
48         a = new EvaluationResult();
49         b = new EvaluationResult();
50
51         a.setLong(10);
52         b.setLong(10);
53
54         EvaluationResult c = EvaluationResult.plus(a, b);
55         assertTrue(20 == c.getLong());
56
57         a.setFloat(10);
58         b.setFloat(10);
59
60         assertTrue(a.isFloat());
61         assertTrue(b.isFloat());
62
63         c = EvaluationResult.plus(a, b);
64         assertTrue(20 == c.getFloat());
65         assertTrue(c.isFloat());
66     }
67
68     public void testSetString() throws Exception JavaDoc
69     {
70         objectUnderTest_.setString("hallo");
71         assertEquals("hallo", objectUnderTest_.getString());
72     }
73
74     public void testSetInt() throws Exception JavaDoc
75     {
76         objectUnderTest_.setLong(1);
77         assertTrue(objectUnderTest_.getLong() == 1);
78     }
79
80     public void testSetFloat() throws Exception JavaDoc
81     {
82         objectUnderTest_.setFloat(2f);
83         assertTrue(objectUnderTest_.getFloat() == 2f);
84     }
85
86     public void testSetBoolean() throws Exception JavaDoc
87     {
88         objectUnderTest_ = EvaluationResult.BOOL_TRUE;
89         assertTrue(objectUnderTest_.getLong() == 1);
90         assertTrue(objectUnderTest_.getFloat() == 1f);
91         assertTrue(objectUnderTest_.getBool());
92
93         objectUnderTest_ = EvaluationResult.BOOL_FALSE;
94         assertTrue(objectUnderTest_.getLong() == 0);
95         assertTrue(objectUnderTest_.getFloat() == 0f);
96         assertTrue(!objectUnderTest_.getBool());
97     }
98
99     public EvaluationResultTest(String JavaDoc name)
100     {
101         super(name);
102     }
103
104     public static Test suite()
105     {
106         TestSuite suite = new TestSuite(EvaluationResultTest.class);
107
108         return suite;
109     }
110 }
Popular Tags