You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2007/07/23 18:18:30 UTC

svn commit: r558788 [2/2] - in /harmony/enhanced/jdktools/trunk/modules/jpda: src/main/native/jdwp/common/agent/core/ src/main/native/jdwp/common/transport/dt_socket/ src/main/native/jdwp/unix/agent/ src/main/native/jdwp/unix/agent/core/ src/main/nativ...

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/DebuggerOnDemand/OnthrowDebuggerLaunchTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/DebuggerOnDemand/OnthrowDebuggerLaunchTest.java?view=auto&rev=558788
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/DebuggerOnDemand/OnthrowDebuggerLaunchTest.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/DebuggerOnDemand/OnthrowDebuggerLaunchTest.java Mon Jul 23 09:18:27 2007
@@ -0,0 +1,330 @@
+/*
+ * 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: $
+ */
+
+/**
+ * Created on 5.06.2006
+ */
+package org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand;
+
+import org.apache.harmony.jpda.tests.framework.TestErrorException;
+import org.apache.harmony.jpda.tests.framework.TestOptions;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPRawTestCase;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPUnitDebuggeeProcessWrapper;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.JPDATestOptions;
+
+/**
+ * This test case exercises possibility of debugge to invoke debugger on demand with "onthrow" option.
+ * 
+ * @see org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand.OnthowDebuggerLaunchDebuggee
+ * @see org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand.OnthrowLaunchDebugger001
+ * @see org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand.OnthrowLaunchDebugger002
+ */
+public class OnthrowDebuggerLaunchTest extends JDWPRawTestCase {
+
+    public static final String EXCEPTION_CLASS_FOR_DEBUGGER = 
+                   "org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand.ExceptionForDebugger";
+
+    public static final String DEBUGGEE_CLASS = 
+                   "org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand.OnthowDebuggerLaunchDebuggee";
+
+    /**
+     * Test launches debuggee (without establishing synchronization connection)
+     * with options suspend=y,onuncaught=n, debuggee executes
+     * <code>OnthrowLaunchedDebugger001</code>, test establishes synch
+     * connection with debugger and in cycle receives messages from debugger.
+     */
+    public void testDebuggerLaunch001() {
+        logWriter.println("==> testDebuggerLaunch started");
+
+        String DEBUGGER_NAME = "org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand.OnthrowLaunchDebugger001";
+        String isSuspend = "y";
+        String isOnuncaught = "n";
+
+        performTest(DEBUGGER_NAME, isSuspend, isOnuncaught);
+
+        logWriter.println("==> testDebuggerLaunch ended");
+    }
+
+    /**
+     * Test launches debuggee (without establishing synchronization connection)
+     * with option suspend=y,onuncaught=n, debuggee executes
+     * <code>OnthrowLaunchedDebugger002</code>, test establishes synch
+     * connection with debugger and in cycle receives messages from debugger.
+     * 
+     */
+
+    public void testDebuggerLaunch002() {
+        logWriter.println("==> testDebuggerLaunch002 started");
+
+        String DEBUGGER_NAME = "org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand.OnthrowLaunchDebugger002";
+        String isSuspend = "y";
+        String isOnuncaught = "n";
+
+        performTest(DEBUGGER_NAME, isSuspend, isOnuncaught);
+
+        logWriter.println("==> testDebuggerLaunch002 ended");
+    }
+
+    
+    /**
+     * Test launches debuggee (without establishing synchronization connection)
+     * with option suspend=n,onuncaught=n debuggee executes
+     * <code>OnthrowLaunchedDebugger001</code>, test establishes synch
+     * connection with debugger and in cycle receives messages from debugger.
+     * 
+     */
+    public void testDebuggerLaunch003() {
+        logWriter.println("==> testDebuggerLaunch started");
+
+        String DEBUGGER_NAME = "org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand.OnthrowLaunchDebugger001";
+        String isSuspend = "n";
+        String isOnuncaught = "n";
+
+        performTest(DEBUGGER_NAME, isSuspend, isOnuncaught);
+
+        logWriter.println("==> testDebuggerLaunch ended");
+    }
+    
+    /**
+     * Test executes debuggee (without establishing synchronization connection)
+     * with option suspend=n,onuncaught=n debuggee executes
+     * <code>OnthrowLaunchedDebugger002</code>, test establishes synch
+     * connection with debugger and in cycle receives messages from debugger.
+     * 
+     */
+    public void testDebuggerLaunch004() {
+        logWriter.println("==> testDebuggerLaunch started");
+
+        String DEBUGGER_NAME = "org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand.OnthrowLaunchDebugger002";
+        String isSuspend = "n";
+        String isOnuncaught = "n";
+
+        performTest(DEBUGGER_NAME, isSuspend, isOnuncaught);
+
+        logWriter.println("==> testDebuggerLaunch ended");
+    }
+
+    /**
+     * Method prepares cmd for launching debuggee and debugger. Passes
+     * debugger's cmd as parameter "launch" to debuggee's cmd. Then launches
+     * debuggee and wait for synch connection from debugger, that should be
+     * launched by debuggee. After that, method starts receiving messages in
+     * loop from debugger. Messages of three types: OK, FAIL, END. In case of
+     * FAIL or END messages, loop is ended.
+     * 
+     * @param DEBUGGER_NAME
+     *            name of debugger that debuggee will launch
+     * @param isSuspendDebuggee
+     *            option defines should debuggee be suspended on start
+     * @param isOnuncaught
+     *            parameter that is passed to debuggee (see JDWP agent launch
+     *            options)
+     */
+    void performTest(String debuggerName, String isSuspendDebuggee, String isOnuncaught) {
+
+        try {
+	        // prepare command line for debugger and debuggee processes
+	
+	        String address = settings.getTransportAddress();
+	        String debuggerCmd = prepareDebuggerCmd(debuggerName, address, 
+                    isSuspendDebuggee, isOnuncaught);
+	        logWriter.println("=> Debugger command: " + debuggerCmd);
+	
+	        String debuggeeCmd = prepareDebuggeeCmd(debuggerCmd, address, 
+	                                      isSuspendDebuggee, isOnuncaught);
+	        logWriter.println("=> Debuggee command: " + debuggeeCmd);
+	
+	        // launch debuggee process, which will launch debugger process 
+	
+	        debuggeeWrapper.launchProcessAndRedirectors(debuggeeCmd);
+	
+	        // listen for synch connection from launched debugger 
+	
+	        logWriter.println("=> Listen for synch connection from launched debugger");
+	        debuggerSynchronizer.startServer();
+	        logWriter.println("=> Synch connection with launched debugger established");
+        } catch (Exception e) {
+            throw new TestErrorException(e);
+        }
+
+        // exchange synch messages with debugger
+
+        for (;;) {
+            String message = debuggerSynchronizer.receiveMessage();
+            if (message != null) {
+                logWriter.println("=> Message received from DEBUGGER: " + message);
+                if (message.equals("FAILURE")) {
+                    logWriter.println("##FAILURE: error message received from debugger");
+                    fail("Some error received from debugger");
+                } else if (message.equals("END")) {
+                    logWriter.println("=> Debugger ends work");
+                    break;
+                } else if (!message.equals("OK")) {
+                    logWriter.println("##FAILURE: unexpected message received from debugger");
+                    fail("Unexpected message received from debugger");
+                }
+            } else {
+                logWriter.println("##FAILURE: null message received from debugger");
+                fail("Null message received from debugger");
+            }
+        }
+    }
+
+    ////////////////////////////////////////////////////////////////////////////////////////////
+
+    protected String getDebuggeeClassName() {
+        return DEBUGGEE_CLASS;
+    }
+
+    /**
+     * Creates wrapper for debuggee process.
+     */
+    protected JDWPUnitDebuggeeProcessWrapper createDebuggeeWrapper() {
+        return new JDWPUnitDebuggeeProcessWrapper(settings, logWriter);
+    }
+
+    /**
+     * Creates wrapper for synch connection with debugger.
+     */
+    protected JPDADebuggeeSynchronizer createDebuggerSyncronizer(){
+        return new JPDADebuggeeSynchronizer(logWriter, settings);
+    }
+
+    /**
+     * Creates wrapper object for accessing test options;
+     */
+    protected JPDATestOptions createTestOptions() {
+        return new LaunchedDebugger.JPDADebuggerOnDemandOptions();
+    }
+    
+    protected void internalSetUp() throws Exception {
+        super.internalSetUp();
+
+        // set fixed address for attaching connection
+
+        String address = settings.getTransportAddress();
+        if (address == null) {
+        	settings.setTransportAddress(TestOptions.DEFAULT_ATTACHING_ADDRESS);
+        }
+
+        // set fixed port for debuggee sync connection
+
+    	debuggeeSyncPort = settings.getSyncPortString();
+    	if (debuggeeSyncPort == null) {
+    		debuggeeSyncPort = TestOptions.DEFAULT_STATIC_SYNC_PORT;
+    	}
+    	
+        // prepare for synch connection with debugger
+
+        logWriter.println("=> Prepare synch connection with debugger");
+        debuggerSynchronizer = createDebuggerSyncronizer();
+        debuggerSyncPortNumber = debuggerSynchronizer.bindServer();
+
+        // create wrapper for debuggee process
+
+        debuggeeWrapper = createDebuggeeWrapper();
+    }
+
+    /**
+     * Overrides inherited method to stop started debuggee VM and close all
+     * connections.
+     */
+    protected void internalTearDown() {
+        if (debuggerSynchronizer != null) {
+            logWriter.println("Close synch connection with debugger");
+            debuggerSynchronizer.stop();
+        }
+
+        if (debuggeeWrapper != null) {
+            debuggeeWrapper.finishProcessAndRedirectors();
+            logWriter.println("Finished debuggee VM process and closed connection");
+        }
+        super.internalTearDown();
+    }
+
+    /**
+     * Prepares command line for launching debuggee.
+     *
+     * @param debuggerCmd cmd to launch debugger. Value of parameter "launch"
+     * @param agentAddress address for connection with debugger
+     * @param isSuspendDebuggee should debuggee be suspended on start
+     * @param isOnuncaught should debuggee waits for uncaught exception (see JDWP agent launch options)
+     * @return command line for launching debuggee
+     */
+    private String prepareDebuggerCmd(String debuggerName, String transportAddress,
+            String isSuspendDebuggee, String isOnuncaught) {
+
+        String cmdLine = settings.getDebuggeeJavaPath() 
+            + " -cp " + settings.getDebuggeeClassPath()
+            + " -Djpda.settings.connectorKind=attach"
+	        + " -Djpda.settings.debuggeeSuspend=" + isSuspendDebuggee
+	        + " -Djpda.settings.transportAddress=" + transportAddress
+	        + " -Djpda.settings.syncDebuggerPort=" + debuggerSyncPortNumber
+	        + " -Djpda.settings.syncPort=" + debuggeeSyncPort
+	        + " " + debuggerName;
+   	
+        return cmdLine;
+    }
+
+    /**
+     * Prepares command line for launching debuggee.
+     *
+     * @param debuggerCmd cmd to launch debugger. Value of parameter "launch"
+     * @param agentAddress address for connection with debugger
+     * @param isSuspendDebuggee should debuggee be suspended on start
+     * @param isOnuncaught should debuggee waits for uncaught exception (see JDWP agent launch options)
+     * @return command line for launching debuggee
+     */
+    private String prepareDebuggeeCmd(String debuggerCmd, String transportAddress,
+            String isSuspendDebuggee, String isOnuncaught) {
+
+    	String cmdLine = settings.getDebuggeeJavaPath() 
+    	        + " -cp "
+                + settings.getDebuggeeClassPath() 
+    	        + " \""
+                + "-agentlib:" + settings.getDebuggeeAgentName()
+                + "=transport=dt_socket,address=" + transportAddress 
+                + ",server=y"
+                + ",suspend=" + isSuspendDebuggee 
+                + ",onuncaught=" + isOnuncaught 
+                + ",onthrow=" + EXCEPTION_CLASS_FOR_DEBUGGER
+                + ",launch=\'" + debuggerCmd + "\'"
+                + "," + settings.getDebuggeeAgentExtraOptions()
+    	        + "\""
+                + " " + settings.getDebuggeeVMExtraOptions()
+                + " -Djpda.settings.syncPort=" + debuggeeSyncPort 
+                + " " + getDebuggeeClassName();
+
+        return cmdLine;
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(OnthrowDebuggerLaunchTest.class);
+    }
+
+    protected JDWPUnitDebuggeeProcessWrapper debuggeeWrapper;
+
+    protected JPDADebuggeeSynchronizer debuggerSynchronizer;
+    private int debuggerSyncPortNumber;
+    private String debuggeeSyncPort;
+}

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/DebuggerOnDemand/OnthrowDebuggerLaunchTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/DebuggerOnDemand/OnthrowLaunchDebugger001.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/DebuggerOnDemand/OnthrowLaunchDebugger001.java?view=auto&rev=558788
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/DebuggerOnDemand/OnthrowLaunchDebugger001.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/DebuggerOnDemand/OnthrowLaunchDebugger001.java Mon Jul 23 09:18:27 2007
@@ -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 Aleksander V. Budniy
+ * @version $Revision: $
+ */
+
+/**
+ * Created on 11.06.2006
+ */
+package org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand;
+
+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;
+
+/**
+ * This debugger is invoked by debuggee on demand. Debugger establishes synch connection with debuggee and with Test.
+ * Debugger only performs <code>VirtualMachine::Version</code> command, sends message (OK or FAIL) to debugged, then releases debuggee.
+ * 
+ * @see org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand.OnthowDebuggerLaunchDebuggee
+ */
+public class OnthrowLaunchDebugger001 extends LaunchedDebugger {
+    
+    public void testDebugger002() {
+        logWriter.println("***> OnthrowLaunchDebugger001 started");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+                
+        logWriter.println("**> Send VirtualMachine::Version command");
+        CommandPacket packet = new CommandPacket(
+                JDWPCommands.VirtualMachineCommandSet.CommandSetID,
+                JDWPCommands.VirtualMachineCommandSet.VersionCommand);
+        
+        ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
+        logWriter.println("**> Check reply on Version command");
+        if (!checkReplyPacketWithoutFail(reply, "VirtualMachine::Version command")) {
+            testSynchronizer.sendMessage("FAIL");
+            fail("error durign performing VirtualMachine::Version command");
+        }
+        testSynchronizer.sendMessage("OK");
+        
+        logWriter.println("**> Send SIGNAL_CONTINUE");
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        testSynchronizer.sendMessage("END");
+        logWriter.println("***> OnthrowLaunchDebugger001 finished");
+    }
+           
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(OnthrowLaunchDebugger001.class);
+    }
+}

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/DebuggerOnDemand/OnthrowLaunchDebugger001.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/DebuggerOnDemand/OnthrowLaunchDebugger002.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/DebuggerOnDemand/OnthrowLaunchDebugger002.java?view=auto&rev=558788
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/DebuggerOnDemand/OnthrowLaunchDebugger002.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/DebuggerOnDemand/OnthrowLaunchDebugger002.java Mon Jul 23 09:18:27 2007
@@ -0,0 +1,122 @@
+/*
+ * 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: $
+ */
+
+/**
+ * Created on 5.06.2006
+ */
+package org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand;
+
+import org.apache.harmony.jpda.tests.framework.TestErrorException;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+/**
+ * This debugger is invoked by debuggee on demand. 
+ * Upon launching debugger establishes synch connection with debuggee and with Test.
+ * Debugger gets RefTypeID of tested class, sets breakpoint inside testMethod, 
+ * waits for breakpoint, gets frames, and prints them. Then it releases debuggee.
+ * After every relevant step, debugger send message (OK or FAIL) to Test.
+ * 
+ * @see org.apache.harmony.jpda.tests.jdwp.DebuggerOnDemand.OnthowDebuggerLaunchDebuggee
+ */
+
+public class OnthrowLaunchDebugger002 extends LaunchedDebugger {
+    
+    protected String getDebuggeeClassName() {
+        return "";
+    }
+    
+    String breakpointMethodName = "testMethod";
+    
+    public void testDebugger() {
+        logWriter.println("***> Debugger started");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        // find checked method
+        long refTypeID = 0;
+        try {
+            refTypeID = getClassIDBySignature(DEBUGGEE_CLASS_SIGNATURE);
+        } catch (TestErrorException e) {
+            logWriter.println("##EXCPETION: " + e);
+            testSynchronizer.sendMessage("FAIL");
+            fail("exception during getting class signature");
+        }
+                
+        logWriter.println("**> Set breakpoint at the beginning of " + breakpointMethodName);
+        long requestID = 0;
+        try {
+            requestID = debuggeeWrapper.vmMirror.setBreakpointAtMethodBegin(
+                        refTypeID, breakpointMethodName);
+        } catch (TestErrorException e) {
+            logWriter.println("##EXCEPTION: " + e);
+            testSynchronizer.sendMessage("FAIL");
+            fail("exception setting breakpoint");
+        }
+        
+        logWriter.println("**> RequestID = " + requestID);
+        logWriter.println("**> Release debuggee");
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        
+        // receive event
+        logWriter.println("**> Wait for breakpoint in " + breakpointMethodName);
+        long breakpointThreadID = 0;
+        try {
+            breakpointThreadID = debuggeeWrapper.vmMirror.waitForBreakpoint(requestID);
+        } catch (TestErrorException e) {
+            logWriter.println("##EXCEPTION: " + e);
+            testSynchronizer.sendMessage("FAIL");
+            fail("exception during waiting for breakpoint");
+        }
+                
+        testSynchronizer.sendMessage("OK");
+        logWriter.println("**> breakpointThreadID = " + breakpointThreadID);
+        
+        //print stack frames
+        logWriter.println("");
+        logWriter.println("**> Get frames, thread = " + breakpointThreadID);
+        FrameInfo[] frameInfos = null;
+        try {
+            frameInfos = jdwpGetFrames(breakpointThreadID, 0, -1);
+        } catch (TestErrorException e) {
+            logWriter.println("##EXCEPTION: " + e);
+            testSynchronizer.sendMessage("FAIL");
+            fail("exception during getting frames");
+        }
+        try {
+            printStackFrame(frameInfos.length, frameInfos);
+        } catch (TestErrorException e) {
+            logWriter.println("##EXCEPTION: " + e);
+            testSynchronizer.sendMessage("FAIL");
+            fail("exception during printing frames");
+        }
+        testSynchronizer.sendMessage("OK");
+        
+        logWriter.println("**> Resume debuggee");
+        debuggeeWrapper.vmMirror.resume();
+               
+        testSynchronizer.sendMessage("END");
+        logWriter.println("***> Debugger finished");
+    }
+    
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(OnthrowLaunchDebugger002.class);
+    }
+}

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/DebuggerOnDemand/OnthrowLaunchDebugger002.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPRawTestCase.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPRawTestCase.java?view=diff&rev=558788&r1=558787&r2=558788
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPRawTestCase.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPRawTestCase.java Mon Jul 23 09:18:27 2007
@@ -81,7 +81,7 @@
     protected void setUp() throws Exception {
         super.setUp();
 
-        settings = new JPDATestOptions();
+        settings = createTestOptions();
         settings.setDebuggeeClassName(getDebuggeeClassName());
 
         logWriter = new JPDALogWriter(System.out, null, settings.isVerbose());
@@ -101,6 +101,13 @@
         }
     }
 
+    /**
+     * Creates wrapper object for accessing test options;
+     */
+    protected JPDATestOptions createTestOptions() {
+        return new JPDATestOptions();
+    }
+    
     /**
      * Overrides inherited JUnit method to provide cleanup and invocation of
      * internalTearDown() method.

Modified: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPSyncTestCase.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPSyncTestCase.java?view=diff&rev=558788&r1=558787&r2=558788
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPSyncTestCase.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPSyncTestCase.java Mon Jul 23 09:18:27 2007
@@ -41,10 +41,17 @@
      * This method is invoked right before starting debuggee VM.
      */
     protected void beforeDebuggeeStart(JDWPUnitDebuggeeWrapper debuggeeWrapper) {
-        synchronizer = new JPDADebuggeeSynchronizer(logWriter, settings);
+        synchronizer = createSynchronizer();
         int port = synchronizer.bindServer();
         debuggeeWrapper.savedVMOptions = "-Djpda.settings.syncPort=" + port;
         super.beforeDebuggeeStart(debuggeeWrapper);
+    }
+
+    /**
+     * Creates wrapper for synchronization channel.
+     */
+    protected JPDADebuggeeSynchronizer createSynchronizer() {
+        return new JPDADebuggeeSynchronizer(logWriter, settings);
     }
 
     /**

Modified: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPTestCase.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPTestCase.java?view=diff&rev=558788&r1=558787&r2=558788
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPTestCase.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPTestCase.java Mon Jul 23 09:18:27 2007
@@ -46,7 +46,7 @@
     /**
      * EventPacket instance with received VM_START event.
      */
-    protected EventPacket vmStartEvent;
+    protected EventPacket initialEvent = null;
 
     /**
      * Overrides inherited method to launch one debuggee VM, establish JDWP
@@ -55,35 +55,57 @@
     protected void internalSetUp() throws Exception {
         super.internalSetUp();
 
-        if (settings.getDebuggeeLaunchKind().equals("manual")) {
-            debuggeeWrapper = new JDWPManualDebuggeeWrapper(settings, logWriter);
-        } else {
-            debuggeeWrapper = new JDWPUnitDebuggeeWrapper(settings, logWriter);
-        }
-
+        // launch debuggee process
+        debuggeeWrapper = createDebuggeeWrapper();
         beforeDebuggeeStart(debuggeeWrapper);
-        logWriter.println("TEST NAME: " + getName());
-        debuggeeWrapper.start();
+        startDebuggeeWrapper();
 
-        logWriter
-                .println("Launched debuggee VM process and established connection");
-        vmStartEvent = debuggeeWrapper.vmMirror
-                .receiveCertainEvent(JDWPConstants.EventKind.VM_INIT);
-        logWriter.println("Received VM_START event");
+        // receive and handle initial event
+        receiveInitialEvent();
 
+        // adjust JDWP types length
         debuggeeWrapper.vmMirror.adjustTypeLength();
         logWriter.println("Adjusted VM-dependent type lengths");
     }
 
     /**
+     * Creates wrapper for debuggee process.
+     */
+    protected JDWPUnitDebuggeeWrapper createDebuggeeWrapper() {
+        if (settings.getDebuggeeLaunchKind().equals("manual")) {
+            return new JDWPManualDebuggeeWrapper(settings, logWriter);
+        } else {
+            return new JDWPUnitDebuggeeWrapper(settings, logWriter);
+        }
+    }
+
+    /**
+     * Starts wrapper for debuggee process.
+     */
+    protected void startDebuggeeWrapper() {
+    	debuggeeWrapper.start();
+        logWriter.println("Established JDWP connection with debuggee VM");
+    }
+    	
+    /**
+     * Receives initial VM_INIT event if debuggee is suspended on event.
+     */
+    protected void receiveInitialEvent() {
+        if (settings.isDebuggeeSuspend()) {
+            initialEvent = 
+                debuggeeWrapper.vmMirror.receiveCertainEvent(JDWPConstants.EventKind.VM_INIT);
+            logWriter.println("Received inital VM_INIT event");
+        }
+    }
+
+    /**
      * Overrides inherited method to stop started debuggee VM and close all
      * connections.
      */
     protected void internalTearDown() {
         if (debuggeeWrapper != null) {
             debuggeeWrapper.stop();
-            logWriter
-                    .println("Finished debuggee VM process and closed connection");
+            logWriter.println("Closed JDWP connection with debuggee VM");
         }
         super.internalTearDown();
     }
@@ -101,9 +123,9 @@
      */
     public void openConnection() {
         debuggeeWrapper.openConnection();
+        logWriter.println("Opened transport connection");
         debuggeeWrapper.vmMirror.adjustTypeLength();
         logWriter.println("Adjusted VM-dependent type lengths");
-        logWriter.println("Opened connection");
     }
 
     /**
@@ -118,7 +140,7 @@
             } catch (Exception e) {
                 throw new TestErrorException(e);
             }
-            logWriter.println("Closed connection");
+            logWriter.println("Closed transport connection");
         }
     }
 
@@ -809,5 +831,4 @@
         checkReplyPacket(reply, "EventRequest::Clear command");
         assertAllDataRead(reply);
     }
-
 }

Added: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPUnitDebuggeeProcessWrapper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPUnitDebuggeeProcessWrapper.java?view=auto&rev=558788
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPUnitDebuggeeProcessWrapper.java (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPUnitDebuggeeProcessWrapper.java Mon Jul 23 09:18:27 2007
@@ -0,0 +1,308 @@
+/*
+ * 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 Vitaly A. Provodin
+ * @version $Revision: 1.4 $
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.share;
+
+import java.io.IOException;
+import java.util.Vector;
+
+import org.apache.harmony.jpda.tests.framework.LogWriter;
+import org.apache.harmony.jpda.tests.framework.StreamRedirector;
+import org.apache.harmony.jpda.tests.framework.TestErrorException;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPDebuggeeWrapper;
+import org.apache.harmony.jpda.tests.share.JPDATestOptions;
+
+/**
+ * This class provides basic DebuggeeWrapper implementation based on JUnit framework,
+ * which can launch and control debuggee process.
+ */
+public class JDWPUnitDebuggeeProcessWrapper extends JDWPDebuggeeWrapper {
+
+    /**
+     * Target VM debuggee process.
+     */
+    public Process process;
+
+    protected StreamRedirector errRedir;
+    protected StreamRedirector outRedir;
+
+    /**
+     * Creates new instance with given data.
+     * 
+     * @param settings
+     *            test run options
+     * @param logWriter
+     *            where to print log messages
+     */
+    public JDWPUnitDebuggeeProcessWrapper(JPDATestOptions settings, LogWriter logWriter) {
+        super(settings, logWriter);
+    }
+
+    /**
+     * Launches process and redirects output.
+     */
+    public void launchProcessAndRedirectors(String cmdLine) throws IOException {
+        logWriter.println("Launch process: " + cmdLine);
+        process = launchProcess(cmdLine);
+        logWriter.println("Launched process");
+        if (process != null) {
+            logWriter.println("Start redirectors");
+            errRedir = new StreamRedirector(process.getErrorStream(), logWriter, "STDERR");
+            errRedir.setDaemon(true);
+            errRedir.start();
+            outRedir = new StreamRedirector(process.getInputStream(), logWriter, "STDOUT");
+            outRedir.setDaemon(true);
+            outRedir.start();
+            logWriter.println("Started redirectors");
+        }
+    }
+
+    /**
+     * Waits for process to exit and closes uotput redirectors
+     */
+    public void finishProcessAndRedirectors() {
+        if (process != null) {
+            try {
+                logWriter.println("Waiting for process exit");
+                WaitForProcessExit(process);
+                logWriter.println("Finished process");
+            } catch (IOException e) {
+                throw new TestErrorException("IOException in waiting for process exit: ", e);
+            }
+
+            logWriter.println("Waiting for redirectors finish");
+            if (outRedir != null) {
+                outRedir.exit();
+                try {
+                    outRedir.join(settings.getTimeout());
+                } catch (InterruptedException e) {
+                    logWriter.println("InterruptedException in stopping outRedirector: " + e);
+                }
+                if (outRedir.isAlive()) {
+                    logWriter.println("WARNING: redirector not stopped: " + outRedir.getName());
+                }
+            }
+            if (errRedir != null) {
+                errRedir.exit();
+                try {
+                    errRedir.join(settings.getTimeout());
+                } catch (InterruptedException e) {
+                    logWriter.println("InterruptedException in stopping errRedirector: " + e);
+                }
+                if (errRedir.isAlive()) {
+                    logWriter.println("WARNING: redirector not stopped: " + errRedir.getName());
+                }
+            }
+            logWriter.println("Finished redirectors");
+        }
+    }
+
+    /**
+     * Launches process with given command line.
+     * 
+     * @param cmdLine
+     *            command line
+     * @return associated Process object or null if not available
+     * @throws IOException
+     *             if error occurred in launching process
+     */
+    protected Process launchProcess(String cmdLine) throws IOException {
+
+    	// Runtime.exec(String) does not preserve quoted arguments
+    	// process = Runtime.getRuntime().exec(cmdLine);
+
+    	String args[] = splitCommandLine(cmdLine);
+    	process = Runtime.getRuntime().exec(args);
+        return process;
+    }
+
+    /**
+     * Splits command line into arguments preserving spaces in quoted arguments
+     * either with single and double quotes (not prefixed by '\').
+     * 
+     * @param cmdLine
+     *            command line
+     * @return associated Process object or null if not available
+     * @throws IOException
+     *             if error occurred in launching process
+     */
+/*
+    public String[] splitCommandLine(String cmd) {
+
+        // allocate array for parsed arguments
+        int max_argc = 250;
+        Vector argv = new Vector();
+
+        // parse command line
+        int len = cmd.length();
+        if (len > 0) {
+            for (int arg = 0; arg < len;) {
+                // skip initial spaces
+                while (Character.isWhitespace(cmd.charAt(arg))) arg++;
+                // parse non-spaced or quoted argument 
+                for (int p = arg; ; p++) {
+                    // check for ending separator
+                    if (p >= len || Character.isWhitespace(cmd.charAt(p))) {
+                    	if (p > len) p = len;
+                    	String val = cmd.substring(arg, p);
+                        argv.add(val);
+                        arg = p + 1;
+                        break;
+                    }     
+
+                    // check for starting quote
+                    if (cmd.charAt(p) == '\"') {
+                         char quote = cmd.charAt(p++);
+                         // skip all chars until terminating quote or end of line
+                         for (; p < len; p++) {
+                             // check for terminating quote
+                             if (cmd.charAt(p) == quote) 
+                            	 break;
+                             // skip escaped quote
+                             if (cmd.charAt(p) == '\\' && (p+1) < len && cmd.charAt(p+1) == quote) 
+                            	 p++;
+                         }
+                     }
+
+                    // skip escaped quote
+                    if (cmd.charAt(p) == '\\' && (p+1) < len && cmd.charAt(p+1) == '\"') { 
+                    	p++;
+                    }
+                }
+            }
+        }
+
+    	logWriter.println("Splitted command line: " + argv);
+        int size = argv.size();
+        String args[] = new String[size];
+        return (String[])argv.toArray(args);
+	}
+*/
+    public String[] splitCommandLine(String cmd) {
+
+        int len = cmd.length();
+        char chars[] = new char[len];
+        Vector argv = new Vector();
+
+        if (len > 0) {
+            for (int arg = 0; arg < len;) {
+                // skip initial spaces
+                while (Character.isWhitespace(cmd.charAt(arg))) arg++;
+                // parse non-spaced or quoted argument 
+                for (int p = arg, i = 0; ; p++) {
+                    // check for starting quote
+                    if (p < len && (cmd.charAt(p) == '\"' || cmd.charAt(p) == '\'')) {
+                         char quote = cmd.charAt(p++);
+                         // copy all chars until terminating quote or end of line
+                         for (; p < len; p++) {
+                             // check for terminating quote
+                             if (cmd.charAt(p) == quote) { 
+                            	 p++;
+                            	 break;
+                             }
+                             // preserve escaped quote
+                             if (cmd.charAt(p) == '\\' && (p+1) < len && cmd.charAt(p+1) == quote) 
+                            	 p++;
+                             chars[i++] = cmd.charAt(p);
+                         }
+                     }
+
+                    // check for ending separator
+                    if (p >= len || Character.isWhitespace(cmd.charAt(p))) {
+                    	String val = new String(chars, 0, i);
+                        argv.add(val);
+                        arg = p + 1;
+                        break;
+                    }     
+
+                    // preserve escaped quote
+                    if (cmd.charAt(p) == '\\' && (p+1) < len 
+                    		&& (cmd.charAt(p+1) == '\"' || cmd.charAt(p+1) == '\'')) { 
+                    	p++;
+                    }
+
+                    // copy current char
+                    chars[i++] = cmd.charAt(p);
+                }
+            }
+        }
+
+    	logWriter.println("Splitted command line: " + argv);
+        int size = argv.size();
+        String args[] = new String[size];
+        return (String[])argv.toArray(args);
+	}
+
+    /**
+     * Waits for launched process to exit.
+     * 
+     * @param process
+     *            associated Process object or null if not available
+     * @throws IOException
+     *             if any exception occurs in waiting
+     */
+    protected void WaitForProcessExit(Process process) throws IOException {
+        ProcessWaiter thrd = new ProcessWaiter();
+        thrd.setDaemon(true);
+        thrd.start();
+        try {
+            thrd.join(settings.getTimeout());
+        } catch (InterruptedException e) {
+            throw new TestErrorException(e);
+        }
+
+        if (thrd.isAlive()) {
+            thrd.interrupt();
+        }
+
+        try {
+            int exitCode = process.exitValue();
+            logWriter.println("Finished debuggee with exit code: " + exitCode);
+        } catch (IllegalThreadStateException e) {
+            logWriter.printError("Terminate debugge process");
+            process.destroy();
+            throw new TestErrorException("Debuggee process did not finish during timeout", e);
+        }
+
+        // dispose any resources of the process
+        process.destroy();
+    }
+
+    /**
+     * Separate thread for waiting for process exit for specified timeout.
+     */
+    class ProcessWaiter extends Thread {
+        public void run() {
+            try {
+                process.waitFor();
+            } catch (InterruptedException e) {
+                logWriter.println("Ignoring exception in ProcessWaiter thread interrupted: " + e);
+            }
+        }
+    }
+
+    public void start() {
+    }
+
+    public void stop() {
+    }
+}

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPUnitDebuggeeProcessWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPUnitDebuggeeWrapper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPUnitDebuggeeWrapper.java?view=diff&rev=558788&r1=558787&r2=558788
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPUnitDebuggeeWrapper.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/jdwp/share/JDWPUnitDebuggeeWrapper.java Mon Jul 23 09:18:27 2007
@@ -28,9 +28,7 @@
 import java.io.IOException;
 
 import org.apache.harmony.jpda.tests.framework.LogWriter;
-import org.apache.harmony.jpda.tests.framework.StreamRedirector;
 import org.apache.harmony.jpda.tests.framework.TestErrorException;
-import org.apache.harmony.jpda.tests.framework.jdwp.JDWPDebuggeeWrapper;
 import org.apache.harmony.jpda.tests.framework.jdwp.TransportWrapper;
 import org.apache.harmony.jpda.tests.share.JPDATestOptions;
 
@@ -38,23 +36,14 @@
  * This class provides DebuggeeWrapper implementation based on JUnit framework.
  * Debuggee is always launched on local machine and attaches to debugger.
  */
-public class JDWPUnitDebuggeeWrapper extends JDWPDebuggeeWrapper {
-
-    /**
-     * Target VM debuggee process.
-     */
-    public Process process;
+public class JDWPUnitDebuggeeWrapper extends JDWPUnitDebuggeeProcessWrapper {
 
     /**
      * Auxiliary options passed to the target VM on its launch.
      */
     public String savedVMOptions = null;
 
-    StreamRedirector errRedir;
-
-    StreamRedirector outRedir;
-
-    TransportWrapper transport;
+    protected TransportWrapper transport;
 
     /**
      * Creates new instance with given data.
@@ -78,6 +67,7 @@
         String address = settings.getTransportAddress();
 
         if (isListenConnection) {
+            logWriter.println("Start listening on: " + address);
             try {
                 address = transport.startListening(address);
             } catch (IOException e) {
@@ -99,20 +89,10 @@
         logWriter.println("Launch: " + cmdLine);
 
         try {
-            process = launchProcess(cmdLine);
-            if (process != null) {
-                logWriter.println("Start redirectors");
-                errRedir = new StreamRedirector(process.getErrorStream(),
-                        logWriter, "STDERR");
-                errRedir.start();
-                outRedir = new StreamRedirector(process.getInputStream(),
-                        logWriter, "STDOUT");
-                outRedir.start();
-            }
+            launchProcessAndRedirectors(cmdLine);
+            logWriter.println("Launched debuggee process");
             openConnection();
-
-            logWriter.println("Established connection");
-
+            logWriter.println("Established transport connection");
         } catch (Exception e) {
             throw new TestErrorException(e);
         }
@@ -125,98 +105,19 @@
     public void stop() {
         disposeConnection();
 
-        if (process != null) {
-            logWriter.println("Waiting for debuggee exit");
-            try {
-                WaitForProcessExit(process);
-            } catch (IOException e) {
-                logWriter.println("IOException in stopping process: " + e);
-            }
-
-            logWriter.println("Waiting for redirectors");
-            if (outRedir != null) {
-                outRedir.exit();
-                try {
-                    outRedir.join(settings.getTimeout());
-                } catch (InterruptedException e) {
-                    logWriter
-                            .println("InterruptedException in stopping outRedirector: "
-                                    + e);
-                }
-            }
-            if (errRedir != null) {
-                errRedir.exit();
-                try {
-                    errRedir.join(settings.getTimeout());
-                } catch (InterruptedException e) {
-                    logWriter
-                            .println("InterruptedException in stopping errRedirector: "
-                                    + e);
-                }
-            }
-        }
+        finishProcessAndRedirectors();
 
         closeConnection();
         if (settings.isListenConnectorKind()) {
             try {
                 transport.stopListening();
             } catch (IOException e) {
-                logWriter
-                        .println("IOException in stopping transport listening: "
-                                + e);
+                logWriter.println("IOException in stopping transport listening: " + e);
             }
         }
     }
 
     /**
-     * Launches process with given command line.
-     * 
-     * @param cmdLine
-     *            command line
-     * @return associated Process object or null if not available
-     * @throws IOException
-     *             if error occurred in launching process
-     */
-    protected Process launchProcess(String cmdLine) throws IOException {
-        process = Runtime.getRuntime().exec(cmdLine);
-        return process;
-    }
-
-    /**
-     * Waits for launched process to exit.
-     * 
-     * @param process
-     *            associated Process object or null if not available
-     * @throws IOException
-     *             if any exception occurs in waiting
-     */
-    protected void WaitForProcessExit(Process process) throws IOException {
-        ProcessWaiter thrd = new ProcessWaiter();
-        thrd.start();
-        try {
-            thrd.join(settings.getTimeout());
-        } catch (InterruptedException e) {
-            throw new TestErrorException(e);
-        }
-
-        if (thrd.isAlive()) {
-            thrd.interrupt();
-        }
-
-        try {
-            int exitCode = process.exitValue();
-            logWriter.println("Finished debuggee with exit code: " + exitCode);
-        } catch (IllegalThreadStateException e) {
-            logWriter.printError("Enforced debuggee termination");
-            process.destroy();
-            throw new TestErrorException("Debuggee process did not finish during timeout", e);
-        }
-
-        // dispose any resources of the process
-        process.destroy();
-    }
-
-    /**
      * Opens connection with debuggee.
      */
     protected void openConnection() {
@@ -227,8 +128,7 @@
             } else {
                 String address = settings.getTransportAddress();
                 logWriter.println("Attaching for JDWP connection");
-                transport.attach(address, settings.getTimeout(), settings
-                        .getTimeout());
+                transport.attach(address, settings.getTimeout(), settings.getTimeout());
             }
             setConnection(transport);
         } catch (IOException e) {
@@ -245,9 +145,7 @@
             try {
                 vmMirror.dispose();
             } catch (Exception e) {
-                logWriter
-                        .println("Ignoring exception in disposing debuggee VM: "
-                                + e);
+                logWriter.println("Ignoring exception in disposing debuggee VM: " + e);
             }
         }
     }
@@ -260,23 +158,7 @@
             try {
                 vmMirror.closeConnection();
             } catch (IOException e) {
-                logWriter.println("Ignoring exception in closing connection: "
-                        + e);
-            }
-        }
-    }
-
-    /**
-     * Separate thread for waiting for process exit for specified timeout.
-     */
-    class ProcessWaiter extends Thread {
-        public void run() {
-            try {
-                process.waitFor();
-            } catch (InterruptedException e) {
-                logWriter
-                        .println("Ignoring exception in ProcessWaiter thread interrupted: "
-                                + e);
+                logWriter.println("Ignoring exception in closing connection: " + e);
             }
         }
     }

Modified: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/share/JPDADebuggeeSynchronizer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/share/JPDADebuggeeSynchronizer.java?view=diff&rev=558788&r1=558787&r2=558788
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/share/JPDADebuggeeSynchronizer.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/share/JPDADebuggeeSynchronizer.java Mon Jul 23 09:18:27 2007
@@ -47,17 +47,17 @@
 
     public final static String SGNL_CONTINUE = "continue";
 
-    private Socket clientSocket = null;
+    protected Socket clientSocket = null;
 
-    private ServerSocket serverSocket = null;
+    protected ServerSocket serverSocket = null;
 
-    private DataOutputStream out;
+    protected DataOutputStream out;
 
-    private DataInputStream in;
+    protected DataInputStream in;
 
-    private TestOptions settings;
+    protected TestOptions settings;
 
-    private LogWriter logWriter;
+    protected LogWriter logWriter;
 
     /**
      * A constructor that initializes an instance of the class with specified
@@ -123,9 +123,9 @@
     public synchronized String receiveMessage() {
         String msg;
         try {
-            logWriter.println("[SYNC] Waiting...");
+            logWriter.println("[SYNC] Waiting for any messsage");
             msg = in.readUTF();
-            logWriter.println("[SYNC] received message: " + msg);
+            logWriter.println("[SYNC] Received message: " + msg);
         } catch (EOFException e) {
             return null;
         } catch (IOException e) {
@@ -142,13 +142,12 @@
     public synchronized String receiveMessageWithoutException(String invoker) {
         String msg;
         try {
-            logWriter.println("[SYNC] Waiting...");
+            logWriter.println("[SYNC] Waiting for any message");
             msg = in.readUTF();
             logWriter.println("[SYNC] Received message: " + msg);
         } catch (Throwable thrown) {
             if (invoker != null) {
-                logWriter
-                        .println("#### receiveMessageWithoutException: Exception occurred:");
+                logWriter.println("#### receiveMessageWithoutException: Exception occurred:");
                 logWriter.println("#### " + thrown);
                 logWriter.println("#### Invoker = " + invoker);
             }
@@ -158,12 +157,21 @@
     }
 
     /**
+     * Returns socket port to be used for connection.
+     * 
+     * @return port number
+     */
+    public int getSyncPortNumber() {
+        return settings.getSyncPortNumber();
+    }
+
+    /**
      * Binds server to listen socket port.
      * 
      * @return port number
      */
     public synchronized int bindServer() {
-        int port = settings.getSyncPortNumber();
+        int port = getSyncPortNumber();
         try {
             logWriter.println("[SYNC] Binding socket on port: " + port);
             serverSocket = new ServerSocket(port);
@@ -202,10 +210,9 @@
     public synchronized void startClient() {
         long timeout = settings.getTimeout();
         String host = "localhost";
-        int port = settings.getSyncPortNumber();
+        int port = getSyncPortNumber();
         try {
-            logWriter.println("[SYNC] Attaching socket to: " + host + ":"
-                    + port);
+            logWriter.println("[SYNC] Attaching socket to: " + host + ":" + port);
             clientSocket = new Socket(host, port);
             logWriter.println("[SYNC] Attached socket");
 
@@ -214,8 +221,7 @@
             in = new DataInputStream(clientSocket.getInputStream());
         } catch (IOException e) {
             throw new TestErrorException(
-                    "[SYNC] Exception in attaching for socket sync connection",
-                    e);
+                    "[SYNC] Exception in attaching for socket sync connection", e);
         }
     }
 
@@ -234,9 +240,8 @@
             if (serverSocket != null)
                 serverSocket.close();
         } catch (IOException e) {
-            logWriter
-                    .println("[SYNC] Ignoring exception in closing socket sync connection: "
-                            + e);
+            logWriter.println
+                    ("[SYNC] Ignoring exception in closing socket sync connection: " + e);
         }
         logWriter.println("[SYNC] Closed socket");
     }

Modified: harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/share/SyncDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/share/SyncDebuggee.java?view=diff&rev=558788&r1=558787&r2=558788
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/share/SyncDebuggee.java (original)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/test/common/unit/org/apache/harmony/jpda/tests/share/SyncDebuggee.java Mon Jul 23 09:18:27 2007
@@ -41,8 +41,15 @@
      */
     public void onStart() {
         super.onStart();
-        synchronizer = new JPDADebuggeeSynchronizer(logWriter, settings);
+        synchronizer = createSynchronizer();
         synchronizer.startClient();
+    }
+
+    /**
+     * Creates wrapper for synchronization channel.
+     */
+    protected JPDADebuggeeSynchronizer createSynchronizer() {
+        return new JPDADebuggeeSynchronizer(logWriter, settings);
     }
 
     /**