Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 25093 invoked from network); 9 Feb 2007 06:43:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Feb 2007 06:43:19 -0000 Received: (qmail 68659 invoked by uid 500); 9 Feb 2007 06:43:26 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 68634 invoked by uid 500); 9 Feb 2007 06:43:26 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 68625 invoked by uid 99); 9 Feb 2007 06:43:26 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Feb 2007 22:43:26 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Feb 2007 22:43:19 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id D26EB1A981A; Thu, 8 Feb 2007 22:42:58 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r505200 - in /harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security: Security2Test.java SecurityTest.java Date: Fri, 09 Feb 2007 06:42:58 -0000 To: commits@harmony.apache.org From: smishura@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070209064258.D26EB1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: smishura Date: Thu Feb 8 22:42:57 2007 New Revision: 505200 URL: http://svn.apache.org/viewvc?view=rev&rev=505200 Log: Refactor tests and delete duplicated testing for Security.addProvider() Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Security2Test.java harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Security2Test.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Security2Test.java?view=diff&rev=505200&r1=505199&r2=505200 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Security2Test.java (original) +++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Security2Test.java Thu Feb 8 22:42:57 2007 @@ -25,82 +25,10 @@ import java.util.Map; import java.util.Set; -import tests.support.Support_ProviderJCE; -import tests.support.Support_ProviderRSA; import tests.support.Support_ProviderTrust; import tests.support.Support_TestProvider; public class Security2Test extends junit.framework.TestCase { - - /** - * @tests java.security.Security#addProvider(java.security.Provider) - */ - public void test_addProviderLjava_security_Provider() { - // Test for method int - // java.security.Security.addProvider(java.security.Provider) - - // adding the dummy RSA provider - Provider rsa = new Support_ProviderRSA(); - String rsaName = rsa.getName(); - try { - int prefPos = Security.addProvider(rsa); - Provider provTest[] = Security.getProviders(); - Provider result = Security.getProvider(rsaName); - assertTrue("ERROR:the RSA provider was not added properly", result - .getName().equals(rsaName) - && result.getInfo().equals(rsa.getInfo()) - && result.getVersion() == rsa.getVersion()); - // Provider should have been added at the end of the sequence of - // providers. - assertTrue("provider is not found at the expected position", - provTest[prefPos - 1].getName().equals(rsaName)); - } finally { - // Now remove it - does nothing if provider not actually installed - Security.removeProvider(rsaName); - } - - // adding TestProvider provider - Provider test = new Support_TestProvider(); - try { - int prefPosTest = Security.addProvider(test); - Provider provTest2[] = Security.getProviders(); - Provider result2 = provTest2[prefPosTest - 1]; - assertTrue( - "ERROR: the TestProvider provider was not added properly", - result2.getName().equals(test.getName()) - && result2.getInfo().equals(test.getInfo()) - && result2.getVersion() == test.getVersion()); - } finally { - // Now remove it - does nothing if provider not actually installed - Security.removeProvider(test.getName()); - } - - // adding the dummy entrust provider - Provider entrust = new Support_ProviderTrust(); - try { - int prefPosEnt = Security.addProvider(entrust); - Provider provTest3[] = Security.getProviders(); - assertTrue( - "ERROR: the entrust provider was not added properly", - provTest3[prefPosEnt - 1].getName().equals( - entrust.getName()) - && provTest3[prefPosEnt - 1].getInfo().equals( - entrust.getInfo()) - && provTest3[prefPosEnt - 1].getVersion() == entrust - .getVersion()); - assertTrue("provider should be added at the end of the array", - prefPosEnt == provTest3.length); - - // trying to add the entrust provider again - int prefPosEntAdded = Security.addProvider(entrust); - Security.getProviders(); - assertEquals("addProvider method did not return a -1 for " - + "a provider already added", -1, prefPosEntAdded); - } finally { - // Now remove it - does nothing if provider not actually installed - Security.removeProvider(entrust.getName()); - } - } /** * @tests java.security.Security#getProviders(java.lang.String) Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java?view=diff&rev=505200&r1=505199&r2=505200 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java Thu Feb 8 22:42:57 2007 @@ -98,35 +98,30 @@ } } - public final void testAddProvider() { + /** + * @tests java.security.Security#addProvider(Provider) + */ + public final void test_addProviderLjava_security_Provider() { + + try { + Security.addProvider(null); + fail("No expected NullPointerException"); + } catch (NullPointerException e) { + } Provider p = new MyProvider(); - int newposition; - Provider providers[] = Security.getProviders(); - int providersNumber = providers.length; - + int initNum = Security.getProviders().length; // initial number of providers + try { // add - newposition = Security.addProvider(p); - assertEquals(providersNumber + 1, newposition); + assertEquals(initNum + 1, Security.addProvider(p)); + assertSame(p, Security.getProviders()[initNum]); - providers = Security.getProviders(); - assertSame("Provider not inserted at position " + newposition, p, - providers[newposition - 1]); - // A provider cannot be added if it is already installed - newposition = Security.addProvider(p); - assertEquals(-1, newposition); - - try { - Security.addProvider(null); - fail("No expected NullPointerException."); - } catch (NullPointerException e) { - } + assertEquals(-1, Security.addProvider(p)); } finally { //clean up Security.removeProvider(p.getName()); } - } public final void testRemoveProvider() {