Fixing javax.net.ssl test failures on RI

vogar wasn't working at checkin on the host so I couldn't easily
retest these changes that came from the code review. Sure enought
there were some problems.

   SSLSocketTest now uses a condition variable to synchronize between
   the HandshakeCompletedListener and the main thread since the RI
   does the callback asynchronously.

   Back to ussing Arrays.equals for comparing Session ID byte[] since
   Object.equals does not work.

Change-Id: I667b60dc065438efe4e3728d7a44b446ebc15e64
diff --git a/libcore/luni/src/test/java/javax/net/ssl/SSLSessionContextTest.java b/libcore/luni/src/test/java/javax/net/ssl/SSLSessionContextTest.java
index 4b4ab6a..83ed9c9 100644
--- a/libcore/luni/src/test/java/javax/net/ssl/SSLSessionContextTest.java
+++ b/libcore/luni/src/test/java/javax/net/ssl/SSLSessionContextTest.java
@@ -44,7 +44,7 @@
         byte[] serverId = (byte[]) serverIds.nextElement();
         assertEquals(32, clientId.length);
         assertEquals(32, serverId.length);
-        assertEquals(clientId, serverId);
+        assertTrue(Arrays.equals(clientId, serverId));
     }
 
     @KnownFailure("Should throw NullPointerException on getSession(null)")
@@ -65,8 +65,8 @@
         byte[] serverId = (byte[]) server.getIds().nextElement();
         assertNotNull(client.getSession(clientId));
         assertNotNull(server.getSession(serverId));
-        assertEquals(clientId, client.getSession(clientId).getId());
-        assertEquals(serverId, server.getSession(serverId).getId());
+        assertTrue(Arrays.equals(clientId, client.getSession(clientId).getId()));
+        assertTrue(Arrays.equals(serverId, server.getSession(serverId).getId()));
     }
 
     @KnownFailure("Should return 0 for unlimited, not 10 entries")
diff --git a/libcore/luni/src/test/java/javax/net/ssl/SSLSessionTest.java b/libcore/luni/src/test/java/javax/net/ssl/SSLSessionTest.java
index 52ae279..020cd41 100644
--- a/libcore/luni/src/test/java/javax/net/ssl/SSLSessionTest.java
+++ b/libcore/luni/src/test/java/javax/net/ssl/SSLSessionTest.java
@@ -112,7 +112,7 @@
         assertEquals(0, s.invalid.getId().length);
         assertEquals(32, s.server.getId().length);
         assertEquals(32, s.client.getId().length);
-        assertEquals(s.server.getId(), s.client.getId());
+        assertTrue(Arrays.equals(s.server.getId(), s.client.getId()));
     }
 
     public void test_SSLSession_getLastAccessedTime() {
diff --git a/libcore/luni/src/test/java/javax/net/ssl/SSLSocketTest.java b/libcore/luni/src/test/java/javax/net/ssl/SSLSocketTest.java
index 0e39d47..d02aeee 100644
--- a/libcore/luni/src/test/java/javax/net/ssl/SSLSocketTest.java
+++ b/libcore/luni/src/test/java/javax/net/ssl/SSLSocketTest.java
@@ -353,6 +353,10 @@
                     assertNotNull(socket);
                     assertSame(client, socket);
 
+                    synchronized (handshakeCompletedListenerCalled) {
+                        handshakeCompletedListenerCalled[0] = true;
+                        handshakeCompletedListenerCalled.notify();
+                    }
                     handshakeCompletedListenerCalled[0] = true;
                 } catch (RuntimeException e) {
                     throw e;
@@ -362,8 +366,12 @@
             }
         });
         client.startHandshake();
-        assertTrue(handshakeCompletedListenerCalled[0]);
         thread.join();
+        synchronized (handshakeCompletedListenerCalled) {
+            while (!handshakeCompletedListenerCalled[0]) {
+                handshakeCompletedListenerCalled.wait();
+            }
+        }
     }
 
     /**