Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 208645fd0a8108d8caafa4c1c9c63c286e3d4ccc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.debug.jdi.tests;

import java.util.List;

import com.sun.jdi.IncompatibleThreadStateException;
import com.sun.jdi.IntegerValue;
import com.sun.jdi.InvalidStackFrameException;
import com.sun.jdi.Method;
import com.sun.jdi.ObjectReference;
import com.sun.jdi.StringReference;
import com.sun.jdi.ThreadReference;
import com.sun.jdi.event.BreakpointEvent;
import com.sun.jdi.request.BreakpointRequest;
import com.sun.jdi.request.EventRequest;

/**
 * Test cases for the implementation of providing argumebnt information even if 
 * no debugging information is present in the new java 1.6 VM
 * 
 * @since 3.3
 */
public class ProvideArgumentsTests extends AbstractJDITest {

	/** setup test info locally **/
	public void localSetUp() {}
	
	/**
	 * tests getting argument values from a stackframe when no debugging
	 * info is available 
	 */
	public void testGetArgumentValues() {
		try {
			Method method = getMethod("argValues", "(Ljava/lang/String;ILjava/lang/Object;)V");
			BreakpointRequest br = getBreakpointRequest(method.location());
			br.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
			br.enable();
			
			EventWaiter waiter = new EventWaiter(br, true);
			fEventReader.addEventListener(waiter);
			triggerEvent("argvalues");
			BreakpointEvent bpe = (BreakpointEvent) waiter.waitEvent(10000);
			ThreadReference tref = bpe.thread();
			List list = tref.frame(0).getArgumentValues();
			assertNotNull("list should not be null", list);
			assertTrue("first list item must be a String", list.get(0) instanceof StringReference);
			assertEquals("test string is not the same as was created in MainClass", "teststr", ((StringReference)list.get(0)).value());
			assertTrue("second list item must be an integer", list.get(1) instanceof IntegerValue);
			assertEquals("integer is not the same value as was passed in MainClass", 5, ((IntegerValue)list.get(1)).value());
			assertTrue("third list item must be a Double", list.get(2) instanceof ObjectReference);
			fEventReader.removeEventListener(waiter);
			tref.resume();
		} catch (InterruptedException e) {
			e.printStackTrace();
		} catch (InvalidStackFrameException e) {
			e.printStackTrace();
		} catch (IncompatibleThreadStateException e) {
			e.printStackTrace();
		}
		
	}
}

Back to the top