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 664D011C7E for ; Mon, 15 Sep 2014 19:58:37 +0000 (UTC) Received: (qmail 72903 invoked by uid 500); 15 Sep 2014 19:58:37 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 72830 invoked by uid 500); 15 Sep 2014 19:58:37 -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 72821 invoked by uid 99); 15 Sep 2014 19:58:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Sep 2014 19:58:37 +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; Mon, 15 Sep 2014 19:58:36 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id F27A92388AB9; Mon, 15 Sep 2014 19:58:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1625139 - /commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/ConfigurationAssert.java Date: Mon, 15 Sep 2014 19:58:15 -0000 To: commits@commons.apache.org From: oheger@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140915195815.F27A92388AB9@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: oheger Date: Mon Sep 15 19:58:15 2014 New Revision: 1625139 URL: http://svn.apache.org/r1625139 Log: Added some test helper methods related to the processing of configuration keys. These methods allow the removal of all references to [collections] in test classes. Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/ConfigurationAssert.java Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/ConfigurationAssert.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/ConfigurationAssert.java?rev=1625139&r1=1625138&r2=1625139&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/ConfigurationAssert.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/ConfigurationAssert.java Mon Sep 15 19:58:15 2014 @@ -23,7 +23,12 @@ import static org.junit.Assert.assertTru import java.io.File; import java.net.MalformedURLException; import java.net.URL; +import java.util.Collection; +import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; import org.apache.commons.configuration2.ex.ConfigurationRuntimeException; @@ -140,6 +145,47 @@ public class ConfigurationAssert } /** + * Returns a list with all keys defined for the specified configuration. + * + * @param config the configuration + * @return a list with all keys of this configuration + */ + public static List keysToList(Configuration config) + { + List keyList = new LinkedList(); + appendKeys(config, keyList); + return keyList; + } + + /** + * Returns a set with all keys defined for the specified configuration. + * + * @param config the configuration + * @return a set with all keys of this configuration + */ + public static Set keysToSet(Configuration config) + { + Set keySet = new HashSet(); + appendKeys(config, keySet); + return keySet; + } + + /** + * Appends all keys in the specified configuration to the given collection. + * + * @param config the configuration + * @param collection the target collection + */ + public static void appendKeys(Configuration config, + Collection collection) + { + for (Iterator it = config.getKeys(); it.hasNext();) + { + collection.add(it.next()); + } + } + + /** * Helper method for converting a file to a URL. * * @param file the file