harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r428708 - in /incubator/harmony/enhanced/classlib/trunk/modules/x-net: ./ src/test/impl/java.injected/org/ src/test/impl/java.injected/org/apache/ src/test/impl/java.injected/org/apache/harmony/ src/test/impl/java.injected/org/apache/harmon...
Date Fri, 04 Aug 2006 12:39:36 GMT
Author: tellison
Date: Fri Aug  4 05:39:35 2006
New Revision: 428708

URL: http://svn.apache.org/viewvc?rev=428708&view=rev
Log:
Apply patch HARMONY-1068 ([classlib][x-net] JSSE provider testing)

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateMessageTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateRequestTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateVerifyTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientHelloTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientKeyExchangeTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerHelloTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerKeyExchangeTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/FinishedTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/HelloRequestTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/ServerHelloDoneTest.java   (with props)
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/.classpath
    incubator/harmony/enhanced/classlib/trunk/modules/x-net/build.xml

Modified: incubator/harmony/enhanced/classlib/trunk/modules/x-net/.classpath
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/x-net/.classpath?rev=428708&r1=428707&r2=428708&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/x-net/.classpath (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/x-net/.classpath Fri Aug  4 05:39:35 2006
@@ -1,8 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry output="bin/main" kind="src" path="src/main/java"/>
-	<classpathentry output="bin/test" kind="src" path="src/test/java"/>
+	<classpathentry output="bin/test/impl.injected" kind="src" path="src/test/impl/java.injected"/>
+	<classpathentry output="bin/test/impl" kind="src" path="src/test/impl/java"/>
+	<classpathentry output="bin/test/api" kind="src" path="src/test/api/java"/>
+	<classpathentry output="bin/test/api" kind="src" path="src/test/java"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry sourcepath="JUNIT_SRC_HOME/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/>
-	<classpathentry kind="output" path="bin"/>
+	<classpathentry kind="output" path="bin/main"/>
 </classpath>

Modified: incubator/harmony/enhanced/classlib/trunk/modules/x-net/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/x-net/build.xml?rev=428708&r1=428707&r2=428708&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/x-net/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/x-net/build.xml Fri Aug  4 05:39:35 2006
@@ -91,6 +91,7 @@
         <compile-tests description="api tests" destdir="${hy.x-net.bin.test}/api">
             <javac-elements>
                 <src path="${hy.x-net.src.test}/api/java"/>
+                <src path="${hy.x-net.src.test}/java"/>
                 <include name="**/*Test.java" />
             </javac-elements>
         </compile-tests>
@@ -101,6 +102,13 @@
                 <include name="**/*Test.java" />
             </javac-elements>
         </compile-tests>
+    	
+        <compile-tests description="impl tests" destdir="${hy.x-net.bin.test}/impl">
+            <javac-elements>
+                <src path="${hy.x-net.src.test}/impl/java"/>
+                <include name="**/*Test.java" />
+            </javac-elements>
+        </compile-tests>
     </target>
 
     <target name="run.tests" depends="run.tests.api, run.tests.impl" />
@@ -130,6 +138,21 @@
     </target>
 
     <target name="run.tests.impl" unless="test.noimpl">
+        <run-tests description="impl tests">
+            <junit-elements>
+                <classpath>
+                    <pathelement path="${hy.x-net.bin.test}/impl"/>
+                    <pathelement path="${hy.hdk}/build/test/support.jar" />
+                </classpath>
+            	
+                <batchtest todir="${hy.tests.reports}" haltonfailure="no" unless="test.case">
+                    <fileset dir="${hy.x-net.src.test}/impl/java">
+                        <include name="**/*Test.java"/>
+                    </fileset>
+                </batchtest>
+
+            </junit-elements>
+        </run-tests>
         <run-tests description="impl injected tests">
             <junit-elements>
                 <!-- to pick up junit.jar               -->

Added: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateMessageTest.java?rev=428708&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateMessageTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateMessageTest.java Fri Aug  4 05:39:35 2006
@@ -0,0 +1,107 @@
+package org.apache.harmony.xnet.provider.jsse;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>CertificateMessage</code> constructor and methods
+ *  
+ */
+public class CertificateMessageTest extends TestCase {
+
+	private static String base64certEncoding = "-----BEGIN CERTIFICATE-----\n"
+			+ "MIIC+jCCAragAwIBAgICAiswDAYHKoZIzjgEAwEBADAdMRswGQYDVQQKExJDZXJ0a"
+			+ "WZpY2F0ZSBJc3N1ZXIwIhgPMTk3MDAxMTIxMzQ2NDBaGA8xOTcwMDEyNDAzMzMyMF"
+			+ "owHzEdMBsGA1UEChMUU3ViamVjdCBPcmdhbml6YXRpb24wGTAMBgcqhkjOOAQDAQE"
+			+ "AAwkAAQIDBAUGBwiBAgCqggIAVaOCAhQwggIQMA8GA1UdDwEB/wQFAwMBqoAwEgYD"
+			+ "VR0TAQH/BAgwBgEB/wIBBTAUBgNVHSABAf8ECjAIMAYGBFUdIAAwZwYDVR0RAQH/B"
+			+ "F0wW4EMcmZjQDgyMi5OYW1lggdkTlNOYW1lpBcxFTATBgNVBAoTDE9yZ2FuaXphdG"
+			+ "lvboYaaHR0cDovL3VuaWZvcm0uUmVzb3VyY2UuSWSHBP///wCIByoDolyDsgMwDAY"
+			+ "DVR0eAQH/BAIwADAMBgNVHSQBAf8EAjAAMIGZBgNVHSUBAf8EgY4wgYsGBFUdJQAG"
+			+ "CCsGAQUFBwMBBggrBgEFBQcDAQYIKwYBBQUHAwIGCCsGAQUFBwMDBggrBgEFBQcDB"
+			+ "AYIKwYBBQUHAwUGCCsGAQUFBwMGBggrBgEFBQcDBwYIKwYBBQUHAwgGCCsGAQUFBw"
+			+ "MJBggrBgEFBQgCAgYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GA1UdNgEB/wQDAgE"
+			+ "BMA4GBCpNhgkBAf8EAwEBATBkBgNVHRIEXTBbgQxyZmNAODIyLk5hbWWCB2ROU05h"
+			+ "bWWkFzEVMBMGA1UEChMMT3JnYW5pemF0aW9uhhpodHRwOi8vdW5pZm9ybS5SZXNvd"
+			+ "XJjZS5JZIcE////AIgHKgOiXIOyAzAJBgNVHR8EAjAAMAoGA1UdIwQDAQEBMAoGA1"
+			+ "UdDgQDAQEBMAoGA1UdIQQDAQEBMAwGByqGSM44BAMBAQADMAAwLQIUAL4QvoazNWP"
+			+ "7jrj84/GZlhm09DsCFQCBKGKCGbrP64VtUt4JPmLjW1VxQA==\n"
+			+ "-----END CERTIFICATE-----\n";
+
+	/*
+	 * Test for CertificateMessage(null) and
+	 * CertificateMessage(HandshakeIODataStream, int)
+	 */
+	public void testCertificateMessage1() throws Exception {
+
+		CertificateMessage message = new CertificateMessage(null);
+        assertEquals("incorrect type", Handshake.CERTIFICATE, message.getType());
+        assertEquals("incorrect message", 3, message.length());
+        assertEquals("incorrect message", 0, message.certs.length);
+
+		HandshakeIODataStream out = new HandshakeIODataStream();
+		message.send(out);
+		byte[] encoded = out.getData(1000);
+        assertEquals("incorrect out data length", message.length(), encoded.length);
+
+		HandshakeIODataStream in = new HandshakeIODataStream();
+		in.append(encoded);
+        
+		CertificateMessage message_2 = new CertificateMessage(in, message.length());
+        assertEquals("incorrect message_2", 3, message_2.length());
+        assertEquals("incorrect message_2", 0, message_2.certs.length);
+	}
+
+	/*
+	 * Test for void CertificateMessage(X509Certificate[]),
+	 * CertificateMessage(HandshakeIODataStream, int)
+	 */
+	public void testCertificateMessage2() throws Exception {
+		CertificateFactory certFactory = CertificateFactory.getInstance("X509");
+
+		ByteArrayInputStream bais = new ByteArrayInputStream(base64certEncoding
+				.getBytes());
+		X509Certificate cert = (X509Certificate) certFactory.generateCertificate(bais);
+		CertificateMessage message = new CertificateMessage(
+				new X509Certificate[] { cert });
+        assertEquals("incorrect type", Handshake.CERTIFICATE, message.getType());
+
+        assertTrue("incorrect cert encoding", Arrays.equals(message.certs[0]
+                .getEncoded(), cert.getEncoded()));
+
+		HandshakeIODataStream out = new HandshakeIODataStream();
+		message.send(out);
+		byte[] encoded = out.getData(1000);
+        assertEquals("incorrect out data length", message.length(), encoded.length);
+
+		HandshakeIODataStream in = new HandshakeIODataStream();
+		in.append(encoded);
+		CertificateMessage message_2 = new CertificateMessage(in, message.length());
+        assertEquals("Incorrect message decoding", message.certs.length, message_2.certs.length);
+        assertTrue("incorrect cert encoding", Arrays.equals(message.certs[0]
+                .getEncoded(), message_2.certs[0].getEncoded()));
+
+		in.append(encoded);
+		try {
+			message_2 = new CertificateMessage(in, message.length() - 1);
+			fail("Small length: No expected AlertException");
+		} catch (AlertException e) {
+		}
+
+		in.append(encoded);
+		in.append(new byte[] { 1, 2, 3 });
+		try {
+			message_2 = new CertificateMessage(in, message.length() + 3);
+			fail("Extra bytes: No expected AlertException ");
+		} catch (AlertException e) {
+		}
+	}
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateRequestTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateRequestTest.java?rev=428708&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateRequestTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateRequestTest.java Fri Aug  4 05:39:35 2006
@@ -0,0 +1,87 @@
+package org.apache.harmony.xnet.provider.jsse;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.Arrays;
+
+import javax.security.auth.x500.X500Principal;
+
+import junit.framework.TestCase;
+
+/**
+ * Test for <code>CertificateRequest</code> constructors and methods
+ *  
+ */
+public class CertificateRequestTest extends TestCase {
+
+    private static String base64certEncoding = "-----BEGIN CERTIFICATE-----\n"
+            + "MIIC+jCCAragAwIBAgICAiswDAYHKoZIzjgEAwEBADAdMRswGQYDVQQKExJDZXJ0a"
+            + "WZpY2F0ZSBJc3N1ZXIwIhgPMTk3MDAxMTIxMzQ2NDBaGA8xOTcwMDEyNDAzMzMyMF"
+            + "owHzEdMBsGA1UEChMUU3ViamVjdCBPcmdhbml6YXRpb24wGTAMBgcqhkjOOAQDAQE"
+            + "AAwkAAQIDBAUGBwiBAgCqggIAVaOCAhQwggIQMA8GA1UdDwEB/wQFAwMBqoAwEgYD"
+            + "VR0TAQH/BAgwBgEB/wIBBTAUBgNVHSABAf8ECjAIMAYGBFUdIAAwZwYDVR0RAQH/B"
+            + "F0wW4EMcmZjQDgyMi5OYW1lggdkTlNOYW1lpBcxFTATBgNVBAoTDE9yZ2FuaXphdG"
+            + "lvboYaaHR0cDovL3VuaWZvcm0uUmVzb3VyY2UuSWSHBP///wCIByoDolyDsgMwDAY"
+            + "DVR0eAQH/BAIwADAMBgNVHSQBAf8EAjAAMIGZBgNVHSUBAf8EgY4wgYsGBFUdJQAG"
+            + "CCsGAQUFBwMBBggrBgEFBQcDAQYIKwYBBQUHAwIGCCsGAQUFBwMDBggrBgEFBQcDB"
+            + "AYIKwYBBQUHAwUGCCsGAQUFBwMGBggrBgEFBQcDBwYIKwYBBQUHAwgGCCsGAQUFBw"
+            + "MJBggrBgEFBQgCAgYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GA1UdNgEB/wQDAgE"
+            + "BMA4GBCpNhgkBAf8EAwEBATBkBgNVHRIEXTBbgQxyZmNAODIyLk5hbWWCB2ROU05h"
+            + "bWWkFzEVMBMGA1UEChMMT3JnYW5pemF0aW9uhhpodHRwOi8vdW5pZm9ybS5SZXNvd"
+            + "XJjZS5JZIcE////AIgHKgOiXIOyAzAJBgNVHR8EAjAAMAoGA1UdIwQDAQEBMAoGA1"
+            + "UdDgQDAQEBMAoGA1UdIQQDAQEBMAwGByqGSM44BAMBAQADMAAwLQIUAL4QvoazNWP"
+            + "7jrj84/GZlhm09DsCFQCBKGKCGbrP64VtUt4JPmLjW1VxQA==\n"
+            + "-----END CERTIFICATE-----\n";
+
+public void testCertificateRequest() throws Exception {
+
+        CertificateFactory certFactory = CertificateFactory.getInstance("X509");
+        ByteArrayInputStream bais = new ByteArrayInputStream(base64certEncoding
+                .getBytes());
+        X509Certificate cert = (X509Certificate) certFactory.generateCertificate(bais);
+        X509Certificate[] accepted = {cert};
+        X500Principal[] certificate_authorities = {cert.getIssuerX500Principal()};
+        
+        byte[] certificate_types = new byte[] { CertificateRequest.RSA_SIGN,
+                CertificateRequest.RSA_FIXED_DH };
+        CertificateRequest message = new CertificateRequest(certificate_types,
+                accepted);
+        assertEquals("incorrect type", Handshake.CERTIFICATE_REQUEST, message
+                .getType());
+        assertTrue("incorrect CertificateRequest", Arrays.equals(
+                message.certificate_types, certificate_types));
+        assertTrue("incorrect CertificateRequest", Arrays.equals(
+                message.certificate_authorities, certificate_authorities));
+
+		HandshakeIODataStream out = new HandshakeIODataStream();
+		message.send(out);
+		byte[] encoded = out.getData(1000);
+        assertEquals("incorrect out data length", message.length(), encoded.length);
+
+		HandshakeIODataStream in = new HandshakeIODataStream();
+		in.append(encoded);
+		CertificateRequest message_2 = new CertificateRequest(in, message.length());
+        assertTrue("incorrect message decoding", 
+                Arrays.equals(message.certificate_types, message_2.certificate_types));
+        assertTrue("incorrect message decoding", 
+                Arrays.equals(message.certificate_authorities, message_2.certificate_authorities));
+
+		in.append(encoded);
+		try {
+			message_2 = new CertificateRequest(in, message.length() - 1);
+			fail("Small length: No expected AlertException");
+		} catch (AlertException e) {
+		}
+
+		in.append(encoded);
+		in.append(new byte[] { 1, 2, 3 });
+		try {
+			message_2 = new CertificateRequest(in, message.length() + 3);
+			fail("Extra bytes: No expected AlertException ");
+		} catch (AlertException e) {
+		}
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateRequestTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateVerifyTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateVerifyTest.java?rev=428708&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateVerifyTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateVerifyTest.java Fri Aug  4 05:39:35 2006
@@ -0,0 +1,60 @@
+package org.apache.harmony.xnet.provider.jsse;
+
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>CertificateVerify</code> constructor and methods
+ * 
+ */
+public class CertificateVerifyTest extends TestCase {
+
+	public void testCertificateVerify() throws Exception {
+		byte[] anonHash = new byte[0];
+		byte[] RSAHash = new byte[] {
+				1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
+				1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
+				1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
+				1, 2, 3, 4, 5, 6};
+		byte[] DSAHash  = new byte[] {
+				1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
+				1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
+		byte[][] signatures = new byte[][] { anonHash, RSAHash, DSAHash };
+		for (int i = 0; i < 3; i++) {
+			CertificateVerify message = new CertificateVerify(signatures[i]);
+            assertEquals("incorrect type", Handshake.CERTIFICATE_VERIFY,
+                    message.getType());
+            assertTrue("incorrect CertificateVerify", 
+                    Arrays.equals(message.signedHash, signatures[i]));
+
+			HandshakeIODataStream out = new HandshakeIODataStream();
+			message.send(out);
+			byte[] encoded = out.getData(1000);
+            assertEquals("incorrect out data length", message.length(),
+                    encoded.length);
+
+			HandshakeIODataStream in = new HandshakeIODataStream();
+			in.append(encoded);
+			CertificateVerify message_2 = new CertificateVerify(in, message.length());
+            assertTrue("incorrect message decoding", 
+                    Arrays.equals(message.signedHash, message_2.signedHash));
+
+			in.append(encoded);
+			try {
+				message_2 = new CertificateVerify(in, message.length() - 1);
+				fail("Small length: No expected AlertException");
+			} catch (AlertException e) {
+			}
+
+			in.append(encoded);
+			in.append(new byte[] { 1, 2, 3 });
+			try {
+				message_2 = new CertificateVerify(in, message.length() + 3);
+				fail("Extra bytes: No expected AlertException ");
+			} catch (AlertException e) {
+			}
+		}
+	}
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/CertificateVerifyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientHelloTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientHelloTest.java?rev=428708&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientHelloTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientHelloTest.java Fri Aug  4 05:39:35 2006
@@ -0,0 +1,66 @@
+package org.apache.harmony.xnet.provider.jsse;
+
+import java.io.IOException;
+import java.security.SecureRandom;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>ClientHello</code> constructor and methods
+ * 
+ */
+public class ClientHelloTest extends TestCase {
+
+
+	/*
+	 * Test for ClientHello(SecureRandom, byte[], byte[], CipherSuite[]),
+	 * ClientHello(HandshakeIODataStream, int), getType(), getRandom(), and
+	 * send();
+	 */
+	public void testClientHello() throws Exception {
+		byte[] ses_id = new byte[] {1,2,3,4,5,6,7,8,9,0};
+		byte[] version = new byte[] {3, 1 };
+		CipherSuite[] cipher_suite = new CipherSuite[] {
+                CipherSuite.TLS_RSA_WITH_RC4_128_MD5};
+		ClientHello message = new ClientHello(new SecureRandom(), version,
+				ses_id, cipher_suite);
+        assertEquals("incorrect type", Handshake.CLIENT_HELLO, message.getType());
+        assertEquals("incorrect length", 51, message.length());
+        assertEquals("incorrect random", 32, message.getRandom().length);
+
+		HandshakeIODataStream out = new HandshakeIODataStream();
+		message.send(out);
+		byte[] encoded = out.getData(1000);
+        assertEquals("incorrect out data length", message.length(), encoded.length);
+
+		HandshakeIODataStream in = new HandshakeIODataStream();
+		in.append(encoded);
+		ClientHello message_2 = new ClientHello(in, message.length());
+		
+		assertTrue("Incorrect message decoding",
+                Arrays.equals(message.client_version, message_2.client_version));
+        assertTrue("Incorrect message decoding",
+                Arrays.equals(message.getRandom(), message_2.getRandom()));
+
+		in.append(encoded);
+		try {
+			message_2 = new ClientHello(in, message.length()-1);
+			fail("Small length: No expected AlertException");
+		} catch (AlertException e){
+		}
+		
+		in.append(encoded);
+		try {
+			message_2 = new ClientHello(in, message.length()+ 1);
+			fail("Big length: No expected IO exception");
+		} catch (IOException e){
+		}
+		
+		in.append(encoded);
+		in.append(new byte[] {1,2,3});
+		new ClientHello(in, message.length()+ 3);	// extra bytes must be
+                                                     // ignored
+	}
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientHelloTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientKeyExchangeTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientKeyExchangeTest.java?rev=428708&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientKeyExchangeTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientKeyExchangeTest.java Fri Aug  4 05:39:35 2006
@@ -0,0 +1,175 @@
+package org.apache.harmony.xnet.provider.jsse;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>ClientKeyExchange</code> constructor and methods
+ *  
+ */
+public class ClientKeyExchangeTest extends TestCase {
+
+    /*
+     * Test for void ClientKeyExchange(byte[], boolean)
+     */
+    public void testClientKeyExchangebyteArrayboolean() throws Exception {
+        byte[] encrypted_pre_master_secret = new byte[] {
+                1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
+                1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
+        boolean[] isTLS = new boolean[] { true, false };
+
+        for (int i = 0; i < isTLS.length; i++) {
+            ClientKeyExchange message = new ClientKeyExchange(
+                    encrypted_pre_master_secret, isTLS[i]);
+            assertEquals("incorrect type", Handshake.CLIENT_KEY_EXCHANGE,
+                    message.getType());
+
+            assertTrue("incorrect ClientKeyExchange", Arrays.equals(
+                    message.exchange_keys, encrypted_pre_master_secret));
+
+            HandshakeIODataStream out = new HandshakeIODataStream();
+            message.send(out);
+            byte[] encoded = out.getData(1000);
+            assertEquals("incorrect out data length ", message.length(),
+                    encoded.length);
+
+            HandshakeIODataStream in = new HandshakeIODataStream();
+            in.append(encoded);
+            ClientKeyExchange message_2 = new ClientKeyExchange(in, message
+                    .length(), isTLS[i], true);
+
+            assertTrue("Incorrect message decoding", Arrays.equals(
+                    message.exchange_keys, message_2.exchange_keys));
+            assertEquals("Incorrect message decoding", message.length(),
+                    message_2.length());
+
+            in.append(encoded);
+            try {
+                message_2 = new ClientKeyExchange(in, message.length() - 1,
+                        isTLS[i], true);
+                if (isTLS[i]) {
+                    fail("Small length: No expected AlertException");
+                }
+            } catch (AlertException e) {
+                if (!isTLS[i]) {
+                    fail(e.toString());
+                }
+            }
+
+            in.append(encoded);
+            in.append(new byte[] { 1, 2, 3 });
+            try {
+                message_2 = new ClientKeyExchange(in, message.length() + 3,
+                        isTLS[i], true);
+                if (isTLS[i]) {
+                    fail("Extra bytes: No expected AlertException");
+                }
+            } catch (AlertException e) {
+                if (!isTLS[i]) {
+                    fail(e.toString());
+                }
+            }
+        }
+    }
+
+    /*
+     * Test for void ClientKeyExchange(BigInteger)
+     */
+    public void testClientKeyExchangeBigInteger() throws Exception {
+        BigInteger dh_Yc = new BigInteger("1234567890");
+        boolean[] isTLS = new boolean[] { true, false };
+
+        for (int i = 0; i < isTLS.length; i++) {
+            ClientKeyExchange message = new ClientKeyExchange(dh_Yc);
+            assertEquals("incorrect type", Handshake.CLIENT_KEY_EXCHANGE,
+                    message.getType());
+            assertEquals("incorrect ClientKeyExchange", dh_Yc, new BigInteger(
+                    message.exchange_keys));
+
+            HandshakeIODataStream out = new HandshakeIODataStream();
+            message.send(out);
+            byte[] encoded = out.getData(1000);
+            assertEquals("incorrect out data length", message.length(),
+                    encoded.length);
+
+            HandshakeIODataStream in = new HandshakeIODataStream();
+            in.append(encoded);
+            ClientKeyExchange message_2 = new ClientKeyExchange(in, message
+                    .length(), isTLS[i], false);
+
+            assertEquals("Incorrect message decoding", message.length(),
+                    message_2.length());
+            assertTrue("Incorrect message decoding", Arrays.equals(
+                    message.exchange_keys, message_2.exchange_keys));
+
+            in.append(encoded);
+            try {
+                message_2 = new ClientKeyExchange(in, message.length() - 1,
+                        isTLS[i], false);
+                fail("Small length: No expected AlertException");
+            } catch (AlertException e) {
+            }
+
+            in.append(encoded);
+            in.append(new byte[] { 1, 2, 3 });
+            try {
+                message_2 = new ClientKeyExchange(in, message.length() + 3,
+                        isTLS[i], false);
+                fail("Extra bytes: No expected AlertException");
+            } catch (AlertException e) {
+            }
+        }
+    }
+
+    /*
+     * Test for void ClientKeyExchange()
+     */
+    public void testClientKeyExchange() throws Exception {
+
+        ClientKeyExchange message = new ClientKeyExchange();
+        assertEquals("incorrect type", Handshake.CLIENT_KEY_EXCHANGE, message
+                .getType());
+        assertEquals("incorrect ClientKeyExchange", 0,
+                message.exchange_keys.length);
+        assertEquals("incorrect ClientKeyExchange", 0, message.length());
+        assertTrue("incorrect ClientKeyExchange", message.isEmpty());
+
+        HandshakeIODataStream out = new HandshakeIODataStream();
+        message.send(out);
+        byte[] encoded = out.getData(1000);
+        assertEquals("incorrect ClientKeyExchange", 0, message.length());
+        assertEquals("incorrect out data length", message.length(),
+                encoded.length);
+
+        HandshakeIODataStream in = new HandshakeIODataStream();
+        in.append(encoded);
+        ClientKeyExchange message_2 = new ClientKeyExchange(in, message
+                .length(), true, false);
+
+        assertEquals("Incorrect message decoding", 0,
+                message_2.exchange_keys.length);
+        assertEquals("Incorrect message decoding", 0, message_2.length());
+        assertTrue("Incorrect message decoding", message_2.isEmpty());
+
+        in.append(encoded);
+        try {
+            message_2 = new ClientKeyExchange(in, message.length() - 1, true,
+                    false);
+            fail("Small length: No expected IOException");
+        } catch (IOException e) {
+        }
+
+        in.append(encoded);
+        in.append(new byte[] { 1, 2, 3 });
+        try {
+            message_2 = new ClientKeyExchange(in, message.length() + 3, true,
+                    false);
+            fail("Extra bytes: No expected IOException");
+        } catch (IOException e) {
+        }
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ClientKeyExchangeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerHelloTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerHelloTest.java?rev=428708&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerHelloTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerHelloTest.java Fri Aug  4 05:39:35 2006
@@ -0,0 +1,66 @@
+package org.apache.harmony.xnet.provider.jsse;
+
+import java.io.IOException;
+import java.security.SecureRandom;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>ServerHello</code> constructor and methods
+ *  
+ */
+public class ServerHelloTest extends TestCase {
+
+    public void testServerHello() throws Exception {
+        byte[] session_id = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
+        CipherSuite cipher_suite = CipherSuite.TLS_DH_DSS_WITH_DES_CBC_SHA;
+        byte[] server_version = new byte[] { 3, 1 };
+        ServerHello message = new ServerHello(new SecureRandom(),
+                server_version, session_id, cipher_suite, (byte) 0);
+        assertEquals("incorrect type", Handshake.SERVER_HELLO, message
+                .getType());
+
+        assertTrue("incorrect CertificateRequest", Arrays.equals(
+                message.server_version, server_version));
+        assertTrue("incorrect CertificateRequest", Arrays.equals(
+                message.session_id, session_id));
+        assertEquals("incorrect CertificateRequest", cipher_suite,
+                message.cipher_suite);
+
+        HandshakeIODataStream out = new HandshakeIODataStream();
+        message.send(out);
+        byte[] encoded = out.getData(1000);
+        assertEquals("incorrect out data length", message.length(),
+                encoded.length);
+
+        HandshakeIODataStream in = new HandshakeIODataStream();
+        in.append(encoded);
+        ServerHello message_2 = new ServerHello(in, message.length());
+
+        assertTrue("incorrect message decoding", Arrays.equals(
+                message.server_version, message_2.server_version));
+        assertTrue("incorrect message decoding", Arrays.equals(
+                message.session_id, message_2.session_id));
+        assertTrue("incorrect message decoding", Arrays.equals(message.random,
+                message_2.random));
+        assertEquals("incorrect message decoding", message.cipher_suite,
+                message_2.cipher_suite);
+
+        in.append(encoded);
+        try {
+            new ServerHello(in, message.length() - 1);
+            fail("Small length: No expected AlertException");
+        } catch (AlertException e) {
+        }
+
+        in.append(encoded);
+        in.append(new byte[] { 1, 2, 3 });
+        try {
+            new ServerHello(in, message.length() + 3);
+            fail("Extra bytes: No expected AlertException ");
+        } catch (AlertException e) {
+        }
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerHelloTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerKeyExchangeTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerKeyExchangeTest.java?rev=428708&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerKeyExchangeTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerKeyExchangeTest.java Fri Aug  4 05:39:35 2006
@@ -0,0 +1,170 @@
+package org.apache.harmony.xnet.provider.jsse;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>ServerKeyExchange</code> constructor and methods
+ *  
+ */
+public class ServerKeyExchangeTest extends TestCase {
+
+    public void testServerKeyExchange_RSA_EXPORT() throws Exception {
+        BigInteger rsa_mod = new BigInteger(
+                "0620872145533812525365347773040950432706816921321053881493952289532007782427182339053847578435298266865073748931755945944874247298083566202475988854994079");
+        BigInteger rsa_exp = new BigInteger("65537");
+
+        byte[] hash = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5,
+                6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6 };
+        ServerKeyExchange message = new ServerKeyExchange(rsa_mod, rsa_exp,
+                null, hash);
+        assertEquals("incorrect type", Handshake.SERVER_KEY_EXCHANGE, message
+                .getType());
+
+        assertTrue("incorrect ServerKeyExchange", Arrays.equals(message.hash,
+                hash));
+        assertEquals("incorrect ServerKeyExchange", rsa_mod, message.par1);
+        assertEquals("incorrect ServerKeyExchange", rsa_exp, message.par2);
+        assertNull("incorrect ServerKeyExchange", message.par3);
+
+        HandshakeIODataStream out = new HandshakeIODataStream();
+        message.send(out);
+        byte[] encoded = out.getData(1000);
+        assertEquals("incorrect out data length", message.length(),
+                encoded.length);
+
+        HandshakeIODataStream in = new HandshakeIODataStream();
+        in.append(encoded);
+        ServerKeyExchange message_2 = new ServerKeyExchange(in, message
+                .length(), CipherSuite.KeyExchange_RSA_EXPORT);
+
+        assertTrue("incorrect message decoding", Arrays.equals(message.hash,
+                message_2.hash));
+        assertEquals("incorrect message decoding", message.par1, message_2.par1);
+        assertEquals("incorrect message decoding", message.par2, message_2.par2);
+        assertNull("incorrect message decoding", message_2.par3);
+        assertEquals("incorrect message decoding", message.getRSAPublicKey(),
+                message_2.getRSAPublicKey());
+
+        in.append(encoded);
+        try {
+            new ServerKeyExchange(in, message.length() - 1,
+                    CipherSuite.KeyExchange_RSA_EXPORT);
+            fail("Small length: No expected AlertException");
+        } catch (AlertException e) {
+        }
+
+        in.append(encoded);
+        in.append(new byte[] { 1, 2, 3 });
+        try {
+            new ServerKeyExchange(in, message.length() + 3,
+                    CipherSuite.KeyExchange_RSA_EXPORT);
+            fail("Extra bytes: No expected AlertException ");
+        } catch (AlertException e) {
+        }
+    }
+
+    public void testServerKeyExchange_DHE_DSS() throws Exception {
+        BigInteger dh_p = new BigInteger("1234567890");
+        BigInteger dh_g = new BigInteger("987654321");
+        BigInteger dh_Ys = new BigInteger("123123123");
+        byte[] hash = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5,
+                6, 7, 8, 9, 0 };
+        ServerKeyExchange message = new ServerKeyExchange(dh_p, dh_g, dh_Ys,
+                hash);
+        assertEquals("incorrect type", Handshake.SERVER_KEY_EXCHANGE, message
+                .getType());
+
+        assertTrue("incorrect ServerKeyExchange", Arrays.equals(message.hash,
+                hash));
+        assertEquals("incorrect ServerKeyExchange", dh_p, message.par1);
+        assertEquals("incorrect ServerKeyExchange", dh_g, message.par2);
+        assertEquals("incorrect ServerKeyExchange", dh_Ys, message.par3);
+
+        HandshakeIODataStream out = new HandshakeIODataStream();
+        message.send(out);
+        byte[] encoded = out.getData(1000);
+        assertEquals("incorrect out data length", message.length(),
+                encoded.length);
+
+        HandshakeIODataStream in = new HandshakeIODataStream();
+        in.append(encoded);
+        ServerKeyExchange message_2 = new ServerKeyExchange(in, message
+                .length(), CipherSuite.KeyExchange_DHE_DSS);
+
+        assertTrue("incorrect message decoding", Arrays.equals(message.hash,
+                message_2.hash));
+        assertEquals("incorrect message decoding", message.par1, message_2.par1);
+        assertEquals("incorrect message decoding", message.par2, message_2.par2);
+        assertEquals("incorrect message decoding", message.par3, message_2.par3);
+
+        in.append(encoded);
+        try {
+            new ServerKeyExchange(in, message.length() - 1,
+                    CipherSuite.KeyExchange_DHE_DSS);
+            fail("Small length: No expected AlertException");
+        } catch (AlertException e) {
+        }
+
+        in.append(encoded);
+        in.append(new byte[] { 1, 2, 3 });
+        try {
+            new ServerKeyExchange(in, message.length() + 3,
+                    CipherSuite.KeyExchange_DHE_DSS);
+            fail("Extra bytes: No expected AlertException ");
+        } catch (AlertException e) {
+        }
+    }
+
+    public void testServerKeyExchange_DH_anon() throws Exception {
+        BigInteger dh_p = new BigInteger("1234567890");
+        BigInteger dh_g = new BigInteger("987654321");
+        BigInteger dh_Ys = new BigInteger("123123123");
+        ServerKeyExchange message = new ServerKeyExchange(dh_p, dh_g, dh_Ys,
+                null);
+        assertEquals("incorrect type", Handshake.SERVER_KEY_EXCHANGE, message
+                .getType());
+
+        assertNull("incorrect ServerKeyExchange", message.hash);
+        assertEquals("incorrect ServerKeyExchange", dh_p, message.par1);
+        assertEquals("incorrect ServerKeyExchange", dh_g, message.par2);
+        assertEquals("incorrect ServerKeyExchange", dh_Ys, message.par3);
+
+        HandshakeIODataStream out = new HandshakeIODataStream();
+        message.send(out);
+        byte[] encoded = out.getData(1000);
+        assertEquals("incorrect out data length", message.length(),
+                encoded.length);
+
+        HandshakeIODataStream in = new HandshakeIODataStream();
+        in.append(encoded);
+        ServerKeyExchange message_2 = new ServerKeyExchange(in, message
+                .length(), CipherSuite.KeyExchange_DH_anon);
+
+        assertNull("incorrect message decoding", message_2.hash);
+        assertEquals("incorrect message decoding", message.par1, message_2.par1);
+        assertEquals("incorrect message decoding", message.par2, message_2.par2);
+        assertEquals("incorrect message decoding", message.par3, message_2.par3);
+
+        in.append(encoded);
+        try {
+            new ServerKeyExchange(in, message.length() - 1,
+                    CipherSuite.KeyExchange_DH_anon);
+            fail("Small length: No expected AlertException");
+        } catch (AlertException e) {
+        }
+
+        in.append(encoded);
+        in.append(new byte[] { 1, 2, 3 });
+        try {
+            new ServerKeyExchange(in, message.length() + 3,
+                    CipherSuite.KeyExchange_DH_anon);
+            fail("Extra bytes: No expected AlertException ");
+        } catch (AlertException e) {
+        }
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java.injected/org/apache/harmony/xnet/provider/jsse/ServerKeyExchangeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/FinishedTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/FinishedTest.java?rev=428708&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/FinishedTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/FinishedTest.java Fri Aug  4 05:39:35 2006
@@ -0,0 +1,53 @@
+package org.apache.harmony.xnet.tests.provider.jsse;
+
+import java.util.Arrays;
+
+import org.apache.harmony.xnet.provider.jsse.AlertException;
+import org.apache.harmony.xnet.provider.jsse.Finished;
+import org.apache.harmony.xnet.provider.jsse.Handshake;
+import org.apache.harmony.xnet.provider.jsse.HandshakeIODataStream;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>Finished</code> constructor and methods
+ *  
+ */
+public class FinishedTest extends TestCase {
+
+    public void testFinished() throws Exception {
+        byte[] bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2 };
+        Finished message = new Finished(bytes);
+        assertEquals("incorrect type", Handshake.FINISHED, message.getType());
+        assertTrue("incorrect CertificateVerify", Arrays.equals(message
+                .getData(), bytes));
+
+        HandshakeIODataStream out = new HandshakeIODataStream();
+        message.send(out);
+        byte[] encoded = out.getData(1000);
+        assertEquals("incorrect out data length", message.length(),
+                encoded.length);
+
+        HandshakeIODataStream in = new HandshakeIODataStream();
+        in.append(encoded);
+        Finished message_2 = new Finished(in, message.length());
+        assertTrue("incorrect message decoding", Arrays.equals(message
+                .getData(), message_2.getData()));
+
+        in.append(encoded);
+        try {
+            message_2 = new Finished(in, message.length() - 1);
+            fail("Small length: No expected AlertException");
+        } catch (AlertException e) {
+        }
+
+        in.append(encoded);
+        in.append(new byte[] { 1, 2, 3 });
+        try {
+            message_2 = new Finished(in, message.length() + 3);
+            fail("Extra bytes: No expected AlertException ");
+        } catch (AlertException e) {
+        }
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/FinishedTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/HelloRequestTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/HelloRequestTest.java?rev=428708&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/HelloRequestTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/HelloRequestTest.java Fri Aug  4 05:39:35 2006
@@ -0,0 +1,49 @@
+package org.apache.harmony.xnet.tests.provider.jsse;
+
+import org.apache.harmony.xnet.provider.jsse.AlertException;
+import org.apache.harmony.xnet.provider.jsse.Handshake;
+import org.apache.harmony.xnet.provider.jsse.HandshakeIODataStream;
+import org.apache.harmony.xnet.provider.jsse.HelloRequest;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>HelloRequest</code> constructor and methods
+ *
+ */
+public class HelloRequestTest extends TestCase {
+
+    public void testHelloRequest() throws Exception {
+        HelloRequest message = new HelloRequest();
+        assertEquals("incorrect type", Handshake.HELLO_REQUEST, message
+                .getType());
+        assertEquals("incorrect HelloRequest", 0, message.length());
+
+        HandshakeIODataStream out = new HandshakeIODataStream();
+        message.send(out);
+        byte[] encoded = out.getData(1000);
+        assertEquals("incorrect out data length", message.length(),
+                encoded.length);
+
+        HandshakeIODataStream in = new HandshakeIODataStream();
+        in.append(encoded);
+        HelloRequest message_2 = new HelloRequest(in, message.length());
+        assertEquals("incorrect message decoding", 0, message_2.length());
+
+        in.append(encoded);
+        try {
+            new HelloRequest(in, message.length() - 1);
+            fail("Small length: No expected AlertException");
+        } catch (AlertException e) {
+        }
+
+        in.append(encoded);
+        in.append(new byte[] { 1, 2, 3 });
+        try {
+            new HelloRequest(in, message.length() + 3);
+            fail("Extra bytes: No expected AlertException ");
+        } catch (AlertException e) {
+        }
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/HelloRequestTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/ServerHelloDoneTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/ServerHelloDoneTest.java?rev=428708&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/ServerHelloDoneTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/ServerHelloDoneTest.java Fri Aug  4 05:39:35 2006
@@ -0,0 +1,55 @@
+package org.apache.harmony.xnet.tests.provider.jsse;
+
+import java.io.IOException;
+
+import org.apache.harmony.xnet.provider.jsse.AlertException;
+import org.apache.harmony.xnet.provider.jsse.Handshake;
+import org.apache.harmony.xnet.provider.jsse.HandshakeIODataStream;
+import org.apache.harmony.xnet.provider.jsse.ServerHelloDone;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>ServerHelloDone</code> constructor and methods
+ *  
+ */
+public class ServerHelloDoneTest extends TestCase {
+
+    /*
+     * Class under test for void ServerHelloDone()
+     */
+    public void testServerHelloDone() throws Exception {
+
+        ServerHelloDone message = new ServerHelloDone();
+        assertEquals("incorrect type", Handshake.SERVER_HELLO_DONE, message
+                .getType());
+        assertEquals("incorrect ServerHelloDone", 0, message.length());
+
+        HandshakeIODataStream out = new HandshakeIODataStream();
+        message.send(out);
+        byte[] encoded = out.getData(1000);
+        assertEquals("incorrect out data length", message.length(),
+                encoded.length);
+
+        HandshakeIODataStream in = new HandshakeIODataStream();
+        in.append(encoded);
+        ServerHelloDone message_2 = new ServerHelloDone(in, message.length());
+        assertEquals("incorrect message decoding", 0, message_2.length());
+
+        in.append(encoded);
+        try {
+            new ServerHelloDone(in, message.length() - 1);
+            fail("Small length: No expected AlertException");
+        } catch (AlertException e) {
+        }
+
+        in.append(encoded);
+        in.append(new byte[] { 1, 2, 3 });
+        try {
+            new ServerHelloDone(in, message.length() + 3);
+            fail("Extra bytes: No expected AlertException ");
+        } catch (AlertException e) {
+        }
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/test/impl/java/org/apache/harmony/xnet/tests/provider/jsse/ServerHelloDoneTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message