Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-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 2179617AA5 for ; Thu, 7 May 2015 20:14:39 +0000 (UTC) Received: (qmail 60332 invoked by uid 500); 7 May 2015 20:14:38 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 60024 invoked by uid 500); 7 May 2015 20:14:38 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 59814 invoked by uid 99); 7 May 2015 20:14:38 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 May 2015 20:14:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4B01EE4432; Thu, 7 May 2015 20:14:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: britter@apache.org To: commits@commons.apache.org Date: Thu, 07 May 2015 20:14:41 -0000 Message-Id: <6792a7ee59a7427db353b41e52e58162@git.apache.org> In-Reply-To: <537df6ac3d604f8aae9e56a372796621@git.apache.org> References: <537df6ac3d604f8aae9e56a372796621@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [4/8] [lang] Fix whitespaces and indentation Fix whitespaces and indentation Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/18b3437c Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/18b3437c Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/18b3437c Branch: refs/heads/master Commit: 18b3437c15d78c54510964728486831822809d9c Parents: 3dbf1ee Author: Benedikt Ritter Authored: Thu May 7 20:49:52 2015 +0200 Committer: Benedikt Ritter Committed: Thu May 7 20:49:52 2015 +0200 ---------------------------------------------------------------------- .../commons/lang3/test/SwitchDefaults.java | 58 ++++++++++---------- .../commons/lang3/test/SystemDefaults.java | 16 +++--- 2 files changed, 36 insertions(+), 38 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/18b3437c/src/test/java/org/apache/commons/lang3/test/SwitchDefaults.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/lang3/test/SwitchDefaults.java b/src/test/java/org/apache/commons/lang3/test/SwitchDefaults.java index d48bd37..cacf37d 100644 --- a/src/test/java/org/apache/commons/lang3/test/SwitchDefaults.java +++ b/src/test/java/org/apache/commons/lang3/test/SwitchDefaults.java @@ -58,46 +58,44 @@ import org.junit.runners.model.Statement; * */ public class SwitchDefaults implements TestRule { + + @Override + public Statement apply(Statement stmt, Description description) { + SystemDefaults defaults = description.getAnnotation(SystemDefaults.class); + if (defaults == null) { + return stmt; + } + return applyTimeZone(defaults, applyLocale(defaults, stmt)); + } + private Statement applyTimeZone(SystemDefaults defaults, final Statement stmt) { + if (defaults.timezone().isEmpty()) { + return stmt; + } + final TimeZone newTimeZone = TimeZone.getTimeZone(defaults.timezone()); - @Override - public Statement apply(Statement stmt, Description description) { - SystemDefaults defaults = description.getAnnotation(SystemDefaults.class); - if(defaults == null) { - return stmt; - } - return applyTimeZone(defaults, applyLocale(defaults, stmt)); - } - - private Statement applyTimeZone(SystemDefaults defaults, final Statement stmt) { - if(defaults.timezone().isEmpty()) { - return stmt; - } - - final TimeZone newTimeZone = TimeZone.getTimeZone(defaults.timezone()); - return new Statement() { @Override public void evaluate() throws Throwable { - TimeZone save = TimeZone.getDefault(); + TimeZone save = TimeZone.getDefault(); try { - TimeZone.setDefault(newTimeZone); + TimeZone.setDefault(newTimeZone); stmt.evaluate(); } finally { - TimeZone.setDefault(save); + TimeZone.setDefault(save); } } - }; - } + }; + } + + private Statement applyLocale(SystemDefaults defaults, final Statement stmt) { + if (defaults.locale().isEmpty()) { + return stmt; + } + + final Locale newLocale = LocaleUtils.toLocale(defaults.locale()); - private Statement applyLocale(SystemDefaults defaults, final Statement stmt) { - if(defaults.locale().isEmpty()) { - return stmt; - } - - final Locale newLocale = LocaleUtils.toLocale(defaults.locale()); - return new Statement() { @Override public void evaluate() throws Throwable { @@ -109,7 +107,7 @@ public class SwitchDefaults implements TestRule { Locale.setDefault(save); } } - }; - } + }; + } } http://git-wip-us.apache.org/repos/asf/commons-lang/blob/18b3437c/src/test/java/org/apache/commons/lang3/test/SystemDefaults.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/lang3/test/SystemDefaults.java b/src/test/java/org/apache/commons/lang3/test/SystemDefaults.java index 1c95f28..e5893a2 100644 --- a/src/test/java/org/apache/commons/lang3/test/SystemDefaults.java +++ b/src/test/java/org/apache/commons/lang3/test/SystemDefaults.java @@ -29,12 +29,12 @@ import java.lang.annotation.Target; @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface SystemDefaults { - /** - * The name of the Locale to be used while running a test method - */ - String locale() default ""; - /** - * The name of the TimeZone to be used while running a test method - */ - String timezone() default ""; + /** + * The name of the Locale to be used while running a test method + */ + String locale() default ""; + /** + * The name of the TimeZone to be used while running a test method + */ + String timezone() default ""; }