Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 243C6200B72 for ; Fri, 26 Aug 2016 18:41:45 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 22C4E160AB6; Fri, 26 Aug 2016 16:41:45 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 44511160A94 for ; Fri, 26 Aug 2016 18:41:44 +0200 (CEST) Received: (qmail 60887 invoked by uid 500); 26 Aug 2016 16:41:43 -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 60878 invoked by uid 99); 26 Aug 2016 16:41:43 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Aug 2016 16:41:43 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 0AFDD1A5C61 for ; Fri, 26 Aug 2016 16:41:43 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.374 X-Spam-Level: X-Spam-Status: No, score=0.374 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id dQkmpoFIs-5k for ; Fri, 26 Aug 2016 16:41:41 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id C87375F39B for ; Fri, 26 Aug 2016 16:41:40 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id BE642E0178 for ; Fri, 26 Aug 2016 16:41:39 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id C318A3A0EF2 for ; Fri, 26 Aug 2016 16:41:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1757890 - in /commons/proper/configuration/trunk/src/test: java/org/apache/commons/configuration2/ resources/ Date: Fri, 26 Aug 2016 16:41:38 -0000 To: commits@commons.apache.org From: oheger@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160826164138.C318A3A0EF2@svn01-us-west.apache.org> archived-at: Fri, 26 Aug 2016 16:41:45 -0000 Author: oheger Date: Fri Aug 26 16:41:38 2016 New Revision: 1757890 URL: http://svn.apache.org/viewvc?rev=1757890&view=rev Log: [CONFIGURATION-638] Removed temporary files in tests. Some tests have been rewritten to use JUnit's TemporaryFolder class to prevent that temporary files or folders remain after test exectuion. Thanks to Ahmet Celik for the patch. Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestDynamicCombinedConfiguration.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java commons/proper/configuration/trunk/src/test/resources/testMultiTenentConfigurationBuilder5.xml Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestDynamicCombinedConfiguration.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestDynamicCombinedConfiguration.java?rev=1757890&r1=1757889&r2=1757890&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestDynamicCombinedConfiguration.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestDynamicCombinedConfiguration.java Fri Aug 26 16:41:38 2016 @@ -52,6 +52,8 @@ import org.apache.commons.configuration2 import org.apache.commons.configuration2.tree.xpath.XPathExpressionEngine; import org.junit.BeforeClass; import org.junit.Test; +import org.junit.Rule; +import org.junit.rules.TemporaryFolder; public class TestDynamicCombinedConfiguration { @@ -72,6 +74,10 @@ public class TestDynamicCombinedConfigur /** A helper object for creating builder parameters. */ private static Parameters parameters; + /** Helper object for creating temporary files. */ + @Rule + public TemporaryFolder folder = new TemporaryFolder(); + @BeforeClass public static void setUpOnce() { @@ -342,9 +348,10 @@ public class TestDynamicCombinedConfigur { final int threadCount = 25; System.getProperties().remove("Id"); + System.setProperty("TemporaryFolder", folder.getRoot().getAbsolutePath()); // create a new configuration File input = new File("target/test-classes/testMultiDynamic_default.xml"); - File output = new File("target/test-classes/testwrite/testMultiDynamic_default.xml"); + File output = folder.newFile("testMultiDynamic_default.xml"); output.delete(); output.getParentFile().mkdir(); copyFile(input, output); Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java?rev=1757890&r1=1757889&r2=1757890&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java Fri Aug 26 16:41:38 2016 @@ -68,6 +68,8 @@ import org.apache.commons.configuration2 import org.apache.commons.lang3.mutable.MutableObject; import org.junit.Before; import org.junit.Test; +import org.junit.Rule; +import org.junit.rules.TemporaryFolder; /** * Test for loading and saving properties files. @@ -95,6 +97,10 @@ public class TestPropertiesConfiguration private static String testBasePath2 = ConfigurationAssert.TEST_DIR.getParentFile().getAbsolutePath(); private static File testSavePropertiesFile = ConfigurationAssert.getOutFile("testsave.properties"); + /** Helper object for creating temporary files. */ + @Rule + public TemporaryFolder folder = new TemporaryFolder(); + @Before public void setUp() throws Exception { @@ -297,7 +303,7 @@ public class TestPropertiesConfiguration public void testSaveToCustomURL() throws Exception { // save the configuration to a custom URL - URL url = new URL("foo", "", 0, "./target/testsave-custom-url.properties", new FileURLStreamHandler()); + URL url = new URL("foo", "", 0, folder.newFile("testsave-custom-url.properties").getAbsolutePath(), new FileURLStreamHandler()); FileHandler handlerSave = new FileHandler(conf); handlerSave.save(url); @@ -778,8 +784,7 @@ public class TestPropertiesConfiguration @Test public void testFileWithSharpSymbol() throws Exception { - File file = new File("target/sharp#1.properties"); - file.createNewFile(); + File file = folder.newFile("sharp#1.properties"); PropertiesConfiguration conf = new PropertiesConfiguration(); FileHandler handler = new FileHandler(conf); Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java?rev=1757890&r1=1757889&r2=1757890&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java (original) +++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java Fri Aug 26 16:41:38 2016 @@ -54,6 +54,8 @@ import org.apache.commons.configuration2 import org.apache.commons.configuration2.tree.xpath.XPathExpressionEngine; import org.junit.Before; import org.junit.Test; +import org.junit.Rule; +import org.junit.rules.TemporaryFolder; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; @@ -87,11 +89,15 @@ public class TestXMLConfiguration /** Constant for the transformer factory property.*/ static final String PROP_FACTORY = "javax.xml.transform.TransformerFactory"; + /** Helper object for creating temporary files. */ + @Rule + public TemporaryFolder folder = new TemporaryFolder(); + /** The File that we test with */ private final String testProperties = ConfigurationAssert.getTestFile("test.xml").getAbsolutePath(); private final String testProperties2 = ConfigurationAssert.getTestFile("testDigesterConfigurationInclude1.xml").getAbsolutePath(); - private final File testSaveConf = ConfigurationAssert.getOutFile("testsave.xml"); - private final File testSaveFile = ConfigurationAssert.getOutFile("testsample2.xml"); + private File testSaveConf; + private File testSaveFile; private final String testFile2 = ConfigurationAssert.getTestFile("sample.xml").getAbsolutePath(); /** Constant for the number of test threads. */ @@ -105,6 +111,8 @@ public class TestXMLConfiguration @Before public void setUp() throws Exception { + testSaveConf = folder.newFile("testsave.xml"); + testSaveFile = folder.newFile("testsample2.xml"); conf = createFromFile(testProperties); removeTestFile(); } Modified: commons/proper/configuration/trunk/src/test/resources/testMultiTenentConfigurationBuilder5.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/resources/testMultiTenentConfigurationBuilder5.xml?rev=1757890&r1=1757889&r2=1757890&view=diff ============================================================================== --- commons/proper/configuration/trunk/src/test/resources/testMultiTenentConfigurationBuilder5.xml (original) +++ commons/proper/configuration/trunk/src/test/resources/testMultiTenentConfigurationBuilder5.xml Fri Aug 26 16:41:38 2016 @@ -32,17 +32,17 @@ - - - \ No newline at end of file +