commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r895218 - /commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDynamicCombinedConfiguration.java
Date Sat, 02 Jan 2010 16:16:02 GMT
Author: oheger
Date: Sat Jan  2 16:16:01 2010
New Revision: 895218

URL: http://svn.apache.org/viewvc?rev=895218&view=rev
Log:
Make tests a bit faster by reducing the loop count in tests with multiple threads.

Modified:
    commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDynamicCombinedConfiguration.java

Modified: commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDynamicCombinedConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDynamicCombinedConfiguration.java?rev=895218&r1=895217&r2=895218&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDynamicCombinedConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDynamicCombinedConfiguration.java
Sat Jan  2 16:16:01 2010
@@ -18,26 +18,33 @@
 package org.apache.commons.configuration;
 
 import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.io.Reader;
-import java.io.FileReader;
 import java.io.Writer;
-import java.io.FileWriter;
 
 import junit.framework.TestCase;
+
 import org.apache.commons.configuration.tree.xpath.XPathExpressionEngine;
 import org.apache.commons.lang.text.StrLookup;
 
 public class TestDynamicCombinedConfiguration extends TestCase
 {
-    private static String PATTERN ="${sys:Id}";
+    private static String PATTERN = "${sys:Id}";
     private static String PATTERN1 = "target/test-classes/testMultiConfiguration_${sys:Id}.xml";
     private static String DEFAULT_FILE = "target/test-classes/testMultiConfiguration_default.xml";
     private static final File MULTI_TENENT_FILE = new File(
             "conf/testMultiTenentConfigurationBuilder4.xml");
-     private static final File MULTI_DYNAMIC_FILE = new File(
+    private static final File MULTI_DYNAMIC_FILE = new File(
             "conf/testMultiTenentConfigurationBuilder5.xml");
-    
+
+    /** Constant for the number of test threads. */
+    private static final int THREAD_COUNT = 3;
+
+    /** Constant for the number of loops in the multi-thread tests. */
+    private static final int LOOP_COUNT = 100;
+
     public void testConfiguration() throws Exception
     {
         DynamicCombinedConfiguration config = new DynamicCombinedConfiguration();
@@ -69,20 +76,18 @@
 
     public void testConcurrentGetAndReload() throws Exception
     {
-        final int threadCount = 5;
-        final int loopCount = 500;
         System.getProperties().remove("Id");
         DefaultConfigurationBuilder factory = new DefaultConfigurationBuilder();
         factory.setFile(MULTI_TENENT_FILE);
         CombinedConfiguration config = factory.getConfiguration(true);
 
         assertEquals(config.getString("rowsPerPage"), "50");
-        Thread testThreads[] = new Thread[threadCount];
-        int failures[] = new int[threadCount];
+        Thread testThreads[] = new Thread[THREAD_COUNT];
+        int failures[] = new int[THREAD_COUNT];
 
         for (int i = 0; i < testThreads.length; ++i)
         {
-            testThreads[i] = new ReloadThread(config, failures, i, loopCount, false, null,
"50");
+            testThreads[i] = new ReloadThread(config, failures, i, LOOP_COUNT, false, null,
"50");
             testThreads[i].start();
         }
 
@@ -97,8 +102,6 @@
 
     public void testConcurrentGetAndReload2() throws Exception
     {
-        final int threadCount = 5;
-        final int loopCount = 500;
         System.getProperties().remove("Id");
         DefaultConfigurationBuilder factory = new DefaultConfigurationBuilder();
         factory.setFile(MULTI_TENENT_FILE);
@@ -106,13 +109,13 @@
 
         assertEquals(config.getString("rowsPerPage"), "50");
 
-        Thread testThreads[] = new Thread[threadCount];
-        int failures[] = new int[threadCount];
+        Thread testThreads[] = new Thread[THREAD_COUNT];
+        int failures[] = new int[THREAD_COUNT];
         System.setProperty("Id", "2002");
         assertEquals(config.getString("rowsPerPage"), "25");
         for (int i = 0; i < testThreads.length; ++i)
         {
-            testThreads[i] = new ReloadThread(config, failures, i, loopCount, false, null,
"25");
+            testThreads[i] = new ReloadThread(config, failures, i, LOOP_COUNT, false, null,
"25");
             testThreads[i].start();
         }
 
@@ -128,8 +131,6 @@
 
     public void testConcurrentGetAndReloadMultipleClients() throws Exception
     {
-        final int threadCount = 5;
-        final int loopCount = 500;
         System.getProperties().remove("Id");
         DefaultConfigurationBuilder factory = new DefaultConfigurationBuilder();
         factory.setFile(MULTI_TENENT_FILE);
@@ -137,13 +138,13 @@
 
         assertEquals(config.getString("rowsPerPage"), "50");
 
-        Thread testThreads[] = new Thread[threadCount];
-        int failures[] = new int[threadCount];
+        Thread testThreads[] = new Thread[THREAD_COUNT];
+        int failures[] = new int[THREAD_COUNT];
         String[] ids = new String[] {null, "2002", "3001", "3002", "3003"};
         String[] expected = new String[] {"50", "25", "15", "25", "50"};
         for (int i = 0; i < testThreads.length; ++i)
         {
-            testThreads[i] = new ReloadThread(config, failures, i, loopCount, true, ids[i],
expected[i]);
+            testThreads[i] = new ReloadThread(config, failures, i, LOOP_COUNT, true, ids[i],
expected[i]);
             testThreads[i].start();
         }
 



Mime
View raw message