jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1457573 [2/2] - in /jmeter/trunk: ./ extras/ src/components/org/apache/jmeter/assertions/gui/ src/components/org/apache/jmeter/config/ src/components/org/apache/jmeter/control/ src/components/org/apache/jmeter/extractor/ src/components/org...
Date Sun, 17 Mar 2013 22:17:45 GMT
Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeDialog.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeDialog.java?rev=1457573&r1=1457572&r2=1457573&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeDialog.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeDialog.java Sun Mar 17 22:17:44
2013
@@ -60,65 +60,65 @@ import org.apache.log.Logger;
  */
 public class SearchTreeDialog extends JDialog implements ActionListener {
     /**
-	 * 
-	 */
-	private static final long serialVersionUID = -4436834972710248247L;
+     *
+     */
+    private static final long serialVersionUID = -4436834972710248247L;
 
-	private static final Logger logger = LoggingManager.getLoggerForClass();
+    private static final Logger logger = LoggingManager.getLoggerForClass();
 
     private JButton searchButton;
-    
-	private JLabeledTextField searchTF;
-	
-	private JCheckBox isRegexpCB;
-
-	private JCheckBox isCaseSensitiveCB;
-
-	private JButton cancelButton;
-
-	/**
-	 * Store last search
-	 */
-	private transient String lastSearch = null;
+
+    private JLabeledTextField searchTF;
+
+    private JCheckBox isRegexpCB;
+
+    private JCheckBox isCaseSensitiveCB;
+
+    private JButton cancelButton;
+
+    /**
+     * Store last search
+     */
+    private transient String lastSearch = null;
 
     private JButton searchAndExpandButton;
-	
-	public SearchTreeDialog() {
+
+    public SearchTreeDialog() {
         super((JFrame) null, JMeterUtils.getResString("search_tree_title"), true); //$NON-NLS-1$
         init();
     }
-	
+
     @Override
     protected JRootPane createRootPane() {
         JRootPane rootPane = new JRootPane();
         // Hide Window on ESC
-        Action escapeAction = new AbstractAction("ESCAPE") { 
+        Action escapeAction = new AbstractAction("ESCAPE") {
             /**
-             * 
+             *
              */
             private static final long serialVersionUID = -6543764044868772971L;
 
             @Override
-            public void actionPerformed(ActionEvent actionEvent) { 
+            public void actionPerformed(ActionEvent actionEvent) {
                 setVisible(false);
-            } 
+            }
         };
         // Do search on Enter
-        Action enterAction = new AbstractAction("ENTER") { 
+        Action enterAction = new AbstractAction("ENTER") {
             /**
-             * 
+             *
              */
             private static final long serialVersionUID = -3661361497864527363L;
 
             @Override
-            public void actionPerformed(ActionEvent actionEvent) { 
+            public void actionPerformed(ActionEvent actionEvent) {
                 doSearch(actionEvent);
-            } 
+            }
         };
         ActionMap actionMap = rootPane.getActionMap();
         actionMap.put(escapeAction.getValue(Action.NAME), escapeAction);
         actionMap.put(enterAction.getValue(Action.NAME), enterAction);
-        InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);  
+        InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
         inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME));
         inputMap.put(KeyStrokes.ENTER, enterAction.getValue(Action.NAME));
 
@@ -130,7 +130,7 @@ public class SearchTreeDialog extends JD
 
         searchTF = new JLabeledTextField(JMeterUtils.getResString("search_text_field"), 20);
//$NON-NLS-1$
         if(!StringUtils.isEmpty(lastSearch)) {
-        	searchTF.setText(lastSearch);
+            searchTF.setText(lastSearch);
         }
         isRegexpCB = new JCheckBox(JMeterUtils.getResString("search_text_chkbox_regexp"),
false); //$NON-NLS-1$
         isCaseSensitiveCB = new JCheckBox(JMeterUtils.getResString("search_text_chkbox_case"),
false); //$NON-NLS-1$
@@ -141,14 +141,14 @@ public class SearchTreeDialog extends JD
         JPanel searchCriterionPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
         searchCriterionPanel.add(isCaseSensitiveCB);
         searchCriterionPanel.add(isRegexpCB);
-        
+
         JPanel searchPanel = new JPanel();
         searchPanel.setLayout(new BoxLayout(searchPanel, BoxLayout.Y_AXIS));
         searchPanel.setBorder(BorderFactory.createEmptyBorder(7, 3, 3, 3));
         searchPanel.add(searchTF, BorderLayout.NORTH);
         searchPanel.add(searchCriterionPanel, BorderLayout.CENTER);
         JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
-        
+
         searchButton = new JButton(JMeterUtils.getResString("search")); //$NON-NLS-1$
         searchButton.addActionListener(this);
         searchAndExpandButton = new JButton(JMeterUtils.getResString("search_expand")); //$NON-NLS-1$
@@ -160,7 +160,7 @@ public class SearchTreeDialog extends JD
         buttonsPanel.add(cancelButton);
         searchPanel.add(buttonsPanel, BorderLayout.SOUTH);
         this.getContentPane().add(searchPanel);
-    	searchTF.requestFocusInWindow();
+        searchTF.requestFocusInWindow();
 
         this.pack();
         ComponentUtil.centerComponentInWindow(this);
@@ -172,35 +172,35 @@ public class SearchTreeDialog extends JD
      */
     @Override
     public void actionPerformed(ActionEvent e) {
-    	if(e.getSource()==cancelButton) {
-    	    searchTF.requestFocusInWindow();
-    		this.setVisible(false);
-    		return;
-    	} 
-    	doSearch(e);
+        if(e.getSource()==cancelButton) {
+            searchTF.requestFocusInWindow();
+            this.setVisible(false);
+            return;
+        }
+        doSearch(e);
     }
 
-	/**
-	 * @param e {@link ActionEvent}
-	 */
-	private void doSearch(ActionEvent e) {
-	    boolean expand = e.getSource()==searchAndExpandButton;
-		String wordToSearch = searchTF.getText();
-    	if(StringUtils.isEmpty(wordToSearch)) {
+    /**
+     * @param e {@link ActionEvent}
+     */
+    private void doSearch(ActionEvent e) {
+        boolean expand = e.getSource()==searchAndExpandButton;
+        String wordToSearch = searchTF.getText();
+        if(StringUtils.isEmpty(wordToSearch)) {
             return;
         } else {
-        	this.lastSearch = wordToSearch;
+            this.lastSearch = wordToSearch;
         }
-    	
-    	// reset previous result
-    	ActionRouter.getInstance().doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.SEARCH_RESET));
+
+        // reset previous result
+        ActionRouter.getInstance().doActionNow(new ActionEvent(e.getSource(), e.getID(),
ActionNames.SEARCH_RESET));
         // do search
-    	Searcher searcher = null; 
-    	if(isRegexpCB.isSelected()) {
-    		searcher = new RegexpSearcher(isCaseSensitiveCB.isSelected(), searchTF.getText());
-    	} else {
-    		searcher = new RawTextSearcher(isCaseSensitiveCB.isSelected(), searchTF.getText());
-    	}
+        Searcher searcher = null;
+        if(isRegexpCB.isSelected()) {
+            searcher = new RegexpSearcher(isCaseSensitiveCB.isSelected(), searchTF.getText());
+        } else {
+            searcher = new RawTextSearcher(isCaseSensitiveCB.isSelected(), searchTF.getText());
+        }
         GuiPackage guiPackage = GuiPackage.getInstance();
         JMeterTreeModel jMeterTreeModel = guiPackage.getTreeModel();
         Set<JMeterTreeNode> nodes = new HashSet<JMeterTreeNode>();
@@ -221,7 +221,7 @@ public class SearchTreeDialog extends JD
         }
         GuiPackage guiInstance = GuiPackage.getInstance();
         JTree jTree = guiInstance.getMainFrame().getTree();
-        
+
         for (Iterator<JMeterTreeNode> iterator = nodes.iterator(); iterator.hasNext();)
{
             JMeterTreeNode jMeterTreeNode = iterator.next();
             jMeterTreeNode.setMarkedBySearch(true);
@@ -232,5 +232,5 @@ public class SearchTreeDialog extends JD
         GuiPackage.getInstance().getMainFrame().repaint();
         searchTF.requestFocusInWindow();
         this.setVisible(false);
-	}
+    }
 }
\ No newline at end of file

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/Searcher.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/Searcher.java?rev=1457573&r1=1457572&r2=1457573&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/Searcher.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/Searcher.java Sun Mar 17 22:17:44 2013
@@ -25,10 +25,10 @@ import java.util.List;
  */
 public interface Searcher {
 
-	/**
-	 * Implements the search
-	 * @param textTokens List<String> content to be searched
-	 * @return true if search on textTokens is successful
-	 */
-	boolean search(List<String> textTokens);
+    /**
+     * Implements the search
+     * @param textTokens List<String> content to be searched
+     * @return true if search on textTokens is successful
+     */
+    boolean search(List<String> textTokens);
 }

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/util/FileDialoger.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/util/FileDialoger.java?rev=1457573&r1=1457572&r2=1457573&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/util/FileDialoger.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/util/FileDialoger.java Sun Mar 17 22:17:44
2013
@@ -124,7 +124,7 @@ public final class FileDialoger {
         }
         String ext = ".jmx";//$NON-NLS-1$
         if (filename != null) {
-        	jfc.setDialogTitle(filename);
+            jfc.setDialogTitle(filename);
             jfc.setSelectedFile(filename.lastIndexOf(System.getProperty("file.separator"))
> 0 ?
                     new File(filename) :
                     new File(lastJFCDirectory, filename));

Modified: jmeter/trunk/test/src/org/apache/jmeter/config/TestCVSDataSet.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/config/TestCVSDataSet.java?rev=1457573&r1=1457572&r2=1457573&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/config/TestCVSDataSet.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/config/TestCVSDataSet.java Sun Mar 17 22:17:44
2013
@@ -95,7 +95,7 @@ public class TestCVSDataSet extends JMet
     }
     
     public void testutf8() throws Exception {
-    	
+
         CSVDataSet csv = new CSVDataSet();
         csv.setFilename(findTestPath("testfiles/testutf8.csv"));
         csv.setVariableNames("a,b,c,d");

Modified: jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java?rev=1457573&r1=1457572&r2=1457573&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java Sun Mar 17 22:17:44 2013
@@ -318,7 +318,7 @@ public class JMeterTest extends JMeterTe
         return suite;
     }
 
-	/*
+    /*
      * Test GUI elements - create the suite of tests
      */
     private static Test suiteBeanComponents() throws Exception {
@@ -398,7 +398,7 @@ public class JMeterTest extends JMeterTe
     }
     
 
-	/*
+    /*
      * Check that function descriptions are OK
      */
     public void runFunction2() throws Exception {

Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java?rev=1457573&r1=1457572&r2=1457573&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java Sun
Mar 17 22:17:44 2013
@@ -286,8 +286,8 @@ public class TestCookieManager extends J
             assertNotNull(s);
             HC3CookieHandler hc3CookieHandler = (HC3CookieHandler) man.getCookieHandler();
             org.apache.commons.httpclient.Cookie[] c = 
-            		hc3CookieHandler.getCookiesForUrl(man.getCookies(), url, 
-            		CookieManager.ALLOW_VARIABLE_COOKIES);
+                    hc3CookieHandler.getCookiesForUrl(man.getCookies(), url, 
+                    CookieManager.ALLOW_VARIABLE_COOKIES);
             assertEquals("/sub1",c[0].getPath());
             assertFalse(c[0].isPathAttributeSpecified());
             assertEquals("/sub1",c[1].getPath());
@@ -311,8 +311,8 @@ public class TestCookieManager extends J
             assertNotNull(s);
             HC3CookieHandler hc3CookieHandler = (HC3CookieHandler) man.getCookieHandler();
             org.apache.commons.httpclient.Cookie[] c = 
-            		hc3CookieHandler.getCookiesForUrl(man.getCookies(), url, 
-            		CookieManager.ALLOW_VARIABLE_COOKIES);
+                    hc3CookieHandler.getCookiesForUrl(man.getCookies(), url, 
+                    CookieManager.ALLOW_VARIABLE_COOKIES);
             assertEquals("/sub1",c[0].getPath());
             assertFalse(c[0].isPathAttributeSpecified());
             assertEquals("/sub1",c[1].getPath());
@@ -338,8 +338,8 @@ public class TestCookieManager extends J
             HC3CookieHandler hc3CookieHandler = (HC3CookieHandler) man.getCookieHandler();
            
             org.apache.commons.httpclient.Cookie[] c = 
-            		hc3CookieHandler.getCookiesForUrl(man.getCookies(), url, 
-            		CookieManager.ALLOW_VARIABLE_COOKIES);
+                    hc3CookieHandler.getCookiesForUrl(man.getCookies(), url, 
+                    CookieManager.ALLOW_VARIABLE_COOKIES);
             assertEquals("/sub1",c[0].getPath());
             assertFalse(c[0].isPathAttributeSpecified());
             assertEquals("/sub1",c[1].getPath());
@@ -372,8 +372,8 @@ public class TestCookieManager extends J
             assertNull(s);
             HC3CookieHandler hc3CookieHandler = (HC3CookieHandler) man.getCookieHandler();
             org.apache.commons.httpclient.Cookie[] c = 
-            		hc3CookieHandler.getCookiesForUrl(man.getCookies(), url, 
-            		CookieManager.ALLOW_VARIABLE_COOKIES);
+                    hc3CookieHandler.getCookiesForUrl(man.getCookies(), url, 
+                    CookieManager.ALLOW_VARIABLE_COOKIES);
             assertEquals(0,c.length); // Cookies again ignored
         }
 

Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/proxy/TestHttpRequestHdr.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/proxy/TestHttpRequestHdr.java?rev=1457573&r1=1457572&r2=1457573&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/proxy/TestHttpRequestHdr.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/proxy/TestHttpRequestHdr.java Sun
Mar 17 22:17:44 2013
@@ -182,7 +182,7 @@ public class TestHttpRequestHdr  extends
         String url = "http://[::1]:8080/matrix.html";
         testEncodedArguments(url);
     }
-        	
+
     public void testEncodedArguments(String url) throws Exception {
         // A HTTP GET request, with encoding not known 
         String contentEncoding = "";
@@ -274,11 +274,11 @@ public class TestHttpRequestHdr  extends
     }
     
     public void testGetRequestEncodings() throws Exception {
-    	testGetRequestEncodings("http://localhost/matrix.html");
+        testGetRequestEncodings("http://localhost/matrix.html");
     }
     
     public void testGetRequestEncodingsIPv6() throws Exception {
-    	testGetRequestEncodings("http://[::1]:8080/matrix.html");
+        testGetRequestEncodings("http://[::1]:8080/matrix.html");
     }
     
     public void testGetRequestEncodings(String url) throws Exception {

Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PostWriterTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PostWriterTest.java?rev=1457573&r1=1457572&r2=1457573&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PostWriterTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PostWriterTest.java Sun
Mar 17 22:17:44 2013
@@ -70,11 +70,11 @@ public class PostWriterTest extends Test
         temporaryFile = File.createTempFile("foo", "txt");
         OutputStream output = null;
         try {
-	        output = new FileOutputStream(temporaryFile);
-	        output.write(TEST_FILE_CONTENT);
-	        output.flush();
+            output = new FileOutputStream(temporaryFile);
+            output.write(TEST_FILE_CONTENT);
+            output.flush();
         } finally {
-        	JOrphanUtils.closeQuietly(output);
+            JOrphanUtils.closeQuietly(output);
         }
     }
 
@@ -82,7 +82,7 @@ public class PostWriterTest extends Test
     protected void tearDown() throws Exception {
         // delete temporay file
         if(!temporaryFile.delete()) {
-        	fail("Could not delete file:"+temporaryFile.getAbsolutePath());
+            fail("Could not delete file:"+temporaryFile.getAbsolutePath());
         }
     }
 
@@ -420,7 +420,7 @@ public class PostWriterTest extends Test
         
         checkContentTypeUrlEncoded(connection);
         expectedUrl = new StringBuilder("title=").append(titleValue).append("&description=")
-        		.append(descriptionValue).toString().getBytes("US-ASCII");
+                .append(descriptionValue).toString().getBytes("US-ASCII");
         checkContentLength(connection, expectedUrl.length);
         checkArraysHaveSameContent(expectedUrl, connection.getOutputStreamContent());
         assertEquals(
@@ -512,7 +512,7 @@ public class PostWriterTest extends Test
         checkContentTypeUrlEncoded(connection);
         StringBuilder sb = new StringBuilder();
         expectedUrl = (sb.append("title=").append(titleValue.replaceAll("%20", "+").replaceAll("%C3%85",
"%C5"))
-        		.append("&description=").append(descriptionValue.replaceAll("%C3%85", "%C5"))).toString().getBytes("US-ASCII");
+                .append("&description=").append(descriptionValue.replaceAll("%C3%85",
"%C5"))).toString().getBytes("US-ASCII");
         checkContentLength(connection, expectedUrl.length);
         checkArraysHaveSameContent(expectedUrl, connection.getOutputStreamContent());
         assertEquals(
@@ -530,7 +530,7 @@ public class PostWriterTest extends Test
         checkContentTypeUrlEncoded(connection);
         sb = new StringBuilder();
         expectedUrl = (sb.append("title=").append(titleValue.replaceAll("%20", "+").replaceAll("%C3%85",
"%C5"))
-        		.append("&description=").append(descriptionValue.replaceAll("%C3%85", "%C5"))).toString().getBytes("US-ASCII");
+                .append("&description=").append(descriptionValue.replaceAll("%C3%85",
"%C5"))).toString().getBytes("US-ASCII");
         checkContentLength(connection, expectedUrl.length);
         checkArraysHaveSameContent(expectedUrl, connection.getOutputStreamContent());
         assertEquals(

Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java?rev=1457573&r1=1457572&r2=1457573&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java
(original)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java
Sun Mar 17 22:17:44 2013
@@ -121,7 +121,7 @@ public class TestHTTPSamplersAgainstHttp
                     httpServer = null;
                     // delete temporay file
                     if(!temporaryFile.delete()) {
-                    	fail("Could not delete file:"+temporaryFile.getAbsolutePath());
+                        fail("Could not delete file:"+temporaryFile.getAbsolutePath());
                     }
             }
         };

Modified: jmeter/trunk/test/src/org/apache/jmeter/resources/PackageTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/resources/PackageTest.java?rev=1457573&r1=1457572&r2=1457573&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/resources/PackageTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/resources/PackageTest.java Sun Mar 17 22:17:44
2013
@@ -73,7 +73,7 @@ import org.apache.jorphan.util.JOrphanUt
 public class PackageTest extends TestCase {
     private static final String basedir = new File(System.getProperty("user.dir")).getParent();
 
-	private static final File srcFiledir = new File(basedir,"src");
+    private static final File srcFiledir = new File(basedir,"src");
 
     private static final String MESSAGES = "messages";
 
@@ -112,50 +112,50 @@ public class PackageTest extends TestCas
         }
         BufferedReader fileReader = null;
         try {
-        	fileReader = new BufferedReader(new InputStreamReader(ras));
-	        String s;
-	        while ((s = fileReader.readLine()) != null) {
-	            if (s.length() > 0 && !s.startsWith("#") && !s.startsWith("!"))
{
-	                int equ = s.indexOf('=');
-	                String key = s.substring(0, equ);
-	                if (resourcePrefix.equals(MESSAGES)){// Only relevant for messages
-	                    /*
-	                     * JMeterUtils.getResString() converts space to _ and lowercases
-	                     * the key, so make sure all keys pass the test
-	                     */
-	                    if ((key.indexOf(' ') >= 0) || !key.toLowerCase(java.util.Locale.ENGLISH).equals(key))
{
-	                        System.out.println("Invalid key for JMeterUtils " + key);
-	                        fails++;
-	                    }
-	                }
-	                String val = s.substring(equ + 1);
-	                l.add(key); // Store the key
-	                /*
-	                 * Now check for invalid message format: if string contains {0}
-	                 * and ' there may be a problem, so do a format with dummy
-	                 * parameters and check if there is a { in the output. A bit
-	                 * crude, but should be enough for now.
-	                 */
-	                if (val.indexOf("{0}") > 0 && val.indexOf('\'') > 0) {
-	                    String m = java.text.MessageFormat.format(val, DUMMY_PARAMS);
-	                    if (m.indexOf('{') > 0) {
-	                        fails++;
-	                        System.out.println("Incorrect message format ? (input/output) for:
"+key);
-	                        System.out.println(val);
-	                        System.out.println(m);
-	                    }
-	                }
-	
-	                if (!isPureAscii(val)) {
-	                    fails++;
-	                    System.out.println("Incorrect char value in: "+s);                 
  
-	                }
-	            }
-	        }
-	        return fails;
+            fileReader = new BufferedReader(new InputStreamReader(ras));
+            String s;
+            while ((s = fileReader.readLine()) != null) {
+                if (s.length() > 0 && !s.startsWith("#") && !s.startsWith("!"))
{
+                    int equ = s.indexOf('=');
+                    String key = s.substring(0, equ);
+                    if (resourcePrefix.equals(MESSAGES)){// Only relevant for messages
+                        /*
+                         * JMeterUtils.getResString() converts space to _ and lowercases
+                         * the key, so make sure all keys pass the test
+                         */
+                        if ((key.indexOf(' ') >= 0) || !key.toLowerCase(java.util.Locale.ENGLISH).equals(key))
{
+                            System.out.println("Invalid key for JMeterUtils " + key);
+                            fails++;
+                        }
+                    }
+                    String val = s.substring(equ + 1);
+                    l.add(key); // Store the key
+                    /*
+                     * Now check for invalid message format: if string contains {0}
+                     * and ' there may be a problem, so do a format with dummy
+                     * parameters and check if there is a { in the output. A bit
+                     * crude, but should be enough for now.
+                     */
+                    if (val.indexOf("{0}") > 0 && val.indexOf('\'') > 0) {
+                        String m = java.text.MessageFormat.format(val, DUMMY_PARAMS);
+                        if (m.indexOf('{') > 0) {
+                            fails++;
+                            System.out.println("Incorrect message format ? (input/output)
for: "+key);
+                            System.out.println(val);
+                            System.out.println(m);
+                        }
+                    }
+
+                    if (!isPureAscii(val)) {
+                        fails++;
+                        System.out.println("Incorrect char value in: "+s);              
     
+                    }
+                }
+            }
+            return fails;
         }
         finally {
-        	JOrphanUtils.closeQuietly(fileReader);
+            JOrphanUtils.closeQuietly(fileReader);
         }
     }
 
@@ -238,19 +238,19 @@ public class PackageTest extends TestCas
      * @return list of properties files subject to I18N
      */
     public static final String[] getResources(File srcFiledir) {
-    	Set<String> set = new TreeSet<String>();
-		findFile(srcFiledir, set, new FilenameFilter() {
-			@Override
+        Set<String> set = new TreeSet<String>();
+        findFile(srcFiledir, set, new FilenameFilter() {
+            @Override
             public boolean accept(File dir, String name) {
-				return new File(dir, name).isDirectory() 
-						|| (
-								name.equals("messages.properties") ||
-								(name.endsWith("Resources.properties")
-								&& !name.matches("Example\\d+Resources\\.properties")));
-			}
-		});
-		return set.toArray(new String[set.size()]);
-	}
+                return new File(dir, name).isDirectory() 
+                        || (
+                                name.equals("messages.properties") ||
+                                (name.endsWith("Resources.properties")
+                                && !name.matches("Example\\d+Resources\\.properties")));
+            }
+        });
+        return set.toArray(new String[set.size()]);
+    }
     
     /**
      * Find resources matching filenamefiler and adds them to set removing everything before
"/org"
@@ -259,23 +259,23 @@ public class PackageTest extends TestCas
      * @param filenameFilter
      */
     private static void findFile(File file, Set<String> set,
-			FilenameFilter filenameFilter) {
-    	File[] foundFiles = file.listFiles(filenameFilter);
-    	if (foundFiles == null) { // Better error than NPE
-    	    System.err.println("Not a directory: "+file);
-    	    return;
-    	}
-    	for (File file2 : foundFiles) {
-			if(file2.isDirectory()) {
-				findFile(file2, set, filenameFilter);
-			} else {
-				String absPath2 = file2.getAbsolutePath().replace('\\', '/'); // Fix up Windows paths
+            FilenameFilter filenameFilter) {
+        File[] foundFiles = file.listFiles(filenameFilter);
+        if (foundFiles == null) { // Better error than NPE
+            System.err.println("Not a directory: "+file);
+            return;
+        }
+        for (File file2 : foundFiles) {
+            if(file2.isDirectory()) {
+                findFile(file2, set, filenameFilter);
+            } else {
+                String absPath2 = file2.getAbsolutePath().replace('\\', '/'); // Fix up Windows
paths
                 int indexOfOrg = absPath2.indexOf("/org");
-				int lastIndex = absPath2.lastIndexOf('.');
-				set.add(absPath2.substring(indexOfOrg, lastIndex));
-			}
-		}
-	}
+                int lastIndex = absPath2.lastIndexOf('.');
+                set.add(absPath2.substring(indexOfOrg, lastIndex));
+            }
+        }
+    }
     
     /*
      * Use a suite to ensure that the default is done first
@@ -333,71 +333,71 @@ public class PackageTest extends TestCas
      * @throws Exception
      */
     public void checkI18n() throws Exception {
-    	Map<String, Map<String,String>> missingLabelsPerBundle = new HashMap<String,
Map<String,String>>();
-    	for (String prefix : prefixList) {
-        	Properties messages = new Properties();
-        	messages.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(prefix.substring(1)+".properties"));
-        	checkMessagesForLanguage( missingLabelsPerBundle , missingLabelsPerBundle, messages,prefix.substring(1),
lang);
-		}
-    	
-    	assertEquals(missingLabelsPerBundle.size()+" missing labels, labels missing:"+printLabels(missingLabelsPerBundle),
0, missingLabelsPerBundle.size());
-    }
-
-	/**
-	 * Check messages are available in language
-	 * @param missingLabelsPerBundle2 
-	 * @param missingLabelsPerBundle 
-	 * @param messages Properties messages in english
-	 * @param language Language 
-	 * @throws IOException
-	 */
-	private void checkMessagesForLanguage(Map<String, Map<String, String>> missingLabelsPerBundle,
Map<String, Map<String, String>> missingLabelsPerBundle2, Properties messages,
String bundlePath,String language)
-			throws IOException {
-		Properties messagesFr = new Properties();
-		String languageBundle = bundlePath+"_"+language+ ".properties";
-		InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(languageBundle);
-		if(inputStream == null) {
-			Map<String, String> messagesAsProperties = new HashMap<String, String>();
-			for (Iterator<Map.Entry<Object, Object>> iterator = messages.entrySet().iterator();
iterator.hasNext();) {
-				Map.Entry<Object, Object> entry = iterator.next();
-				messagesAsProperties.put((String) entry.getKey(), (String) entry.getValue()); 
-			}
-			missingLabelsPerBundle.put(languageBundle, messagesAsProperties);
-			return;
-		}
-    	messagesFr.load(inputStream);
+        Map<String, Map<String,String>> missingLabelsPerBundle = new HashMap<String,
Map<String,String>>();
+        for (String prefix : prefixList) {
+            Properties messages = new Properties();
+            messages.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(prefix.substring(1)+".properties"));
+            checkMessagesForLanguage( missingLabelsPerBundle , missingLabelsPerBundle, messages,prefix.substring(1),
lang);
+        }
+        
+        assertEquals(missingLabelsPerBundle.size()+" missing labels, labels missing:"+printLabels(missingLabelsPerBundle),
0, missingLabelsPerBundle.size());
+    }
+
+    /**
+     * Check messages are available in language
+     * @param missingLabelsPerBundle2 
+     * @param missingLabelsPerBundle 
+     * @param messages Properties messages in english
+     * @param language Language 
+     * @throws IOException
+     */
+    private void checkMessagesForLanguage(Map<String, Map<String, String>> missingLabelsPerBundle,
Map<String, Map<String, String>> missingLabelsPerBundle2, Properties messages,
String bundlePath,String language)
+            throws IOException {
+        Properties messagesFr = new Properties();
+        String languageBundle = bundlePath+"_"+language+ ".properties";
+        InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(languageBundle);
+        if(inputStream == null) {
+            Map<String, String> messagesAsProperties = new HashMap<String, String>();
+            for (Iterator<Map.Entry<Object, Object>> iterator = messages.entrySet().iterator();
iterator.hasNext();) {
+                Map.Entry<Object, Object> entry = iterator.next();
+                messagesAsProperties.put((String) entry.getKey(), (String) entry.getValue());

+            }
+            missingLabelsPerBundle.put(languageBundle, messagesAsProperties);
+            return;
+        }
+        messagesFr.load(inputStream);
     
-    	Map<String, String> missingLabels = new TreeMap<String,String>();
-    	for (Iterator<Map.Entry<Object,Object>> iterator =  messages.entrySet().iterator();
iterator.hasNext();) {
-    		Map.Entry<Object,Object> entry = iterator.next();
-			String key = (String)entry.getKey();
-			if(!messagesFr.containsKey(key)) {
-				missingLabels.put(key,(String) entry.getValue());
-			}
-		}
-    	if(!missingLabels.isEmpty()) {
-    		missingLabelsPerBundle.put(languageBundle, missingLabels);
-    	}
-	}
-
-	/**
-	 * Build message with misssing labels per bundle
-	 * @param missingLabelsPerBundle
-	 * @return String
-	 */
+        Map<String, String> missingLabels = new TreeMap<String,String>();
+        for (Iterator<Map.Entry<Object,Object>> iterator =  messages.entrySet().iterator();
iterator.hasNext();) {
+            Map.Entry<Object,Object> entry = iterator.next();
+            String key = (String)entry.getKey();
+            if(!messagesFr.containsKey(key)) {
+                missingLabels.put(key,(String) entry.getValue());
+            }
+        }
+        if(!missingLabels.isEmpty()) {
+            missingLabelsPerBundle.put(languageBundle, missingLabels);
+        }
+    }
+
+    /**
+     * Build message with misssing labels per bundle
+     * @param missingLabelsPerBundle
+     * @return String
+     */
     private String printLabels(Map<String, Map<String, String>> missingLabelsPerBundle)
{
-    	StringBuilder builder = new StringBuilder();
-    	for (Iterator<Map.Entry<String,Map<String, String>>> iterator =  missingLabelsPerBundle.entrySet().iterator();
iterator.hasNext();) {
-    		Map.Entry<String,Map<String, String>> entry = iterator.next();
-    		builder.append("Missing labels in bundle:"+entry.getKey()+"\r\n");
-        	for (Iterator<Map.Entry<String,String>> it2 =  entry.getValue().entrySet().iterator();
it2.hasNext();) {
-        		Map.Entry<String,String> entry2 = it2.next();
-    			builder.append(entry2.getKey()+"="+entry2.getValue()+"\r\n");
-    		}
-    		builder.append("======================================================\r\n");
-		}
-    	return builder.toString();
-	}
+        StringBuilder builder = new StringBuilder();
+        for (Iterator<Map.Entry<String,Map<String, String>>> iterator =
 missingLabelsPerBundle.entrySet().iterator(); iterator.hasNext();) {
+            Map.Entry<String,Map<String, String>> entry = iterator.next();
+            builder.append("Missing labels in bundle:"+entry.getKey()+"\r\n");
+            for (Iterator<Map.Entry<String,String>> it2 =  entry.getValue().entrySet().iterator();
it2.hasNext();) {
+                Map.Entry<String,String> entry2 = it2.next();
+                builder.append(entry2.getKey()+"="+entry2.getValue()+"\r\n");
+            }
+            builder.append("======================================================\r\n");
+        }
+        return builder.toString();
+    }
 
     // Check that calls to getResString use a valid property key name
     public void checkResourceReferences() {

Modified: jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java?rev=1457573&r1=1457572&r2=1457573&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java (original)
+++ jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java Sun Mar 17 22:17:44 2013
@@ -268,7 +268,7 @@ public final class AllTests {
             InputStream inputStream = null;
             try {
                 System.out.println("Setting up logging props using file: " + args[1]);
-            	inputStream = new FileInputStream(args[1]);
+                inputStream = new FileInputStream(args[1]);
                 props.load(inputStream);
                 LoggingManager.initializeLogging(props);
             } catch (FileNotFoundException e) {
@@ -276,7 +276,7 @@ public final class AllTests {
             } catch (IOException e) {
                 System.out.println(e.getLocalizedMessage());
             } finally {
-            	JOrphanUtils.closeQuietly(inputStream);
+                JOrphanUtils.closeQuietly(inputStream);
             }
         }
     }



Mime
View raw message