Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3557,7 +3557,7 @@ run JMeter unless all the JMeter jars are added.
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
classpath="${lib.opt}/${checkstyle-all.jar}"/>
<checkstyle config="checkstyle.xml">
<fileset dir="src" includes="**/*"/>
<fileset dir="." includes="test/**/*,src/**/*"/>
<formatter type="plain"/>
<formatter type="xml" toFile="build/checkstyle_errors.xml"/>
</checkstyle>
Expand Down
8 changes: 6 additions & 2 deletions checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ limitations under the License.
"http://checkstyle.sourceforge.net/dtds/suppressions_1_1.dtd">

<suppressions>
<suppress checks="NewlineAtEndOfFile" files=".*.properties"/>
<suppress checks="FileLength" files="HTTPSamplerBase.java"/>
<suppress checks="NewlineAtEndOfFile" files=".*.properties"/>
<suppress checks="FileLength" files="HTTPSamplerBase.java"/>
<!-- Slightly more lenient for tests -->
<suppress checks="(EmptyCatchBlock|AvoidEscapedUnicodeCharacters)"
files="test[\\/].*"/>
<suppress checks="NewlineAtEndOfFile" files="test[\\/].*.xml"/>
</suppressions>
12 changes: 6 additions & 6 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
<property name="localeLanguage" value="en"/>
<property name="charset" value="UTF-8"/>
<property name="severity" value="error"/>
<property name="fileExtensions" value="java, groovy, properties, xml"/>
<property name="fileExtensions"
value="java, groovy, xml, xsd, dtd, htm, html, txt, properties"/>

<!-- Verify that EVERY source file has the appropriate license -->
<module name="RegexpHeader">
Expand All @@ -34,15 +35,14 @@
</module>

<!-- Miscellaneous -->
<module name="FileTabCharacter">
<!-- No tabs allowed! -->
<property name="fileExtensions" value="java, groovy, xml, xsd, dtd, htm, html, txt, properties"/>
<module name="FileTabCharacter"/>
<module name="NewlineAtEndOfFile">
<property name="fileExtensions" value="java, groovy, xml, xsd, dtd"/>
</module>
<module name="NewlineAtEndOfFile"/>
<module name="RegexpMultiline">
<!-- No more than 2 blank lines allowed. -->
<property name="format" value="\r?\n[\t ]*\r?\n[\t ]*\r?\n[\t ]*\r?\n"/>
<property name="fileExtensions" value="java, xml, properties"/>
<property name="fileExtensions" value="java, groovy, xml, properties"/>
<property name="message" value="Unnecessary consecutive lines"/>
</module>
<!--<module name="RegexpOnFilename">-->
Expand Down
29 changes: 5 additions & 24 deletions test/src/org/apache/commons/cli/avalon/ClutilTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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;
}
};

Expand All @@ -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;
}
};

Expand Down Expand Up @@ -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;
}
};

Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion test/src/org/apache/jmeter/assertions/SizeAssertionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand All @@ -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();
Expand Down Expand Up @@ -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<SampleEvent> events = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion test/src/org/apache/jmeter/functions/ChangeCaseSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ class ChangeCaseSpec extends Specification {
" " | "capitalize" | " "
}

}
}
6 changes: 3 additions & 3 deletions test/src/org/apache/jmeter/functions/EvalFunctionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand All @@ -55,7 +56,6 @@ public void evalTest1() throws Exception {
eval.setParameters(parms);
s = eval.execute(null,null);
assertEquals("select name from customers",s);

}

@Test
Expand Down
10 changes: 5 additions & 5 deletions test/src/org/apache/jmeter/functions/PackageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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");
Expand Down
10 changes: 3 additions & 7 deletions test/src/org/apache/jmeter/functions/TestSetProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<CompoundVariable> params;

private JMeterVariables vars;

private JMeterContext jmctx;

@Before
Expand Down
10 changes: 2 additions & 8 deletions test/src/org/apache/jmeter/functions/TestTimeShiftFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -156,7 +153,6 @@ public void testWrongFormatDate() throws Exception {
assertThat(value, is(equalTo("")));
}


@Test
public void testRandomPeriod() throws Exception {
Random r = new Random();
Expand All @@ -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<CompoundVariable> params = makeParams("yyyy-MMMM-dd", "2017-juillet-01", "P1D", "fr_FR", "");
Expand Down
Loading