From 77ff0208b240807517ad005a50f0627793e18c9e Mon Sep 17 00:00:00 2001 From: Graham Russell Date: Wed, 20 Dec 2017 14:50:21 +0000 Subject: [PATCH] Expanded Checkstyle to files in src and test; fixed newly checked files --- build.xml | 2 +- checkstyle-suppressions.xml | 8 +++-- checkstyle.xml | 12 ++++---- .../commons/cli/avalon/ClutilTestCase.java | 29 ++++--------------- .../assertions/ResponseAssertionTest.java | 1 + .../jmeter/assertions/SMIMEAssertionTest.java | 1 + .../jmeter/assertions/SizeAssertionTest.java | 3 +- .../assertions/TestJSONPathAssertion.java | 4 +-- .../jmeter/control/TestSwitchController.java | 2 +- .../control/TestTransactionController.java | 13 ++++----- .../extractor/BoundaryExtractorSpec.groovy | 2 +- .../extractor/TestJSONPostProcessor.java | 6 ++-- .../jmeter/functions/ChangeCaseSpec.groovy | 2 +- .../jmeter/functions/EvalFunctionTest.java | 6 ++-- .../apache/jmeter/functions/PackageTest.java | 10 +++---- .../jmeter/functions/TestSetProperty.java | 10 ++----- .../functions/TestTimeShiftFunction.java | 10 ++----- .../jmeter/gui/util/MenuFactorySpec.groovy | 2 +- .../jmeter/gui/util/TristateCheckBoxTest.java | 14 +++++---- .../org/apache/jmeter/junit/JMeterTest.java | 8 ++--- .../protocol/http/config/UrlConfigTest.java | 5 ++-- .../http/control/TestHC4CookieManager.java | 2 -- .../protocol/http/parser/TestHTMLParser.java | 2 +- .../protocol/http/proxy/TestProxyControl.java | 8 ++--- .../http/sampler/NullURLConnection.java | 3 +- .../protocol/http/sampler/PutWriterTest.java | 2 +- ...stHTTPSamplersAgainstHttpMirrorServer.java | 8 ----- .../protocol/http/util/TestHTTPFileArgs.java | 4 +-- .../dashboard/ApdexPerTransactionTest.java | 1 + .../apache/jmeter/resources/PackageTest.java | 2 +- .../jmeter/save/TestCSVSaveService.java | 2 +- .../gui/TestBooleanPropertyEditor.java | 2 +- .../jmeter/visualizers/TestRenderAsJson.java | 1 + .../apache/jorphan/exec/TestKeyToolUtils.java | 3 +- .../jorphan/gui/ObjectTableSorterTest.java | 10 +++++-- .../jorphan/math/TestStatCalculator.java | 4 +-- .../src/org/apache/jorphan/test/AllTests.java | 5 ++-- .../apache/jorphan/util/TestConverter.java | 2 +- .../apache/jorphan/util/TestJorphanUtils.java | 19 +++++------- 39 files changed, 99 insertions(+), 131 deletions(-) diff --git a/build.xml b/build.xml index ad797d33608..b4d174f356d 100644 --- a/build.xml +++ b/build.xml @@ -3557,7 +3557,7 @@ run JMeter unless all the JMeter jars are added. - + diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml index 26fa5b67459..a6508bdf4f8 100644 --- a/checkstyle-suppressions.xml +++ b/checkstyle-suppressions.xml @@ -21,6 +21,10 @@ limitations under the License. "http://checkstyle.sourceforge.net/dtds/suppressions_1_1.dtd"> - - + + + + + \ No newline at end of file diff --git a/checkstyle.xml b/checkstyle.xml index 73cfbd33186..afde4f43de7 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -24,7 +24,8 @@ - + @@ -34,15 +35,14 @@ - - - + + + - - + diff --git a/test/src/org/apache/commons/cli/avalon/ClutilTestCase.java b/test/src/org/apache/commons/cli/avalon/ClutilTestCase.java index 8c7ab336bd8..d3086a0b5fd 100644 --- a/test/src/org/apache/commons/cli/avalon/ClutilTestCase.java +++ b/test/src/org/apache/commons/cli/avalon/ClutilTestCase.java @@ -22,49 +22,30 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -// Renamed from org.apache.avalon.excalibur.cli - import java.util.List; + import org.junit.Test; -/** - * - */ public final class ClutilTestCase { private static final String[] ARGLIST1 = new String[] { "--you", "are", "--all", "-cler", "kid" }; - private static final String[] ARGLIST2 = new String[] { "-Dstupid=idiot", "are", "--all", "here", "-d" }; - private static final String[] ARGLIST3 = new String[] { // duplicates "-Dstupid=idiot", "are", "--all", "--all", "here" }; - private static final String[] ARGLIST4 = new String[] { // incompatible (blee/all) "-Dstupid", "idiot", "are", "--all", "--blee", "here" }; - private static final String[] ARGLIST5 = new String[] { "-f", "myfile.txt" }; - private static final int DEFINE_OPT = 'D'; - private static final int CASE_CHECK_OPT = 'd'; - private static final int YOU_OPT = 'y'; - private static final int ALL_OPT = 'a'; - private static final int CLEAR1_OPT = 'c'; - private static final int CLEAR2_OPT = 'l'; - private static final int CLEAR3_OPT = 'e'; - private static final int CLEAR5_OPT = 'r'; - private static final int BLEE_OPT = 'b'; - private static final int FILE_OPT = 'f'; - private static final int TAINT_OPT = 'T'; private static final CLOptionDescriptor DEFINE = new CLOptionDescriptor("define", @@ -686,7 +667,7 @@ public void testPartParse() { final ParserControl control = new AbstractParserControl() { @Override public boolean isFinished(int lastOptionCode) { - return (lastOptionCode == YOU_OPT); + return lastOptionCode == YOU_OPT; } }; @@ -710,7 +691,7 @@ public void test2PartParse() { final ParserControl control1 = new AbstractParserControl() { @Override public boolean isFinished(int lastOptionCode) { - return (lastOptionCode == YOU_OPT); + return lastOptionCode == YOU_OPT; } }; @@ -750,7 +731,7 @@ public void test2PartPartialParse() { final ParserControl control1 = new AbstractParserControl() { @Override public boolean isFinished(final int lastOptionCode) { - return (lastOptionCode == CLEAR1_OPT); + return lastOptionCode == CLEAR1_OPT; } }; @@ -957,7 +938,7 @@ public void testCombinations() throws Exception { "-?=[A] -? [B] -?"); } - private void check(String args[], String canon){ + private void check(String[] args, String canon){ final CLArgsParser parser = new CLArgsParser(args, OPTIONS); assertNull(parser.getErrorString(),parser.getErrorString()); diff --git a/test/src/org/apache/jmeter/assertions/ResponseAssertionTest.java b/test/src/org/apache/jmeter/assertions/ResponseAssertionTest.java index c8b60d2ddab..b58fcde2549 100644 --- a/test/src/org/apache/jmeter/assertions/ResponseAssertionTest.java +++ b/test/src/org/apache/jmeter/assertions/ResponseAssertionTest.java @@ -28,6 +28,7 @@ import java.net.URL; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; + import org.apache.jmeter.samplers.SampleResult; import org.apache.jmeter.threads.JMeterContext; import org.apache.jmeter.threads.JMeterContextService; diff --git a/test/src/org/apache/jmeter/assertions/SMIMEAssertionTest.java b/test/src/org/apache/jmeter/assertions/SMIMEAssertionTest.java index efbe3e2539f..97105647570 100644 --- a/test/src/org/apache/jmeter/assertions/SMIMEAssertionTest.java +++ b/test/src/org/apache/jmeter/assertions/SMIMEAssertionTest.java @@ -28,6 +28,7 @@ import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.internet.MimeMessage; + import org.apache.jmeter.samplers.SampleResult; import org.apache.jorphan.test.JMeterSerialTest; import org.junit.Before; diff --git a/test/src/org/apache/jmeter/assertions/SizeAssertionTest.java b/test/src/org/apache/jmeter/assertions/SizeAssertionTest.java index f00e42927ea..7464cae67c8 100644 --- a/test/src/org/apache/jmeter/assertions/SizeAssertionTest.java +++ b/test/src/org/apache/jmeter/assertions/SizeAssertionTest.java @@ -34,7 +34,8 @@ public class SizeAssertionTest extends JMeterTestCase { private SizeAssertion assertion; - private SampleResult sample1, sample0; + private SampleResult sample1; + private SampleResult sample0; private AssertionResult result; private final String data1 = "response Data\n" + "line 2\n\nEOF"; private final int data1Len = data1.length(); diff --git a/test/src/org/apache/jmeter/assertions/TestJSONPathAssertion.java b/test/src/org/apache/jmeter/assertions/TestJSONPathAssertion.java index 9ed413fdf08..70c1a15f1cb 100644 --- a/test/src/org/apache/jmeter/assertions/TestJSONPathAssertion.java +++ b/test/src/org/apache/jmeter/assertions/TestJSONPathAssertion.java @@ -17,11 +17,11 @@ */ package org.apache.jmeter.assertions; +import static org.junit.Assert.assertEquals; + import org.apache.jmeter.samplers.SampleResult; import org.junit.Test; -import static org.junit.Assert.assertEquals; - public class TestJSONPathAssertion { @Test diff --git a/test/src/org/apache/jmeter/control/TestSwitchController.java b/test/src/org/apache/jmeter/control/TestSwitchController.java index 5b697e40b20..e0e67f00d0e 100644 --- a/test/src/org/apache/jmeter/control/TestSwitchController.java +++ b/test/src/org/apache/jmeter/control/TestSwitchController.java @@ -212,7 +212,7 @@ public void testTest2() throws Exception { * cond = Switch condition * exp[] = expected results */ - private void runTest2(String cond, String exp[]) throws Exception { + private void runTest2(String cond, String[] exp) throws Exception { int loops = 3; LoopController controller = new LoopController(); controller.setLoops(loops); diff --git a/test/src/org/apache/jmeter/control/TestTransactionController.java b/test/src/org/apache/jmeter/control/TestTransactionController.java index 555ed45d145..b09e496f91d 100644 --- a/test/src/org/apache/jmeter/control/TestTransactionController.java +++ b/test/src/org/apache/jmeter/control/TestTransactionController.java @@ -18,6 +18,11 @@ package org.apache.jmeter.control; +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + import org.apache.jmeter.assertions.ResponseAssertion; import org.apache.jmeter.junit.JMeterTestCase; import org.apache.jmeter.reporters.ResultCollector; @@ -33,11 +38,6 @@ import org.apache.jorphan.collections.ListedHashTree; import org.junit.Test; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertEquals; - public class TestTransactionController extends JMeterTestCase { @@ -48,7 +48,6 @@ public class TestTransactionController extends JMeterTestCase { public void testIssue57958() throws Exception { JMeterContextService.getContext().setVariables(new JMeterVariables()); - TestSampleListener listener = new TestSampleListener(); TransactionController transactionController = new TransactionController(); @@ -90,8 +89,6 @@ public void testIssue57958() throws Exception { assertEquals("Number of samples in transaction : 1, number of failing samples : 1", listener.events.get(0).getResult().getResponseMessage()); } - - public class TestSampleListener extends ResultCollector implements SampleListener { public List events = new ArrayList<>(); diff --git a/test/src/org/apache/jmeter/extractor/BoundaryExtractorSpec.groovy b/test/src/org/apache/jmeter/extractor/BoundaryExtractorSpec.groovy index 1cf1a567b37..b75a248f244 100644 --- a/test/src/org/apache/jmeter/extractor/BoundaryExtractorSpec.groovy +++ b/test/src/org/apache/jmeter/extractor/BoundaryExtractorSpec.groovy @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + package org.apache.jmeter.extractor import org.apache.jmeter.samplers.SampleResult diff --git a/test/src/org/apache/jmeter/extractor/TestJSONPostProcessor.java b/test/src/org/apache/jmeter/extractor/TestJSONPostProcessor.java index 5a60c1cde2c..c2c13486097 100644 --- a/test/src/org/apache/jmeter/extractor/TestJSONPostProcessor.java +++ b/test/src/org/apache/jmeter/extractor/TestJSONPostProcessor.java @@ -22,9 +22,6 @@ import java.nio.charset.StandardCharsets; -import net.minidev.json.parser.JSONParser; -import net.minidev.json.parser.ParseException; - import org.apache.jmeter.extractor.json.jsonpath.JSONPostProcessor; import org.apache.jmeter.samplers.SampleResult; import org.apache.jmeter.threads.JMeterContext; @@ -34,6 +31,9 @@ import org.junit.Assert; import org.junit.Test; +import net.minidev.json.parser.JSONParser; +import net.minidev.json.parser.ParseException; + public class TestJSONPostProcessor { private static final String VAR_NAME = "varName"; diff --git a/test/src/org/apache/jmeter/functions/ChangeCaseSpec.groovy b/test/src/org/apache/jmeter/functions/ChangeCaseSpec.groovy index 20b6a335a01..f592e2b543f 100644 --- a/test/src/org/apache/jmeter/functions/ChangeCaseSpec.groovy +++ b/test/src/org/apache/jmeter/functions/ChangeCaseSpec.groovy @@ -66,4 +66,4 @@ class ChangeCaseSpec extends Specification { " " | "capitalize" | " " } -} \ No newline at end of file +} diff --git a/test/src/org/apache/jmeter/functions/EvalFunctionTest.java b/test/src/org/apache/jmeter/functions/EvalFunctionTest.java index e7b0571b054..f7d0729a322 100644 --- a/test/src/org/apache/jmeter/functions/EvalFunctionTest.java +++ b/test/src/org/apache/jmeter/functions/EvalFunctionTest.java @@ -18,6 +18,9 @@ package org.apache.jmeter.functions; +import static org.apache.jmeter.functions.FunctionTestHelper.makeParams; +import static org.junit.Assert.assertEquals; + import java.util.Collection; import org.apache.jmeter.engine.util.CompoundVariable; @@ -27,8 +30,6 @@ import org.apache.jmeter.threads.JMeterVariables; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.apache.jmeter.functions.FunctionTestHelper.makeParams; public class EvalFunctionTest extends JMeterTestCase { @@ -55,7 +56,6 @@ public void evalTest1() throws Exception { eval.setParameters(parms); s = eval.execute(null,null); assertEquals("select name from customers",s); - } @Test diff --git a/test/src/org/apache/jmeter/functions/PackageTest.java b/test/src/org/apache/jmeter/functions/PackageTest.java index ba4182ec34d..3df620d6960 100644 --- a/test/src/org/apache/jmeter/functions/PackageTest.java +++ b/test/src/org/apache/jmeter/functions/PackageTest.java @@ -203,7 +203,8 @@ public void BSH1() throws Exception { } // Function objects to be tested - private static CSVRead cr1, cr4; + private static CSVRead cr1; + private static CSVRead cr4; // Helper class used to implement co-routine between two threads private static class Baton { @@ -279,13 +280,11 @@ public void CSVThread2() throws Exception { } } - public void CSVSetup() throws Exception { cr1 = setCSVReadParams("testfiles/unit/FunctionsPackageTest.csv", "1"); cr4 = setCSVReadParams("testfiles/unit/FunctionsPackageTest.csv", "next"); } - // XPathFileContainer tests public void XPathtestNull() throws Exception { @@ -383,10 +382,11 @@ public void XPathFile2() throws Exception{ assertEquals("u3",xp1.execute()); assertEquals("u4",xp1.execute()); assertEquals("p3",xp2a.execute()); - } - private static XPath sxp1,sxp2; + private static XPath sxp1; + private static XPath sxp2; + // Use same XPath for both threads public void XPathSetup1() throws Exception{ sxp1 = setupXPath("testfiles/XPathTest.xml","//user/@username"); diff --git a/test/src/org/apache/jmeter/functions/TestSetProperty.java b/test/src/org/apache/jmeter/functions/TestSetProperty.java index bbb9c50b235..f528058003c 100644 --- a/test/src/org/apache/jmeter/functions/TestSetProperty.java +++ b/test/src/org/apache/jmeter/functions/TestSetProperty.java @@ -20,9 +20,6 @@ import static org.junit.Assert.assertEquals; -import org.apache.jorphan.test.JMeterSerialTest; -import org.junit.Assert; - import java.util.Collection; import java.util.LinkedList; @@ -33,18 +30,17 @@ import org.apache.jmeter.threads.JMeterContextService; import org.apache.jmeter.threads.JMeterVariables; import org.apache.jmeter.util.JMeterUtils; +import org.apache.jorphan.test.JMeterSerialTest; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; public class TestSetProperty extends JMeterTestCase implements JMeterSerialTest { - protected AbstractFunction function; + protected AbstractFunction function; private SampleResult result; - private Collection params; - private JMeterVariables vars; - private JMeterContext jmctx; @Before diff --git a/test/src/org/apache/jmeter/functions/TestTimeShiftFunction.java b/test/src/org/apache/jmeter/functions/TestTimeShiftFunction.java index 685f8bbad2f..b8d3c0d6608 100644 --- a/test/src/org/apache/jmeter/functions/TestTimeShiftFunction.java +++ b/test/src/org/apache/jmeter/functions/TestTimeShiftFunction.java @@ -45,14 +45,11 @@ import org.junit.Test; public class TestTimeShiftFunction extends JMeterTestCase { - private Function function; + private Function function; private SampleResult result; - private JMeterVariables vars; - private JMeterContext jmctx = null; - private String value; @Before @@ -156,7 +153,6 @@ public void testWrongFormatDate() throws Exception { assertThat(value, is(equalTo(""))); } - @Test public void testRandomPeriod() throws Exception { Random r = new Random(); @@ -174,10 +170,8 @@ public void testRandomPeriod() throws Exception { randomFutureDate = LocalDateTime.parse(value); checkFutureDate = LocalDateTime.now().plusMinutes(randomInt); assertThat(randomFutureDate, within(5, ChronoUnit.SECONDS, checkFutureDate) ); - } - - + @Test public void testNowPlusOneDayWithLocale() throws Exception { Collection params = makeParams("yyyy-MMMM-dd", "2017-juillet-01", "P1D", "fr_FR", ""); diff --git a/test/src/org/apache/jmeter/gui/util/MenuFactorySpec.groovy b/test/src/org/apache/jmeter/gui/util/MenuFactorySpec.groovy index d2c3fbfbc62..e91b8d557f3 100644 --- a/test/src/org/apache/jmeter/gui/util/MenuFactorySpec.groovy +++ b/test/src/org/apache/jmeter/gui/util/MenuFactorySpec.groovy @@ -31,4 +31,4 @@ class MenuFactorySpec extends JMeterSpec { expect: MenuFactory.createDefaultAddMenu().itemCount == 6 + 3 // items + seperators } -} \ No newline at end of file +} diff --git a/test/src/org/apache/jmeter/gui/util/TristateCheckBoxTest.java b/test/src/org/apache/jmeter/gui/util/TristateCheckBoxTest.java index eaf2a03ba7e..c4654e679e8 100644 --- a/test/src/org/apache/jmeter/gui/util/TristateCheckBoxTest.java +++ b/test/src/org/apache/jmeter/gui/util/TristateCheckBoxTest.java @@ -34,7 +34,7 @@ //derived from: http://www.javaspecialists.eu/archive/Issue145.html public class TristateCheckBoxTest { - public static void main(String args[]) throws Exception { + public static void main(String[] args) throws Exception { JFrame frame = new JFrame("TristateCheckBoxTest"); frame.setLayout(new GridLayout(0, 1, 15, 15)); UIManager.LookAndFeelInfo[] lfs = @@ -101,13 +101,17 @@ public void actionPerformed(ActionEvent e) { private static void switchOnAction(TristateCheckBox tristateBox) { switch(tristateBox.getState()) { case SELECTED: - System.out.println("Selected"); break; + System.out.println("Selected"); + break; case DESELECTED: - System.out.println("Not Selected"); break; + System.out.println("Not Selected"); + break; case INDETERMINATE: - System.out.println("Tristate Selected"); break; + System.out.println("Tristate Selected"); + break; default: - System.err.println("Unexpected state: " + tristateBox.getState()); break; + System.err.println("Unexpected state: " + tristateBox.getState()); + break; } } } diff --git a/test/src/org/apache/jmeter/junit/JMeterTest.java b/test/src/org/apache/jmeter/junit/JMeterTest.java index 93f7cd08077..1cf982acad5 100644 --- a/test/src/org/apache/jmeter/junit/JMeterTest.java +++ b/test/src/org/apache/jmeter/junit/JMeterTest.java @@ -243,8 +243,6 @@ public void checkGuiSet() throws Exception { assertEquals("Should not have any names left over, check name of components in EN (default) Locale, which must match name attribute of component", 0, scanprintMap(guiTitles, "GUI")); } - - /* * Test GUI elements - create the suite of tests */ @@ -456,7 +454,7 @@ public static Collection getObjects(Class extendsClass) throws Except objects.add(c.newInstance()); } catch (InstantiationException e) { caught = e; - try { + try { // CHECKSTYLE IGNORE NestedTryDepth // Events often have this constructor objects.add(c.getConstructor(new Class[] { Object.class }).newInstance( new Object[] { myThis })); @@ -501,14 +499,14 @@ public static Collection getObjects(Class extendsClass) throws Except if (objects.isEmpty()) { System.out.println("No classes found that extend " + exName + ". Check the following:"); System.out.println("Search paths are:"); - String ss[] = JMeterUtils.getSearchPaths(); + String[] ss = JMeterUtils.getSearchPaths(); for (String s : ss) { System.out.println(s); } if (!classPathShown) {// Only dump it once System.out.println("Class path is:"); String cp = System.getProperty("java.class.path"); - String classPathElements[] = JOrphanUtils.split(cp, java.io.File.pathSeparator); + String[] classPathElements = JOrphanUtils.split(cp, java.io.File.pathSeparator); for (String classPathElement : classPathElements) { System.out.println(classPathElement); } diff --git a/test/src/org/apache/jmeter/protocol/http/config/UrlConfigTest.java b/test/src/org/apache/jmeter/protocol/http/config/UrlConfigTest.java index 4b503e44b50..9968d928b6b 100644 --- a/test/src/org/apache/jmeter/protocol/http/config/UrlConfigTest.java +++ b/test/src/org/apache/jmeter/protocol/http/config/UrlConfigTest.java @@ -23,8 +23,8 @@ import org.apache.jmeter.config.Arguments; import org.apache.jmeter.junit.JMeterTestCase; -import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; import org.apache.jmeter.protocol.http.sampler.HTTPNullSampler; +import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; import org.apache.jmeter.protocol.http.util.HTTPConstants; import org.apache.jmeter.testelement.property.JMeterProperty; import org.apache.jmeter.testelement.property.NullProperty; @@ -33,10 +33,9 @@ import org.junit.Test; public class UrlConfigTest extends JMeterTestCase { - private HTTPSamplerBase config; + private HTTPSamplerBase config; private HTTPSamplerBase defaultConfig; - private HTTPSamplerBase partialConfig; @Before diff --git a/test/src/org/apache/jmeter/protocol/http/control/TestHC4CookieManager.java b/test/src/org/apache/jmeter/protocol/http/control/TestHC4CookieManager.java index 1edf01c7c6f..fc925c785b7 100644 --- a/test/src/org/apache/jmeter/protocol/http/control/TestHC4CookieManager.java +++ b/test/src/org/apache/jmeter/protocol/http/control/TestHC4CookieManager.java @@ -97,8 +97,6 @@ public void testSendCookie2() throws Exception { sampler.setMethod(HTTPConstants.GET); assertNotNull(man.getCookieHeaderForURL(sampler.getUrl())); } - - /** * Test that the cookie domain field is actually handled as browsers do diff --git a/test/src/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java b/test/src/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java index 47f6f5597fc..fb95866e3db 100644 --- a/test/src/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java +++ b/test/src/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java @@ -400,7 +400,7 @@ private static void filetest(HTMLParser p, String file, String url, String resul TreeSet temp = new TreeSet<>(new Comparator() { @Override public int compare(Object o1, Object o2) { - return (o1.toString().compareTo(o2.toString())); + return o1.toString().compareTo(o2.toString()); } }); while (result.hasNext()) { diff --git a/test/src/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java b/test/src/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java index 30b847d97e7..52205cb5a9e 100644 --- a/test/src/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java +++ b/test/src/org/apache/jmeter/protocol/http/proxy/TestProxyControl.java @@ -18,22 +18,20 @@ package org.apache.jmeter.protocol.http.proxy; -import org.apache.jmeter.samplers.SampleResult; -import org.junit.Before; -import org.junit.Test; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.apache.jmeter.protocol.http.sampler.HTTPNullSampler; import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; +import org.apache.jmeter.samplers.SampleResult; +import org.junit.Before; +import org.junit.Test; public class TestProxyControl { private HTTPSamplerBase sampler; private ProxyControl control; - @Before public void setUp() { control = new ProxyControl(); diff --git a/test/src/org/apache/jmeter/protocol/http/sampler/NullURLConnection.java b/test/src/org/apache/jmeter/protocol/http/sampler/NullURLConnection.java index 7e854f721b5..4f1bf47dc50 100644 --- a/test/src/org/apache/jmeter/protocol/http/sampler/NullURLConnection.java +++ b/test/src/org/apache/jmeter/protocol/http/sampler/NullURLConnection.java @@ -18,15 +18,14 @@ package org.apache.jmeter.protocol.http.sampler; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; -import java.net.MalformedURLException; import java.util.Properties; /** * Dummy URLConnection class for use by classes that need an * URLConnection for junit tests. - * */ public final class NullURLConnection extends URLConnection { diff --git a/test/src/org/apache/jmeter/protocol/http/sampler/PutWriterTest.java b/test/src/org/apache/jmeter/protocol/http/sampler/PutWriterTest.java index dacfc92cc48..592d3c7f634 100644 --- a/test/src/org/apache/jmeter/protocol/http/sampler/PutWriterTest.java +++ b/test/src/org/apache/jmeter/protocol/http/sampler/PutWriterTest.java @@ -24,9 +24,9 @@ import org.apache.jmeter.config.Arguments; import org.apache.jmeter.protocol.http.util.HTTPArgument; +import org.apache.jmeter.protocol.http.util.HTTPConstants; import org.apache.jmeter.protocol.http.util.HTTPFileArg; import org.junit.Test; -import org.apache.jmeter.protocol.http.util.HTTPConstants; public class PutWriterTest { diff --git a/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java b/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java index 6103664b800..96e110f01d5 100644 --- a/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java +++ b/test/src/org/apache/jmeter/protocol/http/sampler/TestHTTPSamplersAgainstHttpMirrorServer.java @@ -292,13 +292,6 @@ private void testPostRequest_UrlEncoded(int samplerType, String samplerDefaultEn default: fail("Unexpected switch value: "+test); } - - - - - - - } private void testPostRequest_FormMultipart(int samplerType, String samplerDefaultEncoding) throws Exception { @@ -1186,7 +1179,6 @@ private void setupFileUploadData( // Set the file upload data HTTPFileArg[] hfa = {new HTTPFileArg(fileValue == null ? "" : fileValue.getAbsolutePath(), fileField, fileMimeType)}; httpSampler.setHTTPFiles(hfa); - } /** diff --git a/test/src/org/apache/jmeter/protocol/http/util/TestHTTPFileArgs.java b/test/src/org/apache/jmeter/protocol/http/util/TestHTTPFileArgs.java index 1e13dcb30b1..510d42e16be 100644 --- a/test/src/org/apache/jmeter/protocol/http/util/TestHTTPFileArgs.java +++ b/test/src/org/apache/jmeter/protocol/http/util/TestHTTPFileArgs.java @@ -18,11 +18,11 @@ package org.apache.jmeter.protocol.http.util; -import java.util.List; - import static org.junit.Assert.assertEquals; import java.util.LinkedList; +import java.util.List; + import org.apache.jmeter.testelement.property.PropertyIterator; import org.junit.Test; diff --git a/test/src/org/apache/jmeter/report/dashboard/ApdexPerTransactionTest.java b/test/src/org/apache/jmeter/report/dashboard/ApdexPerTransactionTest.java index 5bdddf12d00..b2c44886040 100644 --- a/test/src/org/apache/jmeter/report/dashboard/ApdexPerTransactionTest.java +++ b/test/src/org/apache/jmeter/report/dashboard/ApdexPerTransactionTest.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; + import java.util.Map; import java.util.Set; diff --git a/test/src/org/apache/jmeter/resources/PackageTest.java b/test/src/org/apache/jmeter/resources/PackageTest.java index 7da6338251c..9be58e32a69 100644 --- a/test/src/org/apache/jmeter/resources/PackageTest.java +++ b/test/src/org/apache/jmeter/resources/PackageTest.java @@ -283,7 +283,7 @@ private static void findFile(File file, Set set, */ public static Test suite() { TestSuite ts = new TestSuite("Resources PackageTest"); - String languages[] = JMeterMenuBar.getLanguages(); + String[] languages = JMeterMenuBar.getLanguages(); for(String prefix : prefixList){ TestSuite pfx = new TestSuite(prefix) ; pfx.addTest(new PackageTest("testLang","", prefix)); // load the default resource diff --git a/test/src/org/apache/jmeter/save/TestCSVSaveService.java b/test/src/org/apache/jmeter/save/TestCSVSaveService.java index 98d893efcf8..9114b5f08ae 100644 --- a/test/src/org/apache/jmeter/save/TestCSVSaveService.java +++ b/test/src/org/apache/jmeter/save/TestCSVSaveService.java @@ -34,7 +34,7 @@ public class TestCSVSaveService extends JMeterTestCase { private void checkSplitString(String input, char delim, String[] expected) throws Exception { - String out[] = CSVSaveService.csvSplitString(input, delim); + String[] out = CSVSaveService.csvSplitString(input, delim); checkStrings(expected, out); } diff --git a/test/src/org/apache/jmeter/testbeans/gui/TestBooleanPropertyEditor.java b/test/src/org/apache/jmeter/testbeans/gui/TestBooleanPropertyEditor.java index 3cf16225e97..6053b9de2d0 100644 --- a/test/src/org/apache/jmeter/testbeans/gui/TestBooleanPropertyEditor.java +++ b/test/src/org/apache/jmeter/testbeans/gui/TestBooleanPropertyEditor.java @@ -56,7 +56,7 @@ public void testBooleanPropertyEditor() { private void testBooleanEditor(PropertyEditor propertyEditor) { assertNotNull("Expected to find property editor", propertyEditor); - String tags[] = propertyEditor.getTags(); + String[] tags = propertyEditor.getTags(); assertEquals(2,tags.length); assertEquals(TRUE,tags[0]); assertEquals(FALSE,tags[1]); diff --git a/test/src/org/apache/jmeter/visualizers/TestRenderAsJson.java b/test/src/org/apache/jmeter/visualizers/TestRenderAsJson.java index da696097439..8398ba37c19 100644 --- a/test/src/org/apache/jmeter/visualizers/TestRenderAsJson.java +++ b/test/src/org/apache/jmeter/visualizers/TestRenderAsJson.java @@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals; import java.lang.reflect.Method; + import org.junit.Before; import org.junit.Test; diff --git a/test/src/org/apache/jorphan/exec/TestKeyToolUtils.java b/test/src/org/apache/jorphan/exec/TestKeyToolUtils.java index 92073bc70a0..7c01d0d6ee8 100644 --- a/test/src/org/apache/jorphan/exec/TestKeyToolUtils.java +++ b/test/src/org/apache/jorphan/exec/TestKeyToolUtils.java @@ -27,15 +27,14 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; + import org.junit.Test; public class TestKeyToolUtils { - /* * Check the assumption that a missing executable will generate * either an IOException or status which is neither 0 nor 1 - * */ @Test public void testCheckKeytool() throws Exception { diff --git a/test/src/org/apache/jorphan/gui/ObjectTableSorterTest.java b/test/src/org/apache/jorphan/gui/ObjectTableSorterTest.java index 6580bb06e9c..a7b30600706 100644 --- a/test/src/org/apache/jorphan/gui/ObjectTableSorterTest.java +++ b/test/src/org/apache/jorphan/gui/ObjectTableSorterTest.java @@ -139,8 +139,14 @@ public void fixLastRowWithDescendingValue() { @Test public void customKeyOrder() { - HashMap customKeyOrder = asList("a", "c", "b", "d").stream().reduce(new HashMap(), (map,key) -> { map.put(key, map.size()); return map; }, (a,b) -> a); - Comparator customKeyComparator = (a,b) -> customKeyOrder.get(a).compareTo(customKeyOrder.get(b)); + HashMap customKeyOrder = asList("a", "c", "b", "d").stream() + .reduce(new HashMap(), + (map, key) -> { + map.put(key, map.size()); + return map; + }, + (a, b) -> a); + Comparator customKeyComparator = (a, b) -> customKeyOrder.get(a).compareTo(customKeyOrder.get(b)); sorter.setValueComparator(0, customKeyComparator).setSortKey(new SortKey(0, SortOrder.ASCENDING)); List> expected = asList(a3(), c1(), b2(), d4()); assertRowOrderAndIndexes(expected); diff --git a/test/src/org/apache/jorphan/math/TestStatCalculator.java b/test/src/org/apache/jorphan/math/TestStatCalculator.java index 05792fec860..e4d319702d8 100644 --- a/test/src/org/apache/jorphan/math/TestStatCalculator.java +++ b/test/src/org/apache/jorphan/math/TestStatCalculator.java @@ -40,7 +40,7 @@ public void setUp() { @Test public void testPercentagePoint() throws Exception { - long values[] = new long[] { + long[] values = new long[] { 10L,9L,5L,6L,1L,3L,8L,2L,7L,4L }; for (long l : values) { @@ -54,7 +54,7 @@ public void testPercentagePoint() throws Exception { @Ignore // Disabled due to in progress Bug 61071 public void testPercentagePointBug() throws Exception { - long values[] = new long[] { + long[] values = new long[] { 10L,9L,5L,6L,1L,3L,8L,2L,7L,4L }; DescriptiveStatistics statistics = new DescriptiveStatistics(); diff --git a/test/src/org/apache/jorphan/test/AllTests.java b/test/src/org/apache/jorphan/test/AllTests.java index e49f1d13c8b..83a216a4f89 100644 --- a/test/src/org/apache/jorphan/test/AllTests.java +++ b/test/src/org/apache/jorphan/test/AllTests.java @@ -17,7 +17,6 @@ package org.apache.jorphan.test; -import javax.crypto.Cipher; import java.awt.GraphicsEnvironment; import java.io.File; import java.io.IOException; @@ -34,7 +33,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; -import junit.framework.TestCase; +import javax.crypto.Cipher; import org.apache.commons.lang3.time.StopWatch; import org.apache.jmeter.junit.categories.ExcludeCategoryFilter; @@ -53,6 +52,8 @@ import org.junit.runner.notification.RunListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + +import junit.framework.TestCase; import spock.lang.Specification; /** diff --git a/test/src/org/apache/jorphan/util/TestConverter.java b/test/src/org/apache/jorphan/util/TestConverter.java index ae9ab2cca6f..872c1d834a9 100644 --- a/test/src/org/apache/jorphan/util/TestConverter.java +++ b/test/src/org/apache/jorphan/util/TestConverter.java @@ -25,11 +25,11 @@ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; + import org.junit.Test; /** * Tests for {@link Converter} - * */ public class TestConverter { diff --git a/test/src/org/apache/jorphan/util/TestJorphanUtils.java b/test/src/org/apache/jorphan/util/TestJorphanUtils.java index 69ba8127dca..85e1aeecd04 100644 --- a/test/src/org/apache/jorphan/util/TestJorphanUtils.java +++ b/test/src/org/apache/jorphan/util/TestJorphanUtils.java @@ -110,7 +110,7 @@ public void testSplitStringStringFalseWithLeadingSplitChars() { @Test public void testSplit3() { String in = "a,bc,,"; // Test ignore trailing split characters - String out[] = JOrphanUtils.split(in, ",",true);// Ignore adjacent delimiters + String[] out = JOrphanUtils.split(in, ",",true);// Ignore adjacent delimiters assertThat(out, CoreMatchers.equalTo(new String[] { "a", "bc" })); out = JOrphanUtils.split(in, ",",false); assertThat(out, CoreMatchers.equalTo(new String[] { "a", "bc", "", "" })); @@ -119,7 +119,8 @@ public void testSplit3() { @Test public void testSplitStringStringTrueWithLeadingComplexSplitCharacters() { // Test leading split characters - assertThat(JOrphanUtils.split(" , ,a ,bc", " ,", true), CoreMatchers.equalTo(new String[] { "a", "bc" })); + assertThat(JOrphanUtils.split(" , ,a ,bc", " ,", true), + CoreMatchers.equalTo(new String[] { "a", "bc" })); } @Test @@ -130,29 +131,25 @@ public void testSplitStringStringFalseWithLeadingComplexSplitCharacters() { } @Test - public void testSplitStringStringTrueTruncate() throws Exception - { + public void testSplitStringStringTrueTruncate() throws Exception { assertThat(JOrphanUtils.split("a;,b;,;,;,d;,e;,;,f", ";,", true), CoreMatchers.equalTo(new String[] { "a", "b", "d", "e", "f" })); } @Test - public void testSplitStringStringFalseTruncate() throws Exception - { + public void testSplitStringStringFalseTruncate() throws Exception { assertThat(JOrphanUtils.split("a;,b;,;,;,d;,e;,;,f", ";,", false), CoreMatchers.equalTo(new String[] { "a", "b", "", "", "d", "e", "", "f" })); } @Test - public void testSplitStringStringTrueDoubledSplitChar() throws Exception - { + public void testSplitStringStringTrueDoubledSplitChar() throws Exception { assertThat(JOrphanUtils.split("a;;b;;;;;;d;;e;;;;f", ";;", true), CoreMatchers.equalTo(new String[] { "a", "b", "d", "e", "f" })); } @Test - public void testSplitStringStringFalseDoubledSplitChar() throws Exception - { + public void testSplitStringStringFalseDoubledSplitChar() throws Exception { assertThat(JOrphanUtils.split("a;;b;;;;;;d;;e;;;;f", ";;", false), CoreMatchers.equalTo(new String[] { "a", "b", "", "", "d", "e", "", "f" })); @@ -161,7 +158,7 @@ public void testSplitStringStringFalseDoubledSplitChar() throws Exception // Empty string @Test public void testEmpty(){ - String out[] = JOrphanUtils.split("", ",", false); + String[] out = JOrphanUtils.split("", ",", false); assertEquals(0, out.length); }