KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > dbc > DbcTest


1 /*
2  * JBoss, Home of Professional Open Source.
3  * Copyright 2006, Red Hat Middleware LLC, and individual contributors
4  * as indicated by the @author tags. See the copyright.txt file in the
5  * distribution for a full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22 package test.dbc;
23
24 import junit.framework.TestCase;
25 import test.dbc.java.Sorter;
26 import test.dbc.office.Computer;
27 import test.dbc.office.Developer;
28 import test.dbc.office.OfficeManager;
29 import test.dbc.stack.Stack;
30 import test.dbc.stack.StackImpl;
31
32 /**
33  *
34  * @author <a HREF="mailto:kabir.khan@jboss.org">Kabir Khan</a>
35  * @version $Revision: 57186 $
36  */

37 public class DbcTest extends TestCase
38 {
39     public DbcTest(String JavaDoc name) {
40         super(name);
41
42     }
43
44     public void testOffice()throws Exception JavaDoc
45     {
46        System.out.println("****************** TEST OFFICE ******************");
47        OfficeManager officeManager = new OfficeManager();
48
49        Computer compA = officeManager.createComputer("comp A");
50        //officeManager.createComputer("comp B");
51
Developer kabir = officeManager.createDeveloper("Kabir");
52
53        officeManager.assignComputer(compA, kabir);
54
55        
56        Developer bill = officeManager.createDeveloper("Bill");
57
58        Computer compB = officeManager.createComputer("comp B");
59        officeManager.assignComputer(compB, bill);
60             
61        try
62        {
63           officeManager.createDeveloper(null);
64           if (true)throw new Exception JavaDoc("Did not validate developer null name");
65        }
66        catch(RuntimeException JavaDoc e)
67        {
68        }
69        
70     }
71     
72    public void testStack()throws Exception JavaDoc
73    {
74        System.out.println("****************** TEST STACK ******************");
75       Stack s = new StackImpl();
76       s.push("one");
77       s.push("two");
78       s.pop();
79
80       s.push("two");
81       s.push("three");
82       s.pop();
83       s.pop();
84       s.pop();
85       try
86       {
87          s.pop();
88           throw new Exception JavaDoc("Did not validate empty stack before pop");
89       }
90       catch(RuntimeException JavaDoc e)
91       {
92          System.out.println(e.getMessage());
93       }
94    }
95    
96    public void testJavaExpression()throws Exception JavaDoc
97    {
98        System.out.println("****************** TEST SORTER ******************");
99        
100        int[] unsorted = new int[]{4, 1, 5, 3};
101        Sorter.sort(unsorted);
102        
103        try
104        {
105           Sorter.brokenSort(unsorted);
106           throw new Exception JavaDoc("Did not validate list was not sorted");
107        }
108        catch(RuntimeException JavaDoc e)
109        {
110          System.out.println(e.getMessage());
111        }
112    }
113    
114
115 }
Popular Tags