001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package test.dbc;
023:
024: import junit.framework.TestCase;
025: import test.dbc.java.Sorter;
026: import test.dbc.office.Computer;
027: import test.dbc.office.Developer;
028: import test.dbc.office.OfficeManager;
029: import test.dbc.stack.Stack;
030: import test.dbc.stack.StackImpl;
031:
032: /**
033: *
034: * @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a>
035: * @version $Revision: 57186 $
036: */
037: public class DbcTest extends TestCase {
038: public DbcTest(String name) {
039: super (name);
040:
041: }
042:
043: public void testOffice() throws Exception {
044: System.out
045: .println("****************** TEST OFFICE ******************");
046: OfficeManager officeManager = new OfficeManager();
047:
048: Computer compA = officeManager.createComputer("comp A");
049: //officeManager.createComputer("comp B");
050: Developer kabir = officeManager.createDeveloper("Kabir");
051:
052: officeManager.assignComputer(compA, kabir);
053:
054: Developer bill = officeManager.createDeveloper("Bill");
055:
056: Computer compB = officeManager.createComputer("comp B");
057: officeManager.assignComputer(compB, bill);
058:
059: try {
060: officeManager.createDeveloper(null);
061: if (true)
062: throw new Exception(
063: "Did not validate developer null name");
064: } catch (RuntimeException e) {
065: }
066:
067: }
068:
069: public void testStack() throws Exception {
070: System.out
071: .println("****************** TEST STACK ******************");
072: Stack s = new StackImpl();
073: s.push("one");
074: s.push("two");
075: s.pop();
076:
077: s.push("two");
078: s.push("three");
079: s.pop();
080: s.pop();
081: s.pop();
082: try {
083: s.pop();
084: throw new Exception(
085: "Did not validate empty stack before pop");
086: } catch (RuntimeException e) {
087: System.out.println(e.getMessage());
088: }
089: }
090:
091: public void testJavaExpression() throws Exception {
092: System.out
093: .println("****************** TEST SORTER ******************");
094:
095: int[] unsorted = new int[] { 4, 1, 5, 3 };
096: Sorter.sort(unsorted);
097:
098: try {
099: Sorter.brokenSort(unsorted);
100: throw new Exception("Did not validate list was not sorted");
101: } catch (RuntimeException e) {
102: System.out.println(e.getMessage());
103: }
104: }
105:
106: }
|