Merge pull request #479 from wutingbupt/master

Fix the parameter related bug [[testng-users] Unexpected behavior when excluding methods with parameters in testng.xml. Is this a bug?]
diff --git a/src/main/java/org/testng/xml/TestNGContentHandler.java b/src/main/java/org/testng/xml/TestNGContentHandler.java
index af2e338..cfa4654 100755
--- a/src/main/java/org/testng/xml/TestNGContentHandler.java
+++ b/src/main/java/org/testng/xml/TestNGContentHandler.java
@@ -18,11 +18,7 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Stack;
-import java.util.Properties;
-import java.util.HashMap;
-import java.util.Set;
 
 /**
  * Suite definition parser utility.
@@ -55,7 +51,8 @@
     SUITE,
     TEST,
     CLASS,
-    INCLUDE
+    INCLUDE,
+    EXCLUDE
   }
   private Stack<Location> m_locations = new Stack<Location>();
 
@@ -578,15 +575,7 @@
       xmlInclude(true, attributes);
     }
     else if ("exclude".equals(qName)) {
-      if (null != m_currentExcludedMethods) {
-        m_currentExcludedMethods.add(name);
-      }
-      else if (null != m_currentRuns) {
-        m_currentExcludedGroups.add(name);
-      }
-      else if (null != m_currentPackage) {
-        m_currentPackage.getExclude().add(name);
-      }
+      xmlExclude(true, attributes);
     }
     else if ("parameter".equals(qName)) {
       String value = expandValue(attributes.getValue("value"));
@@ -656,6 +645,24 @@
     }
   }
 
+  private void xmlExclude(boolean start, Attributes attributes) {
+    if (start) {
+      m_locations.push(Location.EXCLUDE);
+      String name = attributes.getValue("name");
+      if (null != m_currentExcludedMethods) {
+        m_currentExcludedMethods.add(name);
+      }
+      else if (null != m_currentRuns) {
+        m_currentExcludedGroups.add(name);
+      }
+      else if (null != m_currentPackage) {
+        m_currentPackage.getExclude().add(name);
+      }
+    } else {
+      popLocation(Location.EXCLUDE);
+    }
+  }
+
   private void pushLocation(Location l) {
     m_locations.push(l);
   }
@@ -724,6 +731,8 @@
     }
     else if ("include".equals(qName)) {
       xmlInclude(false, null);
+    } else if ("exclude".equals(qName)){
+      xmlExclude(false, null);
     }
   }