001: /*BEGIN_COPYRIGHT_BLOCK
002: *
003: * Copyright (c) 2001-2007, JavaPLT group at Rice University (javaplt@rice.edu)
004: * All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions are met:
008: * * Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.
010: * * Redistributions in binary form must reproduce the above copyright
011: * notice, this list of conditions and the following disclaimer in the
012: * documentation and/or other materials provided with the distribution.
013: * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
014: * names of its contributors may be used to endorse or promote products
015: * derived from this software without specific prior written permission.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
018: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
019: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
020: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
021: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
022: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
023: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
024: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
025: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
026: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
027: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028: *
029: * This software is Open Source Initiative approved Open Source Software.
030: * Open Source Initative Approved is a trademark of the Open Source Initiative.
031: *
032: * This file is part of DrJava. Download the current version of this project
033: * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
034: *
035: * END_COPYRIGHT_BLOCK*/
036:
037: /*BEGIN_COPYRIGHT_BLOCK
038: *
039: * Copyright (c) 2001-2007, JavaPLT group at Rice University (javaplt@rice.edu)
040: * All rights reserved.
041: *
042: * Redistribution and use in source and binary forms, with or without
043: * modification, are permitted provided that the following conditions are met:
044: * * Redistributions of source code must retain the above copyright
045: * notice, this list of conditions and the following disclaimer.
046: * * Redistributions in binary form must reproduce the above copyright
047: * notice, this list of conditions and the following disclaimer in the
048: * documentation and/or other materials provided with the distribution.
049: * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
050: * names of its contributors may be used to endorse or promote products
051: * derived from this software without specific prior written permission.
052: *
053: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
054: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
055: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
056: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
057: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
058: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
059: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
060: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
061: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
062: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
063: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
064: *
065: * This software is Open Source Initiative approved Open Source Software.
066: * Open Source Initative Approved is a trademark of the Open Source Initiative.
067: *
068: * This file is part of DrJava. Download the current version of this project
069: * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
070: *
071: * END_COPYRIGHT_BLOCK*/
072:
073: package edu.rice.cs.drjava.model.debug;
074:
075: import edu.rice.cs.drjava.DrJavaTestCase;
076:
077: /**
078: * Tests that the DebugWatchData class can display state correctly.
079: * @version $Id: DebugWatchDataTest.java 4255 2007-08-28 19:17:37Z mgricken $
080: */
081: public final class DebugWatchDataTest extends DrJavaTestCase {
082:
083: /**
084: * Tests the state of a watch after its creation.
085: */
086: public void testFirstCreation() {
087: DebugWatchData data = new DebugWatchData("foo");
088: assertEquals("should have a name on startUp", "foo", data
089: .getName());
090: assertEquals("should have no value on startUp", "", data
091: .getValue());
092: assertEquals("should have no type on startUp", "", data
093: .getType());
094: assertTrue("should not be changed on startUp", !data
095: .isChanged());
096: }
097:
098: /**
099: * Tests that a watch displays its value and type correctly,
100: * then hides it when the thread resumes. Also tests that
101: * the changed flag works correctly.
102: */
103: public void testInScopeThenCleared() {
104: DebugWatchData data = new DebugWatchData("foo");
105:
106: // Set value and type
107: data.setValue(new Integer(7));
108: data.setType("java.lang.Integer");
109: assertEquals("should have a value", "7", data.getValue());
110: assertEquals("should have a type", "java.lang.Integer", data
111: .getType());
112: assertTrue("should be changed", data.isChanged());
113:
114: // Hide value and type
115: data.hideValueAndType();
116: assertEquals("should have no value after hide", "", data
117: .getValue());
118: assertEquals("should have no type after hide", "", data
119: .getType());
120: assertTrue("should not be changed after hide", !data
121: .isChanged());
122:
123: // Make sure using same value doesn't indicate a change
124: data.setValue(new Integer(7));
125: assertTrue("should not be changed after setting same value",
126: !data.isChanged());
127:
128: // Make sure using a new value indicates a change
129: data.setValue(new Integer(8));
130: assertTrue("should be changed after setting different value",
131: data.isChanged());
132: }
133:
134: /**
135: * Tests that a watch displays correctly if it is not in scope.
136: */
137: public void testNotInScope() {
138: DebugWatchData data = new DebugWatchData("bar");
139: data.setNoValue();
140: data.setNoType();
141:
142: assertEquals("should not be in scope", DebugWatchData.NO_VALUE,
143: data.getValue());
144: assertEquals("should not have a type", DebugWatchData.NO_TYPE,
145: data.getType());
146: assertTrue("should not appear changed", !data.isChanged());
147: }
148:
149: }
|