You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ge...@apache.org on 2006/11/28 18:49:31 UTC
svn commit: r480141 [24/38] - in
/harmony/enhanced/jdktools/trunk/modules/jpda: ./ doc/ doc/images/ make/
src/ src/common/ src/common/other/ src/common/other/jpda/
src/common/other/jpda/jdwp/ src/common/other/jpda/jdwp/agent/
src/common/other/jpda/jdwp...
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/SingleStepTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/SingleStepTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/SingleStepTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/SingleStepTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Aleksander V. Budniy
+ * @version $Revision: 1.5 $
+ */
+
+/**
+ * Created on 14.07.2005
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.Events;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.EventMod;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+
+/**
+ * JDWP Unit test for SINGLE_STEP event.
+ */
+public class SingleStepTest extends JDWPEventTestCase {
+
+ private String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/Events/SingleStepDebuggee;";
+
+ private String DEBUGGEE_CLASS_NAME = "org.apache.harmony.jpda.tests.jdwp.Events.SingleStepDebuggee";
+
+ protected String getDebuggeeClassName() {
+ return DEBUGGEE_CLASS_NAME;
+ }
+
+ /**
+ * This test case exercises SINGLE_STEP event.<BR>
+ * Runs stepFunction() function four times to checks
+ * SINGLE_STEP event with LINE and OVER steps.
+ *
+ */
+ public void testSingleStep1() {
+ stepFunction(JDWPConstants.StepSize.LINE, JDWPConstants.StepDepth.OVER);
+
+ }
+
+ /**
+ * This test case exercises SINGLE_STEP event.<BR>
+ * Runs stepFunction() function four times to checks
+ * SINGLE_STEP event with LINE and INTO steps.
+ *
+ */
+ public void testSingleStep2() {
+ stepFunction(JDWPConstants.StepSize.LINE, JDWPConstants.StepDepth.INTO);
+ }
+
+ /**
+ * This test case exercises SINGLE_STEP event.<BR>
+ * Runs stepFunction() function four times to checks
+ * SINGLE_STEP event with MIN and OVER steps.
+ *
+ */
+ public void testSingleStep3() {
+ stepFunction(JDWPConstants.StepSize.MIN, JDWPConstants.StepDepth.OVER);
+ }
+
+ /**
+ * This test case exercises SINGLE_STEP event.<BR>
+ * Runs stepFunction() function four times to checks
+ * SINGLE_STEP event with MIN and INTO steps.
+ *
+ */
+ public void testSingleStep4() {
+ stepFunction(JDWPConstants.StepSize.MIN, JDWPConstants.StepDepth.INTO);
+ }
+
+ /**
+ * Runs SingleStepDebuggee and sets breakpoint to its
+ * breakpointTest method, sends a request for single step event, then
+ * verifies that requested SINGLE_STEP event with StepSize and StepDepth
+ * steps occurs.
+ */
+
+ void stepFunction(byte StepSize, byte StepDepth) {
+ logWriter.println("=> testSingleStep started");
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ //find checked method
+ long refTypeID = getClassIDBySignature(debuggeeSignature);
+
+ logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+ logWriter.println("=> referenceTypeID for Debuggee class = " + refTypeID);
+ logWriter.println("=> Send ReferenceType::Methods command and get methodIDs ");
+
+ long requestID = debuggeeWrapper.vmMirror.setBreakpointAtMethodBegin(
+ refTypeID, "breakpointTest");
+ logWriter.println("=> breakpointID = " + requestID);
+ logWriter.println("=> starting thread");
+
+ //execute the breakpoint
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ long breakpointThreadID = debuggeeWrapper.vmMirror
+ .waitForBreakpoint(requestID);
+
+ logWriter.println("=> breakpointThreadID = " + breakpointThreadID);
+
+ // Sending a SINGLE_STEP request
+
+ CommandPacket setRequestCommand = new CommandPacket(
+ JDWPCommands.EventRequestCommandSet.CommandSetID,
+ JDWPCommands.EventRequestCommandSet.SetCommand);
+
+ setRequestCommand
+ .setNextValueAsByte(JDWPConstants.EventKind.SINGLE_STEP);
+ setRequestCommand.setNextValueAsByte(JDWPConstants.SuspendPolicy.ALL);
+ setRequestCommand.setNextValueAsInt(1);
+ setRequestCommand.setNextValueAsByte(EventMod.ModKind.Step);
+ setRequestCommand.setNextValueAsThreadID(breakpointThreadID);
+ setRequestCommand.setNextValueAsInt(StepSize);
+ setRequestCommand.setNextValueAsInt(StepDepth);
+
+ ReplyPacket setRequestReply = debuggeeWrapper.vmMirror
+ .performCommand(setRequestCommand);
+
+ checkReplyPacket(setRequestReply, "Set SINGLE_STEP event");
+
+ requestID = setRequestReply.getNextValueAsInt();
+
+ logWriter.println("=> RequestID = " + requestID);
+ assertAllDataRead(setRequestReply);
+
+ //resume debuggee
+ resumeDebuggee();
+
+ //receive event
+ logWriter.println("==> Wait for SINGLE_STEP event");
+ CommandPacket event = debuggeeWrapper.vmMirror.receiveEvent();
+ ParsedEvent[] parsedEvents = ParsedEvent.parseEventPacket(event);
+
+ //check if received event is expected
+ logWriter.println("==> Received " + parsedEvents.length + " events");
+
+ // trace events
+ for (int i = 0; i < parsedEvents.length; i++) {
+ logWriter.println("");
+ logWriter.println("==> Event #" + i + ";");
+ logWriter.println("==> EventKind: " + parsedEvents[i].getEventKind() + "("
+ + JDWPConstants.EventKind.getName(parsedEvents[i].getEventKind()) + ")");
+ logWriter.println("==> RequestID: " + parsedEvents[i].getRequestID());
+ }
+
+ // check all
+ assertEquals("Received wrong number of events,", 1, parsedEvents.length);
+ assertEquals("Received wrong event request ID,", requestID, parsedEvents[0].getRequestID());
+ assertEquals("Invalid event kind,", JDWPConstants.EventKind.SINGLE_STEP,
+ parsedEvents[0].getEventKind(),
+ JDWPConstants.EventKind.getName(JDWPConstants.EventKind.SINGLE_STEP),
+ JDWPConstants.EventKind.getName(parsedEvents[0].getEventKind()));
+
+ // clear SINGLE_STEP event
+ logWriter.println("==> Clearing SINGLE_STEP event..");
+ //ReplyPacket reply =
+ debuggeeWrapper.vmMirror.clearEvent(JDWPConstants.EventKind.SINGLE_STEP, (int) requestID);
+ checkReplyPacket(setRequestReply, "Clear SINGLE_STEP event");
+ logWriter.println("==> SINGLE_STEP event has been cleared");
+
+ // resuming debuggee
+ logWriter.println("==> Resuming debuggee");
+ resumeDebuggee();
+ logWriter.println("==> Test PASSED!");
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(SingleStepTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/SingleStepTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/ThreadEndTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/ThreadEndTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/ThreadEndTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/ThreadEndTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anton V. Karnachuk
+ * @version $Revision: 1.4 $
+ */
+
+/**
+ * Created on 11.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.Events;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.Event;
+import org.apache.harmony.jpda.tests.framework.jdwp.EventMod;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent.*;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for THREAD_END event.
+ */
+public class ThreadEndTest extends JDWPEventTestCase {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(ThreadEndTest.class);
+ }
+
+ /**
+ * This testcase is for THREAD_END event.
+ * <BR>It runs EventDebuggee and verifies that requested
+ * THREAD_END event occurs.
+ */
+ public void testThreadEndEvent001() {
+ logWriter.println("==> testThreadEndEvent001 - STARTED...");
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ logWriter.println("=> set ThreadEndEvent...");
+ ReplyPacket reply;
+ byte eventKind = JDWPConstants.EventKind.THREAD_END;
+ byte suspendPolicy = JDWPConstants.SuspendPolicy.NONE;
+ EventMod[] mods = new EventMod[0];
+ Event eventToSet = new Event(eventKind, suspendPolicy, mods);
+
+ reply = debuggeeWrapper.vmMirror.setEvent(eventToSet);
+ checkReplyPacket(reply, "Set THREAD_END event");
+
+ logWriter.println("=> set ThreadEndEvent - DONE");
+
+ // start the thread
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ // wait for thread start and finish
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ logWriter.println("=> vmMirror.receiveEvent()...");
+ CommandPacket event = debuggeeWrapper.vmMirror.receiveEvent();
+
+ assertNotNull("Invalid (null) event received", event);
+ logWriter.println("=> Event received!");
+
+ ParsedEvent[] parsedEvents = ParsedEvent.parseEventPacket(event);
+ logWriter.println("=> Number of events = " + parsedEvents.length);
+ assertEquals("Invalid number of events,", 1, parsedEvents.length);
+ logWriter.println("=> EventKind() = " + parsedEvents[0].getEventKind()
+ + " (" + JDWPConstants.EventKind.getName(parsedEvents[0].getEventKind()) + ")");
+ assertEquals("Invalid event kind,",
+ JDWPConstants.EventKind.THREAD_END,
+ parsedEvents[0].getEventKind(),
+ JDWPConstants.EventKind.getName(JDWPConstants.EventKind.THREAD_END),
+ JDWPConstants.EventKind.getName(parsedEvents[0].getEventKind()));
+ logWriter.println("=> EventRequestID() = " + parsedEvents[0].getRequestID());
+
+ long threadID = ((Event_THREAD_DEATH)parsedEvents[0]).getThreadID();
+ logWriter.println("=> threadID = " + threadID);
+ String threadName = debuggeeWrapper.vmMirror.getThreadName(threadID);
+ logWriter.println("=> threadName = " + threadName);
+ assertEquals("Invalid thread name", EventDebuggee.testedThreadName, threadName);
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("==> testThreadEndEvent001 - OK");
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/ThreadEndTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/ThreadStartTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/ThreadStartTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/ThreadStartTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/ThreadStartTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anton V. Karnachuk
+ * @version $Revision: 1.4 $
+ */
+
+/**
+ * Created on 11.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.Events;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.Event;
+import org.apache.harmony.jpda.tests.framework.jdwp.EventMod;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent.*;
+import org.apache.harmony.jpda.tests.jdwp.Events.EventDebuggee;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for THREAD_START event.
+ */
+public class ThreadStartTest extends JDWPEventTestCase {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(ThreadStartTest.class);
+ }
+
+ /**
+ * This testcase is for THREAD_START event.
+ * <BR>It runs EventDebuggee and verifies that requested
+ * THREAD_START event occurs.
+ */
+ public void testThreadStartEvent001() {
+ logWriter.println("==> testThreadStartEvent001 - STARTED...");
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ logWriter.println("=> set ThreadStartEvent...");
+ ReplyPacket reply;
+ byte eventKind = JDWPConstants.EventKind.THREAD_START;
+ byte suspendPolicy = JDWPConstants.SuspendPolicy.NONE;
+ EventMod[] mods = new EventMod[0];
+ Event eventToSet = new Event(eventKind, suspendPolicy, mods);
+
+ reply = debuggeeWrapper.vmMirror.setEvent(eventToSet);
+ checkReplyPacket(reply, "Set THREAD_START event");
+
+ logWriter.println("=> set ThreadStartEvent - DONE");
+
+ // start the thread
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ // wait for thread start and finish
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ logWriter.println("=> vmMirror.receiveEvent()...");
+ CommandPacket event = debuggeeWrapper.vmMirror.receiveEvent();
+
+ assertNotNull("Invalid (null) event received", event);
+ logWriter.println("=> Event received!");
+
+ ParsedEvent[] parsedEvents = ParsedEvent.parseEventPacket(event);
+ logWriter.println("=> Number of events = " + parsedEvents.length);
+ assertEquals("Invalid number of events,", 1, parsedEvents.length);
+ logWriter.println("=> EventKind() = " + parsedEvents[0].getEventKind()
+ + " (" + JDWPConstants.EventKind.getName(parsedEvents[0].getEventKind()) + ")");
+ assertEquals("Invalid event kind,",
+ JDWPConstants.EventKind.THREAD_START,
+ parsedEvents[0].getEventKind(),
+ JDWPConstants.EventKind.getName(JDWPConstants.EventKind.THREAD_START),
+ JDWPConstants.EventKind.getName(parsedEvents[0].getEventKind()));
+ logWriter.println("=> EventRequestID() = " + parsedEvents[0].getRequestID());
+
+ long threadID = ((Event_THREAD_START)parsedEvents[0]).getThreadID();
+ logWriter.println("=> threadID = " + threadID);
+ String threadName = debuggeeWrapper.vmMirror.getThreadName(threadID);
+ logWriter.println("=> threadName = " + threadName);
+ assertEquals("Invalid thread name", EventDebuggee.testedThreadName, threadName);
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("==> testThreadStartEvent001 - OK");
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/ThreadStartTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/VMDeath002Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/VMDeath002Test.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/VMDeath002Test.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/VMDeath002Test.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,204 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Aleksander V. Budniy
+ * @version $Revision: 1.4 $
+ */
+
+/**
+ * Created on 14.07.2005
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.Events;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for requested VM_DEATH event.
+ */
+
+public class VMDeath002Test extends JDWPSyncTestCase {
+
+ int requestID = 0;
+
+ static String DEBUGGEE_CLASS_NAME = "org.apache.harmony.jpda.tests.jdwp.Events.EventDebuggee";
+
+ protected String getDebuggeeClassName() {
+ return DEBUGGEE_CLASS_NAME;
+ }
+
+ /**
+ * This testcase is for requested VM_DEATH event.<BR>
+ * It starts EventDebuggee class, send request for
+ * VM_DEATH event, receives events and verifies that:
+ * <BR> - requested VM_DEATH event
+ * is received with the expected RequestID, returned by EventRequest.Set command;
+ * <BR> - automatic VM_DEATH event
+ * is received with the RequestID = 0;
+ */
+ public void testVMDeathRequest() {
+ logWriter.println("==> testVMDeathRequest started");
+
+ //check capability, relevant for this test
+ logWriter.println("=> Check capability: canRequestVMDeathEvent");
+ debuggeeWrapper.vmMirror.capabilities();
+ boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canRequestVMDeathEvent;
+ if (!isCapability) {
+ logWriter.println("##WARNING: this VM doesn't possess capability: canRequestVMDeathEvent");
+ return;
+ }
+ boolean success = true;
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ //set request for VM_DEATH event with suspend policy SUSPEND_ALL
+ byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
+ logWriter.println("=> Create request for VM_DEATH event with suspend policy: "
+ + suspendPolicy + "/"
+ + JDWPConstants.SuspendPolicy.getName(suspendPolicy));
+ CommandPacket setRequestCommand = new CommandPacket(
+ JDWPCommands.EventRequestCommandSet.CommandSetID,
+ JDWPCommands.EventRequestCommandSet.SetCommand);
+
+ setRequestCommand.setNextValueAsByte(JDWPConstants.EventKind.VM_DEATH);
+ setRequestCommand.setNextValueAsByte(JDWPConstants.SuspendPolicy.ALL);
+ setRequestCommand.setNextValueAsInt(0);
+
+ ReplyPacket setRequestReply = debuggeeWrapper.vmMirror
+ .performCommand(setRequestCommand);
+ checkReplyPacket(setRequestReply, "Set VM_DEATH event");
+
+ requestID = setRequestReply.getNextValueAsInt();
+ logWriter.println("==> RequestID = " + requestID);
+
+ assertAllDataRead(setRequestReply);
+
+ //release debuggee
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ //receive and parse event set
+ logWriter.println("=> Wait for VM_DEATH event");
+ CommandPacket eventPacket = debuggeeWrapper.vmMirror.receiveEvent();
+ ParsedEvent[] parsedEvents = ParsedEvent.parseEventPacket(eventPacket);
+ int eventsCount = parsedEvents.length;
+ logWriter.println("==> Received event set: count=" + eventsCount);
+
+ //ckeck if received events are expected
+ int requestedEvents = 0;
+ int autoEvents = 0;
+ int wrongEvents = 0;
+ for (int i = 0; i < eventsCount; i++) {
+ ParsedEvent event = parsedEvents[i];
+ logWriter.println("=> Event #" + i + ";");
+
+ // print event info
+ byte eventSuspendPolicy = event.getSuspendPolicy();
+ logWriter.println("===> SuspendPolicy=" + eventSuspendPolicy + "/"
+ + JDWPConstants.SuspendPolicy.getName(eventSuspendPolicy));
+ byte eventKind = event.getEventKind();
+ logWriter.println("===> EventKind=" + eventKind + "/"
+ + JDWPConstants.EventKind.getName(eventKind));
+ int eventRequestID = event.getRequestID();
+ logWriter.println("===> RequestID=" + eventRequestID);
+
+ // check if event is expected
+ if (eventKind == JDWPConstants.EventKind.VM_DEATH) {
+ if (eventRequestID == requestID) {
+ requestedEvents++;
+ logWriter.println("===> found requested VM_DEATH event!");
+
+ // check suspend p[olicy for requested event
+ if (eventSuspendPolicy != suspendPolicy) {
+ logWriter.println("## FAILURE: requested VM_DEATH event "
+ + "with unexpected SuspendPolicy: "
+ + eventSuspendPolicy);
+ success = false;
+ }
+ } else if (parsedEvents[i].getRequestID() == 0) {
+ autoEvents++;
+ logWriter.println("===> found auto VM_DEATH event!");
+ // for automatical event suspend policy can be changed
+ } else {
+ logWriter.println("## FAILURE: VM_DEATH event "
+ + "with unexpected RequestID: "
+ + eventRequestID);
+ success = false;
+ }
+ } else {
+ wrongEvents++;
+ logWriter.println("## FAILURE: unexpected event kind: "
+ + eventKind);
+ success = false;
+ }
+ }
+
+ // check number of found events
+ {
+ if (eventsCount != 2) {
+ logWriter.println("## FAILURE: received wrong number of events: "
+ + eventsCount);
+ success = false;
+ }
+
+ if (requestedEvents > 1) {
+ logWriter.println("## FAILURE: too many requested VM_DEATH events: "
+ + requestedEvents);
+ success = false;
+ } else if (requestedEvents < 1) {
+ logWriter.println("## FAILURE: received no requested VM_DEATH events: "
+ + requestedEvents);
+ success = false;
+ }
+
+ if (autoEvents > 1) {
+ logWriter.println("## FAILURE: too many auto VM_DEATH events: "
+ + autoEvents);
+ success = false;
+ } else if (autoEvents < 1) {
+ logWriter.println("## FAILURE: received no auto VM_DEATH events: "
+ + autoEvents);
+ success = false;
+ }
+
+ if (wrongEvents > 0) {
+ logWriter.println("## FAILURE: Received unexpected events: "
+ + wrongEvents);
+ success = false;
+ }
+
+ assertTrue("Failure in processing VM_DEATH event", success);
+ }
+
+ logWriter.println("=> Resume debuggee");
+ resumeDebuggee();
+
+ logWriter.println("==> test PASSED!");
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(VMDeath002Test.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/VMDeath002Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/VMDeathTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/VMDeathTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/VMDeathTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/VMDeathTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anton V. Karnachuk
+ * @version $Revision: 1.4 $
+ */
+
+/**
+ * Created on 06.04.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.Events;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+
+/**
+ * JDWP Unit test for automatic VM_DEATH event.
+ */
+public class VMDeathTest extends JDWPEventTestCase {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(VMDeathTest.class);
+ }
+
+ /**
+ * This testcase is for automatic VM_DEATH event.<BR>
+ * It starts EventDebuggee and verifies that expected
+ * automatic VM_DEATH event occurs.
+ */
+ public void testVMDeathEvent() {
+ logWriter.println("testVMDeathEvent started");
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ CommandPacket event = debuggeeWrapper.vmMirror.receiveEvent();
+ ParsedEvent[] parsedEvents = ParsedEvent.parseEventPacket(event);
+
+ logWriter.println("requestID = " + parsedEvents[0].getRequestID());
+ assertEquals("Invalid number of events,", 1, parsedEvents.length);
+ assertEquals("Invalid event kind,",
+ JDWPConstants.EventKind.VM_DEATH,
+ parsedEvents[0].getEventKind(),
+ JDWPConstants.EventKind.getName(JDWPConstants.EventKind.VM_DEATH),
+ JDWPConstants.EventKind.getName(parsedEvents[0].getEventKind()));
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Events/VMDeathTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/BytecodesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/BytecodesTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/BytecodesTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/BytecodesTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anton V. Karnachuk
+ * @version $Revision: 1.6 $
+ */
+
+/**
+ * Created on 14.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.Method;
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+
+/**
+ * JDWP Unit test for Method.Bytecodes command.
+ */
+public class BytecodesTest extends JDWPMethodTestCase {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(BytecodesTest.class);
+ }
+
+ /**
+ * This testcase exercises Method.Bytecodes command.
+ * <BR>It runs MethodDebuggee. Gets methods with ReferenceType.Methods command,
+ * prints it's bytecodes received with Method.Bytecodes command.
+ */
+ public void testBytecodesTest001() throws UnsupportedEncodingException {
+ logWriter.println("testBytecodesTest001 started");
+
+ //check capability, relevant for this test
+ logWriter.println("=> Check capability: canGetBytecodes");
+ debuggeeWrapper.vmMirror.capabilities();
+ boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canGetBytecodes;
+ if (!isCapability) {
+ logWriter.println("##WARNING: this VM doesn't possess capability: canGetBytecodes");
+ return;
+ }
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ long classID = getClassIDBySignature("L"+getDebuggeeClassName().replace('.', '/')+";");
+
+ MethodInfo[] methodsInfo = jdwpGetMethodsInfo(classID);
+ assertFalse("Invalid number of methods", methodsInfo.length == 0);
+
+ for (int i = 0; i < methodsInfo.length; i++) {
+ logWriter.println(methodsInfo[i].toString());
+
+ // get variable table for this class
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.MethodCommandSet.CommandSetID,
+ JDWPCommands.MethodCommandSet.BytecodesCommand);
+ packet.setNextValueAsClassID(classID);
+ packet.setNextValueAsMethodID(methodsInfo[i].getMethodID());
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "Method::Bytecodes command");
+
+ int bytes = reply.getNextValueAsInt();
+ logWriter.println("bytes = " + bytes);
+
+ byte[] bytecode = new byte[bytes];
+ for (int j = 0; j < bytes; j++) {
+ bytecode[j] = reply.getNextValueAsByte();
+ }
+
+ logWriter.println("Bytecode=" + new String(bytecode));
+ }
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/BytecodesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/IsObsoleteTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/IsObsoleteTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/IsObsoleteTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/IsObsoleteTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anton V. Karnachuk
+ * @version $Revision: 1.5 $
+ */
+
+/**
+ * Created on 14.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.Method;
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+
+/**
+ * JDWP Unit test for Method.IsObsolete command.
+ */
+public class IsObsoleteTest extends JDWPMethodTestCase {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(IsObsoleteTest.class);
+ }
+
+ /**
+ * This testcase exercises Method.IsObsolete command.
+ * <BR>It runs MethodDebuggee, receives checked method,
+ * which is not obsolete, and checks it with Method.IsObsolete command.
+ */
+ public void testIsObsoleteTest001() throws UnsupportedEncodingException {
+ logWriter.println("testObsoleteTest001 started");
+
+ //check capability, relevant for this test
+ logWriter.println("=> Check, can VM redefine classes");
+ debuggeeWrapper.vmMirror.capabilities();
+ boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canRedefineClasses;
+ if (!isCapability) {
+ logWriter.println("##WARNING: this VM can't redefine classes");
+ return;
+ }
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ long classID = getClassIDBySignature("L"+getDebuggeeClassName().replace('.', '/')+";");
+
+ MethodInfo[] methodsInfo = jdwpGetMethodsInfo(classID);
+ assertFalse("Invalid number of methods", methodsInfo.length == 0);
+
+ for (int i = 0; i < methodsInfo.length; i++) {
+ logWriter.println(methodsInfo[i].toString());
+
+ // get variable table for this class
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.MethodCommandSet.CommandSetID,
+ JDWPCommands.MethodCommandSet.IsObsoleteCommand);
+ packet.setNextValueAsClassID(classID);
+ packet.setNextValueAsMethodID(methodsInfo[i].getMethodID());
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "Method::IsObsolete command");
+
+ boolean isObsolete = reply.getNextValueAsBoolean();
+ logWriter.println("isObsolete=" + isObsolete);
+ }
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/IsObsoleteTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/JDWPMethodTestCase.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/JDWPMethodTestCase.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/JDWPMethodTestCase.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/JDWPMethodTestCase.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anton V. Karnachuk
+ * @version $Revision: 1.3 $
+ */
+
+/**
+ * Created on 14.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.Method;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+
+
+public class JDWPMethodTestCase extends JDWPSyncTestCase {
+
+ protected String getDebuggeeClassName() {
+ return MethodDebuggee.class.getName();
+ }
+
+ static class MethodInfo {
+ private long methodID;
+ private String name;
+ private String signature;
+ private int modBits;
+
+ public MethodInfo(long methodID, String name, String signature,
+ int modBits) {
+ super();
+ this.methodID = methodID;
+ this.name = name;
+ this.signature = signature;
+ this.modBits = modBits;
+ }
+
+ /**
+ * @return Returns the methodID.
+ */
+ public long getMethodID() {
+ return methodID;
+ }
+ /**
+ * @return Returns the modBits.
+ */
+ public int getModBits() {
+ return modBits;
+ }
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @return Returns the signature.
+ */
+ public String getSignature() {
+ return signature;
+ }
+ public String toString() {
+ return ""+methodID+" "+name+" "+signature+" "+modBits;
+ }
+
+ }
+
+ protected MethodInfo[] jdwpGetMethodsInfo(long classID) {
+
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.MethodsCommand);
+ packet.setNextValueAsClassID(classID);
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+
+ assertTrue(reply.getErrorCode() == JDWPConstants.Error.NONE);
+ int declared = reply.getNextValueAsInt();
+
+ MethodInfo[] methodsInfo = new MethodInfo[declared];
+ for (int i = 0; i < declared; i++) {
+ methodsInfo[i] = new MethodInfo(
+ reply.getNextValueAsMethodID(),
+ reply.getNextValueAsString(),
+ reply.getNextValueAsString(),
+ reply.getNextValueAsInt()
+ );
+ }
+ return methodsInfo;
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/JDWPMethodTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/LineTableTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/LineTableTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/LineTableTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/LineTableTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anton V. Karnachuk
+ * @version $Revision: 1.3 $
+ */
+
+/**
+ * Created on 14.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.Method;
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+
+/**
+ * JDWP Unit test for Method.LineTable command.
+ */
+public class LineTableTest extends JDWPMethodTestCase {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(LineTableTest.class);
+ }
+
+ /**
+ * This testcase exercises Method.LineTable command.
+ * <BR>It runs MethodDebuggee, receives methods of debuggee.
+ * For each received method sends Method.LineTable command
+ * and prints returned LineTable.
+ */
+ public void testLineTableTest001() throws UnsupportedEncodingException {
+ logWriter.println("testLineTableTest001 started");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ long classID = getClassIDBySignature("L"+getDebuggeeClassName().replace('.', '/')+";");
+
+ MethodInfo[] methodsInfo = jdwpGetMethodsInfo(classID);
+ assertFalse("Invalid number of methods: 0", methodsInfo.length == 0);
+
+ for (int i = 0; i < methodsInfo.length; i++) {
+ logWriter.println(methodsInfo[i].toString());
+
+ // get variable table for this class
+ ReplyPacket reply = getLineTable(classID, methodsInfo[i].getMethodID());
+
+ long start = reply.getNextValueAsLong();
+ logWriter.println("start = " + start);
+ long end = reply.getNextValueAsLong();
+ logWriter.println("end = " + end);
+
+ int lines = reply.getNextValueAsInt();
+ logWriter.println("lines = "+lines);
+
+ for (int j = 0; j < lines; j++) {
+ long lineCodeIndex = reply.getNextValueAsLong();
+ logWriter.println("lineCodeIndex = "+lineCodeIndex);
+ int lineNumber = reply.getNextValueAsInt();
+ logWriter.println("lineNumber = "+lineNumber);
+ }
+ }
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/LineTableTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/MethodDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/MethodDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/MethodDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/MethodDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anton V. Karnachuk
+ * @version $Revision: 1.2 $
+ */
+
+/**
+ * Created on 10.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.Method;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class MethodDebuggee extends SyncDebuggee {
+
+ public void run() {
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ logWriter.println("Hello World!");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ public static void main(String [] args) {
+ runDebuggee(MethodDebuggee.class);
+ }
+
+}
\ No newline at end of file
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/MethodDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/VariableTableTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/VariableTableTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/VariableTableTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/VariableTableTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anton V. Karnachuk
+ * @version $Revision: 1.3 $
+ */
+
+/**
+ * Created on 14.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.Method;
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+
+/**
+ * JDWP Unit test for Method.VariableTable command.
+ */
+public class VariableTableTest extends JDWPMethodTestCase {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(VariableTableTest.class);
+ }
+
+ /**
+ * This testcase exercises Method.VariableTable command.
+ * <BR>It runs MethodDebuggee, receives methods of debuggee.
+ * For each received method sends Method.VariableTable command
+ * and prints returned VariableTable.
+ */
+ public void testVariableTableTest001() throws UnsupportedEncodingException {
+ logWriter.println("testVariableTableTest001 started");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ long classID = getClassIDBySignature("L"+getDebuggeeClassName().replace('.', '/')+";");
+
+ MethodInfo[] methodsInfo = jdwpGetMethodsInfo(classID);
+ assertFalse("Invalid number of methods: 0", methodsInfo.length == 0);
+
+ for (int i = 0; i < methodsInfo.length; i++) {
+ logWriter.println(methodsInfo[i].toString());
+
+ // get variable table for this class
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.MethodCommandSet.CommandSetID,
+ JDWPCommands.MethodCommandSet.VariableTableCommand);
+ packet.setNextValueAsClassID(classID);
+ packet.setNextValueAsMethodID(methodsInfo[i].getMethodID());
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "Method::VariableTable command");
+
+ int argCnt = reply.getNextValueAsInt();
+ logWriter.println("argCnt = "+argCnt);
+ int slots = reply.getNextValueAsInt();
+ logWriter.println("slots = "+slots);
+ for (int j = 0; j < slots; j++) {
+ long codeIndex = reply.getNextValueAsLong();
+ logWriter.println("codeIndex = "+codeIndex);
+ String name = reply.getNextValueAsString();
+ logWriter.println("name = "+name);
+ String signature = reply.getNextValueAsString();
+ logWriter.println("signature = "+signature);
+ int length = reply.getNextValueAsInt();
+ logWriter.println("length = "+length);
+ int slot = reply.getNextValueAsInt();
+ logWriter.println("slot = "+slot);
+ }
+
+ }
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/VariableTableTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/VariableTableWithGenericTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/VariableTableWithGenericTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/VariableTableWithGenericTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/VariableTableWithGenericTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Anton V. Karnachuk
+ * @version $Revision: 1.3 $
+ */
+
+/**
+ * Created on 14.02.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.Method;
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+
+/**
+ * JDWP Unit test for Method.VariableTableWithGeneric command.
+ */
+
+public class VariableTableWithGenericTest extends JDWPMethodTestCase {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(VariableTableWithGenericTest.class);
+ }
+
+ /**
+ * This testcase exercises Method.VariableTableWithGeneric command.
+ * <BR>It runs MethodDebuggee, receives methods of debuggee.
+ * For each received method sends Method.VariableTableWithGeneric command
+ * and prints returned VariableTable.
+ */
+ public void testVariableTableWithGenericTest001() throws UnsupportedEncodingException {
+ logWriter.println("VariableTableWithGeneric started");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ long classID = getClassIDBySignature("L"+getDebuggeeClassName().replace('.', '/')+";");
+
+ MethodInfo[] methodsInfo = jdwpGetMethodsInfo(classID);
+ assertFalse("Invalid number of methods: 0", methodsInfo.length == 0);
+
+ for (int i = 0; i < methodsInfo.length; i++) {
+ logWriter.println(methodsInfo[i].toString());
+
+ // get variable table for this class
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.MethodCommandSet.CommandSetID,
+ JDWPCommands.MethodCommandSet.VariableTableWithGenericCommand);
+ packet.setNextValueAsClassID(classID);
+ packet.setNextValueAsMethodID(methodsInfo[i].getMethodID());
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "Method::VariableTableWithGeneric command");
+
+ int argCnt = reply.getNextValueAsInt();
+ logWriter.println("argCnt = "+argCnt);
+ int slots = reply.getNextValueAsInt();
+ logWriter.println("slots = "+slots);
+ for (int j = 0; j < slots; j++) {
+ long codeIndex = reply.getNextValueAsLong();
+ logWriter.println("codeIndex = "+codeIndex);
+ String name = reply.getNextValueAsString();
+ logWriter.println("name = "+name);
+ String signature = reply.getNextValueAsString();
+ logWriter.println("signature = "+signature);
+ String genericSignature = reply.getNextValueAsString();
+ logWriter.println("genericSignature = "+genericSignature);
+ int length = reply.getNextValueAsInt();
+ logWriter.println("length = "+length);
+ int slot = reply.getNextValueAsInt();
+ logWriter.println("slot = "+slot);
+ }
+ }
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/Method/VariableTableWithGenericTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/AttachConnectorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/AttachConnectorTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/AttachConnectorTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/AttachConnectorTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Aleksander V. Budniy
+ * @version $Revision: 1.6 $
+ */
+
+/**
+ * Created on 12.08.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.MultiSession;
+
+import org.apache.harmony.jpda.tests.framework.TestOptions;
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPUnitDebuggeeWrapper;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test to check capacity for work of attaching connector.
+ */
+public class AttachConnectorTest extends JDWPSyncTestCase {
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.MultiSession.ConnectorKindDebuggee";
+ }
+
+ /**
+ * This testcase checks capacity for work of attaching connector.
+ * <BR>Before debuggee start it sets up connector kind to attaching and starts
+ * ConnectorKindDebuggee. Then testcase performs VirtualMachine.Version
+ * command and checks it's correctness.
+ * It is expected that command returns not empty strings describing VM version.
+ */
+ public void testAttachConnector001() {
+
+ logWriter.println("==> testAttachConnector001 started..");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ for (int i = 0; i < 3; i++) {
+
+ CommandPacket packet = new CommandPacket(
+ JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+ JDWPCommands.VirtualMachineCommandSet.VersionCommand);
+ ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+ checkReplyPacket(reply, "VirtualMachine::Version command");
+
+ String description = reply.getNextValueAsString();
+ int jdwpMajor = reply.getNextValueAsInt();
+ int jdwpMinor = reply.getNextValueAsInt();
+ String vmVersion = reply.getNextValueAsString();
+ String vmName = reply.getNextValueAsString();
+
+ logWriter.println("description\t= " + description);
+ logWriter.println("jdwpMajor\t= " + jdwpMajor);
+ logWriter.println("jdwpMinor\t= " + jdwpMinor);
+ logWriter.println("vmVersion\t= " + vmVersion);
+ logWriter.println("vmName\t\t= " + vmName);
+
+ assertTrue("Invalid description.length = 0", description.length() > 0);
+ assertTrue("Invalid vmVersion.length = 0", vmVersion.length() > 0);
+ assertTrue("Invalid vmName.length = 0", vmName.length() > 0);
+
+ logWriter.println("=> CHECK PASSED");
+ logWriter.println("System property: "
+ + System.getProperty("isDebuggeeRunning"));
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ logWriter.println("");
+ logWriter.println("=> CLOSE CONNECTION..");
+ closeConnection();
+ logWriter.println("=> CONNECTION CLOSED");
+
+ logWriter.println("");
+ logWriter.println("=> OPEN NEW CONNECTION..");
+ openConnection();
+ logWriter.println("=> CONNECTION OPENED");
+ logWriter.println("");
+
+ }
+ synchronizer.sendMessage("stop");
+ synchronizer.receiveMessage("END");
+ logWriter.println("==> testAttachConnector001 PASSED!");
+ }
+
+ protected void beforeDebuggeeStart(JDWPUnitDebuggeeWrapper debuggeeWrapper) {
+ settings.setAttachConnectorKind();
+ if (settings.getTransportAddress() == null) {
+ settings.setTransportAddress(TestOptions.DEFAULT_ATTACHING_ADDRESS);
+ }
+ logWriter.println("ATTACH connector kind");
+ super.beforeDebuggeeStart(debuggeeWrapper);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(AttachConnectorTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/AttachConnectorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/BreakpointTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/BreakpointTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/BreakpointTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/BreakpointTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Aleksander V. Budniy
+ * @version $Revision: 1.3 $
+ */
+
+/**
+ * Created on 4.08.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.MultiSession;
+
+import org.apache.harmony.jpda.tests.framework.TestOptions;
+import org.apache.harmony.jpda.tests.framework.TestErrorException;
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPUnitDebuggeeWrapper;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for verifying canceling of BREAKPOINT event after re-connection.
+ */
+public class BreakpointTest extends JDWPSyncTestCase {
+
+ private String DEBUGGEE_SIGNATURE = "Lorg/apache/harmony/jpda/tests/jdwp/MultiSession/MultiSessionDebuggee;";
+
+ private String METHOD_NAME = "printWord";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.MultiSession.MultiSessionDebuggee";
+ }
+
+ /**
+ * This testcase verifies canceling of BREAKPOINT event after re-connection.
+ * <BR>It runs MultiSessionDebuggee, sets request for BREAKPOINT event
+ * and re-connects.
+ * <BR>It is expected that no any events, including BREAKPOINT, occur after re-connection
+ * and before MultiSessionDebuggee finish.
+ */
+ public void testClearBreakpoint001() {
+ logWriter.println("==> testClearBreakpoint001 started..");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ long classID = debuggeeWrapper.vmMirror.getClassID(DEBUGGEE_SIGNATURE);
+
+ //long requestID =
+ debuggeeWrapper.vmMirror.setBreakpointAtMethodBegin(
+ classID, METHOD_NAME);
+
+ logWriter.println("");
+ logWriter.println("=> CLOSE CONNECTION");
+ closeConnection();
+ logWriter.println("=> CONNECTION CLOSED");
+
+ logWriter.println("");
+ logWriter.println("=> OPEN NEW CONNECTION");
+ openConnection();
+ logWriter.println("=> CONNECTION OPENED");
+
+ //resuming debuggee
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ // receive event
+ logWriter.println("=> Wait for event..");
+ CommandPacket event = null;
+ try {
+ event = debuggeeWrapper.vmMirror.receiveEvent();
+ } catch (TestErrorException thrown) {
+ logWriter.println("=> Exception while receiving event:" + thrown);
+
+ }
+ if (event == null) {
+ logWriter.println("=> It's expected result, nothing was caught");
+ logWriter.println("=> Resuming debuggee");
+ //resuming debuggee
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("==> testMethodEvent001 PASSED! ");
+ } else {
+
+ logWriter.println("##FAILURE: Event was received");
+
+ try {
+ ParsedEvent[] parsedEvents = ParsedEvent
+ .parseEventPacket(event);
+
+ logWriter.println("=> Number of events = "
+ + parsedEvents.length);
+ for (int i = 0; i < parsedEvents.length; i++) {
+ logWriter.println("=> EventKind() = "
+ + parsedEvents[0].getEventKind()
+ + " ("
+ + JDWPConstants.EventKind.getName(parsedEvents[0]
+ .getEventKind()) + ")");
+ logWriter.println("=> EventRequestID() = "
+ + parsedEvents[0].getRequestID());
+
+ }
+ } catch (Throwable thrown) {
+ logWriter
+ .println("##FAILURE: Exception while analyzing received event:"
+ + thrown);
+ fail("Exception while analyzing received event: "+ thrown);
+ }
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("==> testClearBreakpoint001 PASSED");
+ }
+ }
+
+ protected void beforeDebuggeeStart(JDWPUnitDebuggeeWrapper debuggeeWrapper) {
+ settings.setAttachConnectorKind();
+ if (settings.getTransportAddress() == null) {
+ settings.setTransportAddress(TestOptions.DEFAULT_ATTACHING_ADDRESS);
+ }
+ logWriter.println("ATTACH connector kind");
+ super.beforeDebuggeeStart(debuggeeWrapper);
+ }
+
+ public static void main(String[] args) {
+
+ junit.textui.TestRunner.run(BreakpointTest.class);
+
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/BreakpointTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ClassObjectIDTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ClassObjectIDTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ClassObjectIDTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ClassObjectIDTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Aleksander V. Budniy
+ * @version $Revision: 1.5 $
+ */
+
+/**
+ * Created on 8.7.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.MultiSession;
+
+import org.apache.harmony.jpda.tests.framework.TestOptions;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPUnitDebuggeeWrapper;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for verifying invalidating of classObjectID after re-connection.
+ */
+public class ClassObjectIDTest extends JDWPSyncTestCase {
+
+ private String DEBUGGEE_SIGNATURE = "Lorg/apache/harmony/jpda/tests/jdwp/MultiSession/MultiSessionDebuggee;";
+
+ //private String METHOD_NAME = "printWord";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.MultiSession.MultiSessionDebuggee";
+ }
+
+ /**
+ * This testcase verifies invalidating of classObjectID after re-connection.
+ * <BR>It runs multiSessionDebuggee, gets classID and classObjectID, re-connects
+ * and tries to get refTypeID with ObjectReference.ReferenceType command
+ * using old classObjectID.
+ * <BR>It is expected that INVALID_OBJECT error is returned by command.
+ */
+ public void testClassObjectID001() {
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ long classID = debuggeeWrapper.vmMirror.getClassID(DEBUGGEE_SIGNATURE);
+ long classObjectID = debuggeeWrapper.vmMirror.getClassObjectId(classID);
+
+ logWriter.println("");
+ logWriter.println("=> CLOSE CONNECTION..");
+ closeConnection();
+ logWriter.println("=> CONNECTION CLOSED");
+
+ logWriter.println("");
+ logWriter.println("=> OPEN NEW CONNECTION..");
+ openConnection();
+ logWriter.println("=> CONNECTION OPENED");
+
+ logWriter.println("=> Trying to get classID using old classObjectID");
+ boolean success = false;
+ try {
+ //long requestID =
+ debuggeeWrapper.vmMirror.getReferenceType(classObjectID);
+ } catch (Exception e) {
+ logWriter.println("=> TEST PASSED, because INVALID_OBJECT exception was occurred");
+ success = true;
+ }
+
+ if (!success) {
+ logWriter.println("=> TEST FAILED, because INVALID_OBJECT exception was not occurred");
+ fail("INVALID_OBJECT exception was not occurred");
+ }
+
+ //resuming debuggee
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ protected void beforeDebuggeeStart(JDWPUnitDebuggeeWrapper debuggeeWrapper) {
+ settings.setAttachConnectorKind();
+ if (settings.getTransportAddress() == null) {
+ settings.setTransportAddress(TestOptions.DEFAULT_ATTACHING_ADDRESS);
+ }
+ logWriter.println("ATTACH connector kind");
+ super.beforeDebuggeeStart(debuggeeWrapper);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(ClassObjectIDTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ClassObjectIDTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ClassPrepareTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ClassPrepareTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ClassPrepareTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ClassPrepareTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Aleksander V. Budniy
+ * @version $Revision: 1.6 $
+ */
+
+/**
+ * Created on 8.7.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.MultiSession;
+
+import org.apache.harmony.jpda.tests.framework.TestOptions;
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.jdwp.Events.ClassPrepareDebuggee;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPUnitDebuggeeWrapper;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for verifying canceling of CLASS_PREPARE event after re-connection.
+ */
+public class ClassPrepareTest extends JDWPEventTestCase {
+
+ protected String getDebuggeeClassName() {
+ return ClassPrepareDebuggee.class.getName();
+ }
+
+ /**
+ * This testcase verifies canceling of CLASS_PREPARE event after re-connection.
+ * <BR>It runs ClassPrepareDebuggee, sets request for CLASS_PREPARE event
+ * and re-connects.
+ * <BR>It is expected that only auto VM_DEATH event occurs after re-connection,
+ * but no any other event, including CLASS_PREPARE.
+ */
+ public void testClassPrepare001() {
+ logWriter.println("==> testClassPrepare001 started");
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ String class2prepareRegexp = "org.apache.harmony.jpda.tests.jdwp.Events.Class2Prepare";
+ //String class2prepareSignature = "Lorg/apache/harmony/jpda/tests/jdwp/Events/Class2Prepare;";
+
+ ReplyPacket reply = debuggeeWrapper.vmMirror
+ .setClassPrepared(class2prepareRegexp);
+ checkReplyPacket(reply, "Set CLASS_PREPARE event");
+
+ logWriter.println("");
+ logWriter.println("=> CLOSE CONNECTION..");
+ closeConnection();
+ logWriter.println("=> CONNECTION CLOSED");
+
+ logWriter.println("");
+ logWriter.println("=> OPEN NEW CONNECTION..");
+ openConnection();
+ logWriter.println("=> CONNECTION OPENED");
+
+ logWriter.println("=> Resuming debuggee");
+
+ // start the thread
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ // receive event
+ logWriter.println("=> Wait for event..");
+ CommandPacket eventPacket = debuggeeWrapper.vmMirror.receiveEvent();
+ ParsedEvent[] parsedEvents = ParsedEvent.parseEventPacket(eventPacket);
+ int eventsCount = parsedEvents.length;
+ logWriter.println("=> Received event set: count=" + eventsCount);
+
+ //ckeck if received events are expected
+ int result = 0;
+ int autoEvents = 0;
+ int wrongEvents = 0;
+ for (int i = 0; i < eventsCount; i++) {
+ ParsedEvent event = parsedEvents[i];
+ logWriter.println("=> Event #" + i + ";");
+
+ // print event info
+ byte eventSuspendPolicy = event.getSuspendPolicy();
+ logWriter.println("=> SuspendPolicy=" + eventSuspendPolicy + "/"
+ + JDWPConstants.SuspendPolicy.getName(eventSuspendPolicy));
+ byte eventKind = event.getEventKind();
+ logWriter.println("=> EventKind=" + eventKind + "/"
+ + JDWPConstants.EventKind.getName(eventKind));
+ int eventRequestID = event.getRequestID();
+ logWriter.println("=> RequestID=" + eventRequestID);
+
+ // check if event is expected
+ if (eventKind == JDWPConstants.EventKind.VM_DEATH) {
+ if (parsedEvents[i].getRequestID() == 0) {
+ autoEvents++;
+ logWriter.println("=> found auto VM_DEATH event!");
+ // for automatical event suspend policy can be changed
+ } else {
+ logWriter.println("## FAILURE: VM_DEATH event "
+ + "with unexpected RequestID: " + eventRequestID);
+ result = 1;
+ }
+ } else {
+ wrongEvents++;
+ logWriter.println("## FAILURE: unexpected event kind: "
+ + eventKind);
+ result = 2;
+ }
+ }
+
+ if (1 == result)
+ fail("VM_DEATH event with unexpected RequestID");
+ if (2 == result)
+ fail("Unexpected event kind");
+
+ logWriter.println("==> testClassPrepare001 PASSED!");
+ }
+
+ protected void beforeDebuggeeStart(JDWPUnitDebuggeeWrapper debuggeeWrapper) {
+ settings.setAttachConnectorKind();
+ if (settings.getTransportAddress() == null) {
+ settings.setTransportAddress(TestOptions.DEFAULT_ATTACHING_ADDRESS);
+ }
+ logWriter.println("ATTACH connector kind");
+ super.beforeDebuggeeStart(debuggeeWrapper);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(ClassPrepareTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ClassPrepareTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ConnectorKindDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ConnectorKindDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ConnectorKindDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ConnectorKindDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Aleksander V. Budniy
+ * @version $Revision: 1.3 $
+ */
+
+/**
+ * Created on 12.08.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.MultiSession;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+/**
+ * This class provides simple debuggee class used sync connection.
+ */
+public class ConnectorKindDebuggee extends SyncDebuggee {
+
+ public void run() {
+ int i=0;
+ while(true) {
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ logWriter.println("Hello World ---- "+i);
+ i++;
+
+ String message = synchronizer.receiveMessage();
+ if (!message.equals(JPDADebuggeeSynchronizer.SGNL_CONTINUE)) {
+ break;
+ }
+
+ }
+ synchronizer.sendMessage("END");
+ logWriter.println("Debuggee ended");
+ }
+
+ public static void main(String [] args) {
+ runDebuggee(ConnectorKindDebuggee.class);
+ }
+}
\ No newline at end of file
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ConnectorKindDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native