From 97c4b6bd774960fe9301829cf2d1ac23882e8958 Mon Sep 17 00:00:00 2001 From: Mark Donszelmann Date: Fri, 27 Nov 2009 14:33:32 +0100 Subject: Fixed test for NAR-109 --- src/main/java/net/sf/antcontrib/cpptasks/CCTask.java | 19 ++++++++++--------- .../java/net/sf/antcontrib/cpptasks/TestCCTask.java | 12 +++++++----- 2 files changed, 17 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java b/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java index 62a8e6d..fec91af 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Comparator; import java.util.Enumeration; +import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.List; @@ -173,8 +174,8 @@ public class CCTask extends Task { * Builds a Hashtable to targets needing to be rebuilt keyed by compiler * configuration */ - public static Hashtable getTargetsToBuildByConfiguration(Map targets) { - Hashtable targetsByConfig = new Hashtable(); + public static Map getTargetsToBuildByConfiguration(Map targets) { + Map targetsByConfig = new HashMap(); Iterator targetEnum = targets.values().iterator(); while (targetEnum.hasNext()) { TargetInfo target = (TargetInfo) targetEnum.next(); @@ -688,17 +689,17 @@ public class CCTask extends Task { // // compile all targets with getRebuild() == true // - Hashtable targetsByConfig = getTargetsToBuildByConfiguration(targets); + Map targetsByConfig = getTargetsToBuildByConfiguration(targets); // // build array containing Vectors with precompiled generation // steps going first // Vector[] targetVectors = new Vector[targetsByConfig.size()]; int index = 0; - Enumeration targetVectorEnum = targetsByConfig.elements(); - while (targetVectorEnum.hasMoreElements()) { + Iterator targetVectorEnum = targetsByConfig.values().iterator(); + while (targetVectorEnum.hasNext()) { Vector targetsForConfig = (Vector) targetVectorEnum - .nextElement(); + .next(); // // get the configuration from the first entry // @@ -708,10 +709,10 @@ public class CCTask extends Task { targetVectors[index++] = targetsForConfig; } } - targetVectorEnum = targetsByConfig.elements(); - while (targetVectorEnum.hasMoreElements()) { + targetVectorEnum = targetsByConfig.values().iterator(); + while (targetVectorEnum.hasNext()) { Vector targetsForConfig = (Vector) targetVectorEnum - .nextElement(); + .next(); for (int i = 0; i < targetVectors.length; i++) { if (targetVectors[i] == targetsForConfig) { break; diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestCCTask.java b/src/test/java/net/sf/antcontrib/cpptasks/TestCCTask.java index 82faae2..e26ebb3 100644 --- a/src/test/java/net/sf/antcontrib/cpptasks/TestCCTask.java +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestCCTask.java @@ -19,8 +19,10 @@ package net.sf.antcontrib.cpptasks; import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.util.Hashtable; +import java.util.HashMap; +import java.util.Map; import java.util.Vector; + import junit.framework.TestCase; import net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration; import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration; @@ -53,9 +55,9 @@ public final class TestCCTask TargetInfo target1 = new TargetInfo(config1, new File[] {new File( "src/foo.bar")} , null, new File("foo.obj"), true); - Hashtable targets = new Hashtable(); + Map targets = new HashMap(); targets.put(target1.getOutput(), target1); - Hashtable targetsByConfig = CCTask + Map targetsByConfig = CCTask .getTargetsToBuildByConfiguration(targets); Vector targetsForConfig1 = (Vector) targetsByConfig.get(config1); assertNotNull(targetsForConfig1); @@ -80,12 +82,12 @@ public final class TestCCTask TargetInfo target1 = new TargetInfo(config1, new File[] {new File( "src/foo.bar")} , null, new File("foo.obj"), false); - Hashtable targets = new Hashtable(); + Map targets = new HashMap(); targets.put(target1.getOutput(), target1); // // no targets need to be built, return a zero-length hashtable // - Hashtable targetsByConfig = CCTask + Map targetsByConfig = CCTask .getTargetsToBuildByConfiguration(targets); assertEquals(0, targetsByConfig.size()); } -- cgit v1.2.3