Author: pmouawad
Date: Thu Feb 18 13:14:53 2016
New Revision: 1731066

URL: http://svn.apache.org/viewvc?rev=1731066&view=rev
Log:
Removing duplicate code.
Patch by Graham Russell
#resolve #126

Modified:
    
jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/HTMLAssertionGui.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java
    jmeter/trunk/src/jorphan/org/apache/commons/jexl/bsf/JexlEngine.java
    jmeter/trunk/src/jorphan/org/apache/jorphan/collections/Data.java
    jmeter/trunk/src/jorphan/org/apache/jorphan/exec/KeyToolUtils.java
    jmeter/trunk/src/jorphan/org/apache/jorphan/util/XMLBuffer.java
    
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
    
jmeter/trunk/src/protocol/ldap/org/apache/jmeter/protocol/ldap/config/gui/LdapConfigGui.java
    jmeter/trunk/test/src/org/apache/jmeter/gui/util/TristateCheckBoxTest.java

Modified: 
jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/HTMLAssertionGui.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/HTMLAssertionGui.java?rev=1731066&r1=1731065&r2=1731066&view=diff
==============================================================================
--- 
jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/HTMLAssertionGui.java
 (original)
+++ 
jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/HTMLAssertionGui.java
 Thu Feb 18 13:14:53 2016
@@ -272,16 +272,7 @@ public class HTMLAssertionGui extends Ab
 
         String errorThresholdString = errorThresholdField.getText();
         if (errorThresholdString != null) {
-            boolean isInvalid = false;
-            try {
-                long errorThreshold = Long.parseLong(errorThresholdString);
-                if (errorThreshold < 0) {
-                    isInvalid = true;
-                }
-            } catch (NumberFormatException ex) {
-                isInvalid = true;
-            }
-            if (isInvalid) {
+            if (!isThresholdValid(errorThresholdString)) {
                 log.warn("HTMLAssertionGui: Error threshold Not a valid 
number!");
                 JOptionPane.showMessageDialog(null, "Threshold for errors is 
invalid", "Error",
                         JOptionPane.ERROR_MESSAGE);
@@ -290,17 +281,8 @@ public class HTMLAssertionGui extends Ab
 
         String warningThresholdString = warningThresholdField.getText();
         if (warningThresholdString != null) {
-            boolean isInvalid = false;
-            try {
-                long warningThreshold = Long.parseLong(warningThresholdString);
-                if (warningThreshold < 0) {
-                    isInvalid = true;
-                }
-            } catch (NumberFormatException ex) {
-                isInvalid = true;
-            }
-            if (isInvalid) {
-                log.warn("HTMLAssertionGui: Error threshold Not a valid 
number!");
+            if (!isThresholdValid(warningThresholdString)) {
+                log.warn("HTMLAssertionGui: Warning threshold Not a valid 
number!");
                 JOptionPane.showMessageDialog(null, "Threshold for warnings is 
invalid", "Error",
                         JOptionPane.ERROR_MESSAGE);
             }
@@ -308,6 +290,22 @@ public class HTMLAssertionGui extends Ab
     }
 
     /**
+     * @param errorThresholdString Threshold as String
+     * @return boolean
+     */
+    private boolean isThresholdValid(String errorThresholdString) {
+        boolean isValid = true;
+        try {
+            if (Long.parseLong(errorThresholdString) < 0) {
+                isValid = false;
+            }
+        } catch (NumberFormatException ex) {
+            isValid = false;
+        }
+        return isValid;
+    }
+
+    /**
      * Method gets called when one of the threshold fields gains focus
      * 
      * @param e The {@link FocusEvent} with detailed information about the 
focus gain

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java?rev=1731066&r1=1731065&r2=1731066&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java 
(original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java Thu 
Feb 18 13:14:53 2016
@@ -186,14 +186,7 @@ public final class ActionRouter implemen
      *            the ActionListener to receive the notifications
      */
     public void addPreActionListener(Class<?> action, ActionListener listener) 
{
-        if (action != null) {
-            Set<ActionListener> set = preActionListeners.get(action.getName());
-            if (set == null) {
-                set = new HashSet<>();
-            }
-            set.add(listener);
-            preActionListeners.put(action.getName(), set);
-        }
+        addActionListener(action, listener, preActionListeners);
     }
 
     /**
@@ -208,11 +201,20 @@ public final class ActionRouter implemen
      *            the ActionListener to receive the notifications
      */
     public void removePreActionListener(Class<?> action, ActionListener 
listener) {
+        removeActionListener(action, listener, preActionListeners);
+    }
+
+    /**
+     * @param action {@link Class}
+     * @param e {@link ActionListener}
+     * @param actionListeners {@link Set}
+     */
+    private void removeActionListener(Class<?> action, ActionListener 
listener, Map<String, Set<ActionListener>> actionListeners) {
         if (action != null) {
-            Set<ActionListener> set = preActionListeners.get(action.getName());
+            Set<ActionListener> set = actionListeners.get(action.getName());
             if (set != null) {
                 set.remove(listener);
-                preActionListeners.put(action.getName(), set);
+                actionListeners.put(action.getName(), set);
             }
         }
     }
@@ -229,13 +231,22 @@ public final class ActionRouter implemen
      *            The {@link ActionListener} to be registered
      */
     public void addPostActionListener(Class<?> action, ActionListener 
listener) {
+        addActionListener(action, listener, postActionListeners);
+    }
+
+    /**
+     * @param action {@link Class}
+     * @param list {@link ActionListener}
+     * @param actionListeners {@link Set}
+     */
+    private void addActionListener(Class<?> action, ActionListener listener, 
Map<String, Set<ActionListener>> actionListeners) {
         if (action != null) {
-            Set<ActionListener> set = 
postActionListeners.get(action.getName());
+            Set<ActionListener> set = actionListeners.get(action.getName());
             if (set == null) {
                 set = new HashSet<>();
             }
             set.add(listener);
-            postActionListeners.put(action.getName(), set);
+            actionListeners.put(action.getName(), set);
         }
     }
 
@@ -250,30 +261,33 @@ public final class ActionRouter implemen
      * @param listener The {@link ActionListener} that should be deregistered
      */
     public void removePostActionListener(Class<?> action, ActionListener 
listener) {
-        if (action != null) {
-            Set<ActionListener> set = 
postActionListeners.get(action.getName());
-            if (set != null) {
-                set.remove(listener);
-                postActionListeners.put(action.getName(), set);
-            }
-        }
+        removeActionListener(action, listener, postActionListeners);
     }
 
+    /**
+     * @param action {@link Class}
+     * @param e {@link ActionEvent}
+     */
     protected void preActionPerformed(Class<? extends Command> action, 
ActionEvent e) {
-        if (action != null) {
-            Set<ActionListener> listenerSet = 
preActionListeners.get(action.getName());
-            if (listenerSet != null && listenerSet.size() > 0) {
-                ActionListener[] listeners = listenerSet.toArray(new 
ActionListener[listenerSet.size()]);
-                for (ActionListener listener : listeners) {
-                    listener.actionPerformed(e);
-                }
-            }
-        }
+        actionPerformed(action, e, preActionListeners);
     }
 
+    /**
+     * @param action {@link Class}
+     * @param e {@link ActionEvent}
+     */
     protected void postActionPerformed(Class<? extends Command> action, 
ActionEvent e) {
+        actionPerformed(action, e, postActionListeners);
+    }
+
+    /**
+     * @param action {@link Class}
+     * @param e {@link ActionEvent}
+     * @param actionListeners {@link Set}
+     */
+    private void actionPerformed(Class<? extends Command> action, ActionEvent 
e, Map<String, Set<ActionListener>> actionListeners) {
         if (action != null) {
-            Set<ActionListener> listenerSet = 
postActionListeners.get(action.getName());
+            Set<ActionListener> listenerSet = 
actionListeners.get(action.getName());
             if (listenerSet != null && listenerSet.size() > 0) {
                 ActionListener[] listeners = listenerSet.toArray(new 
ActionListener[listenerSet.size()]);
                 for (ActionListener listener : listeners) {

Modified: jmeter/trunk/src/jorphan/org/apache/commons/jexl/bsf/JexlEngine.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/commons/jexl/bsf/JexlEngine.java?rev=1731066&r1=1731065&r2=1731066&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/commons/jexl/bsf/JexlEngine.java 
(original)
+++ jmeter/trunk/src/jorphan/org/apache/commons/jexl/bsf/JexlEngine.java Thu 
Feb 18 13:14:53 2016
@@ -88,7 +88,7 @@ public class JexlEngine extends BSFEngin
             return null;
         }
         try {
-            Script jExpr = null;
+            Script jExpr;
             if (expr instanceof File) {
                 jExpr = ScriptFactory.createScript((File) expr);
             } else if (expr instanceof URL) {
@@ -106,22 +106,7 @@ public class JexlEngine extends BSFEngin
     @Override
     public void exec(String fileName, int lineNo, int colNo, Object script)
             throws BSFException {
-        if (script == null) {
-            return;
-        }
-        try {
-            Script jExpr = null;
-            if (script instanceof File) {
-                jExpr = ScriptFactory.createScript((File) script);
-            } else if (script instanceof URL) {
-                jExpr = ScriptFactory.createScript((URL) script);
-            } else {
-                jExpr = ScriptFactory.createScript((String) script);
-            }
-            jExpr.execute(jc);
-        } catch (Exception e) {
-            throw new BSFException(BSFException.REASON_OTHER_ERROR, 
e.getMessage(), e);
-        }
+        eval(fileName, lineNo, colNo, script);
     }
 
     /** {@inheritDoc} */

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/collections/Data.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/collections/Data.java?rev=1731066&r1=1731065&r2=1731066&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/collections/Data.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/collections/Data.java Thu Feb 
18 13:14:53 2016
@@ -213,17 +213,17 @@ public class Data implements Serializabl
      */
     private void sortData(String column, int start, int end) {
         int x = start, y = end - 1;
-        String basis = ((List<?>) data.get(column)).get((x + y) / 
2).toString();
+        String basis = data.get(column).get((x + y) / 2).toString();
         if (x == y) {
             return;
         }
 
         while (x <= y) {
-            while (x < end && ((List<?>) 
data.get(column)).get(x).toString().compareTo(basis) < 0) {
+            while (x < end && 
data.get(column).get(x).toString().compareTo(basis) < 0) {
                 x++;
             }
 
-            while (y >= (start - 1) && ((List<?>) 
data.get(column)).get(y).toString().compareTo(basis) > 0) {
+            while (y >= (start - 1) && 
data.get(column).get(y).toString().compareTo(basis) > 0) {
                 y--;
             }
 
@@ -416,7 +416,7 @@ public class Data implements Serializabl
     public Object getColumnValue(String column) {
         try {
             if (currentPos < size) {
-                return ((List<?>) data.get(column)).get(currentPos);
+                return data.get(column).get(currentPos);
             } else {
                 return null;
             }
@@ -434,15 +434,7 @@ public class Data implements Serializabl
      */
     public Object getColumnValue(int column) {
         String columnName = header.get(column);
-        try {
-            if (currentPos < size) {
-                return ((List<?>) data.get(columnName)).get(currentPos);
-            } else {
-                return null;
-            }
-        } catch (Exception e) {
-            return null;
-        }
+        return getColumnValue(columnName);
     }
 
     public Object getColumnValue(int column, int row) {

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/exec/KeyToolUtils.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/exec/KeyToolUtils.java?rev=1731066&r1=1731065&r2=1731066&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/exec/KeyToolUtils.java 
(original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/exec/KeyToolUtils.java Thu Feb 
18 13:14:53 2016
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.commons.io.FileUtils;
@@ -183,15 +184,15 @@ public class KeyToolUtils {
             if (quote) {
                 builder.append("\"");
             }
-            builder.append(redact? "{redacted}" : string);
+            builder.append(redact ? "{redacted}" : string);
             if (quote) {
                 builder.append("\"");
             }
             builder.append(" ");
             redact = string.equals("-storepass") || string.equals("-keypass");
         }
-        if(arguments.size()>0) {
-            builder.setLength(builder.length()-1); // trim trailing space
+        if (arguments.size() > 0) {
+            builder.setLength(builder.length() - 1); // trim trailing space
         }
         return builder.toString();
     }
@@ -289,7 +290,7 @@ public class KeyToolUtils {
         ByteArrayOutputStream certOut = new ByteArrayOutputStream();
         KeyToolUtils.keytool("-gencert", keystore, password, 
INTERMEDIATE_CA_ALIAS, certReqIn, certOut, "-ext", "ku:c=dig,keyE");
 
-        // inport the certificate
+        // import the certificate
         InputStream certIn = new ByteArrayInputStream(certOut.toByteArray());
         KeyToolUtils.keytool("-importcert", keystore, password, alias, certIn, 
null, "-noprompt");
     }
@@ -318,6 +319,15 @@ public class KeyToolUtils {
         arguments.add(keystore.getName());
         arguments.add("-storepass"); // $NON-NLS-1$
         arguments.add(storePass);
+        runNativeCommand(nativeCommand, arguments);
+        return nativeCommand.getOutResult();
+    }
+
+    /**
+     * @param nativeCommand {@link SystemCommand}
+     * @param arguments {@link List}
+     */
+    private static void runNativeCommand(SystemCommand nativeCommand, 
List<String> arguments) throws IOException {
         try {
             int exitVal = nativeCommand.run(arguments);
             if (exitVal != 0) {
@@ -326,7 +336,6 @@ public class KeyToolUtils {
         } catch (InterruptedException e) {
             throw new IOException("Command was interrupted\n" + 
nativeCommand.getOutResult(), e);
         }
-        return nativeCommand.getOutResult();
     }
 
     /**
@@ -371,7 +380,8 @@ public class KeyToolUtils {
             InputStream input, OutputStream output, String ... parameters)
             throws IOException {
         final File workingDir = keystore.getParentFile();
-        final SystemCommand nativeCommand = new SystemCommand(workingDir, 0L, 
0, null, input, output, null);
+        final SystemCommand nativeCommand =
+                new SystemCommand(workingDir, 0L, 0, null, input, output, 
null);
         final List<String> arguments = new ArrayList<>();
         arguments.add(getKeyToolPath());
         arguments.add(command);
@@ -383,18 +393,9 @@ public class KeyToolUtils {
         arguments.add(password);
         arguments.add("-alias"); // $NON-NLS-1$
         arguments.add(alias);
-        for (String parameter : parameters) {
-            arguments.add(parameter);
-        }
+        Collections.addAll(arguments, parameters);
 
-        try {
-            int exitVal = nativeCommand.run(arguments);
-            if (exitVal != 0) {
-                throw new IOException("Command failed, code: " + exitVal + 
"\n" + nativeCommand.getOutResult());
-            }
-        } catch (InterruptedException e) {
-            throw new IOException("Command was interrupted\n" + 
nativeCommand.getOutResult(), e);
-        }
+        runNativeCommand(nativeCommand, arguments);
     }
 
     /**

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/util/XMLBuffer.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/util/XMLBuffer.java?rev=1731066&r1=1731065&r2=1731066&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/util/XMLBuffer.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/util/XMLBuffer.java Thu Feb 18 
13:14:53 2016
@@ -32,24 +32,24 @@ public class XMLBuffer{
 
     private final ArrayStack tags = new ArrayStack(); // opened tags
 
-    public XMLBuffer(){
+    public XMLBuffer() {
 
     }
 
-    private void startTag(String t){
+    private void startTag(String t) {
         sb.append("<");
         sb.append(t);
         sb.append(">");
     }
 
-    private void endTag(String t){
+    private void endTag(String t) {
         sb.append("</");
         sb.append(t);
         sb.append(">");
         sb.append("\n");
     }
 
-    private void emptyTag(String t){
+    private void emptyTag(String t) {
         sb.append("<");
         sb.append(t);
         sb.append("/>");
@@ -59,28 +59,29 @@ public class XMLBuffer{
     /**
      * Open a tag; save on stack.
      *
-     * @param tagname name of the tag
+     * @param tagName name of the tag
      * @return this
      */
-    public XMLBuffer openTag(String tagname){
-        tags.push(tagname);
-        startTag(tagname);
+    public XMLBuffer openTag(String tagName) {
+        tags.push(tagName);
+        startTag(tagName);
         return this;
     }
 
     /**
      * Close top tag from stack.
      *
-     * @param tagname name of the tag to close
+     * @param tagName name of the tag to close
      *
      * @return this
      *
      * @throws IllegalArgumentException if the tag names do not match
      */
-    public XMLBuffer closeTag(String tagname){
+    public XMLBuffer closeTag(String tagName) {
         String tag = (String) tags.pop();
-        if (!tag.equals(tagname)) {
-            throw new IllegalArgumentException("Trying to close tag: 
"+tagname+" ; should be "+tag);
+        if (!tag.equals(tagName)) {
+            throw new IllegalArgumentException(
+                    "Trying to close tag: " + tagName + " ; should be " + tag);
         }
         endTag(tag);
         return this;
@@ -89,35 +90,17 @@ public class XMLBuffer{
     /**
      * Add a complete tag with content.
      *
-     * @param tagname name of the tag
+     * @param tagName name of the tag
      * @param content content to put in tag, or empty content, if an empty tag 
should be used
      * @return this
      */
-    public XMLBuffer tag(String tagname, String content){
+    public XMLBuffer tag(String tagName, CharSequence content) {
         if (content.length() == 0) {
-            emptyTag(tagname);
+            emptyTag(tagName);
         } else {
-            startTag(tagname);
+            startTag(tagName);
             sb.append(content);
-            endTag(tagname);
-        }
-        return this;
-    }
-
-    /**
-     * Add a complete tag with content.
-     *
-     * @param tagname name of the tag
-     * @param content content to put in tag, or empty content, if an empty tag 
should be used
-     * @return this
-     */
-    public XMLBuffer tag(String tagname,StringBuilder content){
-        if (content.length() == 0) {
-            emptyTag(tagname);
-        } else {
-            startTag(tagname);
-            sb.append(content);
-            endTag(tagname);
+            endTag(tagName);
         }
         return this;
     }
@@ -126,9 +109,9 @@ public class XMLBuffer{
      * Convert the buffer to a string, closing any open tags
      */
     @Override
-    public String toString(){
-        while(!tags.isEmpty()){
-            endTag((String)tags.pop());
+    public String toString() {
+        while (!tags.isEmpty()) {
+            endTag((String) tags.pop());
         }
         return sb.toString();
     }

Modified: 
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java?rev=1731066&r1=1731065&r2=1731066&view=diff
==============================================================================
--- 
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
 (original)
+++ 
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
 Thu Feb 18 13:14:53 2016
@@ -847,11 +847,18 @@ public class ProxyControl extends Generi
         final GenericController sc = new GenericController();
         sc.setProperty(TestElement.GUI_CLASS, LOGIC_CONTROLLER_GUI);
         sc.setName("-------------------"); // $NON-NLS-1$
+        safelyAddComponent(model, node, sc);
+    }
+
+    private void safelyAddComponent(
+            final JMeterTreeModel model,
+            final JMeterTreeNode node,
+            final GenericController controller) {
         JMeterUtils.runSafe(true, new Runnable() {
             @Override
             public void run() {
                 try {
-                    model.addComponent(sc, node);
+                    model.addComponent(controller, node);
                 } catch (IllegalUserActionException e) {
                     log.error("Program error", e);
                     throw new Error(e);
@@ -877,17 +884,7 @@ public class ProxyControl extends Generi
         final GenericController sc = new GenericController();
         sc.setProperty(TestElement.GUI_CLASS, LOGIC_CONTROLLER_GUI);
         sc.setName(name);
-        JMeterUtils.runSafe(true, new Runnable() {
-            @Override
-            public void run() {
-                try {
-                    model.addComponent(sc, node);
-                } catch (IllegalUserActionException e) {
-                     log.error("Program error", e);
-                     throw new Error(e);
-                }
-            }
-        });
+        safelyAddComponent(model, node, sc);
     }
 
     /**
@@ -908,21 +905,11 @@ public class ProxyControl extends Generi
         sc.setIncludeTimers(false);
         sc.setProperty(TestElement.GUI_CLASS, TRANSACTION_CONTROLLER_GUI);
         sc.setName(name);
-        JMeterUtils.runSafe(true, new Runnable() {
-            @Override
-            public void run() {
-                 try {
-                    model.addComponent(sc, node);
-                } catch (IllegalUserActionException e) {
-                    log.error("Program error", e);
-                    throw new Error(e);
-                }
-            }
-        });
+        safelyAddComponent(model, node, sc);
     }
     /**
-     * Helpler method to replicate any timers found within the Proxy Controller
-     * into the provided sampler, while replacing any occurences of string _T_
+     * Helper method to replicate any timers found within the Proxy Controller
+     * into the provided sampler, while replacing any occurrences of string _T_
      * in the timer's configuration with the provided deltaT.
      * Called from AWT Event thread
      * @param model
@@ -1224,9 +1211,9 @@ public class ProxyControl extends Generi
     private boolean matchesPatterns(String url, CollectionProperty patterns) {
         for (JMeterProperty jMeterProperty : patterns) {
             String item = jMeterProperty.getStringValue();
-            Pattern pattern = null;
             try {
-                pattern = JMeterUtils.getPatternCache().getPattern(item, 
Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.SINGLELINE_MASK);
+                Pattern pattern = JMeterUtils.getPatternCache().getPattern(
+                        item, Perl5Compiler.READ_ONLY_MASK | 
Perl5Compiler.SINGLELINE_MASK);
                 if (JMeterUtils.getMatcher().matches(url, pattern)) {
                     return true;
                 }
@@ -1278,7 +1265,7 @@ public class ProxyControl extends Generi
 
     /**
      * This will notify sample listeners directly within the Proxy of the
-     * sampling that just occured -- so that we have a means to record the
+     * sampling that just occurred -- so that we have a means to record the
      * server's responses as we go.
      *
      * @param event
@@ -1445,10 +1432,9 @@ public class ProxyControl extends Generi
 
     private boolean isValid(String subject) {
         String[] parts = subject.split("\\.");
-        if (!parts[0].endsWith("*")) { // not a wildcard
-            return true;
-        }
-        return parts.length >= 3 && 
AbstractVerifier.acceptableCountryWildcard(subject);
+        return !parts[0].endsWith("*") // not a wildcard
+                || parts.length >= 3
+                && AbstractVerifier.acceptableCountryWildcard(subject);
     }
 
     // This should only be called for a specific host

Modified: 
jmeter/trunk/src/protocol/ldap/org/apache/jmeter/protocol/ldap/config/gui/LdapConfigGui.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/ldap/org/apache/jmeter/protocol/ldap/config/gui/LdapConfigGui.java?rev=1731066&r1=1731065&r2=1731066&view=diff
==============================================================================
--- 
jmeter/trunk/src/protocol/ldap/org/apache/jmeter/protocol/ldap/config/gui/LdapConfigGui.java
 (original)
+++ 
jmeter/trunk/src/protocol/ldap/org/apache/jmeter/protocol/ldap/config/gui/LdapConfigGui.java
 Thu Feb 18 13:14:53 2016
@@ -226,7 +226,7 @@ public class LdapConfigGui extends Abstr
     }
 
     /**
-     * This itemStateChanged listener for changing the card layout for based 
on\
+     * This itemStateChanged listener for changing the card layout for based on
      * the test selected in the User defined test case.
      */
     @Override
@@ -263,27 +263,24 @@ public class LdapConfigGui extends Abstr
                 searchfilter.setText(""); // $NON-NLS-1$
                 delete.setText("");
             } else {
-                cl.show(cards, ""); // $NON-NLS-1$
-                tableAddPanel.clear();
-                add.setText(""); // $NON-NLS-1$
-                tableModifyPanel.clear();
-                modify.setText(""); // $NON-NLS-1$
-                searchbase.setText(""); // $NON-NLS-1$
-                searchfilter.setText(""); // $NON-NLS-1$
-                delete.setText(""); // $NON-NLS-1$
+                resetCardLayout(cl);
             }
         } else {
-            cl.show(cards, ""); // $NON-NLS-1$
-            tableAddPanel.clear();
-            add.setText(""); // $NON-NLS-1$
-            tableModifyPanel.clear();
-            modify.setText(""); // $NON-NLS-1$
-            searchbase.setText(""); // $NON-NLS-1$
-            searchfilter.setText(""); // $NON-NLS-1$
-            delete.setText(""); // $NON-NLS-1$
+            resetCardLayout(cl);
         }
     }
 
+    private void resetCardLayout(CardLayout cl) {
+        cl.show(cards, ""); // $NON-NLS-1$
+        tableAddPanel.clear();
+        add.setText(""); // $NON-NLS-1$
+        tableModifyPanel.clear();
+        modify.setText(""); // $NON-NLS-1$
+        searchbase.setText(""); // $NON-NLS-1$
+        searchfilter.setText(""); // $NON-NLS-1$
+        delete.setText(""); // $NON-NLS-1$
+    }
+
     /**
      * This will create the servername panel in the LdapConfigGui.
      */

Modified: 
jmeter/trunk/test/src/org/apache/jmeter/gui/util/TristateCheckBoxTest.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/gui/util/TristateCheckBoxTest.java?rev=1731066&r1=1731065&r2=1731066&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/gui/util/TristateCheckBoxTest.java 
(original)
+++ jmeter/trunk/test/src/org/apache/jmeter/gui/util/TristateCheckBoxTest.java 
Thu Feb 18 13:14:53 2016
@@ -29,6 +29,7 @@ import javax.swing.JFrame;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.UIManager;
+import javax.swing.WindowConstants;
 
 //derived from: http://www.javaspecialists.eu/archive/Issue145.html
 
@@ -43,7 +44,7 @@ public class TristateCheckBoxTest {
             UIManager.setLookAndFeel(lf.getClassName());
             frame.add(makePanel(lf.getName()));
         }
-        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
         frame.pack();
         frame.setVisible(true);
     }
@@ -85,33 +86,28 @@ public class TristateCheckBoxTest {
             @Override
             public void itemStateChanged(ItemEvent e) {
                 System.out.println(e);
-                switch(tristateBox.getState()) {
-                case SELECTED:
-                    System.out.println("Selected"); break;
-                case DESELECTED:
-                    System.out.println("Not Selected"); break;
-                case INDETERMINATE:
-                    System.out.println("Tristate Selected"); break;
-                default:
-                    System.err.println("Unexpected state: " + 
tristateBox.getState()); break;
-                }
+                switchOnAction(tristateBox);
             }
         });
         tristateBox.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
                 System.out.println(e);
-                switch(tristateBox.getState()) {
-                case SELECTED:
-                    System.out.println("Selected"); break;
-                case DESELECTED:
-                    System.out.println("Not Selected"); break;
-                case INDETERMINATE:
-                    System.out.println("Tristate Selected"); break;
-                default:
-                    System.err.println("Unexpected state: " + 
tristateBox.getState()); break;
-                }
+                switchOnAction(tristateBox);
             }
         });
     }
+
+    private static void switchOnAction(TristateCheckBox tristateBox) {
+        switch(tristateBox.getState()) {
+        case SELECTED:
+            System.out.println("Selected"); break;
+        case DESELECTED:
+            System.out.println("Not Selected"); break;
+        case INDETERMINATE:
+            System.out.println("Tristate Selected"); break;
+        default:
+            System.err.println("Unexpected state: " + tristateBox.getState()); 
break;
+        }
+    }
 }


Reply via email to