01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.debug.jdi.tests;
11:
12: import com.sun.jdi.ClassNotLoadedException;
13: import com.sun.jdi.Field;
14:
15: /**
16: * Tests for JDI com.sun.jdi.Field.
17: */
18: public class FieldTest extends AbstractJDITest {
19:
20: private Field fField;
21:
22: /**
23: * Creates a new test.
24: */
25: public FieldTest() {
26: super ();
27: }
28:
29: /**
30: * Init the fields that are used by this test only.
31: */
32: public void localSetUp() {
33: // Get static field "fObject"
34: fField = getField();
35: }
36:
37: /**
38: * Run all tests and output to standard output.
39: * @param args
40: */
41: public static void main(java.lang.String[] args) {
42: new FieldTest().runSuite(args);
43: }
44:
45: /**
46: * Gets the name of the test case.
47: * @see junit.framework.TestCase#getName()
48: */
49: public String getName() {
50: return "com.sun.jdi.Field";
51: }
52:
53: /**
54: * Test JDI equals() and hashCode().
55: */
56: public void testJDIEquality() {
57: assertTrue("1", fField.equals(fField));
58: Field other = getField("fString");
59: assertTrue("2", !fField.equals(other));
60: assertTrue("3", !fField.equals(new Object()));
61: assertTrue("4", !fField.equals(null));
62: }
63:
64: /**
65: * Test JDI isTransient().
66: */
67: public void testJDIIsTransient() {
68: assertTrue("1", !fField.isTransient());
69: }
70:
71: /**
72: * Test JDI isVolatile().
73: */
74: public void testJDIIsVolatile() {
75: assertTrue("1", !fField.isVolatile());
76: }
77:
78: /**
79: * Test JDI type().
80: */
81: public void testJDIType() {
82: try {
83: assertEquals("1", getMainClass(), fField.type());
84: } catch (ClassNotLoadedException e) {
85: assertTrue("2", false);
86: }
87: }
88:
89: /**
90: * Test JDI typeName().
91: */
92: public void testJDITypeName() {
93: assertEquals("1",
94: "org.eclipse.debug.jdi.tests.program.MainClass", fField
95: .typeName());
96: }
97: }
|