Fixed up so that while in callbacks, calling remote vm will result
in using same thread as doing the callback. Also added
callbackWithConstants as a callback type.
diff --git a/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/proxy/TestCallback.java b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/proxy/TestCallback.java
index be6ee4c..3cd4f47 100644
--- a/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/proxy/TestCallback.java
+++ b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/proxy/TestCallback.java
@@ -11,7 +11,7 @@
  *******************************************************************************/
 /*
  *  $RCSfile: TestCallback.java,v $
- *  $Revision: 1.1 $  $Date: 2003/10/27 17:25:46 $ 
+ *  $Revision: 1.2 $  $Date: 2004/02/04 21:25:31 $ 
  */
 
 import org.eclipse.jem.internal.proxy.core.*;
@@ -24,6 +24,8 @@
 public class TestCallback implements ICallback {
 	
 	Object tester;
+	ProxyFactoryRegistry registry;
+	
 	int counter = 0;
 	
 	/**
@@ -46,8 +48,9 @@
 	
 	// Normally the callback doesn't determine when to stop 
 	// the callback proxy. But for this test it does.
-	public TestCallback(Object t) {
+	public TestCallback(Object t, ProxyFactoryRegistry registry) {
 		tester = t;
+		this.registry = registry;
 	}
 	
 	public Object calledBack(int msgID, IBeanProxy parm){
@@ -55,7 +58,11 @@
 			if (stoppedTest)
 				return null;	// We've already stopped, don't do anymore.
 		}
-		if (parm instanceof IIntegerBeanProxy) {
+		
+		if (msgID != 0) {
+			badMsg = "Msgid " + msgID + " is incorrect. It should be zero.";
+			stopTest();
+		} else if (parm instanceof IIntegerBeanProxy) {
 			int pv = ((IIntegerBeanProxy) parm).intValue();
 			if (++counter != pv) {
 				badParmValue = pv;
@@ -73,11 +80,39 @@
 		}
 		return null;
 	}
+	
+	public Object calledBack(int msgID, Object parm) {
+		if (msgID != 1) {
+			badMsg = "Msgid " + msgID + " is incorrect. It should be one.";
+			stopTest();
+		} else if (parm instanceof Integer){
+			// We are going to use the registry to see what thread id is running when we call into it.
+			IMethodProxy currentThreadMethod = registry.getMethodProxyFactory().getMethodProxy("java.lang.Thread", "currentThread", null);
+			IBeanProxy thread = currentThreadMethod.invokeCatchThrowableExceptions(null);
+			IMethodProxy hashcodeMethod = registry.getMethodProxyFactory().getMethodProxy("java.lang.Object", "hashCode", null);
+			IBeanProxy threadID = hashcodeMethod.invokeCatchThrowableExceptions(thread);
+			if (threadID instanceof INumberBeanProxy) {
+				if (!parm.equals(((INumberBeanProxy) threadID).numberValue())) {
+					badMsg = "ThreadID returned from call not match parm sent it. Means callback not on same thread.";
+					stopTest();
+				}
+			} else {
+				badMsg = "ThreadID returned from call is not valid.";
+				stopTest();
+			}
+		} else {
+			badMsg = "Parm is invalid for calledBack with Object";
+			stopTest();
+		}
+		return null;
+	}
+	
 	public Object calledBack(int msgID, Object[] parms){
 		badMsg = "Failed Callback Test. Shouldn't have gotton to multi-parms"; //$NON-NLS-1$
 		stopTest();
 		return null;
 	}
+	
 	public void calledBackStream(int msgID, InputStream in){
 		badMsg = "Failed Callback Test. Shouldn't have gotton to input stream"; //$NON-NLS-1$
 		stopTest();
diff --git a/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/proxy/TestCallbackStream.java b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/proxy/TestCallbackStream.java
index 9bac761..a15fa49 100644
--- a/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/proxy/TestCallbackStream.java
+++ b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/proxy/TestCallbackStream.java
@@ -11,7 +11,7 @@
  *******************************************************************************/
 /*
  *  $RCSfile: TestCallbackStream.java,v $
- *  $Revision: 1.1 $  $Date: 2003/10/27 17:25:46 $ 
+ *  $Revision: 1.2 $  $Date: 2004/02/04 21:25:31 $ 
  */
 
 import org.eclipse.jem.internal.proxy.core.*;
@@ -42,7 +42,12 @@
 			throw exp;
 		TestCase.assertTrue(testSuccesful);
 	}
-	
+
+	public Object calledBack(int msgID, Object  parm){
+		badMsg = "Failed Callback Test. Shouldn't have gotton to object parm"; //$NON-NLS-1$
+		stopTest();
+		return null;
+	}
 	public Object calledBack(int msgID, IBeanProxy parm){
 		badMsg = "Failed Callback Test. Shouldn't have gotton to parm"; //$NON-NLS-1$
 		stopTest();
diff --git a/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/proxy/TestStandard.java b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/proxy/TestStandard.java
index e46a371..bd67dc0 100644
--- a/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/proxy/TestStandard.java
+++ b/tests/org.eclipse.jem.tests/javatests/org/eclipse/jem/tests/proxy/TestStandard.java
@@ -11,7 +11,7 @@
  *******************************************************************************/
 /*
  *  $RCSfile: TestStandard.java,v $
- *  $Revision: 1.2 $  $Date: 2003/10/27 17:32:36 $ 
+ *  $Revision: 1.3 $  $Date: 2004/02/04 21:25:31 $ 
  */
 import java.io.IOException;
 
@@ -391,7 +391,7 @@
 		assertNotNull(callbackType);
 		Object testObject = new Object();
 		IBeanProxy callbackProxy = callbackType.newInstance();
-		TestCallback cb = new TestCallback(testObject);
+		TestCallback cb = new TestCallback(testObject, registry);
 		registry.getCallbackRegistry().registerCallback(callbackProxy, cb);
 		IMethodProxy start = callbackType.getMethodProxy("start");	//$NON-NLS-1$
 		IMethodProxy stop = callbackType.getMethodProxy("stop");	//$NON-NLS-1$
diff --git a/tests/org.eclipse.jem.tests/vm_tests/org/eclipse/jem/tests/proxy/vm/TestCallback.java b/tests/org.eclipse.jem.tests/vm_tests/org/eclipse/jem/tests/proxy/vm/TestCallback.java
index f605d29..90e94cf 100644
--- a/tests/org.eclipse.jem.tests/vm_tests/org/eclipse/jem/tests/proxy/vm/TestCallback.java
+++ b/tests/org.eclipse.jem.tests/vm_tests/org/eclipse/jem/tests/proxy/vm/TestCallback.java
@@ -11,7 +11,7 @@
  *******************************************************************************/
 /*
  *  $RCSfile: TestCallback.java,v $
- *  $Revision: 1.1 $  $Date: 2003/10/27 17:25:46 $ 
+ *  $Revision: 1.2 $  $Date: 2004/02/04 21:25:31 $ 
  */
 
 import org.eclipse.jem.internal.proxy.common.*;
@@ -31,6 +31,20 @@
 	public void start() {
 		new Thread(new Runnable() {
 			public void run() {
+				// First send back test for IDE calling back on same thread. We do this by sending the thread id
+				// as a constant and the other side will then call back to remote, ask for the thread id, and
+				// see if it matches.
+				try {
+					vmServer.doCallback(new ICallbackRunnable() {
+						public Object run(ICallbackHandler handler) throws CommandException {
+							return handler.callbackAsConstants(callbackID, 1, new Integer(Thread.currentThread().hashCode()));
+						}
+					});
+					
+				} catch (CommandException e) {
+				}
+				
+				// Now do the regular testing.
 				final Integer[] p = new Integer[] {new Integer(0)};
 				while(!stop) {
 					try {