Return-Path: X-Original-To: apmail-incubator-flex-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-flex-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EA0CA9CC6 for ; Tue, 6 Mar 2012 21:44:17 +0000 (UTC) Received: (qmail 65077 invoked by uid 500); 6 Mar 2012 21:44:17 -0000 Delivered-To: apmail-incubator-flex-commits-archive@incubator.apache.org Received: (qmail 65049 invoked by uid 500); 6 Mar 2012 21:44:17 -0000 Mailing-List: contact flex-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: flex-dev@incubator.apache.org Delivered-To: mailing list flex-commits@incubator.apache.org Received: (qmail 65024 invoked by uid 99); 6 Mar 2012 21:44:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Mar 2012 21:44:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Mar 2012 21:44:15 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9AF1A2388993; Tue, 6 Mar 2012 21:43:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1297738 - /incubator/flex/whiteboard/jmclean/validators/src/tests/PostCodeValidatorTests.as Date: Tue, 06 Mar 2012 21:43:55 -0000 To: flex-commits@incubator.apache.org From: jmclean@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120306214355.9AF1A2388993@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jmclean Date: Tue Mar 6 21:43:55 2012 New Revision: 1297738 URL: http://svn.apache.org/viewvc?rev=1297738&view=rev Log: added tests for changing locale and setting error overrides Modified: incubator/flex/whiteboard/jmclean/validators/src/tests/PostCodeValidatorTests.as Modified: incubator/flex/whiteboard/jmclean/validators/src/tests/PostCodeValidatorTests.as URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/jmclean/validators/src/tests/PostCodeValidatorTests.as?rev=1297738&r1=1297737&r2=1297738&view=diff ============================================================================== --- incubator/flex/whiteboard/jmclean/validators/src/tests/PostCodeValidatorTests.as (original) +++ incubator/flex/whiteboard/jmclean/validators/src/tests/PostCodeValidatorTests.as Tue Mar 6 21:43:55 2012 @@ -1,5 +1,7 @@ package tests { + import mx.resources.IResourceManager; + import mx.resources.ResourceManager; import mx.validators.PostCodeValidator; import mx.validators.ValidationResult; @@ -462,6 +464,56 @@ package tests return null; } + + [Test] + public function errorOverrides():void { + var error:String = "New error"; + var resourceManager:IResourceManager = ResourceManager.getInstance(); + var resourcesUS:Object = resourceManager.getResourceBundle("en_US", "validators"); + + assertTrue("Error not overridden", validator.invalidCharError == resourcesUS.content.invalidCharPostcodeError); + validator.invalidCharError = error; + assertTrue("Error overridden", validator.invalidCharError == error); + validator.invalidCharError = null; + assertTrue("Error not overridden", validator.invalidCharError == resourcesUS.content.invalidCharPostcodeError); + + assertTrue("Error not overridden", validator.wrongFormatError == resourcesUS.content.wrongFormatPostcodeError); + validator.wrongFormatError = error; + assertTrue("Error overridden", validator.wrongFormatError == error); + validator.wrongFormatError = null; + assertTrue("Error not overridden", validator.wrongFormatError == resourcesUS.content.wrongFormatPostcodeError); + + assertTrue("Error not overridden", validator.wrongLengthError == resourcesUS.content.wrongLengthPostcodeError); + validator.wrongLengthError = error; + assertTrue("Error overridden", validator.wrongLengthError == error); + validator.wrongLengthError = null; + assertTrue("Error not overridden", validator.wrongLengthError == resourcesUS.content.wrongLengthPostcodeError); + } + + // NOTE: To pass this test project must be compiled with option locale=en_US,en_AU + [Test] + public function changeLocale():void { + var resourceManager:IResourceManager = ResourceManager.getInstance(); + var resourcesUS:Object = resourceManager.getResourceBundle("en_US", "validators"); + var resourcesAU:Object = resourceManager.getResourceBundle("en_AU", "validators"); + + assertTrue("en_US locale loaded", resourcesUS); + assertTrue("en_AU locale loaded", resourcesAU); + + assertTrue("US Error", validator.invalidCharError == resourcesUS.content.invalidCharPostcodeError); + assertTrue("US Error", validator.wrongFormatError == resourcesUS.content.wrongFormatPostcodeError); + assertTrue("US Error", validator.wrongLengthError == resourcesUS.content.wrongLengthPostcodeError); + + resourceManager.localeChain = ["en_AU"]; + + assertTrue("Error changed", validator.invalidCharError != resourcesUS.content.invalidCharPostcodeError); + assertTrue("Error changed", validator.wrongFormatError != resourcesUS.content.wrongFormatPostcodeError); + assertTrue("Error changed", validator.wrongLengthError != resourcesUS.content.wrongLengthPostcodeError); + + assertTrue("AU Error", validator.invalidCharError == resourcesAU.content.invalidCharPostcodeError); + assertTrue("AU Error", validator.wrongFormatError == resourcesAU.content.wrongFormatPostcodeError); + assertTrue("AU Error", validator.wrongLengthError == resourcesAU.content.wrongLengthPostcodeError); + } } } \ No newline at end of file