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 [25/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/MultiSession/EnableCollectionDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/EnableCollectionDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/EnableCollectionDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/EnableCollectionDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,128 @@
+/*
+ * 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 Anatoly F. Bondarenko
+* @version $Revision: 1.5 $
+*/
+
+/**
+* Created on 04.03.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;
+
+public class EnableCollectionDebuggee extends SyncDebuggee {
+
+ static EnableCollectionObject001_01 checkedObject;
+ static boolean checkedObject_Finalized = false;
+ static EnableCollectionObject001_02 patternObject;
+ static boolean patternObject_Finalized = false;
+
+ public void run() {
+ logWriter.println("--> Debuggee: EnableCollectionDebuggee: START");
+
+ checkedObject = new EnableCollectionObject001_01();
+ patternObject = new EnableCollectionObject001_02();
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ String messageFromTest = synchronizer.receiveMessage();
+ if ( messageFromTest.equals("TO_FINISH")) {
+ logWriter.println("--> Debuggee: EnableCollectionDebuggee: FINISH");
+ return;
+ }
+
+ logWriter.println("--> Debuggee: BEFORE System.gc():");
+ logWriter.println("--> Debuggee: checkedObject = " +
+ checkedObject);
+ logWriter.println("--> Debuggee: checkedObject_UNLOADed = " +
+ checkedObject_Finalized);
+ logWriter.println("--> Debuggee: patternObject = " +
+ patternObject);
+ logWriter.println("--> Debuggee: patternObject_UNLOADed = " +
+ patternObject_Finalized);
+
+ checkedObject = null;
+ patternObject = null;
+ long[][] longArray;
+ int i = 0;
+ try {
+ longArray = new long[1000000][];
+ int arraysNumberLimit = 7; // max - longArray.length
+ logWriter.println
+ ("--> Debuggee: memory depletion - creating 'long[1000000]' arrays (" + arraysNumberLimit + ")...");
+ for (; i < arraysNumberLimit; i++) {
+ longArray[i] = new long[1000000];
+ }
+ } catch ( OutOfMemoryError outOfMem ) {
+ logWriter.println("--> Debuggee: OutOfMemoryError!!!");
+ }
+ longArray = null;
+ System.gc();
+ logWriter.println("--> Debuggee: AFTER System.gc():");
+ logWriter.println("--> Debuggee: checkedObject = " +
+ checkedObject);
+ logWriter.println("--> Debuggee: checkedObject_UNLOADed = " +
+ checkedObject_Finalized);
+ logWriter.println("--> Debuggee: patternObject = " +
+ patternObject);
+ logWriter.println("--> Debuggee: patternObject_UNLOADed = " +
+ patternObject_Finalized);
+
+ String messageForTest = null;
+ if ( checkedObject_Finalized ) {
+ if ( patternObject_Finalized ) {
+ messageForTest = "Checked Object is UNLOADed; Pattern Object is UNLOADed;";
+ } else {
+ messageForTest = "Checked Object is UNLOADed; Pattern Object is NOT UNLOADed;";
+ }
+ } else {
+ if ( patternObject_Finalized ) {
+ messageForTest = "Checked Object is NOT UNLOADed; Pattern Object is UNLOADed;";
+ } else {
+ messageForTest = "Checked Object is NOT UNLOADed; Pattern Object is NOT UNLOADed;";
+ }
+ }
+ logWriter.println("--> Debuggee: Send to test message: \"" + messageForTest + "\"");
+ synchronizer.sendMessage(messageForTest);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ logWriter.println("--> Debuggee: EnableCollectionDebuggee: FINISH");
+
+ }
+
+ public static void main(String [] args) {
+ runDebuggee(EnableCollectionDebuggee.class);
+ }
+
+}
+
+class EnableCollectionObject001_01 {
+ protected void finalize() throws Throwable {
+ EnableCollectionDebuggee.checkedObject_Finalized = true;
+ super.finalize();
+ }
+}
+
+class EnableCollectionObject001_02 {
+ protected void finalize() throws Throwable {
+ EnableCollectionDebuggee.patternObject_Finalized = true;
+ super.finalize();
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/EnableCollectionDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/EnableCollectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/EnableCollectionTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/EnableCollectionTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/EnableCollectionTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,163 @@
+/*
+ * 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.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.framework.jdwp.Value;
+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 re-enabling of garbage collecting after re-connection.
+ */
+public class EnableCollectionTest extends JDWPSyncTestCase {
+
+ String checkedFieldName = "checkedObject";
+ static final int testStatusPassed = 0;
+ static final int testStatusFailed = -1;
+ static final String thisCommandName = "MultiSession::EnableCollection command";
+
+ static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/MultiSession/EnableCollectionDebuggee;";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.MultiSession.EnableCollectionDebuggee";
+ }
+
+ /**
+ * This testcase verifies re-enabling of garbage collecting after re-connection.
+ * <BR>It runs EnableCollectionDebuggee, disables garbage collecting for checked object
+ * with ObjectReference.DisableCollection command and re-connects.
+ * <BR>It is expected that checked object is garbage collected after re-connection.
+ */
+ public void testEnableCollection001() {
+ String thisTestName = "testEnableCollection001";
+ logWriter.println("==> testEnableCollection001 started..");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ finalSyncMessage = "TO_FINISH";
+
+ long refTypeID = getClassIDBySignature(debuggeeSignature);
+
+ logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+ logWriter.println("=> referenceTypeID for Debuggee class = " + refTypeID);
+
+ long checkedFieldID = debuggeeWrapper.vmMirror.getFieldID(refTypeID, checkedFieldName);
+
+ logWriter.println
+ ("=> Send ReferenceType::GetValues command for received fieldID and get ObjectID to check...");
+
+ CommandPacket getValuesCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.GetValuesCommand);
+ getValuesCommand.setNextValueAsReferenceTypeID(refTypeID);
+ getValuesCommand.setNextValueAsInt(1);
+ getValuesCommand.setNextValueAsFieldID(checkedFieldID);
+
+ ReplyPacket getValuesReply = debuggeeWrapper.vmMirror.performCommand(getValuesCommand);
+ getValuesCommand = null;
+ checkReplyPacket(getValuesReply, "ReferenceType::GetValues command");
+
+ int returnedValuesNumber = getValuesReply.getNextValueAsInt();
+ logWriter.println("=> Returned values number = " + returnedValuesNumber);
+ assertEquals("Invalid returned number of values,", 1, returnedValuesNumber);
+
+ Value checkedObjectFieldValue = getValuesReply.getNextValueAsValue();
+ byte checkedObjectFieldTag = checkedObjectFieldValue.getTag();
+ logWriter.println("=> Returned field value tag for checked object= " + checkedObjectFieldTag
+ + "(" + JDWPConstants.Tag.getName(checkedObjectFieldTag) + ")");
+ assertEquals("Invalid object tag,", JDWPConstants.Tag.OBJECT_TAG, checkedObjectFieldTag);
+
+ long checkedObjectID = checkedObjectFieldValue.getLongValue();
+ logWriter.println("=> Returned checked ObjectID = " + checkedObjectID);
+
+ logWriter.println
+ ("\n=> CHECK: send " + thisCommandName + " for checked ObjectID...");
+
+ CommandPacket checkedCommand = new CommandPacket(
+ JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
+ JDWPCommands.ObjectReferenceCommandSet.DisableCollectionCommand);
+ checkedCommand.setNextValueAsObjectID(checkedObjectID);
+
+ ReplyPacket checkedReply = debuggeeWrapper.vmMirror.performCommand(checkedCommand);
+ checkedCommand = null;
+ checkReplyPacket(checkedReply, "ObjectReference::DisableCollection command");
+
+ logWriter.println("=> CHECK: Reply is received without any error");
+
+ 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
+ finalSyncMessage = null;
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ String messageFromDebuggee = synchronizer.receiveMessage();
+ logWriter.println
+ ("\n=> Received message from Debuggee = \"" + messageFromDebuggee + "\"" );
+ if ( messageFromDebuggee.equals
+ ("Checked Object is NOT UNLOADed; Pattern Object is UNLOADed;") ) {
+ logWriter.println
+ ("## FAILURE: Checked Object is NOT UNLOADed after " + thisCommandName);
+ fail("Invalid message from debuggee.");
+ } else {
+ logWriter.println("=> PASSED: It is expected result" );
+ }
+
+ assertAllDataRead(checkedReply);
+
+ logWriter.println("=> Send to Debuggee signal to finish ...");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+ logWriter.println("==> testEnableCollection001 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(EnableCollectionTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/EnableCollectionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/EventDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/EventDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/EventDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/EventDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,85 @@
+/*
+ * 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 11.03.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;
+
+/**
+ * Basic debuggee for events unit tests.
+ * Runs new thread
+ */
+public class EventDebuggee extends SyncDebuggee {
+
+ static final String testedThreadName = "SimpleThread";
+
+ private class SimpleThread extends Thread {
+
+ public SimpleThread () {
+ super(testedThreadName);
+ }
+
+ public void run() {
+ logWriter.println("-> SimpleThread: Running...");
+ }
+ }
+
+ public static void main(String[] args) {
+ runDebuggee(EventDebuggee.class);
+ }
+
+ public void run() {
+ logWriter.println("-> EventDebuggee: STARTED");
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ SimpleThread testThread = new SimpleThread();
+ testThread.start();
+ logWriter.println("-> EventDebuggee: SimpleThread started");
+ try {
+ testThread.join();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ logWriter.println("-> EventDebuggee: SimpleThread finished");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ logWriter.println("-> EventDebuggee: wait for signal to continue...");
+ // do NOT finish without signal in order to do NOT generate unexpected events
+
+ while ( true ) {
+ if ( synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE) ) {
+ logWriter.println("-> EventDebuggee: signal received!");
+ break;
+ }
+ }
+
+ logWriter.println("-> EventDebuggee: FINISH...");
+ }
+
+}
+
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/EventDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ExceptionDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ExceptionDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ExceptionDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ExceptionDebuggee.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 11.04.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.MultiSession;
+
+import org.apache.harmony.jpda.tests.jdwp.Events.DebuggeeException;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+
+/**
+ * Debuggee for ExceptionTest unit test.
+ * Generates caught DebuggeeException exception.
+ */
+public class ExceptionDebuggee extends SyncDebuggee {
+
+ public static void main(String[] args) {
+ runDebuggee(ExceptionDebuggee.class);
+ }
+
+ public void run(){
+
+ logWriter.println("--> ExceptionDebuggee: STARTED");
+ // load and prepare DebuggeeException class
+ DebuggeeException ex = new DebuggeeException("dummy exception");
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ logWriter.println("--> ExceptionDebuggee: Wait for SGNL_CONTINUE...");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("--> ExceptionDebuggee: SGNL_CONTINUE has been received!");
+
+ try {
+ // throw caught exception
+ throw new DebuggeeException("Caught debuggee exception");
+ } catch (DebuggeeException e) {
+ logWriter.println("-- ExceptionDebuggee: Exception: \""+e.getMessage()+"\" was thrown");
+ }
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ logWriter.println("DUMP{" + ex + "}");
+ logWriter.println("-- ExceptionDebuggee: FINISHing...");
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ExceptionDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ExceptionTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ExceptionTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ExceptionTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,146 @@
+/*
+ * 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.jdwp.Events.ExceptionDebuggee;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPUnitDebuggeeWrapper;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for verifying canceling of EXCEPTION event after re-connection.
+ */
+public class ExceptionTest extends JDWPEventTestCase {
+
+ protected String getDebuggeeClassName() {
+ return ExceptionDebuggee.class.getName();
+ }
+
+ /**
+ * This testcase verifies canceling of EXCEPTION event after re-connection.
+ * <BR>It runs ExceptionDebuggee, sets request for EXCEPTION event
+ * and re-connects.
+ * <BR>It is expected that only auto VM_DEATH event occurs after re-connection,
+ * but no any other event, including EXCEPTION event.
+ */
+ public void testException001() {
+ logWriter.println(">> testException001: STARTED...");
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ String exceptionSignature = "Lorg/apache/harmony/jpda/tests/jdwp/Events/DebuggeeException;";
+ boolean isCatch = true;
+ boolean isUncatch = true;
+ logWriter.println("\n>> testExceptionEvent: => setException(...)...");
+ debuggeeWrapper.vmMirror.setException(exceptionSignature, isCatch,
+ isUncatch);
+ logWriter.println(">> testExceptionEvent: setException(...) DONE");
+
+ 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);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ // 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");
+ else if (2 == result)
+ fail("Unexpected event kind");
+
+ logWriter.println("==> testException001 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(ExceptionTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/FieldAccessTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/FieldAccessTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/FieldAccessTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/FieldAccessTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,151 @@
+/*
+ * 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.10 $
+ */
+
+/**
+ * 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.jdwp.share.JDWPUnitDebuggeeWrapper;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for verifying canceling of FIELD_ACCESS event after re-connection.
+ */
+public class FieldAccessTest extends JDWPEventTestCase {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(FieldAccessTest.class);
+ }
+
+ protected String getDebuggeeClassName() {
+ return FieldDebuggee.class.getName();
+ }
+
+ /**
+ * This testcase verifies canceling of EXCEPTION event after re-connection.
+ * <BR>It runs FieldDebuggee, sets request for FIELD_ACCESS event
+ * and re-connects.
+ * <BR>It is expected that only auto VM_DEATH event occurs after re-connection,
+ * but no any other event, including FIELD_ACCESS event.
+ */
+ public void testFieldAccess001() {
+
+ logWriter.println("==> testFieldAccess001 started");
+
+ //check capability, relevant for this test
+ logWriter.println("=> Check capability: canWatchFieldAccess");
+ debuggeeWrapper.vmMirror.capabilities();
+ boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canWatchFieldAccess;
+ if (!isCapability) {
+ logWriter.println("##WARNING: this VM doesn't possess capability: canWatchFieldAccess");
+ return;
+ }
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ String classSignature = "Lorg/apache/harmony/jpda/tests/jdwp/MultiSession/FieldDebuggee;";
+ debuggeeWrapper.vmMirror.setFieldAccess(classSignature,
+ JDWPConstants.TypeTag.CLASS, "testIntField");
+
+ logWriter.println("");
+ logWriter.println("=> CLOSE CONNECTION");
+ closeConnection();
+ logWriter.println("=> CONNECTION CLOSE");
+
+ logWriter.println("");
+ logWriter.println("=> OPEN NEW CONNECTION");
+ openConnection();
+ logWriter.println("=> CONNECTION OPENED");
+
+ logWriter.println("=> Resuming debuggee");
+
+ // start the thread
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ // 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");
+ else if (2 == result)
+ fail("Unexpected event kind");
+
+ logWriter.println("==> testFieldAccess001 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);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/FieldAccessTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/FieldDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/FieldDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/FieldDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/FieldDebuggee.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 Anton V. Karnachuk
+ * @version $Revision: 1.2 $
+ */
+
+/**
+ * Created on 11.04.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;
+
+/**
+ * Debuggee for FieldAccessTest and FieldModified unit tests.
+ * Provides access and modification of testIntField field.
+ */
+public class FieldDebuggee extends SyncDebuggee {
+
+ public static void main(String[] args) {
+ runDebuggee(FieldDebuggee.class);
+ }
+
+ private int testIntField = 0;
+
+ public void run(){
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ logWriter.println("--> FieldDebuggee started");
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ testIntField = 512;
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ logWriter.println("--> Access to field testIntField: value="+testIntField);
+
+ logWriter.println("--> FieldDebuggee finished");
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/FieldDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/FieldModificationTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/FieldModificationTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/FieldModificationTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/FieldModificationTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,151 @@
+/*
+ * 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.7 $
+ */
+
+/**
+ * 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.jdwp.share.JDWPUnitDebuggeeWrapper;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+
+/**
+ * JDWP Unit test for verifying canceling of FIELD_MODIFICATION event after re-connection.
+ */
+public class FieldModificationTest extends JDWPEventTestCase {
+
+ protected String getDebuggeeClassName() {
+ return FieldDebuggee.class.getName();
+ }
+
+ /**
+ * This testcase verifies canceling of FIELD_MODIFICATION event after re-connection.
+ * <BR>It runs FieldDebuggee, sets request for FIELD_MODIFICATION event
+ * and re-connects.
+ * <BR>It is expected that only auto VM_DEATH event occurs after re-connection,
+ * but no any other event, including FIELD_MODIFICATION.
+ */
+ public void testFieldModification001() {
+
+ logWriter.println("==> testFieldModification001 started");
+
+ //check capability, relevant for this test
+ logWriter.println("=> Check capability: canWatchFieldModification");
+ debuggeeWrapper.vmMirror.capabilities();
+ boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canWatchFieldModification;
+ if (!isCapability) {
+ logWriter.println("##WARNING: this VM doesn't possess capability: canWatchFieldModification");
+ return;
+ }
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ String classSignature = "Lorg/apache/harmony/jpda/tests/jdwp/MultiSession/FieldDebuggee;";
+ debuggeeWrapper.vmMirror.setFieldModification(classSignature,
+ JDWPConstants.TypeTag.CLASS, "testIntField");
+
+ 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);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ // 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");
+ else if (2 == result)
+ fail("Unexpected event kind");
+
+ logWriter.println("==> testFieldModification001 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(FieldModificationTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/FieldModificationTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/JDWPEventTestCase.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/JDWPEventTestCase.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/JDWPEventTestCase.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/JDWPEventTestCase.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,39 @@
+/*
+ * 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 11.03.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.MultiSession;
+
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+
+/**
+ * Internal class that extends functionality of JDWPSyncTestCase class.
+ */
+abstract class JDWPEventTestCase extends JDWPSyncTestCase {
+
+ protected String getDebuggeeClassName() {
+ return EventDebuggee.class.getName();
+ }
+
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/JDWPEventTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ListenConnectorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ListenConnectorTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ListenConnectorTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ListenConnectorTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,111 @@
+/*
+ * 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 12.08.2005
+ */
+package org.apache.harmony.jpda.tests.jdwp.MultiSession;
+
+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 listening connector.
+ */
+public class ListenConnectorTest extends JDWPSyncTestCase {
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.MultiSession.ConnectorKindDebuggee";
+ }
+
+ /**
+ * Sets kind of connection: listen kind.
+ */
+ protected void beforeDebuggeeStart(JDWPUnitDebuggeeWrapper debuggeeWrapper) {
+ settings.setListenConnectorKind();
+ logWriter.println("LISTEN connector kind");
+ super.beforeDebuggeeStart(debuggeeWrapper);
+ }
+
+ /**
+ * This testcase checks capacity for work of listening connector.
+ * <BR>Before debuggee start it sets up connector kind to listening 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 testListenConnector() {
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ 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);
+
+ if (!(description.length() > 0)) {
+ logWriter.println("\n## FAILURE: description.length = 0");
+ fail("description.length = 0");
+ }
+
+ if (!(vmVersion.length() > 0)) {
+ logWriter.println("\n## FAILURE: vmVersion.length = 0");
+ fail("vmVersion.length = 0");
+ }
+
+ if (!(vmName.length() > 0)) {
+ logWriter.println("\n## FAILURE: vmName.length = 0");
+ fail("vmName.length = 0");
+ }
+
+ logWriter.println("CHECK PASSED");
+ logWriter.println("System property: "
+ + System.getProperty("isDebuggeeRunning"));
+
+ synchronizer.sendMessage("stop");
+ synchronizer.receiveMessage("END");
+ logWriter.println("==> testListenConnector001 PASSED!");
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(ListenConnectorTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ListenConnectorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/MethodEntryExitTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/MethodEntryExitTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/MethodEntryExitTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/MethodEntryExitTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,154 @@
+/*
+ * 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 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.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 some events after re-connection.
+ */
+public class MethodEntryExitTest extends JDWPSyncTestCase {
+
+ private String DEBUGGEE_SIGNATURE = "Lorg/apache/harmony/jpda/tests/jdwp/MultiSession/MultiSessionDebuggee;";
+
+ private String METHOD_NAME = "printWord";
+
+ String classNameRegexp = "org.apache.harmony.jpda.tests.jdwp.MultiSession.MultiSessionDebuggee";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.MultiSession.MultiSessionDebuggee";
+ }
+
+ /**
+ * This testcase verifies canceling of some events after re-connection.
+ * <BR>It runs MultiSessionDebuggee, sets requests for BREAKPOINT, METHOD_ENTRY
+ * and METHOD_EXIT events and then re-connects.
+ * <BR>It is expected that no any events, including requested events, occur after re-connection
+ * and before MultiSessionDebuggee finish.
+ */
+ public void testMethodEvent001() {
+ logWriter.println("==> testMethodEvent001 started..");
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ long classID = debuggeeWrapper.vmMirror.getClassID(DEBUGGEE_SIGNATURE);
+
+ logWriter.println("=> Set breakpoint at method begin");
+ //long requestID =
+ debuggeeWrapper.vmMirror.setBreakpointAtMethodBegin(
+ classID, METHOD_NAME);
+
+ logWriter.println("=> Set request for METHOD_ENTRY event");
+ debuggeeWrapper.vmMirror
+ .setMethodEntry(classNameRegexp);
+
+ logWriter.println("=> Set request for METHOD_EXIT event");
+ debuggeeWrapper.vmMirror.setMethodExit(classNameRegexp);
+
+ 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("==> testMethodEvent001 failed");
+ }
+ }
+
+ 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(MethodEntryExitTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/MethodEntryExitTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/MultiSessionDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/MultiSessionDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/MultiSessionDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/MultiSessionDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,65 @@
+/*
+ * 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 31.01.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 HelloWorld debuggee class used sync connection.
+ */
+public class MultiSessionDebuggee extends SyncDebuggee {
+
+
+
+ public void run() {
+ logWriter.println("Debuggee is started");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("FROM DEBUGGEE: thread was resumed" );
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ printWord();
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ logWriter.println("-> MultiSessionDebuggee: wait for signal to continue...");
+ while ( true ) {
+ if ( synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE) ) {
+ logWriter.println("-> MultiSessionDebuggee: signal received!");
+ break;
+ }
+ }
+
+ logWriter.println("-> MultiSessionDebuggee: FINISH...");
+ }
+
+ public void printWord() {
+ logWriter.println("Hello World ---- " );
+ }
+
+ public static void main(String[] args) {
+ runDebuggee(MultiSessionDebuggee.class);
+ }
+}
\ No newline at end of file
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/MultiSessionDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/RefTypeIDTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/RefTypeIDTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/RefTypeIDTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/RefTypeIDTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,105 @@
+/*
+ * 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 referenceTypeID after re-connection.
+ */
+public class RefTypeIDTest extends JDWPSyncTestCase {
+
+ private final String DEBUGGEE_SIGNATURE = "Lorg/apache/harmony/jpda/tests/jdwp/MultiSession/MultiSessionDebuggee;";
+
+ private final String METHOD_NAME = "printWord";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.MultiSession.MultiSessionDebuggee";
+ }
+
+ /**
+ * This testcase verifies invalidating of referenceTypeID after re-connection.
+ * <BR>It runs multiSessionDebuggee, gets classID, re-connects
+ * and tries to set request for BREAKPOINT event using classID, received before
+ * re-connection.
+ * <BR>It is expected that INVALID_OBJECT or INVALID_CLASS error is returned.
+ */
+ public void testRefTypeID001() {
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ long classID = debuggeeWrapper.vmMirror.getClassID(DEBUGGEE_SIGNATURE);
+
+ logWriter.println("");
+ logWriter.println("=> CLOSE CONNECTION..");
+ closeConnection();
+ logWriter.println("=> CONNECTION CLOSED");
+
+ logWriter.println("");
+ logWriter.println("=> OPEN NEW CONNECTION..");
+ openConnection();
+ logWriter.println("=> CONNECTION OPENED");
+
+ boolean success = false;
+ logWriter.println("=> Trying to set a breakpoint using old classID");
+ try{
+ //long requestID =
+ debuggeeWrapper.vmMirror
+ .setBreakpointAtMethodBegin(classID, METHOD_NAME);
+
+ }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(RefTypeIDTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/RefTypeIDTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ResumeDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ResumeDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ResumeDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ResumeDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,52 @@
+/*
+ * 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 31.01.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 HelloWorld debuggee class used sync connection.
+ */
+public class ResumeDebuggee extends SyncDebuggee {
+
+
+
+ public void run() {
+ logWriter.println("Debuggee is started");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("FROM DEBUGGEE: thread was resumed" );
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ }
+
+
+ public static void main(String[] args) {
+ runDebuggee(ResumeDebuggee.class);
+ }
+}
\ No newline at end of file
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ResumeDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ResumeTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ResumeTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ResumeTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ResumeTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,85 @@
+/*
+ * 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 auto resuming debuggee after re-connection.
+ */
+public class ResumeTest extends JDWPSyncTestCase {
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.MultiSession.ResumeDebuggee";
+ }
+
+ /**
+ * This testcase verifies auto resuming debuggee after re-connection.
+ * <BR>It runs ResumeDebuggee, suspends debuggee with VirtualMachine.Suspend
+ * commands and re-connects.
+ * <BR>It is expected that debuggee is auto resumed after re-connection.
+ */
+ public void testResume() {
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ for(int i = 0; i < 3; i++) {
+ debuggeeWrapper.vmMirror.suspend();
+ }
+
+ logWriter.println("");
+ logWriter.println("CLOSE CONNECTION");
+ closeConnection();
+ logWriter.println("CONNECTION IS CLOSED");
+
+ logWriter.println("");
+ logWriter.println("OPEN NEW CONNECTION");
+ openConnection();
+ logWriter.println("CONNECTION IS OPENED");
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ logWriter.println("DEBUGGEE WAS RESUMED");
+
+ logWriter.println("TEST 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(ResumeTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/ResumeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/SingleStepDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/SingleStepDebuggee.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/SingleStepDebuggee.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/SingleStepDebuggee.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,61 @@
+/*
+ * 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 8.7.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;
+;
+
+/**
+ * Debuggee for SingleStepTest unit test.
+ */
+public class SingleStepDebuggee extends SyncDebuggee {
+
+ public static void main(String[] args) {
+ runDebuggee(SingleStepDebuggee.class);
+ }
+
+ public void breakpointTest() {
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("Line1");
+ logWriter.println("Line2");
+ logWriter.println("Line3");
+ }
+
+ public void run() {
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ logWriter.println("SingleStepDebuggee is started");
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ // Test breakpoint
+ breakpointTest();
+
+ logWriter.println("SingleStepDebuggee is finished");
+ }
+
+}
\ No newline at end of file
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/SingleStepDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/SingleStepTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/SingleStepTest.java?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/SingleStepTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/SingleStepTest.java Tue Nov 28 09:49:08 2006
@@ -0,0 +1,195 @@
+/*
+ * 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.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.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 SINGLE_STEP event after re-connection.
+ */
+public class SingleStepTest extends JDWPSyncTestCase {
+
+ private String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/MultiSession/SingleStepDebuggee;";
+
+ private String DEBUGGEE_CLASS_NAME = "org.apache.harmony.jpda.tests.jdwp.MultiSession.SingleStepDebuggee";
+
+ protected String getDebuggeeClassName() {
+ return DEBUGGEE_CLASS_NAME;
+ }
+
+ /**
+ * This testcase verifies canceling of SINGLE_STEP event after re-connection.
+ * <BR>It runs SingleStepDebuggee and sets request for BREAKPOINT event.
+ * After BREAKPOINT event occurs the testcase sets request for SINGLE_STEP event
+ * and re-connects.
+ * <BR>It is expected that only auto VM_DEATH event occurs after re-connection,
+ * but no any other event, including SINGLE_STEP event.
+ */
+ public void testSingleStep001() {
+ stepFunction(JDWPConstants.StepSize.LINE, JDWPConstants.StepDepth.OVER);
+ }
+
+ void stepFunction(byte StepSize, byte StepDepth) {
+ logWriter.println("=> testSingleStep started");
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ //find checked method
+ long refTypeID = debuggeeWrapper.vmMirror.getClassID(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);
+
+ logWriter.println("");
+ logWriter.println("=> CLOSE CONNECTION..");
+ closeConnection();
+ logWriter.println("=> CONNECTION IS CLOSED");
+
+ logWriter.println("");
+ logWriter.println("=> OPEN NEW CONNECTION..");
+ openConnection();
+ logWriter.println("=> CONNECTION IS OPENED");
+
+ //resume debuggee
+ //ReplyPacket reply = debuggeeWrapper.vmMirror.resume();
+ 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");
+ else if (2 == result)
+ fail("Unexpected event kind");
+
+ logWriter.println("==> testSingleStep001 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(SingleStepTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/MultiSession/SingleStepTest.java
------------------------------------------------------------------------------
svn:eol-style = native