01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: *
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: /**
20: * @author Anton V. Karnachuk
21: * @version $Revision: 1.2 $
22: */
23:
24: /**
25: * Created on 11.03.2005
26: */package org.apache.harmony.jpda.tests.jdwp.Events;
27:
28: import org.apache.harmony.jpda.tests.framework.Breakpoint;
29: import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
30: import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
31: import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
32: import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
33: import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
34:
35: /**
36: * JDWP Unit test for BREAKPOINT event.
37: */
38: public class BreakpointTest extends JDWPEventTestCase {
39:
40: public static void main(String[] args) {
41: junit.textui.TestRunner.run(BreakpointTest.class);
42: }
43:
44: protected String getDebuggeeClassName() {
45: return BreakpointDebuggee.class.getName();
46: }
47:
48: /**
49: * This testcase is for BREAKPOINT event.
50: * <BR>It runs BreakpointDebuggee and set breakpoint to its breakpointTest
51: * method, then verifies that requested BREAKPOINT event occurs.
52: */
53: public void testSetBreakpointEvent() {
54: logWriter.println("testSetBreakpointEvent started");
55:
56: synchronizer
57: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
58:
59: Breakpoint breakpoint = new Breakpoint(
60: "Lorg/apache/harmony/jpda/tests/jdwp/Events/BreakpointDebuggee;",
61: "breakpointTest", 1);
62: ReplyPacket reply;
63: reply = debuggeeWrapper.vmMirror.setBreakpoint(
64: JDWPConstants.TypeTag.CLASS, breakpoint);
65: checkReplyPacket(reply, "Set BREAKPOINT event");
66:
67: logWriter.println("starting thread");
68:
69: // execute the breakpoint
70: synchronizer
71: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
72:
73: CommandPacket event = null;
74: event = debuggeeWrapper.vmMirror.receiveEvent();
75: ParsedEvent[] parsedEvents = ParsedEvent
76: .parseEventPacket(event);
77:
78: assertEquals("Invalid number of events,", 1,
79: parsedEvents.length);
80: assertEquals("Invalid event kind,",
81: JDWPConstants.EventKind.BREAKPOINT, parsedEvents[0]
82: .getEventKind(), JDWPConstants.EventKind
83: .getName(JDWPConstants.EventKind.BREAKPOINT),
84: JDWPConstants.EventKind.getName(parsedEvents[0]
85: .getEventKind()));
86:
87: logWriter.println("BreakpointTest done");
88: }
89: }
|