You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/10/02 04:52:43 UTC

svn commit: r451857 [2/4] - in /incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java: common/javax/security/auth/ common/javax/security/auth/callback/ common/javax/security/auth/kerberos/ common/javax/security/auth/login/ common/javax/s...

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/x500/X500PrivateCredentialTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/x500/X500PrivateCredentialTest.java?view=diff&rev=451857&r1=451856&r2=451857
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/x500/X500PrivateCredentialTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/x500/X500PrivateCredentialTest.java Sun Oct  1 19:52:40 2006
@@ -33,106 +33,83 @@
 import java.security.cert.CertificateEncodingException;
 import java.security.cert.CertificateException;
 import java.security.cert.X509Certificate;
-import java.util.Date;
-import java.util.Set;
-
+import junit.framework.Test;
 import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import java.util.*;
 /**
  * Tests implementation of X500PrivateCredential class
  */
-@SuppressWarnings("serial")
 public class X500PrivateCredentialTest extends TestCase {
 
 	X509Certificate cert= new X509Certificate() {
-		@Override
-        public void checkValidity(){}
-		@Override
-        public void checkValidity(Date date){}
-		@Override
-        public int getVersion() {
+		public void checkValidity(){}
+		public void checkValidity(Date date){}
+		public int getVersion() {
 			return 0;
 		}
-		@Override
-        public BigInteger getSerialNumber() {
+		public BigInteger getSerialNumber() {
 			return null;
 		}
-		@Override
-        public Principal getIssuerDN() {
+		public Principal getIssuerDN() {
 			return null;
 		}
-		@Override
-        public Principal getSubjectDN() {
+		public Principal getSubjectDN() {
 			return null;
 		}
-		@Override
-        public Date getNotBefore() {
+		public Date getNotBefore() {
 			return null;
 		}
-		@Override
-        public Date getNotAfter() {
+		public Date getNotAfter() {
 			return null;
 		}
-		@Override
-        public byte[] getTBSCertificate() throws CertificateEncodingException {
+		public byte[] getTBSCertificate() throws CertificateEncodingException {
 			return null;
 		}
-		@Override
-        public byte[] getSignature() {
+		public byte[] getSignature() {
 			return null;
 		}
-		@Override
-        public String getSigAlgName() {
+		public String getSigAlgName() {
 			return null;
 		}
-		@Override
-        public String getSigAlgOID() {
+		public String getSigAlgOID() {
 			return null;
 		}
-		@Override
-        public byte[] getSigAlgParams() {
+		public byte[] getSigAlgParams() {
 			return null;
 		}
-		@Override
-        public boolean[] getIssuerUniqueID() {
+		public boolean[] getIssuerUniqueID() {
 			return null;
 		}
-		@Override
-        public boolean[] getSubjectUniqueID() {
+		public boolean[] getSubjectUniqueID() {
 			return null;
 		}
-		@Override
-        public boolean[] getKeyUsage() {
+		public boolean[] getKeyUsage() {
 			return null;
 		}
-		@Override
-        public int getBasicConstraints() {
+		public int getBasicConstraints() {
 			return 0;
 		}
-		@Override
-        public byte[] getEncoded() throws CertificateEncodingException {
+		public byte[] getEncoded() throws CertificateEncodingException {
 			return null;
 		}
-		@Override
-        public void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException {
+		public void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException {
 		}
-		@Override
-        public void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException {
+		public void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException {
 		}
-		@Override
-        public String toString() {
+		public String toString() {
 			return null;
 		}
-		@Override
-        public PublicKey getPublicKey() {
+		public PublicKey getPublicKey() {
 			return null;
 		}
-		public Set<String> getCriticalExtensionOIDs() {
+		public Set getCriticalExtensionOIDs() {
 			return null;
 		}
 		public byte[] getExtensionValue(String oid) {
 			return null;
 		}
-		public Set<String> getNonCriticalExtensionOIDs() {
+		public Set getNonCriticalExtensionOIDs() {
 			return null;
 		}
 		public boolean hasUnsupportedCriticalExtension() {
@@ -214,4 +191,13 @@
 			//ignore
 		}
 	}
+
+	public static Test suite() {
+		return new TestSuite(X500PrivateCredentialTest.class);
+	}
+
+	public static void main(String[] args) {
+		junit.textui.TestRunner.run(suite());
+	}
+
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/AuthenticationExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/AuthenticationExceptionTest.java?view=diff&rev=451857&r1=451856&r2=451857
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/AuthenticationExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/AuthenticationExceptionTest.java Sun Oct  1 19:52:40 2006
@@ -75,10 +75,10 @@
      */
     public void testAuthenticationException02() {
         AuthenticationException tE;
-        for (String element : msgs) {
-            tE = new AuthenticationException(element);
-            assertEquals("getMessage() must return: ".concat(element), tE
-                    .getMessage(), element);
+        for (int i = 0; i < msgs.length; i++) {
+            tE = new AuthenticationException(msgs[i]);
+            assertEquals("getMessage() must return: ".concat(msgs[i]), tE
+                    .getMessage(), msgs[i]);
             assertNull("getCause() must return null", tE.getCause());
             try {
                 throw tE;
@@ -127,10 +127,10 @@
      */
     public void testAuthenticationException05() {
         AuthenticationException tE;
-        for (String element : msgs) {
-            tE = new AuthenticationException(element, null);
-            assertEquals("getMessage() must return: ".concat(element), tE
-                    .getMessage(), element);
+        for (int i = 0; i < msgs.length; i++) {
+            tE = new AuthenticationException(msgs[i], null);
+            assertEquals("getMessage() must return: ".concat(msgs[i]), tE
+                    .getMessage(), msgs[i]);
             assertNull("getCause() must return null", tE.getCause());
             try {
                 throw tE;
@@ -169,14 +169,14 @@
      */
     public void testAuthenticationException07() {
         AuthenticationException tE;
-        for (String element : msgs) {
-            tE = new AuthenticationException(element, tCause);
+        for (int i = 0; i < msgs.length; i++) {
+            tE = new AuthenticationException(msgs[i], tCause);
             String getM = tE.getMessage();
             String toS = tCause.toString();
-            if (element.length() > 0) {
-                assertTrue("getMessage() must contain ".concat(element), getM
-                        .indexOf(element) != -1);
-                if (!getM.equals(element)) {
+            if (msgs[i].length() > 0) {
+                assertTrue("getMessage() must contain ".concat(msgs[i]), getM
+                        .indexOf(msgs[i]) != -1);
+                if (!getM.equals(msgs[i])) {
                     assertTrue("getMessage() should contain ".concat(toS), getM
                             .indexOf(toS) != -1);
                 }
@@ -205,18 +205,18 @@
         AuthenticationException eT;
         eT = new AuthenticationException();
         assertNotNull("Incorrect null string", eT.toString());
-        for (String element : msgs) {
-            eT = new AuthenticationException(element);
+        for (int i = 0; i < msgs.length; i++) {
+            eT = new AuthenticationException(msgs[i]);
             assertTrue("Incorrect result string", eT.toString()
-                    .indexOf(element) >= 0);
+                    .indexOf(msgs[i]) >= 0);
 
-            for (Throwable element0 : th) {
-                eT = new AuthenticationException(element, element0);
+            for (int j = 0; j < th.length; j++) {
+                eT = new AuthenticationException(msgs[i], th[j]);
                 assertTrue("Incorrect result string", eT.toString().indexOf(
-                        element) >= 0);
-                if (element0 != null) {
+                        msgs[i]) >= 0);
+                if (th[j] != null) {
                     assertTrue("Incorrect result string", eT.toString()
-                            .indexOf(element0.toString()) >= 0);
+                            .indexOf(th[j].toString()) >= 0);
                 }
             }
         }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/AuthorizeCallbackTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/AuthorizeCallbackTest.java?view=diff&rev=451857&r1=451856&r2=451857
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/AuthorizeCallbackTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/AuthorizeCallbackTest.java Sun Oct  1 19:52:40 2006
@@ -79,12 +79,12 @@
                 "another authorizedIDs",
                 "some long string for authorized IDs some long string for authorized IDs some long string for authorized IDs" };
         AuthorizeCallback auth;
-        for (String element : authenticationIDs) {
-            for (String element0 : authorizedIDs) {
-                auth = new AuthorizeCallback(element,
-                        element0);
-                assertEquals(auth.getAuthenticationID(), element);
-                assertEquals(auth.getAuthorizationID(), element0);
+        for (int i = 0; i < authenticationIDs.length; i++) {
+            for (int j = 0; j < authorizedIDs.length; j++) {
+                auth = new AuthorizeCallback(authenticationIDs[i],
+                        authorizedIDs[j]);
+                assertEquals(auth.getAuthenticationID(), authenticationIDs[i]);
+                assertEquals(auth.getAuthorizationID(), authorizedIDs[j]);
                 assertNull(auth.getAuthorizedID());
                 assertFalse(auth.isAuthorized());
 
@@ -96,19 +96,19 @@
                 assertNull(auth.getAuthorizedID());
                 assertFalse(auth.isAuthorized());
 
-                for (String element1 : newAuthorizedIDs) {
-                    auth.setAuthorizedID(element1);
+                for (int l = 0; l < newAuthorizedIDs.length; l++) {
+                    auth.setAuthorizedID(newAuthorizedIDs[l]);
                     assertNull(auth.getAuthorizedID());
                     auth.setAuthorized(true);
                     assertFalse(auth.getAuthorizedID().equals(
                             auth.getAuthorizationID()));
-                    assertEquals(auth.getAuthorizedID(), element1);
-                    auth.setAuthorizedID(element1 + " ZZZ");
+                    assertEquals(auth.getAuthorizedID(), newAuthorizedIDs[l]);
+                    auth.setAuthorizedID(newAuthorizedIDs[l] + " ZZZ");
                     assertFalse(auth.getAuthorizedID().equals(
                             auth.getAuthorizationID()));
                     assertFalse(auth.getAuthorizedID().equals(
-                            element1));
-                    assertEquals(auth.getAuthorizedID(), element1
+                            newAuthorizedIDs[l]));
+                    assertEquals(auth.getAuthorizedID(), newAuthorizedIDs[l]
                             + " ZZZ");
 
                     auth.setAuthorized(false);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/RealmCallbackTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/RealmCallbackTest.java?view=diff&rev=451857&r1=451856&r2=451857
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/RealmCallbackTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/RealmCallbackTest.java Sun Oct  1 19:52:40 2006
@@ -15,6 +15,11 @@
  *  limitations under the License.
  */
 
+/**
+* @author Vera Y. Petrashkova
+* @version $Revision$
+*/
+
 package javax.security.sasl;
 
 import junit.framework.TestCase;
@@ -23,7 +28,16 @@
  * Tests for constructors and methods of RealmCallback class
  * 
  */
+
 public class RealmCallbackTest extends TestCase {
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(RealmCallbackTest.class);
+    }
+
+    public RealmCallbackTest(String arg0) {
+        super(arg0);
+    }
     
     private static final String[] prompts = {
             "Prompts",
@@ -73,14 +87,14 @@
         RealmCallback rCB;
         StringBuffer sb = new StringBuffer("");
         String ss;
-        for (String element : prompts) {
+        for (int i = 0; i < prompts.length; i++) {
             for (int j = 0; j < prompts.length; j++) {
-                rCB = new RealmCallback(element, defInfo[j]);
+                rCB = new RealmCallback(prompts[i], defInfo[j]);
                 assertEquals("Incoorect default info", rCB.getDefaultText(),
                         defInfo[j]);
-                assertEquals("Incorrect prompt", rCB.getPrompt(), element);
+                assertEquals("Incorrect prompt", rCB.getPrompt(), prompts[i]);
                 assertNull("Not null text", rCB.getText());
-                sb.replace(0, sb.length(), element);
+                sb.replace(0, sb.length(), prompts[i]);
                 sb.append(defInfo[j]);
                 ss = sb.toString();
                 rCB.setText(ss);
@@ -117,13 +131,13 @@
         RealmCallback rCB;
         StringBuffer sb = new StringBuffer("");
         String ss;
-        for (String element : prompts) {
-            rCB = new RealmCallback(element);
+        for (int i = 0; i < prompts.length; i++) {
+            rCB = new RealmCallback(prompts[i]);
             assertNull("Incoorect default info", rCB.getDefaultText());
-            assertEquals("Incorrect prompt", rCB.getPrompt(), element);
+            assertEquals("Incorrect prompt", rCB.getPrompt(), prompts[i]);
             assertNull("Not null text", rCB.getText());
-            sb = new StringBuffer(element);
-            sb.replace(0, sb.length(), element);
+            sb = new StringBuffer(prompts[i]);
+            sb.replace(0, sb.length(), prompts[i]);
             ss = sb.toString();
             rCB.setText(ss);
             assertEquals("Incorrect text", rCB.getText(), ss);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/RealmChoiceCallbackTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/RealmChoiceCallbackTest.java?view=diff&rev=451857&r1=451856&r2=451857
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/RealmChoiceCallbackTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/RealmChoiceCallbackTest.java Sun Oct  1 19:52:40 2006
@@ -119,9 +119,9 @@
      */ 
     public void test02() {
         RealmChoiceCallback rCCB;
-        for (String element : prompts) {
-            rCCB = new RealmChoiceCallback(element, choices, 0, false);
-            assertEquals("Incorrect prompt", rCCB.getPrompt(), element);
+        for (int i = 0; i < prompts.length; i++) {
+            rCCB = new RealmChoiceCallback(prompts[i], choices, 0, false);
+            assertEquals("Incorrect prompt", rCCB.getPrompt(), prompts[i]);
             String [] ch = rCCB.getChoices();
             assertEquals("Incorrect choices length", ch.length, choices.length);
             for (int j = 0; j < ch.length; j++) {
@@ -141,11 +141,11 @@
                 fail("UnsupportedOperationException should be thrown fot non-multiple callback");
             } catch (UnsupportedOperationException e) {
             }
-            for (int element0 : indexes) {
-                rCCB.setSelectedIndex(element0);
+            for (int j = 0; j < indexes.length; j++) {
+                rCCB.setSelectedIndex(indexes[j]);
                 ind = rCCB.getSelectedIndexes();
                 assertEquals("Incorrect index length", ind.length, 1);
-                assertEquals("Incorrect index", ind[0], element0);
+                assertEquals("Incorrect index", ind[0], indexes[j]);
             }
         }        
     }
@@ -159,9 +159,9 @@
      */ 
     public void test03() {
         RealmChoiceCallback rCCB;
-        for (String element : prompts) {
-            rCCB = new RealmChoiceCallback(element, choices, 0, true);
-            assertEquals("Incorrect prompt", rCCB.getPrompt(), element);
+        for (int i = 0; i < prompts.length; i++) {
+            rCCB = new RealmChoiceCallback(prompts[i], choices, 0, true);
+            assertEquals("Incorrect prompt", rCCB.getPrompt(), prompts[i]);
             String[] ch = rCCB.getChoices();
             assertEquals("Incorrect choices length", ch.length, choices.length);
             for (int j = 0; j < ch.length; j++) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/Sasl1Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/Sasl1Test.java?view=diff&rev=451857&r1=451856&r2=451857
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/Sasl1Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/Sasl1Test.java Sun Oct  1 19:52:40 2006
@@ -15,8 +15,14 @@
  *  limitations under the License.
  */
 
+/**
+* @author Vera Y. Petrashkova
+* @version $Revision$
+*/
+
 package javax.security.sasl;
 
+
 import java.security.Provider;
 import java.security.Security;
 import java.util.Enumeration;
@@ -27,11 +33,24 @@
  * Test for Sasl class
  * 
  */
+
 public class Sasl1Test extends TestCase {
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(Sasl1Test.class);
+    }
+
     private Provider [] provs;
     private boolean initProvs = false;
+    /**
+     * Constructor for Sasl2Test.
+     * 
+     * @param arg0
+     */
+    public Sasl1Test(String arg0) {
+        super(arg0);
+    }
 
-    @Override
     protected void setUp() throws Exception {
         super.setUp();
         if (!initProvs) {
@@ -39,13 +58,12 @@
             initProvs = true;
         }
         if (provs != null) {
-            for (Provider element : provs) {
-                Security.removeProvider(element.getName());
+            for (int i = 0; i < provs.length; i++) {
+                Security.removeProvider(provs[i].getName());
             }
         }
     }
     
-    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
         if (provs != null) {
@@ -64,7 +82,7 @@
      * All providers are previously removed.
      */
     public void testGetClient() {    
-        Enumeration<?> en = Sasl.getSaslClientFactories();
+        Enumeration en = Sasl.getSaslClientFactories();
         assertNotNull("List of SaslClientFactories should not be null", en);
         assertFalse("List of SaslClientFactories should not haves elements", en
                 .hasMoreElements());
@@ -79,7 +97,7 @@
      * All providers are previously removed.
      */
     public void testGetSertver() {
-        Enumeration<?> en = Sasl.getSaslServerFactories();
+        Enumeration en = Sasl.getSaslServerFactories();
         assertNotNull("List of SaslServerFactories should not be null", en);
         assertFalse("List of SaslServerFactories should not have elements", en
                 .hasMoreElements());

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/Sasl2Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/Sasl2Test.java?view=diff&rev=451857&r1=451856&r2=451857
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/Sasl2Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/Sasl2Test.java Sun Oct  1 19:52:40 2006
@@ -15,53 +15,78 @@
  *  limitations under the License.
  */
 
+/**
+* @author Vera Y. Petrashkova
+* @version $Revision$
+*/
+
 package javax.security.sasl;
 
+
 import java.security.Provider;
 import java.security.Security;
-import java.util.Enumeration;
+import javax.security.auth.callback.CallbackHandler;
+
+import org.apache.harmony.auth.tests.support.SpiEngUtils;
 
 import junit.framework.TestCase;
 
-import org.apache.harmony.auth.tests.support.SpiEngUtils;
+import java.util.Enumeration;
+import java.util.Map;
 
 /**
  * Test for Sasl class
  * 
  */
-public class Sasl2Test extends TestCase {
 
-    private static final String[] mech = { "mechanism", "NEW-MECHANISM", "AA",
-            "LONG-LONG-LONG-LONG-LONG-LONG-LONG-LONG-LONG-LONG-LONG-LONG-LONG-LONG-LONG" };
+public class Sasl2Test extends TestCase {
 
-    private static final String CLNTSRV = "SaslClientFactory.";
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(Sasl2Test.class);
+    }
 
-    private static final String SRVSSRV = "SaslServerFactory.";
+    Provider[] mProv;
 
     private static final String fClientClass01 = "javax.security.sasl.myClientFactory01";
 
     private static final String fServerClass01 = "javax.security.sasl.myServerFactory01";
 
     private static final String fServerClass02 = "javax.security.sasl.myServerFactory02";
-    
-    Provider[] mProv;
 
-    @Override
+    /*
+     * @see TestCase#tearDown()
+     */
     protected void tearDown() throws Exception {
         super.tearDown();
         if (mProv != null) {
-            for (Provider element : mProv) {
-                Security.removeProvider(element.getName());
+            for (int i = 0; i < mProv.length; i++) {
+                Security.removeProvider(mProv[i].getName());
             }
         }
     }
 
+    /**
+     * Constructor for Sasl2Test.
+     * 
+     * @param arg0
+     */
+    public Sasl2Test(String arg0) {
+        super(arg0);
+    }
+
     private void addProviders() {
-        for (Provider element : mProv) {
-            Security.insertProviderAt(element, 2);
+        for (int i = 0; i < mProv.length; i++) {
+            Security.insertProviderAt(mProv[i], 2);
         }
     }
 
+    private static final String[] mech = { "mechanism", "NEW-MECHANISM", "AA",
+            "LONG-LONG-LONG-LONG-LONG-LONG-LONG-LONG-LONG-LONG-LONG-LONG-LONG-LONG-LONG" };
+
+    private static final String CLNTSRV = "SaslClientFactory.";
+
+    private static final String SRVSSRV = "SaslServerFactory.";
+
     /**
      * Test for <code>getSaslClientFactories()</code> method 
      * 
@@ -89,7 +114,7 @@
 
         addProviders();
 
-        Enumeration<?> en = Sasl.getSaslClientFactories();
+        Enumeration en = Sasl.getSaslClientFactories();
         assertNotNull("List of SaslClientFactories should not be null", en);
         assertTrue("List of SaslClientFactories should have elements", en
                 .hasMoreElements());
@@ -139,7 +164,7 @@
                                 .concat(mech[3]), fClientClass01) };
         addProviders();
 
-        Enumeration<?> en = Sasl.getSaslClientFactories();
+        Enumeration en = Sasl.getSaslClientFactories();
         assertNotNull("List of SaslClientFactories should not be null", en);
         assertTrue("List of SaslClientFactories should have elements", en
                 .hasMoreElements());
@@ -182,7 +207,7 @@
                         "Testing provider SaslClientFactory - 2", CLNTSRV
                                 .concat(mech[1]), fClientClass01) };
         addProviders();
-        Enumeration<?> en = Sasl.getSaslClientFactories();
+        Enumeration en = Sasl.getSaslClientFactories();
         assertNotNull("List of SaslClientFactories should not be null", en);
         assertTrue("List of SaslClientFactories should have elements", en
                 .hasMoreElements());
@@ -242,7 +267,7 @@
         mProv[0].put(CLNTSRV.concat(mech[3]), fClientClass01);
 
         addProviders();
-        Enumeration<?> en = Sasl.getSaslClientFactories();
+        Enumeration en = Sasl.getSaslClientFactories();
         assertNotNull("List of SaslClientFactories should not be null", en);
         assertTrue("List of SaslClientFactories should have elements", en
                 .hasMoreElements());
@@ -290,18 +315,18 @@
                 (new SpiEngUtils()).new MyProvider("MySaslServerProvider4",
                         "Testing provider SaslServerFactory - 4", SRVSSRV
                                 .concat(mech[0]), fServerClass02) };
-        for (Provider element : mProv) {
+        for (int i = 0; i < mProv.length; i++) {
             for (int j = 1; j < mech.length; j++) {
-                element.put(SRVSSRV.concat(mech[j]).concat(mech[j]),
+                mProv[i].put(SRVSSRV.concat(mech[j]).concat(mech[j]),
                         fServerClass02);
-                element.put(SRVSSRV.concat(mech[j]).concat(mech[j]),
+                mProv[i].put(SRVSSRV.concat(mech[j]).concat(mech[j]),
                         fServerClass01);
             }
-            element.put(SRVSSRV.concat(mech[0]).concat(mech[0]),
+            mProv[i].put(SRVSSRV.concat(mech[0]).concat(mech[0]),
                     fServerClass01);
         }
         addProviders();
-        Enumeration<?> en = Sasl.getSaslServerFactories();
+        Enumeration en = Sasl.getSaslServerFactories();
         assertNotNull("List of SaslServerFactories should not be null", en);
         assertTrue("List of SaslServerFactories should have elements", en
                 .hasMoreElements());
@@ -361,7 +386,7 @@
                                 .concat(mech[3]), fServerClass01) };
         addProviders();
 
-        Enumeration<?> en = Sasl.getSaslServerFactories();
+        Enumeration en = Sasl.getSaslServerFactories();
         assertNotNull("List of SaslServerFactories should not be null", en);
         assertTrue("List of SaslServerFactories should have elements", en
                 .hasMoreElements());
@@ -404,7 +429,7 @@
                         "Testing provider SaslServerFactory - 2", SRVSSRV
                                 .concat(mech[1]), fServerClass01) };
         addProviders();
-        Enumeration<?> en = Sasl.getSaslServerFactories();
+        Enumeration en = Sasl.getSaslServerFactories();
         assertNotNull("List of SaslServerFactories should not be null", en);
         assertTrue("List of SaslServerFactories should have elements", en
                 .hasMoreElements());
@@ -464,7 +489,7 @@
         mProv[0].put(SRVSSRV.concat(mech[3]), fServerClass02);
 
         addProviders();
-        Enumeration<?> en = Sasl.getSaslServerFactories();
+        Enumeration en = Sasl.getSaslServerFactories();
         assertNotNull("List of SaslServerFactories should not be null", en);
         assertTrue("List of SaslServerFactories should have elements", en
                 .hasMoreElements());
@@ -487,4 +512,68 @@
                 mProv.length);
     }
 
+}
+
+class myServerFactory01 implements SaslServerFactory {
+    public myServerFactory01() {
+        super();
+    }
+
+    public String[] getMechanismNames(Map map) {
+        return new String[] { "aaaa", "dddddddddddd",
+                "llllllllll sssssssss aaaaaaaaaaa c" };
+    }
+
+    public SaslServer createSaslServer(String mech, String prot,
+            String srvName, Map prop, CallbackHandler ch) throws SaslException {
+        return null;
+    }
+}
+
+class myServerFactory02 implements SaslServerFactory {
+    public myServerFactory02() {
+        super();
+    }
+
+    public String[] getMechanismNames(Map map) {
+        return null;
+    }
+
+    public SaslServer createSaslServer(String mech, String prot,
+            String srvName, Map prop, CallbackHandler ch) throws SaslException {
+        if (prot == null) {
+            throw new SaslException("Protocol is null");
+        }
+        return null;
+    }
+}
+
+class myClientFactory01 implements SaslClientFactory {
+    public myClientFactory01() {
+        super();
+    }
+
+    public String[] getMechanismNames(Map map) {
+        return new String[] { "a1", "a2", "a3", "a4", "a5" };
+    }
+
+    public SaslClient createSaslClient(String[] mech, String prot, String auth,
+            String srvName, Map prop, CallbackHandler ch) throws SaslException {
+        return null;
+    }
+}
+
+class myClientFactory02 implements SaslClientFactory {
+    public myClientFactory02() {
+        super();
+    }
+
+    public String[] getMechanismNames(Map map) {
+        return new String[] { "a11", "a22", "a33", "a44", "a55", "" };
+    }
+
+    public SaslClient createSaslClient(String[] mech, String prot, String auth,
+            String srvName, Map prop, CallbackHandler ch) throws SaslException {
+        return null;
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/Sasl3Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/Sasl3Test.java?view=diff&rev=451857&r1=451856&r2=451857
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/Sasl3Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/Sasl3Test.java Sun Oct  1 19:52:40 2006
@@ -15,21 +15,35 @@
  *  limitations under the License.
  */
 
+/**
+* @author Vera Y. Petrashkova
+* @version $Revision$
+*/
+
 package javax.security.sasl;
 
+
+import java.io.IOException;
 import java.security.Provider;
 import java.security.Security;
+import java.util.Map;
 
+import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
-
-import junit.framework.TestCase;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextOutputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
 
 import org.apache.harmony.auth.tests.support.SpiEngUtils;
 
+import junit.framework.TestCase;
+
 /**
  * Test for Sasl class
  * 
  */
+
 public class Sasl3Test extends TestCase {
     private static final String CLNTSRV = "SaslClientFactory.";
 
@@ -51,7 +65,6 @@
         super(arg0);
     }
 
-    @Override
     protected void setUp() throws Exception {
         super.setUp();
         if (!initProvs) {
@@ -59,8 +72,8 @@
             initProvs = true;
         }
         if (provs != null) {
-            for (Provider element : provs) {
-                Security.removeProvider(element.getName());
+            for (int i = 0; i < provs.length; i++) {
+                Security.removeProvider(provs[i].getName());
             }
         }
     }
@@ -68,20 +81,19 @@
     protected Provider[] mProv;
 
     private void addProviders() {
-        for (Provider element : mProv) {
-            Security.insertProviderAt(element, 1);
+        for (int i = 0; i < mProv.length; i++) {
+            Security.insertProviderAt(mProv[i], 1);
         }
     }
 
     /*
      * @see TestCase#tearDown()
      */
-    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
         if (mProv != null) {
-            for (Provider element : mProv) {
-                Security.removeProvider(element.getName());
+            for (int i = 0; i < mProv.length; i++) {
+                Security.removeProvider(mProv[i].getName());
             }
         }
         if (provs != null) {
@@ -183,7 +195,7 @@
         assertNotNull("Null result", saslC);
         try {
             saslC.unwrap(null, 1, 1);
-            fail("SaslException should be thrown");
+            fail("SaslException sould be thrown");
         } catch (SaslException e) {
         }
         assertFalse("Incorrect isComplete() result", saslC.isComplete());
@@ -191,7 +203,7 @@
         try {
             saslC = Sasl.createSaslClient(new String[] { "NAME-1" }, null,
                     "protocol", null, null, cbH);
-            fail("SaslException should be thrown");
+            fail("SaslException sould be thrown");
         } catch (SaslException e) {
         }
     }
@@ -222,7 +234,7 @@
         try {
             saslC = Sasl.createSaslClient(new String[] { "NAME-1" }, null,
                     "protocol", null, null, cbH);
-            fail("SaslException should be thrown");
+            fail("SaslException sould be thrown");
         } catch (SaslException e) {
         }
     }
@@ -266,7 +278,7 @@
         assertNotNull("Null result for NAME-2", saslC);
         try {
             saslC.unwrap(null, 1, 1);
-            fail("SaslException should be thrown");
+            fail("SaslException sould be thrown");
         } catch (SaslException e) {
         }
         assertFalse("Incorrect isComplete() result", saslC.isComplete());
@@ -275,7 +287,7 @@
         try {
             Sasl.createSaslClient(new String[] { "NAME-1" }, null, "protocol",
                     null, null, cbH);
-            fail("SaslException should be thrown");
+            fail("SaslException sould be thrown");
         } catch (SaslException e) {
         }
         // NAME-6 and NAME-5 were defined in one provider but they are
@@ -284,5 +296,141 @@
         saslC = Sasl.createSaslClient(new String[] { "NAME-6", "NAME-5" },
                 null, "protocol", null, null, cbH);
         assertNotNull("Null result for NAME-6 and NAME-5", saslC);
+    }
+}
+
+/*
+ * Additional classes for creating SaslClient and SaslServer objects
+ */
+
+class mySaslClientFactory implements SaslClientFactory {
+    public mySaslClientFactory() {
+        super();
+    }
+
+    public String[] getMechanismNames(Map prop) {
+        return new String[] { "NAME-1", "NAME-2", "NAME-3", "NAME-4" };
+    }
+
+    public SaslClient createSaslClient(String[] mech, String id,
+            String protocol, String srvName, Map prop, CallbackHandler hnd)
+            throws SaslException {
+        if (mech == null) {
+            throw new SaslException();
+        }
+        if ("NAME-1".equals(mech[0])) {
+            throw new SaslException("Incorrect mechanisms");
+        }
+        if (protocol == null) {
+            throw new SaslException("Protocol is null");
+        }
+        TextOutputCallback[] cb = { new TextOutputCallback(
+                TextOutputCallback.INFORMATION, "Information") };
+        try {
+            hnd.handle(cb);
+        } catch (UnsupportedCallbackException e) {
+            throw new SaslException("Incorrect callback handlere", e);
+        } catch (IOException e) {
+            throw new SaslException("Incorrect callback handlere", e);
+        }
+        return new mySaslClient();
+    }
+
+    public class mySaslClient implements SaslClient {
+        public mySaslClient() {
+            super();
+        }
+
+        public Object getNegotiatedProperty(String s) {
+            return "";
+        }
+
+        public String getMechanismName() {
+            return "Proba";
+        }
+
+        public boolean isComplete() {
+            return false;
+        }
+
+        public boolean hasInitialResponse() {
+            return false;
+        }
+
+        public void dispose() throws SaslException {
+        }
+
+        public byte[] evaluateChallenge(byte[] challenge) throws SaslException {
+            return new byte[0];
+        }
+
+        public byte[] unwrap(byte[] incoming, int offset, int len)
+                throws SaslException {
+            throw new SaslException();
+        }
+
+        public byte[] wrap(byte[] outgoing, int offset, int len)
+                throws SaslException {
+            return new byte[0];
+        }
+    }
+}
+
+class mySaslClientFactoryExt extends mySaslClientFactory {
+    public String[] getMechanismNames(Map prop) {
+        return new String[] { "NAME-5", "NAME-6" };
+    }
+
+    public SaslClient createSaslClient(String[] mech, String id,
+            String protocol, String srvName, Map prop, CallbackHandler hnd)
+            throws SaslException {
+        if (mech == null) {
+            throw new SaslException();
+        }
+        return new mySaslClient();
+    }
+}
+
+class cbHand implements CallbackHandler {
+    public cbHand() {
+    }
+
+    public void handle(Callback[] callbacks) throws IOException,
+            UnsupportedCallbackException {
+        for (int i = 0; i < callbacks.length; i++) {
+            if (callbacks[i] instanceof NameCallback) {
+                NameCallback nc = (NameCallback) callbacks[i];
+                nc.setName("Ok");
+            } else if (callbacks[i] instanceof PasswordCallback) {
+                PasswordCallback pc = (PasswordCallback) callbacks[i];
+                System.err.print(pc.getPrompt());
+                System.err.flush();
+                pc.setPassword(new char[] { 'O', 'k' });
+            } else {
+                throw new UnsupportedCallbackException(callbacks[i],
+                        "Callback should be NamCallback or PasswordCallback");
+            }
+        }
+    }
+}
+
+class cbHandN implements CallbackHandler {
+    public cbHandN() {
+    }
+
+    public void handle(Callback[] callbacks) throws IOException,
+            UnsupportedCallbackException {
+        for (int i = 0; i < callbacks.length; i++) {
+            if (callbacks[i] instanceof TextOutputCallback) {
+                TextOutputCallback toc = (TextOutputCallback) callbacks[i];
+                if (toc.getMessageType() != TextOutputCallback.INFORMATION) {
+                    throw new IOException("Unsupported message type: "
+                            + toc.getMessageType());
+                }
+            } else {
+                throw new UnsupportedCallbackException(callbacks[i],
+                        "Callback should be TextOutputCallback");
+            }
+        }
     }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/Sasl4Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/Sasl4Test.java?view=diff&rev=451857&r1=451856&r2=451857
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/Sasl4Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/Sasl4Test.java Sun Oct  1 19:52:40 2006
@@ -15,21 +15,32 @@
  *  limitations under the License.
  */
 
+/**
+* @author Vera Y. Petrashkova
+* @version $Revision$
+*/
+
 package javax.security.sasl;
 
+
+import java.io.IOException;
 import java.security.Provider;
 import java.security.Security;
+import java.util.Map;
 
 import javax.security.auth.callback.CallbackHandler;
-
-import junit.framework.TestCase;
+import javax.security.auth.callback.TextOutputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
 
 import org.apache.harmony.auth.tests.support.SpiEngUtils;
 
+import junit.framework.TestCase;
+
 /**
  * Test for Sasl class
  * 
  */
+
 public class Sasl4Test extends TestCase {
     private static final String SRVSSRV = "SaslServerFactory.";
 
@@ -38,7 +49,20 @@
     private Provider [] provs;
     private boolean initProvs = false;
 
-    @Override
+    
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(Sasl4Test.class);
+    }
+
+    /**
+     * Constructor for Sasl4Test.
+     * 
+     * @param arg0
+     */
+    public Sasl4Test(String arg0) {
+        super(arg0);
+    }
+
     protected void setUp() throws Exception {
         super.setUp();
         if (!initProvs) {
@@ -46,8 +70,8 @@
             initProvs = true;
         }
         if (provs != null) {
-            for (Provider element : provs) {
-                Security.removeProvider(element.getName());
+            for (int i = 0; i < provs.length; i++) {
+                Security.removeProvider(provs[i].getName());
             }
         }
     }
@@ -55,20 +79,19 @@
     protected Provider[] mProv;
 
     private void addProviders() {
-        for (Provider element : mProv) {
-            Security.insertProviderAt(element, 1);
+        for (int i = 0; i < mProv.length; i++) {
+            Security.insertProviderAt(mProv[i], 1);
         }
     }
 
     /*
      * @see TestCase#tearDown()
      */
-    @Override
     protected void tearDown() throws Exception {
         super.tearDown();
         if (mProv != null) {
-            for (Provider element : mProv) {
-                Security.removeProvider(element.getName());
+            for (int i = 0; i < mProv.length; i++) {
+                Security.removeProvider(mProv[i].getName());
             }
         }
         if (provs != null) {
@@ -272,5 +295,95 @@
         assertNotNull("Null result for MECH-6", saslS);
         saslS = Sasl.createSaslServer("MECH-5", "protocol", null, null, cbH);
         assertNotNull("Null result for MECH-5", saslS);
+    }
+}
+
+/*
+ * Additional class for creating SaslServer object
+ */
+
+class mySaslServerFactory implements SaslServerFactory {
+    public mySaslServerFactory() {
+        super();
+    }
+
+    public String[] getMechanismNames(Map prop) {
+        return new String[] { "MECH-1", "MECH-2", "MECH-3", "MECH-4" };
+    }
+
+    public SaslServer createSaslServer(String mech, String protocol,
+            String srvName, Map prop, CallbackHandler hnd) throws SaslException {
+        if (mech == null) {
+            throw new SaslException();
+        }
+        if ("MECH-1".equals(mech)) {
+            throw new SaslException("Incorrect mechanisms");
+        }
+        if (protocol == null) {
+            throw new SaslException("Protocol is null");
+        }
+        TextOutputCallback[] cb = { new TextOutputCallback(
+                TextOutputCallback.INFORMATION, "Information") };
+        try {
+            hnd.handle(cb);
+        } catch (UnsupportedCallbackException e) {
+            throw new SaslException("Incorrect callback handlere", e);
+        } catch (IOException e) {
+            throw new SaslException("Incorrect callback handlere", e);
+        }
+        return new mySaslServer();
+    }
+
+    public class mySaslServer implements SaslServer {
+        public mySaslServer() {
+            super();
+        }
+
+        public void dispose() throws SaslException {
+        }
+
+        public byte[] evaluateResponse(byte[] challenge) throws SaslException {
+            return new byte[0];
+        }
+
+        public String getMechanismName() {
+            return "Server Proba";
+        }
+
+        public Object getNegotiatedProperty(String s) {
+            return "";
+        }
+
+        public String getAuthorizationID() {
+            return "";
+        }
+
+        public boolean isComplete() {
+            return false;
+        }
+
+        public byte[] unwrap(byte[] incoming, int offset, int len)
+                throws SaslException {
+            throw new SaslException();
+        }
+
+        public byte[] wrap(byte[] outgoing, int offset, int len)
+                throws SaslException {
+            return new byte[0];
+        }
+    }
+}
+
+class mySaslServerFactoryExt extends mySaslServerFactory {
+    public String[] getMechanismNames(Map prop) {
+        return new String[] { "MECH-5", "MECH-6" };
+    }
+
+    public SaslServer createSaslServer(String mech, String protocol,
+            String srvName, Map prop, CallbackHandler hnd) throws SaslException {
+        if (mech == null) {
+            throw new SaslException();
+        }
+        return new mySaslServer();
     }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/SaslExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/SaslExceptionTest.java?view=diff&rev=451857&r1=451856&r2=451857
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/SaslExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/sasl/SaslExceptionTest.java Sun Oct  1 19:52:40 2006
@@ -15,8 +15,14 @@
  *  limitations under the License.
  */
 
+/**
+* @author Vera Y. Petrashkova
+* @version $Revision$
+*/
+
 package javax.security.sasl;
 
+
 import junit.framework.TestCase;
 
 /**
@@ -25,6 +31,19 @@
  */
 public class SaslExceptionTest extends TestCase {
 
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(SaslExceptionTest.class);
+    }
+
+    /**
+     * Constructor for SaslExceptionTests.
+     * 
+     * @param arg0
+     */
+    public SaslExceptionTest(String arg0) {
+        super(arg0);
+    }
+
     static String[] msgs = {
             "",
             "Check new message",
@@ -65,10 +84,10 @@
      */
     public void testSaslException02() {
         SaslException tE;
-        for (String element : msgs) {
-            tE = new SaslException(element);
-            assertEquals("getMessage() must return: ".concat(element), tE
-                    .getMessage(), element);
+        for (int i = 0; i < msgs.length; i++) {
+            tE = new SaslException(msgs[i]);
+            assertEquals("getMessage() must return: ".concat(msgs[i]), tE
+                    .getMessage(), msgs[i]);
             assertNull("getCause() must return null", tE.getCause());
             try {
                 throw tE;
@@ -117,10 +136,10 @@
      */
     public void testSaslException05() {
         SaslException tE;
-        for (String element : msgs) {
-            tE = new SaslException(element, null);
-            assertEquals("getMessage() must return: ".concat(element), tE
-                    .getMessage(), element);
+        for (int i = 0; i < msgs.length; i++) {
+            tE = new SaslException(msgs[i], null);
+            assertEquals("getMessage() must return: ".concat(msgs[i]), tE
+                    .getMessage(), msgs[i]);
             assertNull("getCause() must return null", tE.getCause());
             try {
                 throw tE;
@@ -164,14 +183,14 @@
      */
     public void testSaslException07() {
         SaslException tE;
-        for (String element : msgs) {
-            tE = new SaslException(element, tCause);
+        for (int i = 0; i < msgs.length; i++) {
+            tE = new SaslException(msgs[i], tCause);
             String getM = tE.getMessage();
             String toS = tCause.toString();
-            if (element.length() > 0) {
-                assertTrue("getMessage() must contain ".concat(element), getM
-                        .indexOf(element) != -1);
-                if (!getM.equals(element)) {
+            if (msgs[i].length() > 0) {
+                assertTrue("getMessage() must contain ".concat(msgs[i]), getM
+                        .indexOf(msgs[i]) != -1);
+                if (!getM.equals(msgs[i])) {
                     assertTrue("getMessage() should contain ".concat(toS), getM
                             .indexOf(toS) != -1);
                 }
@@ -206,18 +225,18 @@
         SaslException eT;
         eT = new SaslException();
         assertNotNull("Incorrect null string", eT.toString());
-        for (String element : msgs) {
-            eT = new SaslException(element);
+        for (int i = 0; i < msgs.length; i++) {
+            eT = new SaslException(msgs[i]);
             assertTrue("Incorrect result string", eT.toString()
-                    .indexOf(element) >= 0);
+                    .indexOf(msgs[i]) >= 0);
 
-            for (Throwable element0 : th) {
-                eT = new SaslException(element, element0);
+            for (int j = 0; j < th.length; j++) {
+                eT = new SaslException(msgs[i], th[j]);
                 assertTrue("Incorrect result string", eT.toString().indexOf(
-                        element) >= 0);
-                if (element0 != null) {
+                        msgs[i]) >= 0);
+                if (th[j] != null) {
                     assertTrue("Incorrect result string", eT.toString()
-                            .indexOf(element0.toString()) >= 0);
+                            .indexOf(th[j].toString()) >= 0);
                 }
             }
         }
@@ -256,8 +275,8 @@
         Throwable eT1;
         eT = new SaslException();
 
-        for (String element : msgs) {
-            eT = new SaslException(element);
+        for (int i = 0; i < msgs.length; i++) {
+            eT = new SaslException(msgs[i]);
 
             for (int l = (thUpd.length - 1); l >= 0; l--) {
                 try {
@@ -288,21 +307,21 @@
         eT = new SaslException();
 
         boolean mod = false;
-        for (String element : msgs) {
-            for (Throwable element0 : th) {
+        for (int i = 0; i < msgs.length; i++) {
+            for (int j = 0; j < th.length; j++) {
                 mod = false;
-                for (Throwable element1 : thUpd) {
-                    eT = new SaslException(element, element0);
+                for (int l = 0; l < thUpd.length; l++) {
+                    eT = new SaslException(msgs[i], th[j]);
                     try {
-                        eT1 = eT.initCause(element1);
+                        eT1 = eT.initCause(thUpd[l]);
                         assertEquals(eT1, eT);
                         mod = true;
-                        if ((element0 == null) && !mod) {
+                        if ((th[j] == null) && !mod) {
                             assertEquals("Incorrect cause", eT.getCause(),
-                                    element1);
+                                    thUpd[l]);
                         }
                     } catch (IllegalStateException e) {
-                        if ((element0 == null) && !mod) {
+                        if ((th[j] == null) && !mod) {
                             fail("Unexpected exception: " + e);
                         }
                     }