SSLEngineTest: set up server instead of using anon

This test was relying on "anon" cipher suites so that it didn't have to
do any complicated setup of the server certificate store. Fortunately we
already have a utility class we can use that does this setup for us so
there is no need to rely on anonymous cipher suites that do no
authentication.

(cherry picked from commit 5be4c97a83895b7e1385445db6a1717eb8df3e9b)

Bug: 21195269
Change-Id: I30bf4cd3b99bf946887cca293d616021cfce1bd7
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLEngineTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLEngineTest.java
index 8f68d6e..9360c00 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLEngineTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLEngineTest.java
@@ -36,6 +36,7 @@
 import javax.net.ssl.SSLEngineResult.HandshakeStatus;
 import junit.framework.TestCase;
 import libcore.java.security.StandardNames;
+import libcore.javax.net.ssl.TestSSLContext;
 
 /**
  * Tests for SSLEngine class
@@ -1042,21 +1043,12 @@
 
         private ByteBuffer writeBuffer;
 
-        HandshakeHandler(boolean clientMode, SourceChannel in, SinkChannel out) throws Exception {
+        HandshakeHandler(SSLContext context, boolean clientMode, SourceChannel in, SinkChannel out)
+                throws Exception {
             this.in = in;
             this.out = out;
-            engine = getEngine();
+            engine = context.createSSLEngine();
             engine.setUseClientMode(clientMode);
-            String[] cipherSuites = engine.getSupportedCipherSuites();
-            Set<String> enabledSuites = new HashSet<String>();
-            for (String cipherSuite : cipherSuites) {
-                if (cipherSuite.contains("anon")) {
-                    enabledSuites.add(cipherSuite);
-                }
-            }
-            engine.setEnabledCipherSuites((String[]) enabledSuites.toArray(
-                    new String[enabledSuites.size()]));
-
             engine.beginHandshake();
             status = engine.getHandshakeStatus();
 
@@ -1179,8 +1171,9 @@
         SinkChannel serverSink = serverSendPipe.sink();
         SourceChannel clientSource = serverSendPipe.source();
 
-        clientEngine = new HandshakeHandler(true, clientSource, clientSink);
-        serverEngine = new HandshakeHandler(false, serverSource, serverSink);
+        TestSSLContext context = TestSSLContext.create();
+        clientEngine = new HandshakeHandler(context.clientContext, true, clientSource, clientSink);
+        serverEngine = new HandshakeHandler(context.serverContext, false, serverSource, serverSink);
     }
 
     boolean doHandshake() throws InterruptedException {