KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > dataset > DataValueTest


1 /*
2  * $Id: DataValueTest.java,v 1.2 2005/02/25 19:46:06 rbair Exp $
3  *
4  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5  * Santa Clara, California 95054, U.S.A. All rights reserved.
6  */

7
8 package org.jdesktop.dataset;
9
10 import junit.framework.*;
11
12
13 /**
14  *
15  * @author rbair
16  */

17 public class DataValueTest extends TestCase {
18     
19     public DataValueTest(String JavaDoc testName) {
20         super(testName);
21     }
22     
23     // TODO add test methods here. The name must begin with 'test'. For example:
24
// public void testHello() {}
25

26     protected void setUp() throws Exception JavaDoc {
27     }
28
29     protected void tearDown() throws Exception JavaDoc {
30     }
31
32     public static Test suite() {
33         TestSuite suite = new TestSuite(DataValueTest.class);
34         
35         return suite;
36     }
37
38     /**
39      * Test of getName method, of class org.jdesktop.dataset.DataValue.
40      */

41     public void testGetName() {
42         System.out.println("testGetName");
43         
44         //test that the name can be set
45
DataSet ds = new DataSet();
46         DataValue v = ds.createValue();
47         v.setName("val_1");
48         assertEquals(v.getName(), "val_1");
49         
50         //test that the name cannot be set to null
51
try {
52             v.setName(null);
53             assertTrue(false);
54         } catch (Error JavaDoc e) {
55             assertTrue(true);
56         }
57         
58         //test that the name cannot be set to empty string
59
try {
60             v.setName("");
61             assertTrue(false);
62         } catch (Error JavaDoc e) {
63             assertTrue(true);
64         }
65         
66         
67         //test that the name cannot be set to empty string with spaces
68
try {
69             v.setName(" ");
70             assertTrue(false);
71         } catch (Error JavaDoc e) {
72             assertTrue(true);
73         }
74     }
75
76     /**
77      * Test of getDataSet method, of class org.jdesktop.dataset.DataValue.
78      */

79     public void testGetDataSet() {
80         System.out.println("testGetDataSet");
81         
82         DataSet ds = new DataSet();
83         DataValue v = ds.createValue();
84         assertNotNull(v);
85         assertEquals(ds, v.getDataSet());
86     }
87
88     /**
89      * Test of getExpression method, of class org.jdesktop.dataset.DataValue.
90      */

91     public void testGetExpression() {
92         System.out.println("testGetExpression");
93         
94         DataSet ds = new DataSet();
95         DataValue v = ds.createValue();
96         assertNull(v.getExpression());
97         v.setExpression("");
98         assertEquals("", v.getExpression());
99         v.setExpression(null);
100         assertNull(v.getExpression());
101     }
102
103     /**
104      * Test of getValue method, of class org.jdesktop.dataset.DataValue.
105      */

106     public void testGetValue() {
107         System.out.println("testGetValue");
108         
109         // TODO add your test code below by replacing the default call to fail.
110
// fail("The test case is empty.");
111
}
112 }
Popular Tags