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.4 $
22: */
23:
24: /**
25: * Created on 06.04.2005
26: */package org.apache.harmony.jpda.tests.jdwp.Events;
27:
28: import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
29: import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
30: import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
31: import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
32: import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
33:
34: /**
35: * JDWP Unit test for CLASS_PREPARE event.
36: */
37: public class ClassPrepareTest extends JDWPEventTestCase {
38:
39: protected String getDebuggeeClassName() {
40: return ClassPrepareDebuggee.class.getName();
41: }
42:
43: public static void main(String[] args) {
44: junit.textui.TestRunner.run(ClassPrepareTest.class);
45: }
46:
47: /**
48: * This testcase is for CLASS_PREPARE event.
49: * <BR>It runs ClassPrepareDebuggee to load Class2Prepare class
50: * and verify that requested CLASS_PREPARE event occurs.
51: */
52: public void testClassPrepareEvent() {
53: logWriter.println("testClassPrepareEvent started");
54:
55: synchronizer
56: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
57:
58: String class2prepareRegexp = "org.apache.harmony.jpda.tests.jdwp.Events.Class2Prepare";
59: String class2prepareSignature = "Lorg/apache/harmony/jpda/tests/jdwp/Events/Class2Prepare;";
60:
61: ReplyPacket reply = debuggeeWrapper.vmMirror
62: .setClassPrepared(class2prepareRegexp);
63: checkReplyPacket(reply, "Set CLASS_PREPARE event");
64:
65: // start loading Class2Prepare class
66: synchronizer
67: .sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
68:
69: CommandPacket event = debuggeeWrapper.vmMirror.receiveEvent();
70: ParsedEvent[] parsedEvents = ParsedEvent
71: .parseEventPacket(event);
72:
73: assertEquals("Invalid number of events,", 1,
74: parsedEvents.length);
75: assertEquals(
76: "Invalid event kind,",
77: JDWPConstants.EventKind.CLASS_PREPARE,
78: parsedEvents[0].getEventKind(),
79: JDWPConstants.EventKind
80: .getName(JDWPConstants.EventKind.CLASS_PREPARE),
81: JDWPConstants.EventKind.getName(parsedEvents[0]
82: .getEventKind()));
83: assertEquals("Invalid signature of prepared class,",
84: class2prepareSignature,
85: ((ParsedEvent.Event_CLASS_PREPARE) parsedEvents[0])
86: .getSignature());
87:
88: //logWriter.println("parsedEvent="+parsedEvents[0].getClass().getCanonicalName());
89: //logWriter.println(((ParsedEvent.Event_CLASS_PREPARE)parsedEvents[0]).getSignature());
90: }
91: }
|