Bug 547417 - trying to fix 180 test fails

- doubled timeout time for opening connection
- fail the test if the connection is timed out
- added printStackTrace() in all cases where it was missing

Change-Id: Icb97c5d3f9977adf174b81fbe04911ca55246593
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationSetup.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationSetup.java
index 1be5324..8153472 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationSetup.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationSetup.java
@@ -13,6 +13,8 @@
  *******************************************************************************/
 package org.eclipse.jdt.core.tests.eval;
 
+import static org.junit.Assert.assertTrue;
+
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -56,31 +58,39 @@
 					launcher.setEvalTargetPath(EVAL_DIRECTORY);
 					this.launchedVM = launcher.launch();
 				} catch (TargetException e) {
-					throw new Error(e.getMessage());
+					e.printStackTrace();
+					throw new Error(e.getMessage(), e);
 				}
-	
+
 				// Thread that read the stout of the VM so that the VM doesn't block
 				try {
 					startReader("VM's stdout reader", this.launchedVM.getInputStream(), System.out);
 				} catch (TargetException e) {
+					e.printStackTrace();
 				}
-	
+
 				// Thread that read the sterr of the VM so that the VM doesn't block
 				try {
 					startReader("VM's sterr reader", this.launchedVM.getErrorStream(), System.err);
 				} catch (TargetException e) {
+					e.printStackTrace();
 				}
-	
+
 				// Create context
 				this.context = new EvaluationContext();
-	
+
 				// Create target
 				this.target = new TargetInterface();
-				this.target.connect(server, 30000); // allow 30s max to connect (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=188127)
-	
+				// allow 30s max to connect (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=188127)
+				// Increased to 60 s for https://bugs.eclipse.org/bugs/show_bug.cgi?id=547417
+				this.target.connect(server, 60000); 
+				
+				assertTrue("Failed to connect VM server", this.target.isConnected());
+
 				// Create name environment
 				this.env = new FileSystem(Util.getJavaClassLibs(), new String[0], null);
 			} catch (IOException e1) {
+				e1.printStackTrace();
 				throw new Error("Failed to open socket", e1);
 			}
 		}
@@ -105,7 +115,7 @@
 		}).start();
 	}
 
-	protected void tearDown() {
+	final protected void tearDown() {
 		if (this.context != null) {
 			LocalVirtualMachine vm = this.launchedVM;
 			if (vm != null) {
@@ -125,7 +135,8 @@
 					}
 					this.context = null;
 				} catch (TargetException e) {
-					throw new Error(e.getMessage());
+					e.printStackTrace();
+					throw new Error(e.getMessage(), e);
 				}
 			}
 		}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/TargetInterface.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/TargetInterface.java
index 242e05d..8453a92 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/TargetInterface.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/TargetInterface.java
@@ -69,6 +69,7 @@
 				this.socket.setTcpNoDelay(true);
 				break;
 			} catch (IOException e) {
+				e.printStackTrace();
 			}
 			if (this.socket == null) {
 				try {
@@ -88,6 +89,7 @@
 		try {
 			this.socket.close();
 		} catch (IOException e) {
+			e.printStackTrace();
 			// Already closed. Nothing more to do
 		}
 		this.socket = null;
@@ -141,7 +143,7 @@
 /**
  * Returns whether this interface is connected to the target.
  */
-boolean isConnected() {
+public boolean isConnected() {
 	return this.socket != null;
 }
 /**
@@ -156,6 +158,7 @@
 				try {
 					Util.writeToDisk(true, "d:\\eval\\snippets", className, classes[0]);
 				} catch(IOException e) {
+					e.printStackTrace();
 				}
 			} else {
 				String dirName;
@@ -167,6 +170,7 @@
 				try {
 					Util.writeToDisk(true, dirName, className, classes[i]);
 				} catch(IOException e) {
+					e.printStackTrace();
 				}
 			}
 		}
@@ -187,6 +191,7 @@
 				out.write(classDefinition);
 			}
 		} catch (IOException e) {
+			e.printStackTrace();
 			// The socket has likely been closed on the other end. So the code snippet runner has stopped.
 			disconnect();
 		}