01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 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 java.util.List;
13:
14: import com.sun.jdi.IncompatibleThreadStateException;
15: import com.sun.jdi.IntegerValue;
16: import com.sun.jdi.InvalidStackFrameException;
17: import com.sun.jdi.Method;
18: import com.sun.jdi.ObjectReference;
19: import com.sun.jdi.StringReference;
20: import com.sun.jdi.ThreadReference;
21: import com.sun.jdi.event.BreakpointEvent;
22: import com.sun.jdi.request.BreakpointRequest;
23: import com.sun.jdi.request.EventRequest;
24:
25: /**
26: * Test cases for the implementation of providing argumebnt information even if
27: * no debugging information is present in the new java 1.6 VM
28: *
29: * @since 3.3
30: */
31: public class ProvideArgumentsTests extends AbstractJDITest {
32:
33: /** setup test info locally **/
34: public void localSetUp() {
35: }
36:
37: /**
38: * tests getting argument values from a stackframe when no debugging
39: * info is available
40: */
41: public void testGetArgumentValues() {
42: try {
43: Method method = getMethod("argValues",
44: "(Ljava/lang/String;ILjava/lang/Object;)V");
45: BreakpointRequest br = getBreakpointRequest(method
46: .location());
47: br.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
48: br.enable();
49:
50: EventWaiter waiter = new EventWaiter(br, true);
51: fEventReader.addEventListener(waiter);
52: triggerEvent("argvalues");
53: BreakpointEvent bpe = (BreakpointEvent) waiter
54: .waitEvent(10000);
55: ThreadReference tref = bpe.thread();
56: List list = tref.frame(0).getArgumentValues();
57: assertNotNull("list should not be null", list);
58: assertTrue("first list item must be a String",
59: list.get(0) instanceof StringReference);
60: assertEquals(
61: "test string is not the same as was created in MainClass",
62: "teststr", ((StringReference) list.get(0)).value());
63: assertTrue("second list item must be an integer", list
64: .get(1) instanceof IntegerValue);
65: assertEquals(
66: "integer is not the same value as was passed in MainClass",
67: 5, ((IntegerValue) list.get(1)).value());
68: assertTrue("third list item must be a Double",
69: list.get(2) instanceof ObjectReference);
70: fEventReader.removeEventListener(waiter);
71: tref.resume();
72: } catch (InterruptedException e) {
73: e.printStackTrace();
74: } catch (InvalidStackFrameException e) {
75: e.printStackTrace();
76: } catch (IncompatibleThreadStateException e) {
77: e.printStackTrace();
78: }
79:
80: }
81: }
|